/* ═══════════════════════════ Ритм — design system ═══════════════════════════ */

@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/fonts/inter-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ───────── tokens ───────── */
:root {
  --accent: #5b7cfa;
  --radius: 12px;
  --fs: 15px;

  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --hover: #eeeeea;
  --input: #f4f4f1;
  --border: #e9e9e5;
  --border-strong: #dcdcd6;
  --text: #19191b;
  --muted: #6b6b71;
  --faint: #a2a2a8;
  --danger: #d9423f;
  --ok: #1f9d5a;
  --warn: #c98a12;

  --shadow-sm: 0 1px 2px rgb(20 20 24 / .04);
  --shadow-md: 0 6px 16px -4px rgb(20 20 24 / .10), 0 2px 4px -2px rgb(20 20 24 / .05);
  --shadow-lg: 0 24px 64px -12px rgb(20 20 24 / .28), 0 4px 12px rgb(20 20 24 / .06);

  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 6%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 82%, var(--text));
  --on-accent: #fff;

  --r-sm: calc(var(--radius) * .6);
  --r-md: calc(var(--radius) * .8);
  --pad: 20px;
  --gap: 16px;
  --row: 44px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="sepia"] {
  --bg: #f3eee4; --surface: #fbf8f1; --surface-2: #efe8da; --hover: #eae2d2; --input: #f1ebdf;
  --border: #e3d9c7; --border-strong: #d6cab4; --text: #2c2822; --muted: #776d61; --faint: #a79d90;
}
[data-theme="dark"] {
  --bg: #111113; --surface: #18181b; --surface-2: #222226; --hover: #28282d; --input: #202024;
  --border: #29292e; --border-strong: #36363c; --text: #ececef; --muted: #9d9da6; --faint: #66666e;
  --danger: #ff6b66; --ok: #3ecf8e; --warn: #f0b23a;
  --shadow-sm: none;
  --shadow-md: 0 8px 24px -6px rgb(0 0 0 / .5);
  --shadow-lg: 0 24px 64px -12px rgb(0 0 0 / .7);
  --accent-soft: color-mix(in srgb, var(--accent) 20%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 70%, #fff);
  color-scheme: dark;
}
[data-theme="black"] {
  --bg: #000; --surface: #0c0c0e; --surface-2: #17171a; --hover: #1d1d21; --input: #141417;
  --border: #1f1f23; --border-strong: #2c2c31; --text: #ececef; --muted: #8f8f98; --faint: #5c5c64;
  --danger: #ff6b66; --ok: #3ecf8e; --warn: #f0b23a;
  --shadow-sm: none; --shadow-md: 0 8px 24px -6px rgb(0 0 0 / .8); --shadow-lg: 0 24px 64px -12px rgb(0 0 0 / .9);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 11%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 70%, #fff);
  color-scheme: dark;
}
[data-font="rounded"] { --font: ui-rounded, "SF Pro Rounded", "Nunito", "Inter", system-ui, sans-serif; }
[data-font="serif"] { --font: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif; }
[data-font="mono"] { --font: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace; }
[data-density="compact"] { --pad: 14px; --gap: 12px; --row: 38px; }

/* ───────── base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  line-height: 1.5; letter-spacing: -0.006em; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent; text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.028em; line-height: 1.2; }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: -0.012em; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.icon { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; }
.row.gap { gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.center-y { align-items: center; }
.row > .field { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.sub { padding-left: 14px; border-left: 2px solid var(--border); gap: 10px; }
.danger-text { color: var(--danger) !important; }
.nowrap { white-space: nowrap; }
.push { margin-left: auto; }
[hidden] { display: none !important; }
@media (max-width: 860px) { .hide-sm { display: none; } }

/* ───────── controls ───────── */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--input); border: 1px solid transparent; outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--border); }
input:focus, select:focus, textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent) !important; background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-softer);
}
select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
input.num { width: 76px !important; }
input[type=range] { accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .8rem; font-weight: 550; color: var(--muted); }
.hint { font-size: .78rem; color: var(--faint); }
.check-line { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 40px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 14px;
  border-radius: var(--r-sm); font-weight: 550; font-size: .93rem; white-space: nowrap; color: var(--text);
  border: 1px solid transparent; text-decoration: none !important; transition: background .15s, border-color .15s, filter .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 1px 0 rgb(255 255 255 / .14), 0 1px 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-sm); color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }
.link-btn { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }

.seg { display: inline-flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: calc(var(--r-sm) + 3px); max-width: 100%; }
.seg button { flex: none; padding: 5px 13px; border-radius: var(--r-sm); color: var(--muted); font-weight: 550; font-size: .9rem; min-height: 32px; transition: color .15s, background .15s; }
.seg button:hover { color: var(--text); }
.seg.small button { padding: 3px 10px; min-height: 28px; font-size: .85rem; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.compact-select { width: auto !important; min-height: 34px !important; padding: 4px 32px 4px 12px !important; font-size: .9rem; background-color: var(--surface) !important; border: 1px solid var(--border) !important; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 11px; border-radius: 999px; background: var(--surface-2); font-size: .85rem; color: var(--muted); min-height: 30px; transition: background .15s, color .15s; }
.chip:hover { background: var(--hover); color: var(--text); }
.chip.on { background: var(--accent); color: var(--on-accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--c, var(--accent)); position: relative; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); transition: transform .12s; }
.swatch:hover { transform: scale(1.08); }
.swatch.accent::after { content: "A"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: .72rem; font-weight: 700; }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch.custom { background: conic-gradient(#f43f5e, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #f43f5e); overflow: hidden; cursor: pointer; }
.swatch.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.pill { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 600; line-height: 1.7; vertical-align: 1px; }
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

/* ───────── shell ───────── */
.shell { min-height: 100dvh; display: grid; grid-template-columns: 244px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; padding: 18px 12px 14px; display: flex; flex-direction: column; gap: 1px;
  border-right: 1px solid var(--border); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.03em; padding: 4px 10px 20px; }
.brand.big { font-size: 1.5rem; padding: 0 0 4px; }
.brand-dot { position: relative; width: 20px; height: 20px; border-radius: 6px; background: var(--accent); flex: none; }
.brand-dot::after { content: ""; position: absolute; width: 10px; height: 10px; left: 9px; top: 9px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 45%, var(--bg)); box-shadow: 0 0 0 2px var(--bg); }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 0 10px; height: 36px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 550; font-size: .93rem; text-decoration: none !important; transition: background .12s, color .12s;
}
.nav-link .icon { width: 18px; height: 18px; }
.nav-link:hover { background: var(--hover); color: var(--text); }
.nav-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.nav-link.active .icon { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-md); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 650; font-size: .85rem; flex: none; }
.who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.who b { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--faint); }
.sync::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.sync.live::before { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.sync.offline { color: var(--warn); }
.sync.offline::before { background: var(--warn); }
.offline-bar { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 50; margin-top: calc(8px + env(safe-area-inset-top));
  background: var(--text); color: var(--bg); font-size: .8rem; padding: 5px 12px; border-radius: 999px; box-shadow: var(--shadow-md); }
.tabbar { display: none; }
.main { padding: 32px clamp(16px, 4vw, 48px) 72px; max-width: 1200px; width: 100%; outline: none; min-width: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 16px calc(92px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--border);
  }
  .tab-link { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0 2px; font-size: .66rem; font-weight: 550; color: var(--faint); text-decoration: none !important; }
  .tab-link .icon { width: 36px; height: 26px; padding: 3px 8px; border-radius: 999px; transition: background .15s, color .15s; }
  .tab-link.active { color: var(--text); }
  .tab-link.active .icon { background: var(--accent-soft); color: var(--accent-text); }
  h1 { font-size: 1.5rem; }
}

/* ───────── page ───────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; font-size: .95rem; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow-sm); min-width: 0; }
.card + .card, .card + details.card { margin-top: var(--gap); }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: .95rem; font-weight: 600; }
.card-title .count { color: var(--faint); font-weight: 500; }
.card-link { margin-left: auto; font-size: .82rem; font-weight: 500; color: var(--muted); }
.card-link:hover { color: var(--accent-text); text-decoration: none; }
.group-label { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); margin: 16px 0 4px; }
.group-label:first-child { margin-top: 4px; }
.empty { color: var(--faint); padding: 14px 0 6px; font-size: .92rem; }
.empty.small { padding: 2px 0; font-size: .86rem; }
.list-foot { display: flex; align-items: center; gap: 5px; margin-top: 12px; }
.footer-note { margin-top: 32px; }

/* today */
.summary { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--muted); font-size: .92rem; }
.summary span { display: inline-flex; align-items: center; gap: 6px; }
.summary b { color: var(--text); font-weight: 600; }
.summary .icon { color: var(--faint); }
.today-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.today-col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.today-col .card + .card { margin-top: 0; }
@media (max-width: 800px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .today-col { display: contents; }
  .o-1 { order: 1; } .o-2 { order: 2; } .o-3 { order: 3; } .o-4 { order: 4; }
}

/* agenda */
.agenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ev-btn {
  width: 100%; text-align: left; display: grid; grid-template-columns: 3px 92px 1fr; column-gap: 12px; align-items: baseline;
  padding: 8px 10px 8px 0; border-radius: var(--r-sm); transition: background .12s;
}
.ev-btn:hover { background: var(--hover); }
.ev-bar { align-self: stretch; border-radius: 3px; background: var(--c, var(--accent)); grid-row: span 2; min-height: 18px; }
.ev-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .86rem; }
.ev-title { font-weight: 550; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-width: 0; overflow-wrap: anywhere; }
.ev-title > .icon { color: var(--faint); }
.ev-notes { grid-column: 3; color: var(--muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.past { opacity: .5; }
.ev.now .ev-btn { background: var(--accent-softer); }
.ev.now .ev-time { color: var(--accent-text); font-weight: 600; }
.agenda.compact .ev-btn { grid-template-columns: 3px 80px 1fr; padding: 5px 8px 5px 0; }
.occ-tag { font-size: .7rem; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 0 7px; border-radius: 999px; white-space: nowrap; line-height: 1.7; }
.ev.cancelled .ev-name, .chip-ev.cancelled .ev-name, .tg-ev.cancelled .ev-name { text-decoration: line-through; }
.ev.cancelled, .chip-ev.cancelled, .tg-ev.cancelled { opacity: .55; }
.ev.cancelled .occ-tag { color: var(--danger); }
.ev.ghost, .chip-ev.ghost, .tg-ev.ghost { opacity: .5; }
.ev.ghost .ev-bar { background: repeating-linear-gradient(to bottom, var(--c, var(--accent)) 0 4px, transparent 4px 7px); }
.chip-ev.ghost { border-left-style: dashed; background: transparent; }
.tg-ev.ghost { background: transparent; border: 1px dashed color-mix(in srgb, var(--c, var(--accent)) 55%, transparent); border-left: 3px dashed var(--c, var(--accent)); }
.occ-status { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: var(--r-sm); background: var(--accent-softer); font-size: .9rem; }
.occ-status.is-cancelled { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* tasks */
.quick-add { margin-bottom: 6px; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: flex-start; gap: 10px; min-height: var(--row); padding: 9px 2px; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.task:last-child { border-bottom: 0; }
.task.dragging { opacity: .7; background: var(--surface); border-radius: var(--r-sm); box-shadow: var(--shadow-md); }
.drag-handle { color: var(--faint); cursor: grab; touch-action: none; display: grid; place-items: center; width: 18px; height: 24px; flex: none; opacity: .55; transition: opacity .12s; }
.task:hover .drag-handle, .kcard:hover .drag-handle, .hrow:hover .drag-handle { opacity: 1; }
.checkbox {
  width: 20px; height: 20px; margin-top: 2px; border-radius: 6px; border: 1.6px solid var(--border-strong); display: grid; place-items: center; flex: none; color: transparent;
  transition: background .15s, border-color .15s, transform .1s;
}
.checkbox:hover { border-color: var(--accent); }
.checkbox:active { transform: scale(.9); }
.checkbox.on, .task.done .checkbox { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.task-title { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 1px; overflow-wrap: anywhere; }
.task-title > span:first-child { font-weight: 500; }
.task-notes { font-size: .83rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.done .task-title > span:first-child { text-decoration: line-through; color: var(--faint); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; }
.due { font-size: .76rem; font-weight: 550; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; white-space: nowrap; margin-top: 1px; }
.due.today { color: var(--accent-text); background: var(--accent-soft); }
.due.overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.meta-pill { display: inline-flex; align-items: center; gap: 3px; font-size: .72rem; font-weight: 500; color: var(--muted); background: var(--surface-2); padding: 0 7px; border-radius: 999px; line-height: 1.65; }
.meta-pill.doing { color: var(--accent-text); background: var(--accent-soft); }
.meta-pill.complete { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.done-block summary { cursor: pointer; color: var(--muted); font-weight: 550; list-style: none; display: flex; align-items: center; gap: 6px; }
.done-block summary::-webkit-details-marker { display: none; }
.done-block summary::before { content: "›"; font-size: 1.1rem; transition: transform .15s; }
.done-block[open] summary::before { transform: rotate(90deg); }
.done-block .task-list { margin: 8px 0 12px; }

/* tags */
.tag-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 550;
  color: color-mix(in srgb, var(--c) 78%, var(--text)); background: color-mix(in srgb, var(--c) 13%, transparent); white-space: nowrap; line-height: 1.6;
}
.tag-chips.small .tag-chip { font-size: .7rem; padding: 0 7px; }
.tag-chip.toggle { cursor: pointer; min-height: 30px; padding: 3px 12px; border: 1px solid transparent; transition: background .12s, border-color .12s; }
.tag-chip.toggle:not(.on) { background: var(--surface); border-color: var(--border); color: var(--muted); }
.tag-chip.toggle:not(.on):hover { background: var(--hover); color: var(--text); }
.tag-chip.toggle:not(.on)::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.tag-chip.toggle.all:not(.on)::before { display: none; }
.tag-chip.toggle.on { border-color: color-mix(in srgb, var(--c) 40%, transparent); }
.tag-chip.all { --c: var(--text); }
.tag-count { font-size: .7rem; opacity: .65; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-new { width: 140px !important; min-height: 30px !important; padding: 3px 12px !important; border-radius: 999px !important; font-size: .85rem; }
.tag-filter { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; margin-bottom: 10px; scrollbar-width: none; }
.tag-filter::-webkit-scrollbar { display: none; }
.tag-group { display: flex; align-items: center; gap: 8px; }
.tag-group::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--faint)); }
.tag-admin li { padding: 6px 0; }
.color-dot { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; flex: none; }
.color-dot::-webkit-color-swatch-wrapper { padding: 0; }
.color-dot::-webkit-color-swatch { border: 0; border-radius: 50%; }

/* habits on today */
.habit-today { list-style: none; margin: 0; padding: 0; }
.habit-today li { display: flex; align-items: center; gap: 12px; min-height: var(--row); }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 1.6px solid color-mix(in srgb, var(--c, var(--accent)) 70%, transparent); display: grid; place-items: center; color: transparent; flex: none; transition: background .15s, transform .1s; }
.tick:active { transform: scale(.9); }
.tick.on { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); color: #fff; }

/* ───────── calendar ───────── */
.cal-head { align-items: center; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-title { font-size: 1.4rem; margin-left: 10px; }
.week-label { margin-left: 10px; font-weight: 600; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; box-shadow: var(--shadow-sm); }
.month-wd { background: var(--surface); padding: 10px 10px 6px; font-size: .7rem; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.month-cell { background: var(--surface); min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 3px; position: relative; cursor: pointer; min-width: 0; transition: background .12s; }
.month-cell:hover { background: color-mix(in srgb, var(--surface) 55%, var(--hover)); }
.month-cell.other { background: color-mix(in srgb, var(--surface) 55%, var(--bg)); }
.month-cell.other .month-num { color: var(--faint); }
.month-num { font-size: .82rem; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-variant-numeric: tabular-nums; }
.month-cell.today .month-num { background: var(--accent); color: var(--on-accent); }
.month-add { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity .12s; }
.month-cell:hover .month-add { opacity: 1; }
.month-add:hover { background: var(--hover); }
.chip-ev {
  display: block; width: 100%; text-align: left; font-size: .76rem; font-weight: 500; padding: 1px 6px; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 2.5px solid var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 9%, transparent);
}
.chip-ev:hover { background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); }
.chip-ev.allday { background: color-mix(in srgb, var(--c, var(--accent)) 20%, transparent); border-left-width: 0; }
.chip-time { color: var(--muted); margin-right: 4px; font-variant-numeric: tabular-nums; }
.month-more { font-size: .72rem; color: var(--muted); padding-left: 6px; }
.month-dots { display: none; }
@media (max-width: 700px) {
  .month-cell { min-height: 60px; padding: 4px; align-items: center; }
  .month-cell .chip-ev, .month-cell .month-more, .month-add { display: none; }
  .month-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
  .month-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--accent)); }
  .month-wd { text-align: center; padding: 8px 0 4px; }
  .cal-title { font-size: 1.1rem; margin-left: 4px; }
}
.agenda-day.is-today { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 0 0 3px var(--accent-softer); }
.agenda-day .card-title { margin-bottom: 6px; }
.stack > .card + .card { margin-top: 0; }

.tgrid { --cols: 7; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.tg-head, .tg-allday, .tg-body { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); }
.tg-head { border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.tg-day { padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: background .12s; }
.tg-day:hover { background: var(--hover); }
.tg-wd { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; }
.tg-num { font-size: 1.1rem; font-weight: 600; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-variant-numeric: tabular-nums; }
.tg-day.today .tg-num { background: var(--accent); color: var(--on-accent); }
.tg-allday { border-bottom: 1px solid var(--border); }
.tg-allday .tg-gutter { display: grid; place-items: center; font-size: .68rem; }
.tg-allday-cell { padding: 4px 3px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); min-width: 0; }
.tg-body { position: relative; }
.tg-gutter { position: relative; }
.tg-hour { position: absolute; right: 8px; transform: translateY(-50%); font-size: .68rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.tg-hour:first-child { transform: none; }
.tg-col {
  position: relative; border-left: 1px solid var(--border); cursor: copy;
  background-image: linear-gradient(to bottom, color-mix(in srgb, var(--border) 75%, transparent) 1px, transparent 1px);
  background-size: 100% var(--hour);
}
.tg-col.today { background-color: var(--accent-softer); }
.tg-ev {
  position: absolute; text-align: left; padding: 3px 6px; border-radius: 6px; overflow: hidden; cursor: pointer;
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface)); border-left: 3px solid var(--c, var(--accent));
  display: flex; flex-direction: column; font-size: .78rem; line-height: 1.25; z-index: 1; transition: background .12s, box-shadow .12s;
}
.tg-ev:hover { background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--surface)); box-shadow: var(--shadow-md); z-index: 3; }
.tg-ev-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; overflow-wrap: break-word; hyphens: auto; }
.tg-ev-time { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.tg-ev.short { flex-direction: row; gap: 6px; align-items: center; }
.tg-ev.short .tg-ev-title { white-space: nowrap; }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* ───────── habits ───────── */
.habits-card { padding: calc(var(--pad) * .7); overflow-x: auto; }
.htable { min-width: 520px; }
.hrow { display: grid; grid-template-columns: minmax(150px, 1.6fr) repeat(7, minmax(40px, 1fr)) 56px; align-items: center; min-height: 54px; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.hbody .hrow:last-child { border-bottom: 0; }
.hrow.dragging { opacity: .7; }
.hrow.archived { opacity: .5; }
.hhead { min-height: 44px; }
.hhead .hday { display: flex; flex-direction: column; align-items: center; font-size: .68rem; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.hhead .hday b { font-size: .95rem; color: var(--text); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.hhead .hday.today b { color: var(--accent-text); }
.hname { display: flex; align-items: center; gap: 4px; min-width: 0; }
.hname-btn { text-align: left; display: flex; flex-direction: column; min-width: 0; padding: 4px 6px; border-radius: var(--r-sm); overflow-wrap: anywhere; transition: background .12s; }
.hname-btn:hover { background: var(--hover); }
.hname-btn > span:first-child { font-weight: 550; }
.hday { display: grid; place-items: center; }
.hcell { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: transparent; background: var(--surface-2); transition: background .15s, transform .1s; }
.hcell:hover { background: var(--hover); }
.hcell:active { transform: scale(.9); }
.hcell.planned { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c, var(--accent)) 50%, transparent); }
.hcell.future:not(.on) { opacity: .55; }
.hcell.on { background: var(--c, var(--accent)); color: #fff; }
.hprog { display: grid; place-items: center; }
.ring { width: 40px; height: 40px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg { stroke: var(--c, var(--accent)); stroke-linecap: round; transition: stroke-dasharray .3s; }
.ring text { transform: rotate(90deg); transform-origin: 18px 18px; font-size: 9px; font-weight: 700; fill: var(--muted); font-family: var(--font); }
.ring.full text { fill: var(--c, var(--accent)); }
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist-row { display: grid; grid-template-columns: minmax(100px, 200px) 1fr auto; gap: 12px; align-items: center; }
.hist-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.hist-cells { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; max-width: 360px; }
.hist-cell { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); }
.hist-cell.part { background: color-mix(in srgb, var(--c, var(--accent)) 32%, var(--surface-2)); }
.hist-cell.ok { background: var(--c, var(--accent)); }
@media (max-width: 560px) { .hist-row { grid-template-columns: 1fr; gap: 4px; } .hist-streak { display: none; } }

/* ───────── board ───────── */
.board-tip { margin-bottom: 12px; }
.plan-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 12px var(--pad); margin-bottom: var(--gap); }
.plan-bar label { color: var(--muted); }
.time-compact { width: 108px !important; min-height: 34px !important; }
.plan-summary { flex: 1; min-width: 220px; font-size: .93rem; }
/* Columns always sit side by side; on narrow screens the board scrolls sideways, snapping to columns. */
.board {
  display: grid; grid-template-columns: repeat(3, minmax(min(280px, 80vw), 1fr)); gap: 14px; align-items: start;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; padding-bottom: 8px; scrollbar-width: thin;
}
.board-col { scroll-snap-align: start; background: var(--surface-2); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 140px; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: .9rem; padding: 2px 4px 4px; }
.board-col-head span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.board-col-head span:first-child::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.col-doing .board-col-head span:first-child::before { background: var(--accent); }
.col-done .board-col-head span:first-child::before { background: var(--ok); }
.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.board-empty { padding: 14px; text-align: center; border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); }
.board-col .quick-add { margin: 0; background: var(--surface); border-color: var(--border); }
.board-dots { display: none; }
.kcard {
  position: relative; display: flex; align-items: flex-start; gap: 2px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 10px 10px 4px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s;
}
.kcard:hover { box-shadow: var(--shadow-md); }
.kcard.dragging { opacity: .85; box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); transform: rotate(1deg); }
.kcard .drag-handle { height: 22px; }
.kcard-body { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.kcard-title { font-weight: 550; overflow-wrap: anywhere; padding-right: 4px; }
.kcard.is-done .kcard-title { text-decoration: line-through; color: var(--faint); }
.kcard-slot { font-size: .76rem; font-weight: 550; font-variant-numeric: tabular-nums; color: var(--accent-text); margin-top: 4px; }
.kcard-actions { display: flex; gap: 2px; flex: none; }
.icon-btn.ok:hover { color: var(--ok); }
@media (hover: hover) {
  .kcard-actions { position: absolute; top: 6px; right: 6px; background: var(--surface); border-radius: var(--r-sm); opacity: 0; transition: opacity .12s; box-shadow: 0 0 0 1px var(--border); }
  .kcard:hover .kcard-actions { opacity: 1; }
}
@media (hover: none) { .kcard-actions { flex-direction: column; } }
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick-list li { border-bottom: 1px solid var(--border); }
@media (max-width: 860px) {
  .board { margin: 0 -16px; padding: 0 16px 8px; scroll-padding: 0 16px; }
  .board-dots { display: flex; justify-content: center; gap: 6px; margin: 4px 0 12px; }
  .board-dots button { padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 550; color: var(--muted); background: var(--surface-2); }
  .board-dots button.on { background: var(--accent-soft); color: var(--accent-text); }
}

/* ───────── attachments ───────── */
.att-block { display: flex; flex-direction: column; gap: 8px; }
.att-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.att { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 0; min-width: 0; }
.att-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--muted); flex: none; }
.att-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 9px; flex: none; background: var(--surface-2); }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att-block .row input { width: auto !important; flex: 1 1 160px; min-width: 0; }

/* ───────── markdown ───────── */
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md > * + * { margin-top: .55em; }
.md h3, .md h4, .md h5 { margin: .9em 0 .2em; line-height: 1.3; letter-spacing: -0.015em; }
.md h3 { font-size: 1.15rem; } .md h4 { font-size: 1.04rem; } .md h5 { font-size: .95rem; }
.md > :first-child { margin-top: 0; }
.md code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; background: var(--surface); border: 1px solid var(--border); padding: 0 5px; border-radius: 5px; }
.md pre { background: var(--surface); border: 1px solid var(--border); padding: 10px 12px; border-radius: var(--r-sm); overflow-x: auto; margin: 0; }
.md pre code { background: none; border: 0; padding: 0; }
.md blockquote { margin: 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); }
.md-list { margin: 0; padding-left: 22px; }
.md-list li + li { margin-top: 3px; }
.md-list li.nested { margin-left: 18px; }
.md-list li.task-item { list-style: none; margin-left: -20px; display: flex; gap: 9px; align-items: baseline; }
.md-list li.task-item input { transform: translateY(3px); flex: none; }
.md-list li.task-item .done { text-decoration: line-through; color: var(--faint); }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md-editor { display: flex; flex-direction: column; gap: 6px; }
.md-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.md-tabs { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: 8px; }
.md-tab { padding: 2px 10px; border-radius: 6px; font-size: .8rem; font-weight: 550; color: var(--muted); min-height: 26px; }
.md-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 1px; }
.md-btn { min-width: 30px; height: 28px; padding: 0 6px; border-radius: 6px; color: var(--muted); font-size: .86rem; display: inline-grid; place-items: center; }
.md-btn:hover { background: var(--hover); color: var(--text); }
.md-preview { min-height: 80px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--input); }

/* ───────── settings ───────── */
.settings-block { max-width: 760px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plain-list li { padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.plain-list li:last-child { border-bottom: 0; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-size: .88rem; }
.danger-zone[open] { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.code-line { display: flex; align-items: center; gap: 8px; background: var(--input); border-radius: var(--r-sm); padding: 5px 5px 5px 12px; min-width: 0; }
.code-line code { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .8rem; overflow-x: auto; white-space: nowrap; }
.code-line .btn { flex: none; padding: 0 8px; }
.howto summary { cursor: pointer; font-weight: 550; }
.howto[open] { display: flex; flex-direction: column; gap: 8px; }
.howto ol { margin: 4px 0 0; padding-left: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

/* ───────── modal ───────── */
.modal {
  border: 0; padding: 0; background: var(--surface); color: var(--text); border-radius: calc(var(--radius) + 6px);
  width: min(540px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: var(--shadow-lg);
}
.modal.wide { width: min(760px, calc(100vw - 24px)); }
.modal::backdrop { background: rgb(12 12 16 / .38); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 6px 24px; }
.modal-head h2 { font-size: 1.12rem; }
.modal-body { padding: 10px 24px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 16px 14px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 40%, var(--surface)); }
.modal-foot .btn.ghost.danger-text { background: transparent; border-color: transparent; box-shadow: none; padding: 0 8px; }
@media (max-width: 560px) {
  .modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: calc(var(--radius) + 8px) calc(var(--radius) + 8px) 0 0; max-height: 92dvh; }
  .modal-inner { max-height: 92dvh; }
  .modal-head { padding: 14px 12px 4px 18px; }
  .modal-body { padding: 8px 18px 18px; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal[open] { animation: slide .22s cubic-bezier(.2, .9, .3, 1); }
  @keyframes slide { from { transform: translateY(40px); opacity: .4; } }
}

/* ───────── auth ───────── */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-softer), transparent 70%), var(--bg); }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 32px; box-shadow: var(--shadow-md); }
.form-error { color: var(--danger); font-size: .9rem; }
.form-error:empty { display: none; }

/* ───────── toast ───────── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-md); font-size: .9rem; font-weight: 500; z-index: 100;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
@media (max-width: 860px) { .toast { bottom: calc(92px + env(safe-area-inset-bottom)); } }

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

/* logo */
.logo { flex: none; display: block; }
.logo-bg { fill: var(--accent); }
.brand .logo { filter: drop-shadow(0 2px 4px color-mix(in srgb, var(--accent) 30%, transparent)); }

/* ═════════ v3 ═════════ */
/* compact editors: property grid */
.editor { display: flex; flex-direction: column; gap: 14px; }
.title-input { font-size: 1.15rem !important; font-weight: 600; min-height: 46px !important; letter-spacing: -0.01em; }
.props { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px 14px; align-items: center; }
.prop { display: contents; }
.prop-label { font-size: .82rem; font-weight: 550; color: var(--muted); align-self: start; padding-top: 8px; }
.prop-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.prop-ctl input:not([type=checkbox]):not([type=range]):not([type=color]), .prop-ctl select { width: auto !important; min-height: 34px !important; padding: 5px 10px !important; }
.prop-ctl input[type=date] { width: 142px !important; }
@media (min-width: 561px) { .modal:has(.editor) { width: min(620px, calc(100vw - 24px)); } }
.prop-ctl { gap: 5px; }
.prop-ctl input[type=time] { width: 96px !important; }
.prop-ctl input[type=datetime-local] { width: 200px !important; }
.prop-ctl input.num { width: 66px !important; }
.prop-hint { grid-column: 2; margin-top: -4px; }
.time-range { display: inline-flex; align-items: center; gap: 4px; }
.check-line.inline { min-height: 34px; font-size: .88rem; color: var(--muted); gap: 6px; }
.rep-details { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 8px 0 2px; }
.chip.xs { min-height: 26px; padding: 2px 9px; font-size: .78rem; }
.xs-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.btn.xs-btn { min-height: 28px; padding: 0 10px; font-size: .8rem; }
.swatches .swatch { width: 24px; height: 24px; }
.editor-notes .md-editor textarea { min-height: 90px; }
.att-details summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; font-weight: 550; }
.att-details[open] summary { margin-bottom: 8px; }
@media (max-width: 560px) {
  .props { grid-template-columns: 1fr; gap: 4px; }
  .prop-label { padding-top: 6px; }
  .prop-ctl { margin-bottom: 4px; }
  .prop-hint { grid-column: 1; }
}

/* compact tag select */
.tag-select { position: relative; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip.removable { padding-right: 3px; }
.tag-x { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; color: inherit; opacity: .6; font-size: .9rem; line-height: 1; }
.tag-x:hover { opacity: 1; background: color-mix(in srgb, var(--c) 18%, transparent); }
.tag-add { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 10px; border-radius: 999px; border: 1px dashed var(--border-strong); color: var(--muted); font-size: .8rem; }
.tag-add:hover { border-color: var(--accent); color: var(--accent-text); }
.tag-pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(280px, 80vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); padding: 6px; }
.tag-search { min-height: 34px !important; margin-bottom: 4px; }
.tag-options { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; }
.tag-option { --c: var(--muted); display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; text-align: left; font-size: .9rem; }
.tag-option:hover { background: var(--hover); }
.tag-option .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.tag-option .icon { margin-left: auto; color: var(--accent-text); }
.tag-option.create { color: var(--accent-text); }

/* toasts with undo, confetti, chart tooltip, notices */
.toast.undo { display: flex; align-items: center; gap: 14px; pointer-events: auto; }
.toast-action { color: color-mix(in srgb, var(--accent) 55%, #fff); font-weight: 650; }
.confetti { position: fixed; left: 50%; top: 35%; width: 0; height: 0; z-index: 200; pointer-events: none; }
.confetti i { position: absolute; width: 8px; height: 12px; border-radius: 2px; opacity: 0; animation: confetti var(--d) cubic-bezier(.2, .7, .3, 1) var(--delay) forwards; }
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--x), 50vh) rotate(var(--r)); }
}
.chart-tip { position: absolute; z-index: 150; transform: translate(-50%, -100%); background: var(--text); color: var(--bg); font-size: .78rem; font-weight: 500; padding: 5px 9px; border-radius: 7px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; box-shadow: var(--shadow-md); }
.chart-tip.show { opacity: 1; }
.notice { display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 14px; margin-bottom: 12px; border-radius: var(--r-md); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--border)); color: var(--danger); font-size: .9rem; font-weight: 550; }
.group-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.group-row .link-btn { font-size: .78rem; }
.hint.list-foot { display: flex; align-items: center; gap: 4px; }
.meta-pill.over { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* scheduled tasks in lists */
.agenda.nested { margin: 2px 0 4px 18px; padding-left: 10px; border-left: 2px dotted var(--border-strong); }
.ev-task .ev-btn { cursor: pointer; }
.ev-task .task-bar { background: repeating-linear-gradient(to bottom, var(--faint) 0 3px, transparent 3px 5px); }
.ev-task .checkbox { width: 17px; height: 17px; margin-top: 0; border-radius: 5px; }
.ev-task.done .ev-name { text-decoration: line-through; color: var(--faint); }
.day-tasks { margin-top: 8px; }

/* calendar: task chips, tray, drag */
.chip-ev.chip-task { display: flex; align-items: center; gap: 4px; border-left: 0; background: var(--surface-2); color: var(--text); padding-left: 4px; }
.chip-ev.chip-task:hover { background: var(--hover); }
.chip-ev.chip-task.done .ev-name { text-decoration: line-through; color: var(--faint); }
.chip-box { width: 13px; height: 13px; flex: none; border-radius: 4px; border: 1.4px solid var(--border-strong); display: inline-grid; place-items: center; font-size: 9px; line-height: 1; color: var(--on-accent); background: var(--surface); cursor: pointer; }
.chip-task.done .chip-box, .tg-task.done .chip-box { background: var(--accent); border-color: var(--accent); }
.month-dots i.task-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.month-cell.drop-target { background: var(--accent-softer) !important; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.tray { padding: 10px 14px; margin-bottom: var(--gap); }
.tray summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; list-style: none; }
.tray summary::-webkit-details-marker { display: none; }
.tray-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tray-list .chip-ev { width: auto; max-width: 260px; padding: 4px 8px 4px 2px; cursor: grab; touch-action: none; }
.tg-grip { display: inline-grid; place-items: center; color: var(--faint); cursor: grab; touch-action: none; }
.tg-ev .tg-grip { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; opacity: 0; }
.tg-ev:hover .tg-grip { opacity: .8; }
@media (pointer: coarse) { .tg-ev .tg-grip { opacity: .7; width: 26px; height: 26px; } }
.tg-ev[data-drag] { cursor: grab; }
.tg-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; touch-action: none; }
.tg-resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: currentColor; opacity: 0; }
.tg-ev:hover .tg-resize::after { opacity: .3; }
.tg-task { background: var(--surface) !important; border: 1px solid var(--border-strong); border-left: 3px solid var(--faint); }
.tg-task:hover { border-color: var(--accent); }
.tg-task.done { opacity: .55; }
.tg-task .tg-ev-title { display: flex; align-items: center; gap: 5px; }
.tg-ev.dragging, .drag-ghost { z-index: 5 !important; box-shadow: var(--shadow-lg) !important; opacity: .92; }
body.is-dragging, body.is-dragging * { user-select: none !important; -webkit-user-select: none !important; cursor: grabbing !important; }

/* palette */
.modal.palette { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; margin-bottom: auto; }
.pal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.pal-input { border: 0 !important; background: transparent !important; box-shadow: none !important; font-size: 1.02rem; padding: 4px 0 !important; min-height: 32px !important; color: var(--text); }
.pal-head kbd { font: 500 .7rem var(--font); color: var(--faint); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.pal-results { max-height: min(60vh, 460px); overflow-y: auto; padding: 6px; }
.pal-group { font-size: .68rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); padding: 10px 10px 4px; }
.pal-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--text); }
.pal-item .icon { color: var(--muted); }
.pal-item.on { background: var(--accent-softer); }
.pal-item.on .icon { color: var(--accent-text); }
.pal-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-meta { font-size: .8rem; color: var(--faint); white-space: nowrap; }
@media (max-width: 560px) { .modal.palette { margin-top: 0; margin-bottom: auto; border-radius: 0 0 calc(var(--radius) + 8px) calc(var(--radius) + 8px); } }

/* sidebar search + mobile top bar + "more" sheet + timer pill */
.side-search { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; margin-bottom: 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--faint); font-size: .9rem; text-align: left; }
.side-search:hover { color: var(--muted); border-color: var(--border-strong); }
.side-search kbd { margin-left: auto; font: 500 .68rem var(--font); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.topbar { display: none; }
@media (max-width: 860px) {
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 12px 0 16px; }
  .topbar .brand { padding: 0; font-size: 1rem; }
}
.more-sheet .plain-list a { display: flex; align-items: center; gap: 12px; color: var(--text); padding: 4px 0; text-decoration: none; font-weight: 550; }
.timer-pill {
  position: fixed; z-index: 40; right: 20px; bottom: 20px; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px;
  background: var(--text); color: var(--bg); border-radius: 999px; box-shadow: var(--shadow-lg); font-size: .88rem; max-width: min(420px, calc(100vw - 32px));
}
.timer-pill .t-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; cursor: pointer; }
.timer-pill .t-time { font-variant-numeric: tabular-nums; font-weight: 650; }
.timer-pill .t-time.over { color: #ff8a80; }
.timer-pill button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 18%, transparent); color: inherit; flex: none; }
.timer-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #ff6b66; animation: pulse 1.4s infinite; flex: none; }
@media (max-width: 860px) { .timer-pill { right: 12px; left: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); } }

/* motion: small, optional */
[data-motion="on"] .checkbox.on, [data-motion="on"] .tick.on, [data-motion="on"] .hcell.on { animation: pop-check .28s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop-check { 0% { transform: scale(.7); } 100% { transform: scale(1); } }
[data-motion="on"] .main > * { animation: enter .22s ease-out both; }
[data-motion="on"] .main > *:nth-child(2) { animation-delay: .03s; }
[data-motion="on"] .main > *:nth-child(3) { animation-delay: .06s; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
[data-motion="off"] *, [data-motion="off"] *::before, [data-motion="off"] *::after { animation: none !important; transition: none !important; }
.main-wrap { min-width: 0; }

/* ───────── reviews ───────── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; }
.kpi + .kpi { margin-top: 0; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 550; }
.kpi-value { font-size: 1.9rem; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: .76rem; color: var(--faint); }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--muted); }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi-value { font-size: 1.5rem; } }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; margin-bottom: var(--gap); }
.review-grid .card + .card { margin-top: 0; }
@media (max-width: 760px) { .review-grid { grid-template-columns: minmax(0, 1fr); } }

/* vertical bars: thin, rounded data end, recessive baseline */
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; height: 170px; align-items: end; }
.bar-col { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; outline: none; border-radius: 6px; }
.bar-col:hover, .bar-col:focus-visible { background: var(--accent-softer); }
.bar-val { font-size: .74rem; font-weight: 600; color: var(--muted); min-height: 1em; font-variant-numeric: tabular-nums; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--border-strong); }
.bar { width: min(26px, 60%); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; }
.bar.zero { height: 0 !important; }
.bar-label { font-size: .72rem; color: var(--faint); font-weight: 550; }
.bar-col.today .bar-label { color: var(--accent-text); font-weight: 700; }

/* horizontal labelled bars */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 38%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: .88rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--c, var(--accent)); }
.hbar-val { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.done-list li { padding: 7px 0; }
.check-dot { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); flex: none; }
.link-plain { text-align: left; }
.link-plain:hover { color: var(--accent-text); }
.habit-dot { --c: var(--accent); width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent); flex: none; display: inline-block; }
.habit-dot.on { background: var(--c); box-shadow: none; }
.habit-dot.future { opacity: .35; }
.habit-week { display: flex; flex-direction: column; gap: 10px; }
.hw-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; font-size: .9rem; }
.hw-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-dots { display: inline-flex; gap: 6px; }

/* year heatmap: sequential single hue (accent), 5 steps */
.heat-wrap { display: flex; flex-direction: column; gap: 8px; }
.heat-scroll { overflow-x: auto; padding-bottom: 4px; }
.heat-months, .heat { display: grid; grid-template-columns: repeat(var(--weeks), 12px); gap: 3px; width: max-content; }
.heat-months { font-size: .66rem; color: var(--faint); margin-bottom: 4px; white-space: nowrap; }
.heat-months span { overflow: visible; }
.heat { grid-template-rows: repeat(7, 12px); grid-auto-flow: column; }
.heat-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); outline: none; }
.heat-cell.l1 { background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.heat-cell.l2 { background: color-mix(in srgb, var(--accent) 52%, var(--surface-2)); }
.heat-cell.l3 { background: color-mix(in srgb, var(--accent) 76%, var(--surface-2)); }
.heat-cell.l4 { background: var(--accent); }
.heat-cell.lx { background: transparent; }
.heat-cell:hover, .heat-cell:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--text); }
.heat-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.review-card.wide { margin-top: 0; }

/* project progress on tag boards */
.project-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.progress { --c: var(--accent); width: 220px; max-width: 60vw; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: 4px; background: var(--c); transition: width .3s; }
.icon-btn.on { color: var(--danger); }
.emoji-in { width: 48px !important; text-align: center; padding: 6px !important; }

/* ═════════ phones ═════════ */
/* date / time pills */
.pick { position: relative; display: inline-flex; align-items: center; gap: 2px; min-height: 34px; padding: 0 12px; border-radius: 999px;
  background: var(--input); font-weight: 550; font-size: .9rem; white-space: nowrap; font-variant-numeric: tabular-nums; cursor: pointer; transition: background .15s; }
.pick:hover { background: var(--hover); }
.pick:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.pick.empty { color: var(--faint); font-weight: 500; }
.pick input.pick-in:not([type=checkbox]):not([type=range]):not([type=color]) {
  position: absolute; inset: 0; width: 100% !important; height: 100%; min-height: 0 !important; padding: 0 !important; margin: 0;
  opacity: 0; cursor: pointer; border: 0; box-shadow: none !important; }
.pick input.pick-in::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer; }
.pick-x { position: relative; z-index: 1; width: 22px; height: 22px; margin: 0 -7px 0 4px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted); }
.pick-x:hover { background: var(--border); color: var(--text); }
.toggle-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px 0 10px; border-radius: 999px; background: var(--input); color: var(--muted); font-size: .88rem; cursor: pointer; }
.toggle-chip:has(input:checked) { background: var(--accent-soft); color: var(--accent-text); }
.toggle-chip input { width: 15px; height: 15px; }
.num-unit { display: inline-flex; align-items: center; gap: 6px; }
.plan-start { display: flex; align-items: center; gap: 10px; }
.hprog-text { display: none; }

/* modal grabber (visible on phones only) */
.grabber { display: none; }

@media (pointer: coarse) {
  .chip.xs { min-height: 32px; padding: 4px 12px; font-size: .84rem; }
  .pick, .toggle-chip { min-height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .btn { min-height: 42px; }
  .btn.small { min-height: 36px; }
}

@media (max-width: 560px) {
  /* bottom sheet */
  .modal { width: 100%; max-width: 100%; }
  .modal-head { position: relative; padding: 18px 8px 2px 18px; touch-action: none; }
  .grabber { display: block; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--border-strong); }
  .modal-body { padding: 6px 16px 16px; }
  .modal-foot { gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); }
  .modal-foot .btn { min-height: 46px; font-size: 1rem; }
  .modal-foot .btn.primary { flex: 1 1 auto; }
  .modal-foot .grow:not(.save-status) { display: none; }
  .modal-foot:has(.save-status) .btn.primary { flex: 0 0 auto; min-width: 116px; }
  .modal-foot .btn.ghost.danger-text { font-size: 0; gap: 0; width: 46px; padding: 0; flex: none; }
  .modal-foot .btn.ghost.danger-text .icon { width: 22px; height: 22px; }

  /* editor: a settings-style list, label left, value right */
  .editor { gap: 10px; }
  .title-input { font-size: 1.2rem !important; min-height: 50px !important; }
  .props { grid-template-columns: 92px minmax(0, 1fr); gap: 0; margin: 0 -16px; padding: 0 16px; }
  .prop-label, .prop-ctl { border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent); padding: 10px 0; margin: 0; }
  .prop-label { padding-top: 18px; font-size: .86rem; }
  .prop-ctl { gap: 6px; min-height: 58px; padding-left: 8px !important; }
  .num-unit input.num { width: 64px !important; border-radius: 999px; text-align: center; }
  .prop-hint { grid-column: 1 / -1; margin: -4px 0 8px; }
  .prop-ctl .xs-group { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px;
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .prop-ctl .xs-group::-webkit-scrollbar { display: none; }
  .prop-ctl .xs-group .chip { flex: none; }
  .prop-ctl .seg { max-width: 100%; }
  .prop-ctl select { max-width: 100%; }
  .rep-details { padding-top: 4px; }
  .prop-ctl .swatches { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 4px; margin: -4px -16px -4px -4px; padding-right: 16px; gap: 7px; }
  .prop-ctl .swatches .swatch { flex: none; }
  .editor-notes .md-editor textarea { min-height: 110px; }

  /* page heads */
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head > div:first-child { flex: 1 1 190px; min-width: 0; }
  .page-head .head-actions { flex: 1 1 auto; justify-content: flex-end; }
  .page-head .head-actions { flex-wrap: nowrap; }
  .page-head .head-actions .btn { padding: 0 12px; }
  .page-head .head-actions .compact-select { flex: 1 1 90px; min-width: 0; }
  .page-head .head-actions .btn.primary { margin-left: auto; }
  .btn .btn-text { display: none; }
  .cal-head .head-actions { flex-wrap: wrap; }
  .cal-head .cal-nav { width: 100%; }
  .cal-title { font-size: 1.12rem !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .cal-head .head-actions .seg { order: -1; flex: 1 1 100%; }
  .cal-head .head-actions .seg button { flex: 1 1 0; }
  .cal-head .head-actions .compact-select { flex: 1 1 0; min-width: 0; }

  /* segmented controls stretch instead of wrapping */
  .card .seg { display: flex; }
  .card .seg button { flex: 1 1 auto; min-width: 0; padding: 5px 4px; font-size: .8rem; }

  /* habits: all 7 days fit; progress moves under the name */
  .habits-card { padding: 10px 8px; overflow: visible; }
  .htable { min-width: 0; }
  .hrow { grid-template-columns: minmax(0, 1fr) repeat(7, 32px); column-gap: 2px; min-height: 50px; }
  .hprog { display: none; }
  .hcell { width: 30px; height: 30px; border-radius: 9px; }
  .hname .drag-handle { width: 12px; }
  .hname-btn { padding: 4px 2px; }
  .hname-btn > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hprog-text { display: inline; }
  .hprog-full { display: none; }
  .hhead .hday { font-size: .6rem; }

  /* board plan bar */
  .plan-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px; }
  .plan-summary { min-width: 0; font-size: .88rem; }

  /* notices */
  .notice { font-size: .86rem; padding: 6px 6px 6px 12px; }
  .notice .grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .notice .btn { flex: none; }

  .toolbar { gap: 8px; }
  .week-label { margin-left: 4px; font-size: .95rem; white-space: nowrap; }
}

/* autosave status in editor footers */
.save-status { font-size: .84rem; color: var(--faint); display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.save-status.ok { color: var(--ok); }
.save-status.ok::before { content: '✓'; font-weight: 700; }
.save-status.warn { color: var(--warn); }
.save-status.err { color: var(--danger); white-space: normal; }

/* ═════════ v4: soft depth ═════════ */
:root {
  --accent-2: color-mix(in oklch, var(--accent) 62%, #d15cff);
  --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --glow-1: color-mix(in srgb, var(--accent) 14%, transparent);
  --glow-2: color-mix(in srgb, var(--accent-2) 11%, transparent);

  --card-edge: rgb(255 255 255 / .85);
  --shadow-sm: 0 1px 1px rgb(22 22 40 / .03), 0 2px 6px -2px rgb(22 22 40 / .07);
  --shadow-md: 0 1px 2px rgb(22 22 40 / .04), 0 6px 16px -6px rgb(22 22 40 / .10), 0 18px 40px -18px rgb(22 22 40 / .14);
  --shadow-lg: 0 2px 6px rgb(22 22 40 / .06), 0 24px 60px -16px rgb(22 22 40 / .30);
  --shadow-accent: 0 8px 22px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
[data-theme="light"] { --bg: #f3f3f0; }
[data-theme="sepia"] { --bg: #efe9dd; --card-edge: rgb(255 253 246 / .9); }
[data-theme="dark"], [data-theme="black"] {
  --card-edge: rgb(255 255 255 / .05);
  --glow-1: color-mix(in srgb, var(--accent) 16%, transparent);
  --glow-2: color-mix(in srgb, var(--accent-2) 10%, transparent);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px -12px rgb(0 0 0 / .7);
  --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / .85);
}
[data-theme="dark"] { --bg: #0f0f13; --surface: #17171d; --surface-2: #202027; --border: #26262e; }

/* background: two soft glows from the accent colour */
body {
  background:
    radial-gradient(900px 520px at 8% -8%, var(--glow-1), transparent 62%),
    radial-gradient(760px 480px at 102% 4%, var(--glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
.sidebar { background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(12px); border-right-color: color-mix(in srgb, var(--border) 70%, transparent); }

/* cards float: layered shadow + a light top edge */
.card {
  border-radius: calc(var(--radius) + 6px);
  border-color: color-mix(in srgb, var(--border) 65%, transparent);
  box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-md);
}
.card-title { font-size: 1rem; letter-spacing: -0.015em; }

/* buttons */
.btn.primary { background: var(--grad); box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), var(--shadow-accent); }
.btn.primary:hover { filter: brightness(1.06) saturate(1.05); transform: translateY(-1px); }
.btn.ghost { box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-sm); border-color: color-mix(in srgb, var(--border) 80%, transparent); }
.btn.ghost:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-md); }
.seg { box-shadow: inset 0 1px 2px rgb(0 0 0 / .05); }
.seg button.on { box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-sm), 0 0 0 1px color-mix(in srgb, var(--border) 60%, transparent); }
.chip.on, .tag-chip.toggle.on { box-shadow: var(--shadow-sm); }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { box-shadow: inset 0 1px 2px rgb(0 0 0 / .04); }

/* checkboxes and habit cells light up */
.checkbox { border-radius: 7px; box-shadow: inset 0 1px 2px rgb(0 0 0 / .05); }
.checkbox.on, .task.done .checkbox { background: var(--grad); border-color: transparent; box-shadow: 0 3px 8px -3px color-mix(in srgb, var(--accent) 70%, transparent); }
.hcell { box-shadow: inset 0 1px 2px rgb(0 0 0 / .05); }
.hcell.on { background: linear-gradient(135deg, var(--c, var(--accent)), color-mix(in oklch, var(--c, var(--accent)) 70%, #fff)); box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--c, var(--accent)) 80%, transparent); }
.tick.on { box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--c, var(--accent)) 80%, transparent); }

/* section icons sit on coloured plates */
[data-nav="today"] { --nc: #f59e0b; }
[data-nav="calendar"] { --nc: #3b82f6; }
[data-nav="tasks"] { --nc: #10b981; }
[data-nav="board"] { --nc: #8b5cf6; }
[data-nav="habits"] { --nc: #ec4899; }
[data-nav="review"] { --nc: #14b8a6; }
[data-nav="settings"], [data-nav="more"] { --nc: #8b8d98; }
.nav-link { height: 40px; gap: 12px; }
.nav-link .icon { width: 28px; height: 28px; padding: 5px; border-radius: 9px; color: var(--nc); background: color-mix(in srgb, var(--nc) 14%, transparent); transition: background .15s, color .15s, box-shadow .15s; }
.nav-link.active { box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-md); border-radius: calc(var(--r-sm) + 2px); }
.nav-link.active .icon { color: #fff; background: linear-gradient(135deg, var(--nc), color-mix(in oklch, var(--nc) 65%, #fff)); box-shadow: 0 4px 10px -4px var(--nc); }

/* Today hero */
.hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 20px; align-items: center;
  padding: 22px 24px; margin-bottom: var(--gap); border-radius: calc(var(--radius) + 10px); color: #fff;
  background:
    radial-gradient(420px 220px at 100% 0%, rgb(255 255 255 / .22), transparent 70%),
    radial-gradient(300px 200px at 0% 120%, rgb(0 0 0 / .18), transparent 70%),
    var(--grad);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 18px 40px -18px color-mix(in srgb, var(--accent) 80%, transparent), var(--shadow-md);
}
.hero::after { content: ""; position: absolute; right: -60px; bottom: -80px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid rgb(255 255 255 / .07); pointer-events: none; }
.hero h1 { color: #fff; font-size: 1.85rem; letter-spacing: -0.03em; margin: 2px 0 6px; }
.hero-date { font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.hero-next { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .92rem; opacity: .95; }
.hero-next b { font-weight: 650; }
.hero .summary { color: rgb(255 255 255 / .85); margin-top: 12px; }
.hero .summary b { color: #fff; }
.hero .summary .icon { color: rgb(255 255 255 / .7); }
.hero-ring { position: relative; width: 96px; height: 96px; align-self: start; }
.hero-ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hero-ring-svg circle { fill: none; stroke-width: 6; }
.hero-ring-bg { stroke: rgb(255 255 255 / .22); }
.hero-ring-fg { stroke: #fff; stroke-linecap: round; filter: drop-shadow(0 0 4px rgb(255 255 255 / .6)); transition: stroke-dasharray .6s cubic-bezier(.2, .8, .2, 1); }
.hero-ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.hero-ring-text b { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-ring-text span { font-size: .7rem; opacity: .8; }
.hero-actions { display: flex; gap: 8px; grid-column: 1 / -1; }
.hero-btn { background: rgb(255 255 255 / .16); color: #fff; border: 1px solid rgb(255 255 255 / .22); backdrop-filter: blur(6px); }
.hero-btn:hover { background: rgb(255 255 255 / .24); }
.hero-btn.solid { background: #fff; color: color-mix(in srgb, var(--accent) 85%, #000); border-color: transparent; box-shadow: 0 6px 16px -8px rgb(0 0 0 / .4); }

/* calendar & board pieces get a little volume too */
.tg-ev { background: linear-gradient(180deg, color-mix(in srgb, var(--c, var(--accent)) 20%, var(--surface)), color-mix(in srgb, var(--c, var(--accent)) 11%, var(--surface))); box-shadow: 0 1px 2px rgb(0 0 0 / .05); }
.tgrid, .month { border-radius: calc(var(--radius) + 6px); box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-md); border-color: color-mix(in srgb, var(--border) 65%, transparent); }
.board-col { background: color-mix(in srgb, var(--surface-2) 70%, transparent); box-shadow: inset 0 1px 3px rgb(0 0 0 / .05); border-radius: calc(var(--radius) + 6px); }
.kcard { border-radius: calc(var(--radius) + 2px); box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-sm); transition: box-shadow .15s, transform .15s; }
.kcard:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-md); }
.kpi-value { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bar { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.progress-fill { background: linear-gradient(90deg, var(--c), color-mix(in oklch, var(--c) 60%, #d15cff)); }

/* dialogs */
.modal { border-radius: calc(var(--radius) + 12px); box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-lg); }
.modal::backdrop { background: rgb(12 12 20 / .42); backdrop-filter: blur(8px) saturate(1.2); }

@media (max-width: 860px) {
  /* floating glass tab bar */
  .tabbar {
    left: 10px; right: 10px; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 6px; border-radius: 22px;
    border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); background: color-mix(in srgb, var(--surface) 72%, transparent);
    box-shadow: inset 0 1px 0 var(--card-edge), var(--shadow-lg);
  }
  .tab-link.active .icon { color: #fff; background: linear-gradient(135deg, var(--nc), color-mix(in oklch, var(--nc) 65%, #fff)); box-shadow: 0 4px 10px -4px var(--nc); }
  .main { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
  .timer-pill { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .hero { padding: 18px 18px 16px; border-radius: calc(var(--radius) + 8px); gap: 12px 14px; }
  .hero h1 { font-size: 1.45rem; }
  .hero { grid-template-columns: minmax(0, 1fr) 70px; }
  .hero-main { display: contents; }
  .hero-date, .hero h1 { grid-column: 1; }
  .hero-date { grid-row: 1; }
  .hero h1 { grid-row: 2; margin: 0; }
  .hero-next, .hero .summary { grid-column: 1 / -1; margin: 0; }
  .hero-ring { grid-column: 2; grid-row: 1 / span 2; width: 70px; height: 70px; }
  .hero-ring-text b { font-size: 1rem; }
  .hero .summary { gap: 4px 12px; font-size: .86rem; }
  .hero-actions .btn { flex: 1; }
  .modal { border-radius: calc(var(--radius) + 12px) calc(var(--radius) + 12px) 0 0; }
}
@media (prefers-reduced-transparency: reduce) { .tabbar, .sidebar { backdrop-filter: none; background: var(--surface); } }
