/* =====================================================================
   Geopad — flat, sharp, corporate (Supabase / Apple inspired)
   ===================================================================== */
:root {
  --fs: 13px;
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --bg: #fcfcfc;
  --sidebar: #f8f8f8;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --zebra: #f6f6f6;
  --hover: #efefef;
  --press: rgba(0, 0, 0, 0.055);
  --border: #e5e5e5;
  --border-soft: #efefef;
  --border-strong: #d1d1d1;
  --text: #171717;
  --muted: #666666;
  --faint: #9a9a9a;
  --ink: #000;

  --red: #e5484d;
  --orange: #f76b15;
  --amber: #e2a336;
  --green: #30a46c;
  --teal: #12a594;
  --blue: #0090ff;
  --violet: #8e4ec6;
  --pink: #d6409f;
  --gray: #8b8d98;

  --accent: #17a06b;
  --accent-fg: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 9%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 82%, var(--ink));

  --r: 6px;
  --r-sm: 4px;
  --shadow-pop: 0 8px 24px -6px rgba(0, 0, 0, 0.14), 0 0 0 1px var(--border);
  --shadow-modal: 0 24px 60px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #121212;
  --sidebar: #0f0f0f;
  --surface: #171717;
  --surface-2: #1f1f1f;
  --zebra: #1e1e1e;
  --hover: #252525;
  --press: rgba(255, 255, 255, 0.07);
  --border: #2e2e2e;
  --border-soft: #262626;
  --border-strong: #3e3e3e;
  --text: #ededed;
  --muted: #a1a1a1;
  --faint: #6e6e6e;
  --ink: #fff;

  --red: #ff6369;
  --orange: #ff8b3e;
  --amber: #ffca16;
  --green: #3dd68c;
  --teal: #0bd8b6;
  --blue: #70b8ff;
  --violet: #bf7af0;
  --pink: #ff8dcc;
  --gray: #8b8d98;

  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 60%, var(--ink));
  --shadow-pop: 0 8px 24px -6px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border);
  --shadow-modal: 0 24px 60px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border);
  color-scheme: dark;
}

.accent { --c: var(--accent); }
.red { --c: var(--red); }
.orange { --c: var(--orange); }
.amber { --c: var(--amber); }
.green { --c: var(--green); }
.teal { --c: var(--teal); }
.blue { --c: var(--blue); }
.violet { --c: var(--violet); }
.pink { --c: var(--pink); }
.gray { --c: var(--gray); }

/* ---------------- base ---------------- */
* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-feature-settings: 'cv11', 'ss01'; letter-spacing: -0.003em;
  background: var(--bg); color: var(--text); line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; border-radius: var(--r-sm); }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
small { color: var(--muted); font-size: 0.88em; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.muted { color: var(--muted); margin-bottom: 10px; }
.nil { color: var(--faint); display: inline-flex; align-items: center; }
.icon { flex: none; }
body.modal-open { overflow: hidden; }
.boot { height: 100dvh; display: grid; place-items: center; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ---------------- controls ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 500; white-space: nowrap;
  transition: background 0.1s, border-color 0.1s, opacity 0.1s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: 0.45; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 0.95rem; }
.btn-block { width: 100%; height: 36px; }
.btn-primary { background: var(--accent); border-color: color-mix(in srgb, var(--accent) 75%, var(--ink)); color: var(--accent-fg); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-danger { background: var(--red); border-color: color-mix(in srgb, var(--red) 75%, black); color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 88%, black); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--press); color: var(--text); }
.btn-ghost.danger { color: var(--red); }
.btn-ghost.danger:hover { background: color-mix(in srgb, var(--red) 9%, transparent); color: var(--red); }
.btn-google { height: 36px; }

.icon-btn {
  width: 28px; height: 28px; border-radius: var(--r); flex: none; display: inline-grid; place-items: center; color: var(--muted);
  transition: background 0.1s, color 0.1s;
}
.icon-btn:hover:not(:disabled), .icon-btn.active { background: var(--press); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn.sm { width: 22px; height: 22px; border-radius: var(--r-sm); }
.link { color: var(--accent-text); font-weight: 500; }
.link:hover { text-decoration: underline; }

.input {
  width: 100%; height: 32px; padding: 0 10px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); outline: none; transition: border-color 0.1s, box-shadow 0.1s;
}
.input::placeholder, input::placeholder, textarea::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
select.input {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: 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='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.textarea { height: auto; padding: 8px 10px; resize: none; line-height: 1.45; }
.textarea.big { font-size: 1.1rem; font-weight: 500; min-height: 42px; }
input[type='number']::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type='number'] { -moz-appearance: textfield; }
input[type='date'].input { cursor: pointer; }
input[type='date']::-webkit-calendar-picker-indicator { display: none; }
input[type='search']::-webkit-search-cancel-button { -webkit-appearance: none; }
.input.num { width: 64px; flex: none; text-align: center; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 0.92rem; font-weight: 500; color: var(--muted); }
.field-hint { font-size: 0.9rem; color: var(--muted); }
.field-hint.error { color: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-inline { display: flex; gap: 6px; }
.form-error {
  display: flex; align-items: center; gap: 8px; color: var(--red); padding: 7px 10px; border-radius: var(--r);
  background: color-mix(in srgb, var(--red) 8%, transparent); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent);
}
.meta-line { font-size: 0.9rem; color: var(--faint); font-family: var(--mono); }

.date-field { position: relative; display: flex; align-items: center; }
.date-field > .icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.date-field .input { padding-left: 32px; }
.date-field .icon-btn { position: absolute; right: 5px; }

.callout {
  display: flex; gap: 9px; align-items: flex-start; line-height: 1.45; padding: 8px 10px; border-radius: var(--r);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.callout > .icon { color: var(--accent-text); margin-top: 1px; }
.callout.ok { background: color-mix(in srgb, var(--green) 8%, transparent); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
.callout.ok > .icon { color: var(--green); }

.stepper { display: flex; align-items: center; height: 32px; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); padding: 0 2px; }
.stepper input { width: 34px; border: 0; background: none; text-align: center; outline: none; font-weight: 600; font-family: var(--mono); }
.stepper-suffix { flex: 1; color: var(--muted); white-space: nowrap; }
.stepper .icon-btn { width: 24px; height: 24px; }

.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: 1;
  height: 24px; padding: 0 10px; border-radius: var(--r-sm); font-weight: 500; color: var(--muted); transition: background 0.1s, color 0.1s;
}
.segmented button:hover:not(:disabled) { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong), 0 1px 2px rgba(0, 0, 0, 0.06); }
.form > .segmented { align-self: flex-start; }

.toggle-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; cursor: pointer; }
.toggle-text { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.switch {
  appearance: none; width: 30px; height: 17px; border-radius: 99px; flex: none; cursor: pointer; margin: 0;
  background: var(--border-strong); position: relative; transition: background 0.15s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(13px); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 20px; height: 20px; border-radius: var(--r-sm); background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c); }

.dot { width: 7px; height: 7px; border-radius: 2px; background: var(--c); flex: none; display: inline-block; }
.tag {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 500; padding: 1px 6px; border-radius: var(--r-sm); letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--amber) 12%, transparent); color: color-mix(in srgb, var(--amber) 70%, var(--ink));
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
}
kbd {
  font-family: var(--mono); font-size: 0.78rem; min-width: 18px; text-align: center; padding: 0 4px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); line-height: 16px;
}

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 7px; border-radius: var(--r-sm);
  font-size: 0.92rem; font-weight: 500; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--gray)) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--gray)) 24%, transparent);
  color: color-mix(in srgb, var(--c, var(--gray)) 80%, var(--ink));
}
[data-theme='dark'] .pill { color: color-mix(in srgb, var(--c, var(--gray)) 90%, var(--ink)); }
.pill.gray { color: var(--muted); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--gray)); flex: none; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 6px; border-radius: var(--r-sm);
  font-size: 0.85rem; color: var(--muted); border: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.count {
  display: inline-grid; place-items: center; min-width: 18px; height: 17px; padding: 0 5px; margin-left: 7px; border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 0.82rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
}
.list-tag { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-tag.personal { color: var(--faint); }
.repeat-text { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }

.avatar {
  display: inline-grid; place-items: center; border-radius: 50%; flex: none; object-fit: cover; font-weight: 600; line-height: 1;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent-text);
}

/* ---------------- layout ---------------- */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100dvh; }
.main { overflow-y: auto; background: var(--bg); display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 28px 80px; }

.sidebar {
  display: flex; flex-direction: column; padding: 10px 8px 8px; overflow-y: auto; min-height: 0;
  background: var(--sidebar); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 8px; margin-bottom: 10px; font-weight: 600; font-size: 1.08rem; letter-spacing: -0.01em; }
.brand .tag { margin-left: auto; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 28px; padding: 0 8px; border-radius: var(--r);
  color: var(--muted); text-align: left; transition: background 0.1s, color 0.1s;
}
.nav-item .icon { color: var(--faint); }
.nav-item .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--press); color: var(--text); }
.nav-item.active { background: var(--press); color: var(--text); font-weight: 500; }
.nav-item.active .icon { color: var(--accent); }
.nav-swatch { width: 10px; height: 10px; margin: 0 3px; border-radius: 3px; background: var(--c); flex: none; }
.nav-count { font-family: var(--mono); font-size: 0.85rem; color: var(--faint); }
.nav-count.danger { color: var(--red); }
.nav-section {
  display: flex; align-items: center; justify-content: space-between; padding: 18px 4px 4px 8px;
  font-family: var(--mono); font-size: 0.78rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em;
}
.nav-list-wrap { position: relative; }
.nav-list-wrap .nav-item { padding-right: 30px; }
.nav-list-more { position: absolute; right: 4px; top: 3px; opacity: 0; }
.nav-list-wrap:hover .nav-list-more, .nav-list-more:focus-visible { opacity: 1; }
.nav-list-wrap:hover .nav-count { visibility: hidden; }
.nav-list-wrap .nav-count { position: absolute; right: 10px; top: 6px; }
.nav-hint { text-align: left; font-size: 0.92rem; color: var(--faint); padding: 4px 8px; line-height: 1.4; }
.nav-hint:hover { color: var(--text); }
.sidebar-foot { margin-top: auto; padding-top: 8px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px; border-radius: var(--r); text-align: left; color: var(--faint); }
.user-chip:hover { background: var(--press); color: var(--text); }
.user-chip-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.user-chip-text span { font-weight: 500; color: var(--text); }
.user-chip-text span, .user-chip-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* top bar: Supabase-style breadcrumb header */
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 48px; padding: 0 28px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-title h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
.crumb { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb::before { content: '/'; margin-right: 10px; color: var(--border-strong); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.search {
  display: flex; align-items: center; gap: 7px; height: 28px; width: 220px; padding: 0 5px 0 9px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--faint); transition: border-color 0.1s, box-shadow 0.1s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; height: 100%; color: var(--text); }

/* quiet one-line summary */
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; color: var(--muted); }
.view > .summary { margin-bottom: 12px; padding: 0 2px; }
.sum { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sum b { font-family: var(--mono); font-weight: 600; color: var(--text); }
.sum-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.sum.zero { opacity: 0.55; }
.tt-title .sum-dot { margin-right: 8px; }

/* ---------------- tables ---------------- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 16px; }
.table-toolbar { display: flex; align-items: center; gap: 14px; min-height: 40px; padding: 4px 8px 4px 14px; border-bottom: 1px solid var(--border); }
.table-toolbar .summary { gap: 4px 14px; }
.tt-title { font-weight: 500; display: inline-flex; align-items: center; white-space: nowrap; }
.tt-toggle { gap: 4px; margin-left: -4px; padding: 2px 4px; border-radius: var(--r-sm); }
.tt-toggle:hover { background: var(--press); }
.table { display: flex; flex-direction: column; }
.t-row {
  display: grid; grid-template-columns: var(--cols); align-items: center; column-gap: 12px;
  min-height: 36px; padding: 2px 8px 2px 8px; border-bottom: 1px solid var(--border-soft); position: relative;
}
.table > .t-row:last-child { border-bottom: 0; border-radius: 0 0 var(--r) var(--r); }
/* zebra stripes, then status tints (later rules win), then a hover overlay that keeps the tint */
:root:not(.no-tint) .t-row.st-overdue { --tint: var(--st-overdue); }
:root:not(.no-tint) .t-row.st-today { --tint: var(--st-today); }
:root:not(.no-tint) .t-row.st-soon { --tint: var(--st-soon); }
:root:not(.no-tint) .t-row.st-reminder { --tint: var(--st-reminder); }
:root:not(.no-tint) .t-row.st-done { --tint: var(--st-done); }
.t-row[class*='st-'] { background-color: color-mix(in srgb, var(--tint, transparent) var(--tint-amt), var(--row-base, var(--surface))); }
.t-row.z { --row-base: var(--zebra); }
.no-zebra .t-row.z { --row-base: var(--surface); }
:root:not(.no-tint) .t-row[class*='st-']:not(.st-):not(.st-later) { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--tint) 75%, transparent); }
:root { --tint-amt: 7%; }
[data-theme='dark'] { --tint-amt: 11%; }
.table > .t-row:not(.t-head):not(.t-add):hover { background-image: linear-gradient(var(--press), var(--press)); }
.t-head {
  min-height: 32px; background: var(--head-bg, var(--surface-2)); color: var(--head-fg, var(--faint));
  border-bottom: 1px solid var(--head-bg, var(--border));
  font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.t-head > * { color: inherit !important; font-size: inherit !important; font-family: inherit !important; }
.sort-head {
  display: inline-flex; align-items: center; gap: 5px; justify-self: start; height: 22px; padding: 0 5px; margin-left: -5px;
  border-radius: var(--r-sm); font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; opacity: 0.85;
}
.sort-head .icon { opacity: 0.45; }
.sort-head:hover { opacity: 1; background: rgba(127, 127, 127, 0.18); }
.sort-head.on { opacity: 1; font-weight: 700; }
.sort-head.on .icon { opacity: 1; }
.sort-head.c-num { justify-self: end; margin: 0 -5px 0 0; }

/* filter chips + sort */
.filter-bar { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 10px; border-bottom: 1px solid var(--border); }
.fchips { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.fchips::-webkit-scrollbar { display: none; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-sm); white-space: nowrap;
  color: var(--muted); border: 1px solid transparent;
}
.fchip:hover { background: var(--press); color: var(--text); }
.fchip.on { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 30%, transparent); font-weight: 500; }
.fchip-count { font-family: var(--mono); font-size: 0.82rem; opacity: 0.7; }
.sort-box { display: flex; align-items: center; gap: 2px; flex: none; }
.table-toolbar .fchips { flex: 0 1 auto; }
.done-due { font-family: var(--mono); font-size: 0.88rem; color: var(--faint); }
.done-at { font-family: var(--mono); font-size: 0.85rem; color: var(--faint); }
.empty-inline { padding: 14px 16px; color: var(--muted); }
.repeat-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.repeat-presets .fchip { border-color: var(--border); height: 28px; padding: 0 10px; }
.repeat-presets .fchip.on { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.repeat-custom { align-items: center; margin-top: 8px; }
.repeat-custom select { width: auto; }
.repeat-preview { display: flex; align-items: center; gap: 6px; margin-top: 6px; }

/* status colour classes (pills, badges, summary dots) */
.st-overdue { --c: var(--st-overdue); }
.st-today { --c: var(--st-today); }
.st-soon { --c: var(--st-soon); }
.st-later { --c: var(--st-later); }
.st-reminder { --c: var(--st-reminder); }
.st-done { --c: var(--st-done); }
.badge.st-reminder { color: color-mix(in srgb, var(--c) 80%, var(--ink)); background: color-mix(in srgb, var(--c) 9%, transparent); border-color: color-mix(in srgb, var(--c) 25%, transparent); }
.c-check { display: flex; align-items: center; justify-content: center; }
.c-num { font-family: var(--mono); color: var(--faint); font-size: 0.88rem; text-align: right; }
.c-main { min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 5px 0; }
.t-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.t-text { overflow-wrap: anywhere; }
.t-row.done .t-text { color: var(--faint); text-decoration: line-through; }
.t-row.done .list-tag { opacity: 0.6; }
.c-list, .c-due, .c-added, .c-show, .c-repeat { min-width: 0; display: flex; align-items: center; }
.c-added { font-family: var(--mono); color: var(--muted); font-size: 0.88rem; }
.c-show { gap: 8px; }
.c-show small { font-family: var(--mono); color: var(--faint); font-size: 0.82rem; white-space: nowrap; }
.c-more { display: flex; justify-content: center; }
.row-more { opacity: 0; }
.t-row:hover .row-more, .row-more.active, .row-more:focus-visible { opacity: 1; }
.m-meta { display: none; }

.t-add { background: var(--surface); }
.t-add:focus-within { box-shadow: inset 2px 0 0 var(--accent); }
.add-plus { color: var(--faint); }
.t-add:focus-within .add-plus { color: var(--accent); }
.t-add input.c-main { border: 0; outline: none; background: none; height: 32px; padding: 0; }
.date-btn {
  position: relative; display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--faint); white-space: nowrap; border: 1px dashed var(--border-strong);
}
.date-btn:hover { color: var(--text); border-color: var(--faint); }
.date-btn.set { color: var(--text); border-style: solid; background: var(--surface-2); }
.date-btn input { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; }
.add-go { color: var(--accent-fg) !important; background: var(--accent) !important; }

.check {
  width: 16px; height: 16px; flex: none; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; transition: background 0.12s, border-color 0.12s;
}
.check:hover { border-color: var(--accent); }
.check svg { width: 12px; height: 12px; fill: none; stroke: var(--accent-fg); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset 0.2s var(--ease); }
.check.on { background: var(--st-done, var(--accent)); border-color: var(--st-done, var(--accent)); }
.check.on svg { stroke: #fff; }
.check.on svg { stroke-dashoffset: 0; }

.rem-dot { width: 20px; height: 20px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--faint); border: 1px solid var(--border); background: var(--surface); }
.rem-dot.active { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px 20px 40px; gap: 6px; }
.empty-icon { width: 36px; height: 36px; border-radius: var(--r); display: grid; place-items: center; margin-bottom: 4px; color: var(--muted); border: 1px solid var(--border); background: var(--surface-2); }
.empty-title { font-weight: 500; }
.empty p { color: var(--muted); max-width: 360px; margin-bottom: 8px; }

/* ---------------- menus ---------------- */
.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; z-index: 40; top: calc(100% + 4px); min-width: 180px; padding: 4px;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-pop); animation: pop 0.1s var(--ease);
}
.menu-end { right: 0; }
.menu-start { left: 0; }
.menu-start-up { left: 0; right: 0; top: auto; bottom: calc(100% + 4px); }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; height: 28px; padding: 0 8px; border-radius: var(--r-sm); text-align: left; }
.menu-item .icon { color: var(--muted); }
.menu-item:hover:not(:disabled) { background: var(--press); }
.menu-item:disabled { opacity: 0.4; }
.menu-item.danger, .menu-item.danger .icon { color: var(--red); }
.menu-sep { height: 1px; background: var(--border); margin: 4px -4px; }
@keyframes pop { from { opacity: 0; transform: translateY(-2px); } }

/* ---------------- modal ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(0, 0, 0, 0.4); animation: fade 0.12s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 500px; max-height: calc(100dvh - 48px); display: flex; flex-direction: column; position: relative;
  background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-modal); animation: rise 0.16s var(--ease);
}
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 580px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; height: 46px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 8px 8px; }
.confirm-text { color: var(--muted); line-height: 1.55; }

/* settings */
.settings .modal-body { padding-top: 12px; }
.settings-tabs .segmented { width: 100%; }
.settings-body section { padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.settings-body section:last-child { border-bottom: 0; }
.settings-body h3 { font-family: var(--mono); font-size: 0.8rem; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 5px 0; flex-wrap: wrap; }
.col-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; }
.steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; color: var(--muted); }
.steps li::marker { color: var(--faint); font-family: var(--mono); }
.shortcuts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; color: var(--muted); }
/* colours tab */
.color-input {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px 0 3px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; flex: none;
}
.color-input:hover { border-color: var(--faint); }
.color-input input { width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; }
.color-input input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input::-webkit-color-swatch { border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 3px; }
.color-input input::-moz-color-swatch { border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 3px; }
.color-input span { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.head-preview { margin-top: 10px; border-radius: var(--r); --cols: 1fr 90px 90px; }
.status-colors { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 8px; }
.status-color { grid-template-columns: 150px minmax(0, 1fr) auto !important; min-height: 42px; padding: 4px 8px 4px 12px; }
.status-color:last-child { border-bottom: 0; }
.status-color small { color: var(--muted); }
.colors-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-card { display: flex; align-items: center; gap: 12px; }
.account-name { font-weight: 600; }

/* list sheet */
.sheet-list { display: flex; flex-direction: column; gap: 1px; }
.sheet-row-wrap { display: flex; align-items: center; gap: 4px; }
.sheet-row { flex: 1; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: var(--r); text-align: left; }
.sheet-row .icon { color: var(--muted); }
.sheet-row:hover { background: var(--press); }
.sheet-row.on { background: var(--accent-soft); }
.sheet-row.on > .icon:last-child { color: var(--accent-text); }

/* toasts */
.toasts {
  position: fixed; z-index: 60; right: 20px; bottom: 20px; display: flex; flex-direction: column; align-items: flex-end;
  gap: 6px; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 12px; min-height: 36px;
  background: var(--surface); color: var(--text); border-radius: var(--r); box-shadow: var(--shadow-pop); animation: rise 0.16s var(--ease);
}
.toast.error { border-left: 3px solid var(--red); }
.toast button { font-weight: 500; height: 24px; padding: 0 8px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); }
.toast button:hover { background: var(--press); }
.offline {
  position: fixed; z-index: 45; top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-pop); color: var(--muted);
}

/* ---------------- sign in ---------------- */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.signin-card {
  width: 100%; max-width: 360px; padding: 28px 24px 22px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.signin-brand { display: flex; justify-content: center; }
.signin-card h1 { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.02em; }
.signin-sub { color: var(--muted); margin-top: -6px; }
.signin-card .form { gap: 8px; text-align: left; }
.signin-card .callout { text-align: left; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 0.9rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.signin-links { display: flex; justify-content: center; gap: 16px; }

/* ---------------- floating mini window ---------------- */
.mini-body { background: var(--surface); margin: 0; }
.mini { padding: 10px; }
.mini-head { display: flex; align-items: center; gap: 9px; padding: 2px 2px 8px; }
.mini-head small { display: block; }
.mini-title { font-weight: 600; }
.mini-filter { border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--r); height: 26px; padding: 0 6px; max-width: 120px; }
.mini-add { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--border-strong); color: var(--faint); margin-bottom: 8px; }
.mini-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mini-add input { flex: 1; border: 0; outline: none; background: none; height: 100%; color: var(--text); }
.mini-rows { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.mini-rows:empty { display: none; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--border-soft); }
.mini-row:nth-child(even) { background: var(--zebra); }
.no-zebra .mini-row:nth-child(even) { background: none; }
.mini-row:last-child { border-bottom: 0; }
.mini-row .t-text { flex: 1; min-width: 0; }
.mini-row.done .t-text { color: var(--faint); text-decoration: line-through; }

/* ---------------- phone ---------------- */
.mobile-top, .tabbar { display: none; }

@media (max-width: 860px) {
  html { font-size: max(var(--fs), 14px); }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .content { padding: 12px 12px calc(92px + env(safe-area-inset-bottom)); }
  .hide-mobile { display: none !important; }

  .mobile-top {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .list-switch { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 4px 8px 4px 4px; border-radius: var(--r); }
  .list-switch .icon { color: var(--muted); }
  .avatar-btn { border-radius: 50%; }

  .topbar { position: static; height: auto; padding: 10px 12px; gap: 10px; border-bottom: 0; }
  .topbar .crumb { display: none; }
  .topbar-title h1 { font-size: 1.35rem; }
  .topbar-actions { flex: 1; justify-content: flex-end; min-width: 0; }
  .search { width: 100%; max-width: 190px; }
  .search kbd { display: none; }

  .table-toolbar { flex-wrap: wrap; gap: 6px 12px; padding: 8px 8px 8px 12px; }
  .table-toolbar > .tt-title:first-child:not(.tt-toggle) { display: none; }
  .table > .t-head { display: none; }
  .table > .t-row { grid-template-columns: 28px minmax(0, 1fr) !important; padding: 4px 10px 4px 6px; column-gap: 8px; }
  .table > .t-row > :not(.c-check):not(.c-main) { display: none; }
  .status-color { grid-template-columns: minmax(0, 1fr) auto !important; }
  .status-color small { display: none; }
  .m-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
  .m-meta:empty { display: none; }
  .table > .t-row.t-add { grid-template-columns: 28px minmax(0, 1fr) auto !important; }
  .table > .t-row.t-add > .c-due { display: flex; }
  .check { width: 19px; height: 19px; }

  .tabbar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-around;
    padding: 6px 24px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border-top: 1px solid var(--border);
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 88px; padding: 3px 0; font-size: 0.78rem; font-weight: 500; color: var(--faint); }
  .tab.on { color: var(--accent-text); }
  .tab-icon { position: relative; display: grid; }
  .tab-badge {
    position: absolute; top: -4px; left: 14px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
    background: var(--red); color: #fff; font-size: 0.7rem; font-family: var(--mono); display: grid; place-items: center;
  }
  .fab {
    width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; margin-top: -22px;
    color: var(--accent-fg); background: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 75%, var(--ink));
    box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  .fab:active { transform: scale(0.95); }
  .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); align-items: stretch; }

  .overlay { align-items: flex-end; padding: 0; }
  .modal, .modal-sm, .modal-lg { max-width: none; max-height: 92dvh; border-radius: 12px 12px 0 0; animation: sheet 0.24s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
  @keyframes sheet { from { transform: translateY(100%); } }
  .modal-foot { border-radius: 0; }
  .grid-2, .col-grid { grid-template-columns: 1fr; }
  .shortcuts { grid-template-columns: 1fr 1fr; }
  .input, .t-add input.c-main, .search input { font-size: 16px; } /* stops iOS zoom-on-focus */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
