/* ==========================================================================
   Arc Home Manager — home studio. Design system (light + dark), mobile first.
   Design language shared with Arcston Finance Studio: warm neutral ground, white
   surfaces, ink type, Geist + Geist Mono, soft radii, quiet shadows, one accent.
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #f5f4f1; --bg-2: #eceae6; --surface: #ffffff; --surface-2: #faf9f7; --surface-3: #f3f2ee;
  --ink: #16171a; --ink-2: #3e4044; --muted: #6b6d72; --faint: #a3a5a9;
  --line: #e8e6e1; --line-2: #d9d6d0; --track: #ecebe7;
  --accent-l: #d51f36; --accent-d: #f0475c;
  --accent: var(--accent-l);
  --btn: var(--accent-l); --on-btn: #ffffff;
  --accent-soft: color-mix(in oklab, var(--accent) 10%, var(--surface));
  --accent-ink: color-mix(in oklab, var(--accent) 82%, #000);
  --blue: #0b69b7; --blue-soft: #e8f1fa;
  --green: #147a45; --green-soft: #e5f3ea;
  --amber: #a15c00; --amber-soft: #fcf0dc;
  --red: #c0192e; --red-soft: #fce8ea;
  --violet: #5b3fb5; --violet-soft: #eeeafb;
  --inv: #16171a; --on-inv: #ffffff; --on-inv-2: #b9bbc0; --inv-line: rgba(255, 255, 255, 0.12); --inv-2: rgba(255, 255, 255, 0.07);
  /* categorical chart slots — validated (dataviz) on light surfaces */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c8: #e34948; --c-other: #b4b1aa;
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --sh-1: 0 1px 2px rgba(22, 23, 26, 0.05);
  --sh-2: 0 1px 2px rgba(22, 23, 26, 0.04), 0 10px 28px -10px rgba(22, 23, 26, 0.16);
  --sh-3: 0 28px 70px -18px rgba(22, 23, 26, 0.32), 0 2px 6px rgba(22, 23, 26, 0.06);
  --ring: 0 0 0 3.5px color-mix(in oklab, var(--accent) 20%, transparent);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --side-w: 256px; --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f11; --bg-2: #1c1d21; --surface: #16171a; --surface-2: #1b1c20; --surface-3: #212226;
  --ink: #ecebe7; --ink-2: #c9c8c3; --muted: #9a9ba0; --faint: #6c6e73;
  --line: #25262b; --line-2: #33353b; --track: #2a2b30;
  --accent: var(--accent-d);
  --btn: var(--btn-d, var(--accent-l)); --on-btn: var(--on-btn-d, #ffffff);
  --accent-soft: color-mix(in oklab, var(--accent) 15%, var(--surface));
  --accent-ink: color-mix(in oklab, var(--accent) 85%, #fff);
  --blue: #5ea5f0; --blue-soft: rgba(94, 165, 240, 0.14);
  --green: #45c182; --green-soft: rgba(69, 193, 130, 0.14);
  --amber: #e9a640; --amber-soft: rgba(233, 166, 64, 0.15);
  --red: #f26b79; --red-soft: rgba(242, 107, 121, 0.15);
  --violet: #a898f5; --violet-soft: rgba(168, 152, 245, 0.15);
  --inv: #232428; --on-inv: #f1f0ec; --on-inv-2: #a3a4a8; --inv-line: rgba(255, 255, 255, 0.09); --inv-2: rgba(255, 255, 255, 0.05);
  /* dark steps of the same eight hues — validated against the dark surface */
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767; --c-other: #5d5f64;
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 30px -12px rgba(0, 0, 0, 0.6);
  --sh-3: 0 30px 80px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
html.no-scroll { overflow: hidden; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 var(--font); letter-spacing: -0.004em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11"; -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.022em; }
p { margin: 0; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ok { color: var(--green); }
.bad { color: var(--red); }
.warn { color: var(--amber); }
.ico { flex: none; display: block; }
.dim { opacity: 0.55; }
[hidden] { display: none !important; }
::selection { background: color-mix(in oklab, var(--accent) 22%, transparent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- shell */
.shell { min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 8px) 12px 8px 14px; min-height: calc(56px + var(--safe-t));
  background: color-mix(in oklab, var(--bg) 84%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color 0.2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .tb-title { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .tb-av { border: 0; background: none; padding: 2px; border-radius: 50%; }
.mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--inv); flex: none; box-shadow: inset 0 0 0 1px var(--inv-line); }
.mark svg { width: 70%; height: 70%; }
.mark.lg { width: 54px; height: 54px; border-radius: 16px; }
.mark.xl { width: 72px; height: 72px; border-radius: 20px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in oklab, var(--surface) 90%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a, .tabbar button { height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; position: relative; }
.tabbar .on { color: var(--ink); }
.tabbar .on .ico { color: var(--accent); }
.tabbar .tb-badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px; background: var(--btn); color: var(--on-btn); font-size: 10.5px; font-weight: 600; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface); }
.tabbar .tb-badge:empty { display: none; }
.fab {
  width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 18px; border: 0; display: grid; place-items: center;
  background: var(--btn); color: var(--on-btn); box-shadow: 0 10px 24px -8px color-mix(in oklab, var(--btn) 70%, transparent), 0 0 0 5px var(--bg);
  transition: transform 0.2s var(--spring);
}
.tabbar .fab-slot { justify-content: flex-end; }
.fab:active { transform: scale(0.92); }
.fab .ico { width: 24px; height: 24px; }

.page { max-width: 1180px; margin: 0 auto; padding: 8px 16px calc(var(--tab-h) + var(--safe-b) + 36px); }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin: 6px 0 18px; }
.ph h1 { font-size: 26px; line-height: 1.12; }
.ph p { margin-top: 5px; color: var(--muted); font-size: 14px; }
.ph .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ph-desk { display: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px;
  border: 1px solid transparent; font-weight: 500; white-space: nowrap; background: none; text-decoration: none; color: var(--ink);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s; touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .seg button:focus-visible, .tick:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--btn); color: var(--on-btn); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 1px 2px color-mix(in oklab, var(--btn) 45%, transparent); }
.btn-primary:hover { background: color-mix(in oklab, var(--btn) 88%, #000); }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); box-shadow: var(--sh-1); }
.btn-secondary:hover { border-color: color-mix(in oklab, var(--line-2) 70%, var(--ink)); background: var(--surface-2); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-soft:hover { background: color-mix(in oklab, var(--accent) 16%, var(--surface)); }
.btn-danger { background: var(--red); color: #fff; }
.danger-text { color: var(--red) !important; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13.5px; gap: 6px; border-radius: 9px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15.5px; border-radius: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; border: 1px solid transparent; background: none; color: var(--ink-2);
  transition: background 0.15s, color 0.15s, transform 0.1s; flex: none;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.bordered { border-color: var(--line-2); background: var(--surface); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.link { color: var(--accent-ink); text-decoration: none; font-weight: 500; font-size: 13.5px; display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; }
.link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- forms */
.fm { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.fm .span2, .span2 { grid-column: 1 / -1; }
.fm-intro { color: var(--muted); font-size: 14px; margin: -2px 0 14px; }
.fm-sec { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; padding-top: 6px; display: flex; justify-content: space-between; align-items: baseline; }
.fm-sec small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field > label .opt { color: var(--faint); font-weight: 400; }
.hint { font-size: 12.5px; color: var(--muted); }
.hint.err { color: var(--red); }
.inp, .sel, .ta, .datefield {
  width: 100%; height: 44px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; min-width: 0; font-size: 16px;
}
.inp::placeholder, .ta::placeholder { color: var(--faint); }
.inp:hover, .sel:hover, .ta:hover, .datefield:hover { border-color: color-mix(in oklab, var(--line-2) 60%, var(--ink)); }
.inp:focus, .sel:focus, .ta:focus, .datefield:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }
.inp.num { font-variant-numeric: tabular-nums; }
.inp.big { height: 58px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.ta { height: auto; min-height: 84px; padding: 11px 13px; resize: vertical; line-height: 1.5; }
.sel {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b8d92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.datefield { display: flex; align-items: center; gap: 9px; text-align: left; cursor: pointer; }
.datefield span { flex: 1; font-variant-numeric: tabular-nums; }
.datefield em { font-style: normal; color: var(--faint); }
.datefield .ico:first-child { color: var(--muted); }
.inp-group { display: flex; align-items: stretch; }
.inp-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); font-weight: 500; }
.inp-group .addon.pre { border-right: 0; border-radius: 11px 0 0 11px; }
.inp-group .addon.pre + .inp { border-radius: 0 11px 11px 0; }
.inp-group.big .addon { font-size: 20px; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--bg-2); border-radius: 12px; padding: 3px; gap: 2px; width: 100%; max-width: 100%; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 9px; min-height: 36px; padding: 0 10px; font-weight: 500; font-size: 14px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.15s var(--ease); white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
.seg.inline { width: auto; }
.seg.sm button { min-height: 30px; font-size: 13px; padding: 0 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  min-height: 34px; padding: 0 13px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; font-weight: 500;
  color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s; font-variant-numeric: tabular-nums; white-space: nowrap; text-decoration: none;
}
.chip:hover { border-color: color-mix(in oklab, var(--line-2) 60%, var(--ink)); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.ghost { border-style: dashed; }
.chip .n { font-size: 12px; opacity: 0.7; }
.chip.sm { min-height: 28px; font-size: 12.5px; padding: 0 10px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; scroll-padding: 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; font-size: 14px; color: var(--ink-2); transition: all 0.15s; }
.person:hover { border-color: color-mix(in oklab, var(--line-2) 60%, var(--ink)); }
.person.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; font-size: 14.5px; color: var(--ink); padding: 4px 0; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; width: 42px; height: 26px; border-radius: 99px; background: var(--line-2); position: relative; flex: none; cursor: pointer; transition: background 0.2s var(--ease);
}
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.22s var(--spring); }
.switch input:checked { background: var(--btn); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--ring); outline: none; }
.switch b { font-weight: 500; display: block; }
.switch small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); transition: transform 0.15s var(--spring); }
.sw.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); transform: scale(1.02); }
.sw-custom { position: relative; display: grid; place-items: center; cursor: pointer; color: #fff; overflow: hidden;
  background: conic-gradient(from 200deg, #e0245e, #f59e0b, #65a30d, #0891b2, #4f46e5, #c026d3, #e0245e); }
.sw-custom.has { background: var(--c); }
.sw-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.sw-custom .ico { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick button { width: 42px; height: 42px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); }
.icon-pick button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.icon-pick .ip-more { width: auto; padding: 0 12px; gap: 6px; display: inline-flex; align-items: center; font-size: 13.5px; font-weight: 500; border-style: dashed; }
.field-lbl { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-lbl > label { font-size: 13px; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field-lbl > label .opt { color: var(--faint); font-weight: 400; }
.lbl-link { font-size: 12.5px; gap: 5px; color: var(--muted); }
.lbl-link:hover { color: var(--accent-ink); text-decoration: none; }
.chip-add { color: var(--muted); }
.chip-new { display: inline-flex; align-items: center; gap: 6px; flex: 1 1 240px; min-width: 0; max-width: 360px; }
.chip-new .inp { height: 34px; border-radius: 99px; padding: 0 13px; flex: 1; min-width: 0; font-size: 15px; }
.chip-new .btn { flex: none; border-radius: 99px; }
/* floating icon picker (card on larger screens, sheet on phones) */
.ipk { position: fixed; z-index: 96; width: 348px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-3); padding: 10px; }
.ipk-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.ipk-search .inp { height: 38px; font-size: 14.5px; }
.ipk-scroll { max-height: 340px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; margin: 0 -2px; scrollbar-width: thin; }
.ipk-sheet .ipk-scroll { max-height: 52vh; }
.ipk-g { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; padding: 10px 2px 6px; }
.ipk-g:first-child { padding-top: 2px; }
.ipk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.ipk-i { height: 40px; border-radius: 10px; border: 1px solid transparent; background: none; display: grid; place-items: center; color: var(--ink-2); transition: background 0.12s, color 0.12s; }
.ipk-i:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.ipk-i:focus-visible { outline: none; box-shadow: var(--ring); }
.ipk-i.on { background: var(--ink); color: var(--bg); }
.ipk-none { padding: 14px 4px; }
/* list editor sheet */
.le-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.le-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.le-row .inp, .le-row .sel { height: 42px; }
.le-name { flex: 1 1 140px; min-width: 0; }
.le-time { flex: 0 0 118px; width: 118px; }
.le-cat { flex: 0 1 170px; min-width: 0; }
.le-ico { flex: none; width: 42px; height: 42px; }
.le-move { display: inline-flex; flex: none; }
.le-move .icon-btn[disabled] { opacity: 0.3; pointer-events: none; }
@media (max-width: 520px) {
  .le-row { gap: 4px; }
  .le-row .icon-btn.sm { width: 30px; }
  .le-list.wide .le-row { flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
  .le-list.wide .le-name { flex-basis: calc(100% - 50px); }
  .le-list.wide .le-time, .le-list.wide .le-cat { flex: 1 1 120px; }
  .le-list.wide .le-move { margin-left: auto; }
}
.range { display: flex; align-items: center; gap: 14px; min-height: 44px; }
.range input[type="range"] {
  flex: 1; min-width: 40px; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 99px; outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--accent) 0 var(--p, 40%), var(--track) var(--p, 40%) 100%);
}
.range input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05); cursor: grab; }
.range input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.range output { min-width: 64px; text-align: right; font: 600 15px var(--font); font-variant-numeric: tabular-nums; }
.rep { display: flex; flex-direction: column; gap: 8px; }
.rep-n { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.rep-n .inp { width: 72px; height: 38px; text-align: center; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; }

/* ---------------------------------------------------------------- cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; padding: 16px 18px 0; }
.card-h .seg.inline { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.card-h .seg.inline::-webkit-scrollbar { display: none; }
.card-h h3 { font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card-h h3 .ico { color: var(--muted); }
.card-h .muted { font-size: 13px; }
.card-b { padding: 14px 18px 18px; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card.flat { box-shadow: none; }
.card.pad { padding: 16px 18px; }
.card.click { cursor: pointer; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; text-decoration: none; display: block; }
.card.click:hover { border-color: var(--line-2); box-shadow: var(--sh-2); }
.card.click:active { transform: scale(0.99); }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
.cols { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.cols > * { min-width: 0; }
.sec-t { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 2px 10px; }
.sec-t h2 { font-size: 17px; }
.sec-t:first-child { margin-top: 4px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 559px) { .kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; } }
.kpis > * { min-width: 0; }
.kpi { padding: 14px 16px; position: relative; overflow: hidden; }
.kpi .k-l { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .k-l .ico { color: var(--faint); }
.kpi .k-v { font-size: 23px; font-weight: 600; letter-spacing: -0.03em; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-s { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.kpi.inv { background: var(--inv); border-color: var(--inv); color: var(--on-inv); }
.kpi.inv .k-l, .kpi.inv .k-s { color: var(--on-inv-2); }
.kpi.inv .k-l .ico { color: var(--accent); }
.meter { height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.6s var(--ease); }
.meter.ok i { background: var(--green); }
.meter.warn i { background: var(--amber); }
.meter.bad i { background: var(--red); }
.kpi.inv .meter { background: var(--inv-line); }

/* hero (inverse) card */
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 20px; color: var(--on-inv); background: var(--inv);
  background-image: radial-gradient(120% 90% at 100% 0%, color-mix(in oklab, var(--accent) 26%, transparent) 0%, transparent 55%);
  box-shadow: var(--sh-2);
}
.hero .muted, .hero small { color: var(--on-inv-2); }
.hero .btn-secondary { background: var(--inv-2); border-color: var(--inv-line); color: var(--on-inv); box-shadow: none; }
.hero .btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }
.hero .chip { background: var(--inv-2); border-color: var(--inv-line); color: var(--on-inv); }
.hero .ring svg circle:first-child { stroke: var(--inv-line); }

/* lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); min-width: 0; position: relative; text-decoration: none; color: inherit; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.list > .li:first-child, .card > .li:first-child { border-top: 0; }
.li.click { cursor: pointer; transition: background 0.12s; }
.li.click:hover { background: var(--surface-2); }
.li .li-m { flex: 1; min-width: 0; }
.li .li-t { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .li-t.wrap { white-space: normal; }
.li .li-s { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); margin-top: 3px; }
.li .li-s > span { display: inline-flex; align-items: center; gap: 4px; }
.li .li-v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.li .li-v small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.li.done .li-t { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.li-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in oklab, var(--c, var(--muted)) 13%, var(--surface)); color: var(--c, var(--ink-2)); }
.li-ico.sm { width: 32px; height: 32px; border-radius: 10px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; background: var(--surface-2); border-top: 1px solid var(--line); }
.list > .day-h:first-child { border-top: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }

/* round checkbox */
.tick {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface); flex: none; display: grid; place-items: center;
  color: transparent; transition: all 0.18s var(--ease); padding: 0;
}
.tick:hover { border-color: var(--accent); color: color-mix(in oklab, var(--accent) 45%, transparent); }
.tick.on { background: var(--accent); border-color: var(--accent); color: #fff; animation: pop 0.34s var(--spring); }
.tick.sq { border-radius: 9px; }
.tick .ico { width: 15px; height: 15px; stroke-width: 3; }
@keyframes pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }

/* pills, badges, avatars */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.pill .ico { width: 13px; height: 13px; }
.pill-neutral { background: var(--bg-2); color: var(--ink-2); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-violet { background: var(--violet-soft); color: var(--violet); }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.pts { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border-radius: 99px; padding: 2px 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.av {
  display: inline-grid; place-items: center; width: var(--s); height: var(--s); min-width: var(--s); border-radius: 50%; background: var(--c); color: #fff; flex: none !important;
  aspect-ratio: 1; font-size: calc(var(--s) * 0.38); font-weight: 600; letter-spacing: 0; line-height: 1; user-select: none; overflow: hidden;
}
.av.emo { background: color-mix(in oklab, var(--c) 20%, var(--surface)); font-size: calc(var(--s) * 0.56); }
.av.any { background: var(--bg-2); color: var(--ink-2); }
.av.tog { background: var(--accent-soft); color: var(--accent); }
.av-stack { display: inline-flex; }
.av-stack .av { box-shadow: 0 0 0 2px var(--surface); }
.av-stack .av + .av { margin-left: -8px; }

/* tabs, search, filters, month switcher */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 11px 12px; text-decoration: none; color: var(--muted); font-weight: 500; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14.5px; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs .on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11.5px; background: var(--bg-2); color: var(--muted); border-radius: 99px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.tabs .count:empty { display: none; }
.search { position: relative; flex: 1; min-width: 0; }
.search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search .inp { padding-left: 40px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.monthsw { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: 3px; }
.monthsw b { min-width: 118px; text-align: center; font-weight: 600; font-size: 14px; }
.monthsw .icon-btn { width: 34px; height: 34px; }

/* empty & skeleton */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-ico { width: 56px; height: 56px; border-radius: 18px; background: var(--bg-2); display: grid; place-items: center; color: var(--muted); margin-bottom: 4px; }
.empty h4 { color: var(--ink); font-size: 16px; }
.empty p { max-width: 360px; margin: 0 0 6px; font-size: 14px; }
.empty.sm { padding: 24px 16px; }
.skel { background: linear-gradient(90deg, var(--bg-2), var(--surface-3), var(--bg-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--r); background: var(--amber-soft); color: var(--amber); font-size: 14px; }
.banner.info { background: var(--blue-soft); color: var(--blue); }
.banner.accent { background: var(--accent-soft); color: var(--accent-ink); }
.banner .grow { color: var(--ink-2); }
.banner b { color: var(--ink); }

/* ---------------------------------------------------------------- modal / sheet */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; background: rgba(12, 13, 15, 0.42); opacity: 0; transition: opacity 0.22s; }
.modal-wrap.in { opacity: 1; }
.modal {
  width: 100%; max-width: 100%; background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--sh-3); max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.32s var(--ease); min-width: 0;
}
.modal-wrap.in .modal { transform: none; }
.modal .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line-2); margin: 8px auto -2px; flex: none; }
.modal-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px 4px 20px; }
.modal-h h3 { font-size: 18px; }
.modal-b { padding: 10px 20px 20px; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-f { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface-2); }
.modal-f .sp { flex: 1; }
.confirm-msg { color: var(--ink-2); font-size: 15px; }

#toasts { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--inv); color: var(--on-inv); padding: 11px 12px 11px 16px; border-radius: 16px; box-shadow: var(--sh-3);
  font-weight: 500; font-size: 14px; opacity: 0; transform: translateY(10px) scale(0.98); transition: all 0.26s var(--spring); pointer-events: auto; max-width: 100%;
}
.toast.in { opacity: 1; transform: none; }
.toast .ico { color: #5fd08f; }
.toast-err .ico { color: #ff8595; }
.toast-pts .ico { color: var(--accent-d); }
.toast span { min-width: 0; }
.toast button { border: 0; background: var(--inv-2); color: var(--on-inv); font-weight: 600; font-size: 13px; padding: 6px 10px; border-radius: 10px; margin-left: 4px; }

.pop-menu { position: fixed; z-index: 80; min-width: 220px; max-width: calc(100vw - 16px); max-height: min(70vh, 480px); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-3); padding: 5px; }
.pop-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 11px; border: 0; background: none; border-radius: 9px; text-align: left; font-size: 14.5px; color: var(--ink-2); }
.pop-menu button:hover { background: var(--bg); color: var(--ink); }
.pop-menu button .ico { color: var(--muted); }
.pop-menu button span { flex: 1; }
.pop-menu button.danger, .pop-menu button.danger .ico { color: var(--red); }
.pop-menu button[disabled] { opacity: 0.4; }
.pop-menu kbd { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }

.dp { position: fixed; z-index: 95; width: 296px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-3); padding: 12px; }
.dp-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-t { display: flex; align-items: center; gap: 2px; }
.dp-w, .dp-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-w span { text-align: center; font-size: 11px; color: var(--faint); font-weight: 500; padding: 4px 0; }
.dp-g .d { height: 36px; border: 0; border-radius: 10px; background: none; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink); }
.dp-g .d:hover { background: var(--bg); }
.dp-g .d.out { color: var(--faint); }
.dp-g .d.today { box-shadow: inset 0 0 0 1px var(--line-2); font-weight: 600; }
.dp-g .d.is-sel { background: var(--btn); color: var(--on-btn); font-weight: 600; box-shadow: none; }
.dp-f { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.dp-f .chip { min-height: 28px; font-size: 12.5px; padding: 0 10px; }
.dp-sel {
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 8px; cursor: pointer; font: 600 15px var(--font); color: var(--ink);
  padding: 5px 22px 5px 8px; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8d92' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 6px center;
}
.dp-sel:hover { background-color: var(--bg); }
.dp-sel.yr { color: var(--muted); font-weight: 500; }

.tip { position: fixed; z-index: 99; pointer-events: none; background: var(--inv); color: var(--on-inv); font-size: 12.5px; padding: 8px 11px; border-radius: 10px; box-shadow: var(--sh-2); max-width: 280px; font-variant-numeric: tabular-nums; line-height: 1.45; }
.tip span { display: flex; align-items: center; gap: 6px; }
.tip b { font-weight: 600; }
.tip > b:first-child { display: block; margin-bottom: 2px; }
.tip .tt { border-top: 1px solid var(--inv-line); margin-top: 4px; padding-top: 4px; }
.tdot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; flex: none; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 120; }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gl { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .gl.base { stroke: var(--line-2); stroke-dasharray: none; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: color-mix(in oklab, var(--ink) 5%, transparent); }
.chart .target { stroke: var(--ink-2); stroke-dasharray: 4 4; stroke-width: 1.2; }
.chart-empty { position: relative; }
.chart-empty .msg { position: absolute; inset: 0 0 26px 48px; display: grid; place-items: center; color: var(--muted); font-size: 13.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ring { position: relative; width: var(--s); height: var(--s); flex: none; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring .ring-v { transition: stroke-dashoffset 0.9s var(--ease); }
.ring-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-weight: 600; font-size: calc(var(--s) * 0.22); letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-c small { font-size: 11.5px; font-weight: 500; letter-spacing: 0; margin-top: 4px; color: var(--muted); }
.spark { display: block; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hb { display: grid; grid-template-columns: minmax(96px, 1.1fr) 2fr auto; gap: 12px; align-items: center; padding: 6px 4px; border-radius: 9px; }
.hb:hover { background: var(--surface-2); }
.hb-l { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 14px; }
.hb-l .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-l .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; box-shadow: none; }
.hb-i { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none; background: color-mix(in oklab, var(--c) 14%, var(--surface)); color: var(--c); }
.hb-i .ico { width: 15px; height: 15px; }
.hb-bar { position: relative; height: 10px; background: var(--track); border-radius: 99px; overflow: visible; }
.hb-bar i { display: block; height: 100%; border-radius: 99px; max-width: 100%; }
.hb-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 2px; }
.hb-v { text-align: right; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hb-v small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.split-bar { display: flex; gap: 2px; height: 14px; border-radius: 99px; overflow: hidden; background: var(--track); }
.split-bar i { display: block; height: 100%; min-width: 4px; }
.split-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.split-legend span { display: inline-flex; align-items: center; gap: 6px; }
.split-legend i { width: 10px; height: 10px; border-radius: 3px; }
.heat { max-width: 360px; }
.heat-w, .heat-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat-w span { text-align: center; font-size: 11px; color: var(--faint); padding-bottom: 4px; }
.hc { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--bg-2); }
.hc.pad { background: none; }
.hc.l1 { background: color-mix(in oklab, var(--accent) 20%, var(--surface)); color: var(--ink-2); }
.hc.l2 { background: color-mix(in oklab, var(--accent) 40%, var(--surface)); color: var(--ink); }
.hc.l3 { background: color-mix(in oklab, var(--accent) 66%, var(--surface)); color: #fff; }
.hc.l4 { background: var(--accent); color: #fff; }
.hc.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }
.hc.future { opacity: 0.45; }
.heat-k { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.heat-k .hc { width: 13px; height: 13px; border-radius: 4px; }
.heat-k span:first-child { margin-right: 4px; }
.heat-k span:last-child { margin-left: 4px; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl.compact td, .tbl.compact th { padding: 7px 10px; font-size: 13px; }
details.data > summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style: none; display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; }
details.data > summary::-webkit-details-marker { display: none; }
details.data[open] > summary { margin-bottom: 8px; }

/* ---------------------------------------------------------------- auth */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; background: var(--surface); }
.auth-art { display: none; }
.auth-pane { display: grid; place-items: center; padding: calc(var(--safe-t) + 28px) 20px calc(var(--safe-b) + 24px); }
.auth-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.auth-box .mark { margin-bottom: 14px; }
.auth-box small.k { font-size: 13px; color: var(--muted); font-weight: 500; }
.auth-box h1 { font-size: 26px; line-height: 1.15; }
.auth-box .sub { color: var(--muted); font-size: 14.5px; margin-top: 4px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 24px 0 6px; min-height: 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); transition: all 0.15s var(--spring); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); transform: scale(1.05); }
.pin-dots.shake { animation: shake 0.42s; }
.pin-dots.ok i { background: var(--green); border-color: var(--green); }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
.auth-err { color: var(--red); font-size: 14px; min-height: 20px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; justify-content: center; margin: 10px 0 18px; }
.pinpad button {
  width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--surface-3); font-size: 28px; font-weight: 500; color: var(--ink);
  display: grid; place-items: center; transition: background 0.12s, transform 0.12s; font-variant-numeric: tabular-nums; touch-action: manipulation;
}
.pinpad button:hover { background: var(--bg-2); }
.pinpad button:active { transform: scale(0.92); background: var(--line-2); }
.pinpad button.fn { background: none; color: var(--ink-2); }
.pinpad button.go { background: var(--btn); color: var(--on-btn); }
.pinpad button.go[disabled] { opacity: 0.35; }
.auth-foot { font-size: 13.5px; color: var(--muted); }
.auth-theme { position: fixed; top: calc(var(--safe-t) + 12px); right: 12px; z-index: 5; }
.setup { width: 100%; max-width: 420px; text-align: left; }
.setup .steps { display: flex; gap: 6px; margin: 4px 0 22px; }
.setup .steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--track); }
.setup .steps i.on { background: var(--accent); }
.setup h1 { font-size: 26px; }
.setup .sub { color: var(--muted); margin: 6px 0 22px; }
.setup .fm { margin-bottom: 20px; }
/* sign-in: people on this device, ID field, the code field under the dots */
.known-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 14px; margin: 22px 0 10px; }
.known-p { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 104px; padding: 10px 4px; border: 0; background: none; border-radius: 18px; font-weight: 500; font-size: 14px; color: var(--ink); transition: background 0.15s, transform 0.12s; }
.known-p:hover { background: var(--surface-2); }
.known-p:active { transform: scale(0.96); }
.known-p:focus-visible { outline: none; box-shadow: var(--ring); }
.known-p .av { box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-2); }
.known-p > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-sel { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px 10px 10px; margin-top: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); text-align: left; }
.who-sel b { display: block; font-size: 15px; font-weight: 600; }
.who-sel small { color: var(--muted); font-size: 12.5px; }
.id-field { width: 100%; display: flex; flex-direction: column; gap: 7px; text-align: left; margin-top: 20px; }
.id-field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.auth-box .pin-label { margin-top: 14px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.pin-wrap { position: relative; width: 100%; display: flex; justify-content: center; }
.pin-wrap .pin-dots { margin: 12px 0 6px; }
.pin-inp { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; background: transparent; color: transparent; caret-color: transparent; font-size: 16px; cursor: pointer; }
.pin-wrap:focus-within .pin-dots i:not(.on) { border-color: color-mix(in oklab, var(--accent) 55%, var(--line-2)); }
.auth-keep { margin: 0 0 12px; font-size: 13.5px; }
.auth-foot .link { font-size: 13.5px; }
.muted-link { color: var(--muted); font-size: 13px; margin-top: 8px; }
/* Homes on the sign-in screen: the home name switches homes; "Find your home" when none is picked */
.home-h { max-width: 100%; }
.home-sw { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; padding: 4px 6px 4px 12px; border: 0; border-radius: 14px; background: none; color: inherit; font: inherit; letter-spacing: inherit; cursor: pointer; transition: background 0.15s var(--ease); }
.home-sw:hover { background: var(--surface-2); }
.home-sw:active { transform: scale(0.98); }
.home-sw:focus-visible { outline: none; box-shadow: var(--ring); }
.home-sw-i { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); }
.hm-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.hm-box .hm-list { margin: 20px 0 18px; }
.hm-box .sub + .hm-find { margin-top: 22px; }
.hm-row { display: flex; align-items: center; gap: 4px; }
.hm-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px 10px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: background 0.15s var(--ease); }
.hm-pick:hover { background: var(--surface-2); }
.hm-pick:active { transform: scale(0.99); }
.hm-pick:focus-visible { outline: none; box-shadow: var(--ring); }
.hm-row.is-cur .hm-pick { border-color: var(--accent); }
.hm-pick .mark { width: 42px; height: 42px; border-radius: 13px; margin: 0; }
.hm-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hm-t b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-t small { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-on { flex: none; color: var(--accent); }
.hm-del { flex: none; width: 44px; height: 44px; color: var(--muted); }
.hm-acts { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.hm-acts:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.hm-act { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 7px; border: 0; border-radius: 16px; background: none; color: var(--ink); font: inherit; font-weight: 500; text-align: left; cursor: pointer; transition: background 0.15s var(--ease); }
.hm-act:hover { background: var(--surface-2); }
.hm-act:focus-visible { outline: none; box-shadow: var(--ring); }
.hm-act-i { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 13px; background: var(--surface-3); color: var(--ink-2); }
.hm-find-wrap { padding: 4px 7px 14px; }
.hm-find { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; }
.hm-find .id-field { margin-top: 0; }
.hm-find .hint { margin: 0; }
.hm-find .auth-err { min-height: 0; }
.hm-find .auth-err:empty { display: none; }
.hm-find .btn { margin-top: 6px; }
.hm-or { display: flex; align-items: center; gap: 12px; width: 100%; margin: 20px 0 14px; color: var(--muted); font-size: 13px; }
.hm-or::before, .hm-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.hm-id-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.hm-id { font-size: 15px; padding: 7px 12px; border-radius: 10px; background: var(--surface-3); color: var(--ink); overflow-wrap: anywhere; }
.setup-cancel { display: flex; align-items: center; gap: 6px; width: max-content; margin-bottom: 18px; font-size: 14px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 14px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface); text-align: left; color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s; min-width: 0; }
.choice:hover { border-color: color-mix(in oklab, var(--line-2) 60%, var(--ink)); }
.choice:active { transform: scale(0.98); }
.choice:focus-visible { outline: none; box-shadow: var(--ring); }
.choice.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice b { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.choice small { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.choice-i { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.choice.on .choice-i { background: var(--btn); color: var(--on-btn); }
@media (max-width: 379px) { .choice-grid { grid-template-columns: 1fr; } }
.setup-nav { display: flex; gap: 10px; }
/* short phones: keep the whole sign-in on one screen */
@media (max-width: 1023px) and (max-height: 860px) {
  .auth-box .mark.xl { width: 58px; height: 58px; border-radius: 17px; margin-bottom: 8px; }
  .pinpad { grid-template-columns: repeat(3, 68px); gap: 10px 20px; margin: 6px 0 12px; }
  .pinpad button { width: 68px; height: 68px; font-size: 26px; }
  .who-sel, .id-field { margin-top: 12px; }
}
.setup-nav .btn { height: 52px; border-radius: 14px; }
.setup-nav .btn-primary { flex: 1; font-size: 16px; }
.setup-nav .btn-secondary { width: 52px; padding: 0; flex: none; }

/* ---------------------------------------------------------------- misc components */
.segbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.addbar { display: flex; gap: 8px; align-items: center; }
.addbar .inp { flex: 1; }
.kbd { font: 500 11px var(--mono); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--muted); background: var(--surface-2); }
.update-bar { position: fixed; left: 50%; top: calc(var(--safe-t) + 12px); transform: translateX(-50%); z-index: 95; display: flex; align-items: center; gap: 12px; background: var(--inv); color: var(--on-inv); padding: 8px 8px 8px 16px; border-radius: 99px; box-shadow: var(--sh-3); font-size: 14px; max-width: calc(100vw - 24px); }
.update-bar .ico { color: var(--accent-d); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); text-align: left; text-decoration: none; color: var(--ink); font-weight: 500; font-size: 14px; transition: all 0.15s; min-width: 0; }
.tile:hover { border-color: var(--line-2); box-shadow: var(--sh-2); }
.tile:active { transform: scale(0.97); }
.tile .ti { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in oklab, var(--c, var(--accent)) 13%, var(--surface)); color: var(--c, var(--accent)); }
.tile small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: -6px; }
.more-g { margin-bottom: 18px; }
.more-g h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 8px 2px; font-weight: 600; }
.smart { position: relative; }
.smart .inp { height: 52px; padding-left: 46px; padding-right: 52px; border-radius: 14px; font-size: 16px; }
.smart > .ico { position: absolute; left: 15px; top: 17px; color: var(--accent); }
.smart .go { position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; border-radius: 11px; }
.smart-preview { display: flex; align-items: center; gap: 10px; min-height: 34px; margin-top: 8px; font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.smart-preview b { color: var(--ink); font-weight: 600; }
.me-card { display: flex; align-items: center; gap: 12px; padding: 4px 2px 14px; }
.me-card b { display: block; font-size: 16px; }
.me-card small { color: var(--muted); }

/* ---------------------------------------------------------------- desktop */
@media (min-width: 560px) {
  .kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 720px) {
  .modal-wrap { place-items: center; padding: 24px; }
  .modal { max-width: var(--mw, 540px); border-radius: var(--r-xl); max-height: calc(100vh - 48px); transform: translateY(10px) scale(0.985); transition: transform 0.24s var(--ease); }
  .modal .grab { display: none; }
  .modal-h { padding: 18px 16px 6px 22px; }
  .modal-b { padding: 10px 22px 22px; }
  .modal-f { border-radius: 0 0 var(--r-xl) var(--r-xl); padding: 12px 16px; }
  .g2 { grid-template-columns: 1fr 1fr; }
  .g3 { grid-template-columns: repeat(3, 1fr); }
  .chips.scroll { flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }
  .tabs { margin: 0 0 14px; padding: 0; }
  .inp, .sel, .datefield { font-size: 15px; height: 42px; }
  .ta { font-size: 15px; }
}
@media (min-width: 1024px) {
  body { font-size: 14.5px; }
  .shell { display: grid; grid-template-columns: var(--side-w) 1fr; }
  .topbar, .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
    background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px 12px;
  }
  .side > * { flex-shrink: 0; }
  .side::-webkit-scrollbar { width: 6px; }
  .side::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }
  .brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px 16px; text-decoration: none; color: var(--ink); min-width: 0; }
  .brand b { display: block; font-size: 15px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
  .brand > span:last-child { min-width: 0; }
  .side .btn-new { width: 100%; height: 42px; margin-bottom: 14px; }
  .side .btn-new kbd { margin-left: auto; font: 500 11px var(--mono); opacity: 0.75; }
  .side-nav { display: flex; flex-direction: column; gap: 1px; }
  .nav-label { font-size: 11px; font-weight: 600; color: var(--faint); letter-spacing: 0.07em; text-transform: uppercase; padding: 14px 10px 5px; }
  .side-nav a { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 500; transition: background 0.15s, color 0.15s; }
  .side-nav a .ico { color: var(--muted); }
  .side-nav a:hover { background: var(--surface-2); color: var(--ink); }
  .side-nav a.on { background: var(--bg); color: var(--ink); }
  .side-nav a.on .ico { color: var(--accent); }
  .side-nav a .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--bg); padding: 1px 7px; border-radius: 99px; }
  .side-nav a .count.due { background: var(--red-soft); color: var(--red); }
  .side-nav a.on .count { background: var(--surface); }
  .side-nav a .count:empty { display: none; }
  .side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
  .me-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; border: 0; background: none; text-align: left; width: 100%; }
  .me-chip:hover { background: var(--surface-2); }
  .me-chip .me-t { flex: 1; min-width: 0; }
  .me-chip b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .me-chip small { color: var(--muted); font-size: 12px; }
  .page { padding: 30px 36px 64px; }
  .ph { margin: 0 0 22px; }
  .ph h1 { font-size: 28px; }
  .ph-desk { display: flex; }
  .cols { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .cols.even { grid-template-columns: 1fr 1fr; }
  #toasts { bottom: 24px; }
  .kpi { padding: 18px 20px; }
  .kpi .k-v { font-size: 26px; }
  .hero { padding: 24px 26px; }
}
.sync { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 4px 8px; border: 0; background: none; border-radius: 8px; text-align: left; }
.sync:hover { background: var(--surface-2); }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); flex: none; }
.sync.busy .dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); animation: pulse 1s infinite; }
.sync.err .dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.sync.off .dot { background: var(--faint); box-shadow: 0 0 0 3px var(--bg-2); }
@keyframes pulse { 50% { opacity: 0.35; } }
.theme-seg { display: flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 2px; }
.theme-seg button { flex: 1; height: 28px; border: 0; background: none; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.theme-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.offline-pill { position: fixed; top: calc(var(--safe-t) + 60px); left: 50%; transform: translateX(-50%); z-index: 40; }

@media (min-width: 1024px) { .auth { grid-template-columns: 1.05fr 1fr; } }
@media (min-width: 1024px) {
  .auth-art {
    display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 52px; position: relative; overflow: hidden;
    background: #16171a; color: #fff;
    background-image: radial-gradient(90% 70% at 100% 100%, color-mix(in oklab, var(--accent-l) 40%, transparent), transparent 60%);
  }
  .auth-art .brandmark { display: flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: 0.02em; font-size: 15px; color: #e7e6e2; }
  .auth-art h2 { font-size: 46px; line-height: 1.04; letter-spacing: -0.04em; max-width: 520px; }
  .auth-art h2 em { font-style: normal; color: var(--accent-d); }
  .auth-art ul { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
  .auth-art li { display: flex; gap: 12px; align-items: flex-start; color: #b9bbc0; font-size: 15px; }
  .auth-art li .ico { color: var(--accent-d); margin-top: 2px; }
  .auth-art li b { color: #fff; font-weight: 500; }
  .auth-art .foot { font-size: 13px; color: #8d8f94; }
  .auth-art .glyph { position: absolute; right: -60px; top: 12%; width: 420px; height: 420px; opacity: 0.06; color: #fff; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .side, .topbar, .tabbar, #toasts { display: none !important; }
  body { background: #fff; }
}
/* while a sheet is open on a phone, toasts move to the top so they never cover it */
@media (max-width: 719px) { html.no-scroll #toasts { bottom: auto; top: calc(var(--safe-t) + 12px); } }
