:root {
  --bg: #f5f4f0; --panel: #ffffff; --panel-2: #efeee9; --ink: #16181d; --muted: #6a6f7a; --faint: #a3a7b0;
  --line: #e2e0d9; --accent: #5b5bf0; --accent-ink: #ffffff; --accent-soft: #e6e6fd;
  --danger: #d0453a; --ok: #1f9d62; --warn: #c27a10;
  --now: #ff6b3d; --now-soft: #ffe7dd;
  --shadow: 0 1px 2px rgba(20,20,30,.06), 0 4px 16px rgba(20,20,30,.06);
  --radius: 14px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --ink: #e9ebf0; --muted: #969cab; --faint: #5d6372;
  --line: #262b36; --accent: #8b8bff; --accent-ink: #0f1115; --accent-soft: #23244a;
  --danger: #ff7a6e; --ok: #4fd18f; --warn: #f0b04a; --now: #ff8a5c; --now-soft: #3a2118;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --ink: #e9ebf0; --muted: #969cab; --faint: #5d6372;
  --line: #262b36; --accent: #8b8bff; --accent-ink: #0f1115; --accent-soft: #23244a;
  --danger: #ff7a6e; --ok: #4fd18f; --warn: #f0b04a; --now: #ff8a5c; --now-soft: #3a2118;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--now)); display: grid; place-items: center; color: #fff; font-size: 15px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .ic { width: 20px; text-align: center; font-size: 16px; }
.nav-item .badge { margin-left: auto; font-size: 12px; background: var(--panel-2); color: var(--muted); border-radius: 999px; padding: 0 7px; }
.side .grow { flex: 1; }
.side .capture-btn { margin-top: 10px; }
main { min-width: 0; padding: 28px 32px 120px; max-width: 1400px; }
.bottom-nav { display: none; }
.fab { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: calc(14px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
  .bottom-nav a .ic { font-size: 19px; line-height: 1; }
  .bottom-nav a.active { color: var(--accent); }
  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 41;
    width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 26px; box-shadow: 0 8px 24px rgba(60,60,200,.35); cursor: pointer; }
}

/* ---- headings ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; line-height: 1.1; margin: 0; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--faint); }

/* ---- buttons & inputs ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 10px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--panel-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input { width: 100%; background: var(--panel-2); border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--accent); background: var(--panel); }
textarea.input { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.page-head .row > * { flex: none; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* ---- chips ---- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; color: var(--muted); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tag.due { color: var(--warn); }
.tag.over { color: var(--danger); font-weight: 600; }
.tag.time { color: var(--now); font-weight: 600; font-family: var(--mono); font-size: 11.5px; }

/* ---- task cards ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; position: relative; }
.task + .task { border-top: 1px solid var(--line); }
.list { overflow: hidden; }
.check { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--faint); background: none; cursor: pointer; margin-top: 1px; display: grid; place-items: center; padding: 0; color: transparent; font-size: 12px; transition: all .15s; }
.check:hover { border-color: var(--ok); color: var(--ok); }
.check.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.task .body { flex: 1; min-width: 0; }
.task .title { font-weight: 500; word-wrap: break-word; }
.task.is-done .title { text-decoration: line-through; color: var(--faint); }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; }
.task .bar { position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; }
.prio-1 .title::before { content: "!"; color: var(--danger); font-weight: 700; margin-right: 6px; }
.ai-pending .title { color: var(--muted); }
.spinner { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- now view ---- */
.hello { font-size: 14px; color: var(--muted); }
.clock { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: 22px; color: #fff; margin-bottom: 8px; }
.hero.fixed { background: linear-gradient(135deg, #ff6b3d, #e8456b); }
.hero.block { background: linear-gradient(135deg, var(--hero-c, #5b5bf0), color-mix(in srgb, var(--hero-c, #5b5bf0) 55%, #111)); }
.hero.free { background: linear-gradient(135deg, #3a3f4b, #1d2027); }
.hero .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; opacity: .85; font-weight: 600; }
.hero .big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 4px; line-height: 1.15; }
.hero .when { opacity: .9; font-family: var(--mono); font-size: 13px; }
.hero .progress { height: 4px; background: rgba(255,255,255,.25); border-radius: 4px; margin-top: 14px; overflow: hidden; }
.hero .progress i { display: block; height: 100%; background: #fff; border-radius: 4px; }
.hero .actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.hero .actions .btn { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }
.hero .actions .btn:hover { background: rgba(255,255,255,.28); }
.focus-first { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.focus-first .title { font-size: 17px; font-weight: 600; }
.nudge { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 12px; color: var(--muted); }
.nudge b { color: var(--ink); }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding: 10px 14px; align-items: center; cursor: pointer; }
.tl-item + .tl-item { border-top: 1px solid var(--line); }
.tl-item .t { font-family: var(--mono); font-size: 12.5px; color: var(--muted); width: 92px; flex: none; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

/* ---- board ---- */
.board-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; scroll-snap-type: x mandatory; }
.col { background: var(--panel-2); border-radius: 16px; padding: 10px; scroll-snap-align: start; min-height: 200px; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 600; font-size: 14px; }
.col-head .n { color: var(--faint); font-weight: 500; margin-left: 6px; }
.col-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col .task { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.col .task + .task { border-top: 1px solid var(--line); }
.quick-add { width: 100%; background: transparent; border: 1px dashed var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; outline: none; }
.quick-add:focus { border-style: solid; border-color: var(--accent); background: var(--panel); }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 10px 30px rgba(0,0,0,.2) !important; }
@media (max-width: 820px) { .board { grid-auto-columns: 84vw; margin: 0 -16px; padding: 0 16px 12px; } }

/* ---- week ---- */
.week-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.week { display: grid; grid-template-columns: 52px repeat(7, minmax(118px, 1fr)); min-width: 880px; position: relative; }
.wk-head { position: sticky; top: 0; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 8px; font-size: 13px; text-align: center; }
.wk-head b { display: block; font-size: 18px; }
.wk-head.today b { color: var(--accent); }
.wk-allday { border-bottom: 1px solid var(--line); padding: 4px; min-height: 30px; display: flex; flex-direction: column; gap: 3px; }
.wk-allday .pill { font-size: 11.5px; padding: 2px 6px; border-radius: 6px; background: var(--panel-2); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid var(--warn); }
.wk-hours { position: relative; }
.wk-hour { height: 48px; font-size: 11px; color: var(--faint); text-align: right; padding-right: 8px; transform: translateY(-7px); font-family: var(--mono); }
.wk-day { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 48px; cursor: copy; }
.wk-block { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 4px 7px; font-size: 12px; font-weight: 600; overflow: hidden; cursor: pointer;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 80%, var(--ink)); border: 1px dashed color-mix(in srgb, var(--c) 55%, transparent); }
.wk-event { position: absolute; left: 10px; right: 4px; border-radius: 8px; padding: 4px 7px; font-size: 12px; overflow: hidden; cursor: pointer; z-index: 2;
  background: var(--c, var(--now)); color: #fff; font-weight: 500; box-shadow: var(--shadow); }
.wk-event.done { opacity: .45; text-decoration: line-through; }
.wk-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--now); z-index: 4; pointer-events: none; }
.wk-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }

/* ---- projects ---- */
.area-block { margin-bottom: 26px; }
.area-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.area-head h2 { font-size: 18px; margin: 0; }
.area-head .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-size: 15px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.proj { padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.proj:hover { border-color: var(--faint); }
.proj .name { font-weight: 600; }
.proj .desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.proj .foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: auto; }
.proj.paused { opacity: .6; }

/* ---- sheets (modals) ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10,10,15,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
.sheet { background: var(--panel); border-radius: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: rise .2s ease-out; }
.sheet h3 { margin: 0 0 16px; font-size: 19px; }
.sheet .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.sheet .foot .left { margin-right: auto; }
@media (max-width: 820px) {
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 22px 22px 0 0; max-height: 94vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }

/* ---- capture ---- */
.capture { text-align: center; }
.mic { width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 38px; cursor: pointer; margin: 6px auto 14px; display: grid; place-items: center; transition: transform .15s; }
.mic.live { background: var(--now); animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--now) 60%, transparent); } 70% { box-shadow: 0 0 0 22px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.capture textarea { min-height: 120px; font-size: 16px; }
.capture .hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { padding: 0 0 22px; font-size: 20px; }
.err { color: var(--danger); font-size: 14px; margin-bottom: 10px; }

/* ---- misc ---- */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 80; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
@media (max-width: 820px) { #toast { bottom: calc(var(--nav-h) + 92px + env(safe-area-inset-bottom)); } }
.code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 10px 12px; border-radius: 10px; overflow-x: auto; white-space: pre; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.settings-grid .card { padding: 20px; }
.settings-grid h3 { margin: 0 0 14px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- whiteboard & presentation gallery ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.gcard { overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s; }
.gcard:hover { transform: translateY(-2px); border-color: var(--faint); }
.gcard .thumb { aspect-ratio: 16 / 10; background: #eef1f5; background-image: radial-gradient(#d3d9e1 1px, transparent 1px); background-size: 14px 14px;
  border-bottom: 1px solid var(--line); display: grid; place-items: center; padding: 10px; }
.gcard .thumb svg { width: 100%; height: 100%; }
.thumb-empty { color: #9aa3b0; font-size: 13px; }
.gmeta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 12px 14px; }
.gmeta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 820px) { .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; } .bottom-nav a { font-size: 10.5px; } }

.tag.tg { color: var(--accent, #7c6cff); cursor: pointer; }
.tag.wb { color: var(--now); text-decoration: none; font-weight: 600; }
.tag.wb:hover { text-decoration: underline; }
.chip.tg { color: var(--accent, #7c6cff); }
.chip.tg.on { color: var(--bg); background: var(--accent, #7c6cff); border-color: var(--accent, #7c6cff); }
.chip .n { opacity: .65; font-size: 11px; margin-left: 2px; }
.chip.save { border-style: dashed; }
.chip .x { margin-left: 4px; opacity: .7; }
.views-row { margin-bottom: 8px; }
