/* docket — calm, neutral, content-first. Light + dark, mobile-first.
 *
 * Structure: tokens → base → layout → lists/rows → habits → controls →
 * sheets → feedback → screens. Colour carries meaning only (accent =
 * action/done, red = overdue); everything else is neutral. */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
        U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("assets/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
        U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */

:root {
    color-scheme: light;
    --bg: #f6f6f7;
    --surface: #ffffff;
    --surface-2: #f1f1f3;
    --surface-3: #e8e8eb;
    --border: #e4e4e8;
    --hairline: rgb(0 0 0 / 0.07);
    --fg: #18181b;
    --fg-2: #3f3f46;
    --muted: #71717a;
    --faint: #a1a1aa;
    --accent: #0f766e;
    --accent-strong: #0b5f58;
    --accent-fg: #ffffff;
    --accent-soft: #e3f2f0;
    --danger: #d1433a;
    --danger-soft: #fbeceb;
    --warn: #b45309;
    --warn-soft: #fdf3e2;
    --star: #e8a33a;
    --inverse: #18181b;
    --inverse-fg: #fafafa;
    --inverse-accent: #5fd6c6;
    --scrim: rgb(9 9 11 / 0.32);
    --shadow-1: 0 1px 2px rgb(16 16 20 / 0.05);
    --shadow-2: 0 8px 24px rgb(16 16 20 / 0.12), 0 2px 6px rgb(16 16 20 / 0.06);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tabbar-h: 60px;
    --radius: 14px;
    --radius-sm: 10px;
    --row-pad-x: 14px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0d0d0f;
        --surface: #17171a;
        --surface-2: #212125;
        --surface-3: #2a2a2f;
        --border: #2a2a2f;
        --hairline: rgb(255 255 255 / 0.07);
        --fg: #f4f4f5;
        --fg-2: #d4d4d8;
        --muted: #a1a1aa;
        --faint: #63636b;
        --accent: #3ec7b4;
        --accent-strong: #5fd6c6;
        --accent-fg: #052421;
        --accent-soft: rgb(62 199 180 / 0.14);
        --danger: #f2766d;
        --danger-soft: rgb(242 118 109 / 0.14);
        --warn: #f0b45a;
        --warn-soft: rgb(240 180 90 / 0.14);
        --star: #f0b45a;
        --inverse: #f4f4f5;
        --inverse-fg: #18181b;
        --inverse-accent: #0b5f58;
        --scrim: rgb(0 0 0 / 0.6);
        --shadow-1: none;
        --shadow-2: 0 10px 30px rgb(0 0 0 / 0.5);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d0d0f;
    --surface: #17171a;
    --surface-2: #212125;
    --surface-3: #2a2a2f;
    --border: #2a2a2f;
    --hairline: rgb(255 255 255 / 0.07);
    --fg: #f4f4f5;
    --fg-2: #d4d4d8;
    --muted: #a1a1aa;
    --faint: #63636b;
    --accent: #3ec7b4;
    --accent-strong: #5fd6c6;
    --accent-fg: #052421;
    --accent-soft: rgb(62 199 180 / 0.14);
    --danger: #f2766d;
    --danger-soft: rgb(242 118 109 / 0.14);
    --warn: #f0b45a;
    --warn-soft: rgb(240 180 90 / 0.14);
    --star: #f0b45a;
    --inverse: #f4f4f5;
    --inverse-fg: #18181b;
    --inverse-accent: #0b5f58;
    --scrim: rgb(0 0 0 / 0.6);
    --shadow-1: none;
    --shadow-2: 0 10px 30px rgb(0 0 0 / 0.5);
}

/* ---------- base ---------- */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--fg); }

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    letter-spacing: -0.006em;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: 0.4; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { display: inline-flex; width: 1.1em; height: 1.1em; flex: none; align-items: center; justify-content: center; }
.icon svg { width: 100%; height: 100%; stroke-width: 1.75; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.danger { color: var(--danger); }
.error-text { color: var(--danger); }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.num, .count, .habit-sub, .stat .big, .meta-chip { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */

.app { min-height: 100vh; min-height: 100dvh; }

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: var(--safe-top) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 96px);
}

header.top {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: calc(var(--safe-top) + 18px) 0 12px;
    margin-top: calc(-1 * var(--safe-top));
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
header.top > div:first-child { flex: 1; min-width: 0; }
header.top h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
header.top .sub { margin: 3px 0 0; color: var(--muted); font-size: 14px; font-weight: 450; }
header.top .back { margin-left: -10px; }

.banner {
    position: sticky; top: 0; z-index: 20;
    padding: calc(var(--safe-top) + 6px) 16px 6px;
    background: var(--warn-soft); color: var(--warn);
    font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px;
}

.boot { min-height: 100vh; }
.skeleton { padding-top: 88px; display: grid; gap: 1px; border-radius: var(--radius); overflow: hidden; }
.skeleton div { height: 54px; background: var(--surface); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---------- tab bar + floating add button ---------- */

.tabbar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding: 0 max(8px, calc((100vw - 640px) / 2)) var(--safe-bottom);
    display: grid; grid-template-columns: repeat(4, 1fr); align-items: center;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--hairline);
}
.tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    height: 100%; justify-content: center;
    font-size: 11px; font-weight: 500; color: var(--muted);
}
.tab .icon { width: 23px; height: 23px; }
.tab.active { color: var(--fg); }
.tab.active .icon { color: var(--accent); }
.fab {
    position: fixed; z-index: 31;
    right: max(16px, calc((100vw - 640px) / 2 + 16px));
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
    width: 56px; height: 56px; border-radius: 18px;
    background: var(--accent); color: var(--accent-fg);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-2);
    transition: transform 0.12s ease, background 0.12s;
}
.fab .icon { width: 26px; height: 26px; }
.fab .icon svg { stroke-width: 2.2; }
.fab:active { transform: scale(0.94); background: var(--accent-strong); }

/* ---------- groups ---------- */

.group { margin-top: 22px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 8px; min-height: 22px; }
.group-title {
    margin: 0 2px 8px; font-size: 13px; font-weight: 600; color: var(--fg-2);
    display: inline-flex; align-items: center; gap: 6px;
}
.group-head .group-title { margin: 0; }
.group-title .count { color: var(--faint); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.danger { background: var(--danger); }
.group-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 2px 2px 8px; }
.group-toggle .group-title { margin: 0; }
.chev { color: var(--faint); transition: transform 0.15s; display: inline-flex; }
.chev.open { transform: rotate(90deg); }
.day-title { margin: 16px 2px 8px; font-size: 13px; font-weight: 600; color: var(--fg-2); }
.day-title .muted { font-weight: 500; margin-left: 4px; color: var(--faint); }

.empty-state { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-state.small { padding: 32px 16px; }
.empty-icon {
    width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px;
    background: var(--surface); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; color: var(--accent);
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty-state p { margin: 6px 0; }
.empty-state p:first-of-type { color: var(--fg-2); font-weight: 550; }
.empty-state .pill-btn { margin-top: 14px; }
.empty { padding: 16px 2px; }

/* ---------- rows: one grouped container per run of rows ---------- */

.row {
    position: relative; overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top-width: 0;
}
.row:not(.row + .row) { border-top-width: 1px; border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.row:not(:has(+ .row)) { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.row + .row .row-fg::before {
    content: ""; position: absolute; top: 0; right: 0;
    left: calc(var(--row-pad-x) + 34px + var(--depth, 0) * 22px);
    height: 1px; background: var(--hairline);
}

.row-bg {
    position: absolute; inset: 0;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; font-size: 13.5px; font-weight: 600;
    opacity: 0;
}
.row.swiping .row-bg { opacity: 1; background: linear-gradient(90deg, var(--accent-soft) 50%, var(--warn-soft) 50%); }
.bg-left, .bg-right { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); transition: color 0.1s, transform 0.1s; }
.bg-left.armed { color: var(--accent); transform: scale(1.05); }
.bg-right.armed { color: var(--warn); transform: scale(1.05); }

.row-fg {
    position: relative;
    display: flex; align-items: flex-start; gap: 12px;
    padding: 13px var(--row-pad-x) 13px calc(var(--row-pad-x) + var(--depth, 0) * 22px);
    min-height: 50px;
    background: var(--surface);
    touch-action: pan-y;
    user-select: none; -webkit-user-select: none;
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.1s;
    cursor: pointer;
}
.row-fg:active { background: var(--surface-2); }
.row.swiping .row-fg { transition: none; background: var(--surface); }
.row.compact .row-fg { padding-top: 11px; padding-bottom: 11px; min-height: 46px; align-items: center; }

.check {
    flex: none; width: 22px; height: 22px; margin-top: -0.5px;
    border-radius: 50%; border: 1.5px solid var(--faint);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent-fg); position: relative;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.check::after { content: ""; position: absolute; inset: -12px; }
.check:active { transform: scale(0.86); }
.check.checked { background: var(--accent); border-color: var(--accent); }
.check .icon { width: 14px; height: 14px; }
.check .icon svg { stroke-width: 2.6; }
.check.big { width: 28px; height: 28px; margin-top: 4px; }
.check.big .icon { width: 17px; height: 17px; }
.check.small { width: 20px; height: 20px; }
.row.compact .check { margin-top: 0; }

.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 450; color: var(--fg); word-break: break-word; }
.title-text { flex: 1; min-width: 0; }
.row.done .title-text { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--faint); }
.star-mark { color: var(--star); font-size: 13px; display: inline-flex; align-self: center; }
.note-mark { color: var(--faint); font-size: 12.5px; display: inline-flex; align-self: center; }
.qty {
    flex: none; font-size: 12.5px; font-weight: 600; color: var(--fg-2);
    background: var(--surface-2); padding: 1px 7px; border-radius: 6px;
}
.row-meta { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.meta-chip { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.meta-chip .icon { width: 12.5px; height: 12.5px; color: var(--faint); }
.meta-chip.overdue { color: var(--danger); font-weight: 550; }
.meta-chip.overdue .icon { color: var(--danger); }
.meta-chip.tag { color: var(--muted); }
.meta-chip.list { color: var(--faint); }
.progress .bar { display: inline-block; width: 32px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-right: 2px; }
.progress .bar span { display: block; height: 100%; background: var(--accent); }

/* ---------- habit tiles (Today) ---------- */

.habit-strip {
    display: flex; gap: 8px; overflow-x: auto;
    margin: 0 -16px; padding: 0 16px 2px;
    scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding: 16px;
}
.habit-strip::-webkit-scrollbar { display: none; }
.habit {
    flex: none; display: flex; align-items: center; gap: 10px;
    min-width: 132px; max-width: 220px; padding: 10px 14px 10px 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    text-align: left; scroll-snap-align: start;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.habit:active { transform: scale(0.97); }
.ring {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    background: conic-gradient(var(--accent) var(--deg), var(--surface-3) 0);
    display: flex; align-items: center; justify-content: center;
}
.ring-inner {
    width: 26px; height: 26px; border-radius: 50%; background: var(--surface);
    display: flex; align-items: center; justify-content: center; color: var(--accent-fg);
    transition: background 0.15s;
}
.ring-inner .icon { width: 15px; height: 15px; }
.ring-inner .icon svg { stroke-width: 2.6; }
.habit.done { background: var(--accent-soft); border-color: transparent; }
.habit.done .ring { background: var(--accent); }
.habit.done .ring-inner { background: var(--accent); }
.habit.skipped .ring-inner { background: var(--surface-3); color: var(--muted); }
.habit-text { display: grid; min-width: 0; }
.habit-name { font-size: 14px; font-weight: 550; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-sub { font-size: 12px; color: var(--muted); }
.habit.done .habit-sub { color: var(--accent); }

/* ---------- buttons, chips, inputs ---------- */

.icon-btn {
    width: 40px; height: 40px; border-radius: 12px; flex: none;
    display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
    transition: background 0.12s, color 0.12s;
}
.icon-btn .icon { width: 21px; height: 21px; }
.icon-btn:active { background: var(--surface-2); color: var(--fg); }
.icon-btn.star.on { color: var(--star); }

.text-btn { color: var(--accent); font-size: 13.5px; font-weight: 600; padding: 4px 2px; }
.text-btn:active { opacity: 0.6; }

.pill-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--fg); font-size: 14px; font-weight: 550;
    transition: background 0.12s;
}
.pill-btn:active { background: var(--surface-3); }
.pill-btn.primary { background: var(--accent); color: var(--accent-fg); }
.pill-btn.primary:active { background: var(--accent-strong); }
.pill-btn .icon { width: 16px; height: 16px; }
.wide-btn {
    display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px;
    height: 44px; border-radius: 12px; background: var(--surface-2); margin-top: 10px; font-weight: 550; font-size: 14.5px;
}
.danger-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); height: 36px; padding: 0 10px; border-radius: var(--radius-sm); font-weight: 550; font-size: 14px; }
.danger-btn:active { background: var(--danger-soft); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -18px; padding: 0 18px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500;
    background: var(--surface-2); border: 1px solid transparent; color: var(--fg-2);
    position: relative; white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.chip .icon { width: 14px; height: 14px; }
.chip.active { background: var(--accent-soft); color: var(--accent); }
.chip.active .icon { color: var(--accent); }
.chip.ghost { background: transparent; color: var(--muted); }
.chip .x { display: inline-flex; opacity: 0.5; margin-right: -4px; }
.chip .x .icon { width: 12px; height: 12px; }
.chip.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--hue, 210) 55% 52%); flex: none; }
.chip.tag.active { background: var(--fg); color: var(--bg); }
.chip.link { max-width: 100%; overflow: hidden; text-overflow: ellipsis; color: var(--accent); }
.chip.date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; }
.toggle-chip input { display: none; }

input[type="text"], input[type="url"], input[type="password"], input[type="search"], input[type="number"], input[type="time"], select, textarea {
    width: 100%; height: 42px; padding: 0 12px; border-radius: var(--radius-sm);
    border: 1px solid transparent; background: var(--surface-2);
    font-size: 16px; outline: none; color: var(--fg);
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
textarea { height: auto; padding: 10px 12px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: none; field-sizing: content; min-height: 44px; line-height: 1.45; }
.num { width: 64px !important; text-align: center; padding: 0 4px !important; height: 34px !important; }
.time-input { width: auto !important; }
.select { appearance: auto; }

/* ---------- grouped cards (lists, settings) ---------- */

.cards { display: grid; }
.list-card {
    position: relative;
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 11px var(--row-pad-x); min-height: 54px;
    background: var(--surface); text-align: left;
    border: 1px solid var(--border); border-top-width: 0;
}
.list-card:not(.list-card + .list-card) { border-top-width: 1px; border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.list-card:not(:has(+ .list-card)) { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.list-card + .list-card::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 1px; background: var(--hairline); }
.list-card:active { background: var(--surface-2); }
.list-icon {
    width: 32px; height: 32px; border-radius: 9px; flex: none;
    background: var(--surface-2); font-size: 17px;
    display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.list-name { flex: 1; font-weight: 500; font-size: 15px; display: grid; }
.list-name .muted { font-weight: 450; }
.list-card .count { color: var(--muted); font-size: 14px; }
.list-card .count.danger { color: var(--danger); font-weight: 550; }
.list-card > .icon { color: var(--faint); width: 16px; height: 16px; }

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin-top: 14px; display: grid; gap: 12px;
}
.card h3 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .icon { color: var(--muted); }
.settings p { margin: 0; }
.stack { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14.5px; min-height: 28px; }
.kv > span:first-child { color: var(--fg-2); }
.kv .ok { color: var(--accent); font-weight: 550; }
.kv .bad { color: var(--danger); font-weight: 550; }
.loc-row { display: flex; gap: 8px; align-items: center; }
.emoji-input { width: 52px !important; text-align: center; flex: none; padding: 0 !important; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 3px; border-radius: 11px; gap: 2px; }
.segmented button { height: 32px; border-radius: 8px; font-size: 13.5px; font-weight: 550; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.segmented button .icon { width: 15px; height: 15px; }
.segmented button.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-1), 0 0 0 1px var(--hairline); }

/* ---------- habits view ---------- */

.habit-row {
    display: grid; grid-template-columns: 1fr auto; gap: 12px 10px; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px var(--row-pad-x); margin-bottom: 10px;
}
.habit-info { text-align: left; display: grid; gap: 2px; min-width: 0; }
.habit-title { font-weight: 600; font-size: 15px; }
.streak { font-weight: 600; color: var(--muted); font-size: 13.5px; display: inline-flex; align-items: center; gap: 4px; }
.streak .icon { width: 15px; height: 15px; }
.streak.hot { color: var(--warn); }
.dots { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dot-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dot-day { font-size: 11px; font-weight: 500; color: var(--faint); }
.dot-mark {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--accent-fg);
}
.dot-mark .icon { width: 15px; height: 15px; }
.dot-mark .icon svg { stroke-width: 2.6; }
.dot-btn.done .dot-mark { background: var(--accent); }
.dot-btn.missed .dot-mark { background: transparent; box-shadow: inset 0 0 0 1.5px var(--surface-3); }
.dot-btn.due .dot-mark { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent); }
.dot-btn.skipped .dot-mark { background: var(--surface-3); }
.dot-btn.off .dot-mark { opacity: 0.35; }
.dot-btn.future .dot-mark { background: transparent; box-shadow: inset 0 0 0 1.5px var(--hairline); }
.dot-btn.today .dot-day { color: var(--accent); font-weight: 700; }

/* ---------- habit sheet ---------- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 8px; display: grid; justify-items: center; gap: 2px; }
.stat .big { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.heatmap-wrap { display: flex; gap: 5px; padding: 18px 0 6px; overflow-x: auto; }
.heat-days { display: grid; grid-template-rows: repeat(7, 13px); gap: 3px; font-size: 10px; color: var(--faint); }
.heatmap { display: flex; gap: 3px; }
.week { display: grid; grid-template-rows: repeat(7, 13px); gap: 3px; position: relative; }
.month { position: absolute; top: -17px; left: 0; font-size: 10px; color: var(--faint); white-space: nowrap; }
.cell { width: 13px; height: 13px; border-radius: 3px; background: var(--surface-2); padding: 0; }
.cell.done { background: var(--accent); }
.cell.skipped { background: var(--surface-3); }
.cell.missed { background: var(--danger-soft); }
.cell.due { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cell.off { opacity: 0.45; }
.cell.future { background: transparent; }
.cell:disabled { opacity: 1; }
.cell.off:disabled { opacity: 0.45; }

/* amount chart (habits that track an amount) */
.amount { display: grid; gap: 10px; margin-top: 12px; }
.amount .stats { margin: 4px 0 0; }
.amount .stat .big { font-size: 18px; }
.amount-chart { width: 100%; height: 132px; display: block; overflow: visible; }
.amount-chart .bar { fill: var(--accent); pointer-events: none; }
.amount-chart .bar.picked { fill: var(--fg); }
.amount-chart .hit { fill: transparent; cursor: pointer; }
.amount-chart .grid { stroke: var(--hairline); stroke-dasharray: 2 3; stroke-width: 1; vector-effect: non-scaling-stroke; }
.amount-chart .axis { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.amount-chart .today-tick { fill: var(--faint); }
.chart-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); margin-top: -4px; font-variant-numeric: tabular-nums; }
.chart-readout { margin: 0; font-size: 13.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* ---------- sheets ---------- */

.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); animation: fade 0.18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet {
    position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
    max-width: 640px; margin: 0 auto;
    background: var(--surface); border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-2);
    animation: slide-up 0.26s cubic-bezier(0.2, 0.9, 0.25, 1);
}
@keyframes slide-up { from { transform: translateY(30%); opacity: 0.5; } }
.sheet-full { max-height: calc(100dvh - var(--safe-top) - 28px); overflow-y: auto; overscroll-behavior: contain; }
/* Taller than it looks: the whole strip is the drag/tap target. */
.sheet-grab { display: flex; justify-content: center; padding: 10px 0 12px; position: sticky; top: 0; background: var(--surface); z-index: 2; touch-action: none; }
.sheet-grab span { width: 36px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.sheet-close { position: absolute; top: 8px; right: 8px; z-index: 3; }
.sheet-body { padding: 4px 18px calc(24px + var(--safe-bottom)); }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding-right: 36px; }
.sheet-title { margin: 6px 0 0; font-size: 21px; font-weight: 650; letter-spacing: -0.02em; flex: 1; }
.title-input {
    flex: 1; font-size: 20px !important; font-weight: 600; letter-spacing: -0.015em; border: 0 !important;
    background: transparent !important; padding: 6px 0 !important; min-height: 0; box-shadow: none !important;
}
.occ-note { margin: 0 0 4px 40px; font-size: 13px; color: var(--muted); }
.field { margin-top: 20px; display: grid; gap: 10px; }
.field > label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--fg-2); }
.field > label .icon { color: var(--faint); }
.field > label .muted { font-weight: 450; margin-left: auto; color: var(--muted); }
.field + .field { padding-top: 18px; border-top: 1px solid var(--hairline); }
.time-row { display: flex; align-items: center; gap: 8px; color: var(--faint); }
.time-pick { position: relative; overflow: hidden; }
.time-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; padding: 0; }
.time-input { max-width: 150px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14.5px; color: var(--fg-2); }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wd { height: 36px; border-radius: 9px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--fg-2); }
.wd.active { background: var(--accent); color: var(--accent-fg); }
.toggle { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14.5px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle .muted { flex-basis: 100%; padding-left: 28px; font-size: 13px; }
.steps { display: grid; }
.step { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.step-title { flex: 1; text-align: left; font-size: 15px; }
.step.done .step-title { color: var(--faint); text-decoration: line-through; }
.add-step { display: flex; align-items: center; gap: 12px; color: var(--faint); }
.add-step input { background: transparent; border-color: transparent; padding-left: 0; }
.add-step input:focus { box-shadow: none; border-color: transparent; background: transparent; }
.notes { min-height: 80px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-input { width: 110px !important; height: 32px !important; padding: 0 10px !important; border-radius: 9px !important; font-size: 13.5px !important; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--hairline); }

/* ---------- quick add ---------- */

.sheet-bar { padding: 12px 12px calc(12px + var(--safe-bottom)); border-radius: 18px 18px 0 0; }
.quick-add { display: grid; gap: 10px; }
.qa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.qa-chips:empty { display: none; }
.chip.parsed { height: 28px; padding: 0 10px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 550; }
.chip.parsed .icon { width: 13px; height: 13px; }
.chip.k-tag { background: var(--surface-2); color: var(--fg-2); }
.chip.implicit { height: 28px; padding: 0 10px; background: transparent; border: 1px dashed var(--border); color: var(--muted); font-size: 13px; }
.chip.suggest { height: 30px; }
.chip.suggest .icon { color: var(--accent); }
.qa-suggest { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.qa-suggest::-webkit-scrollbar { display: none; }
.qa-row { display: flex; gap: 6px; align-items: center; }
.qa-input { flex: 1; height: 46px !important; padding: 0 14px !important; border-radius: 13px !important; font-size: 16px !important; }
.qa-send {
    width: 46px; height: 46px; border-radius: 13px; flex: none;
    background: var(--accent); color: var(--accent-fg);
    display: flex; align-items: center; justify-content: center;
}
.qa-send .icon { width: 21px; height: 21px; }
.qa-send .icon svg { stroke-width: 2.2; }
.qa-grab { display: flex; justify-content: center; margin: -6px 0 -2px; padding: 0 0 6px; touch-action: none; }
.qa-grab span { width: 36px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.log-sheet { display: grid; gap: 10px; }
.log-sheet .sheet-grab { padding: 0 0 4px; margin-top: -4px; }
.log-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 4px; }
.log-title { font-size: 16px; font-weight: 600; }
.amount-box { flex: 1; position: relative; display: flex; }
.amount-box .qa-input { padding-right: 52px !important; }
.amount-unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.qa-more { width: 40px; height: 46px; color: var(--muted); display: flex; align-items: center; justify-content: center; }

/* ---------- snackbar ---------- */

.snackbar {
    position: fixed; z-index: 60; left: 12px; right: 12px;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
    max-width: 520px; margin: 0 auto;
    display: flex; align-items: center; gap: 12px;
    min-height: 48px; padding: 0 8px 0 16px; border-radius: 12px;
    background: var(--inverse); color: var(--inverse-fg); box-shadow: var(--shadow-2);
    animation: slide-up 0.2s ease-out; font-size: 14.5px; font-weight: 500;
}
.app:has(.sheet) .snackbar { bottom: auto; top: calc(var(--safe-top) + 12px); }
.snack-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snack-undo { color: var(--inverse-accent); font-weight: 650; height: 36px; padding: 0 10px; border-radius: 8px; }

/* ---------- search ---------- */

.search-top { padding-bottom: 8px; }
.search-box {
    flex: 1; display: flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 4px 0 12px;
    color: var(--faint);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; color: var(--fg); }
.search-tags { margin-top: 6px; }

/* ---------- setup ---------- */

.setup { max-width: 400px; margin: 0 auto; padding: calc(var(--safe-top) + 72px) 20px; display: grid; gap: 16px; }
.setup h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }

.new-list .chips { margin-top: 2px; }

@media (min-width: 700px) {
    .sheet { bottom: 24px; border-radius: 20px; }
    .sheet-full { max-height: calc(100vh - 64px); }
}

/* Our own clear button replaces the WebView's native one. */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
