/* Tasker — same palette and shapes as the Mac/iPhone app. Light and dark via data-theme. */

:root {
  --bg: #F3F3EF; --surface: #FFFFFF; --surface-subtle: #F8F8F4; --border: #E4E4DE;
  --text: #1C1C1A; --muted: #5E5E58; --faint: #8A8A82;
  --accent: #2E52D6; --accent-soft: #EEF1FC; --accent-text: #2A3F99; --on-accent: #FFFFFF;
  --track: #EBEBE5; --warning: #E07800; --warning-text: #8F4300; --warning-soft: #FFF3E3;
  --success: #1F7A3E; --danger: #B3261E; --adhoc-stripe: #B9B9B1;
  --area-0: #2E52D6; --area-1: #0E7C70; --area-2: #7A4BD6; --area-3: #C25E00;
  --area-4: #C2185B; --area-5: #2E7D32; --area-6: #455A64; --area-7: #9E7700;
  --st-ok-fg: #1F7A3E; --st-ok-bg: #E6F4EA; --st-ok-dot: #2E9E52;
  --st-now-fg: #8F4300; --st-now-bg: #FFEFD9; --st-now-dot: #E07800;
  --st-late-fg: #B3261E; --st-late-bg: #FCE8E6; --st-late-dot: #D93025;
  --st-none-fg: #5E5E58; --st-none-bg: #EFEFEA; --st-none-dot: #9A9A92;
  --st-done-fg: #1F7A3E; --st-done-bg: #F0F0EC; --st-done-dot: #1F7A3E;
  --st-sched-fg: #2A3F99; --st-sched-bg: #EEF1FC; --st-sched-dot: #2E52D6;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06);
  --shadow-pop: 0 10px 40px rgb(0 0 0 / 0.16), 0 2px 6px rgb(0 0 0 / 0.08);
  --radius: 16px; --radius-s: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 60px;
  color-scheme: light;
}

/* Dark colours: the same values are repeated below for "system" in dark mode; keep both blocks identical. */
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1F1F1D; --surface-subtle: #262624; --border: #34342F;
  --text: #F0F0EA; --muted: #A9A9A1; --faint: #7D7D76;
  --accent: #8AA2FF; --accent-soft: #252C4A; --accent-text: #BFCBFF; --on-accent: #10142A;
  --track: #30302C; --warning: #FFA347; --warning-text: #FFB866; --warning-soft: #3A2A15;
  --success: #6FCF8E; --danger: #FF8A80; --adhoc-stripe: #5A5A54;
  --area-0: #8AA2FF; --area-1: #4CC7B6; --area-2: #B394FF; --area-3: #FF9F4A;
  --area-4: #FF7EB0; --area-5: #7BD196; --area-6: #9FB3BF; --area-7: #E8C34F;
  --st-ok-fg: #7BD196; --st-ok-bg: #1D3326; --st-ok-dot: #5BC77E;
  --st-now-fg: #FFB866; --st-now-bg: #3A2A15; --st-now-dot: #FFA347;
  --st-late-fg: #FF8A80; --st-late-bg: #3D1F1D; --st-late-dot: #FF6B60;
  --st-none-fg: #A9A9A1; --st-none-bg: #2A2A27; --st-none-dot: #7D7D76;
  --st-done-fg: #7BD196; --st-done-bg: #262624; --st-done-dot: #6FCF8E;
  --st-sched-fg: #BFCBFF; --st-sched-bg: #252C4A; --st-sched-dot: #8AA2FF;
  --shadow: none; --shadow-pop: 0 10px 40px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #141413; --surface: #1F1F1D; --surface-subtle: #262624; --border: #34342F;
    --text: #F0F0EA; --muted: #A9A9A1; --faint: #7D7D76;
    --accent: #8AA2FF; --accent-soft: #252C4A; --accent-text: #BFCBFF; --on-accent: #10142A;
    --track: #30302C; --warning: #FFA347; --warning-text: #FFB866; --warning-soft: #3A2A15;
    --success: #6FCF8E; --danger: #FF8A80; --adhoc-stripe: #5A5A54;
    --area-0: #8AA2FF; --area-1: #4CC7B6; --area-2: #B394FF; --area-3: #FF9F4A;
    --area-4: #FF7EB0; --area-5: #7BD196; --area-6: #9FB3BF; --area-7: #E8C34F;
    --st-ok-fg: #7BD196; --st-ok-bg: #1D3326; --st-ok-dot: #5BC77E;
    --st-now-fg: #FFB866; --st-now-bg: #3A2A15; --st-now-dot: #FFA347;
    --st-late-fg: #FF8A80; --st-late-bg: #3D1F1D; --st-late-dot: #FF6B60;
    --st-none-fg: #A9A9A1; --st-none-bg: #2A2A27; --st-none-dot: #7D7D76;
    --st-done-fg: #7BD196; --st-done-bg: #262624; --st-done-dot: #6FCF8E;
    --st-sched-fg: #BFCBFF; --st-sched-bg: #252C4A; --st-sched-dot: #8AA2FF;
    --shadow: none; --shadow-pop: 0 10px 40px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }
}

/* ---- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
ul { list-style: none; margin: 0; padding: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.warn { color: var(--warning-text); font-weight: 700; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.gap { gap: 10px; }
.gap-s { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; display: block; }
.rot90 { transform: rotate(90deg); }
.icon { transition: transform 0.15s ease; }
.boot { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; }
.boot img { border-radius: 16px; }
.inline-icon { display: inline-block; vertical-align: -2px; }
.dot { display: inline-block; border-radius: 50%; flex: none; }

/* ---- Buttons & inputs ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 14px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger.subtle { border-color: transparent; background: transparent; padding-left: 0; align-self: flex-start; }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn.wide { width: 100%; min-height: 44px; }
.btn:disabled { opacity: 0.5; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--surface-subtle); color: var(--text); }
.icon-btn.danger { color: var(--danger); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; margin-left: 8px; }
.input {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
textarea.input { resize: vertical; min-height: 72px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: auto; }
input.bare { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 6px 0; }
.select-compact { border: 1px solid var(--border); background: var(--surface-subtle); border-radius: 8px; padding: 4px 6px; max-width: 45%; font-size: 13px; }

.switch {
  appearance: none; flex: none; width: 44px; height: 26px; border-radius: 13px; background: var(--track);
  position: relative; cursor: pointer; transition: background 0.15s; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform 0.15s;
}
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(18px); }
.switch.small { width: 36px; height: 22px; }
.switch.small::after { width: 16px; height: 16px; }
.switch.small:checked::after { transform: translateX(14px); }

/* ---- Frame --------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: calc(var(--topbar-h) + env(safe-area-inset-top)); display: flex; align-items: center; gap: 18px;
  padding: env(safe-area-inset-top) max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.brand img { border-radius: 7px; }
.tabs { display: flex; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 14px;
}
.nav-item:hover { color: var(--text); background: var(--surface-subtle); }
.nav-item.is-active { color: var(--accent-text); background: var(--accent-soft); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search {
  display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); width: 240px;
}
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; outline: none; background: transparent; width: 100%; color: var(--text); }
.add-btn { background: var(--accent); color: var(--on-accent); }
.add-btn:hover { background: var(--accent); color: var(--on-accent); filter: brightness(1.06); }
.main { padding: 28px 28px 80px; }
.main.is-busy { cursor: progress; }
.page { margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.page-overview { max-width: 1240px; }
.page-area { max-width: 920px; gap: 18px; }
.page-settings { max-width: 760px; }
.page-week { max-width: none; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head p { margin-top: 6px; font-size: 14px; }

/* ---- Cards & shared bits ------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; width: fit-content; color: var(--fg); background: var(--bg-pill);
}
.pill.compact { padding: 3px 8px; font-size: 11px; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.st-onTrack { --fg: var(--st-ok-fg); --bg-pill: var(--st-ok-bg); --dot: var(--st-ok-dot); }
.st-startNow { --fg: var(--st-now-fg); --bg-pill: var(--st-now-bg); --dot: var(--st-now-dot); }
.st-late, .st-overdue { --fg: var(--st-late-fg); --bg-pill: var(--st-late-bg); --dot: var(--st-late-dot); }
.st-noDeadline { --fg: var(--st-none-fg); --bg-pill: var(--st-none-bg); --dot: var(--st-none-dot); }
.st-done { --fg: var(--st-done-fg); --bg-pill: var(--st-done-bg); --dot: var(--st-done-dot); }
.st-scheduled { --fg: var(--st-sched-fg); --bg-pill: var(--st-sched-bg); --dot: var(--st-sched-dot); }
.tone-late, .tone-overdue { color: var(--danger); }
.tone-startNow { color: var(--warning-text); }
.badge { display: inline-block; padding: 3px 7px; border-radius: 6px; font-size: 11px; font-weight: 500; color: var(--accent-text); background: var(--accent-soft); white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.check { --size: 22px; flex: none; display: grid; place-items: center; min-width: 30px; min-height: 30px; padding: 0; border: 0; background: none; }
.check-box {
  display: grid; place-items: center; width: var(--size); height: var(--size); border-radius: calc(var(--size) * 0.32);
  border: 1.5px solid var(--faint); background: var(--surface); color: #fff; transition: background 0.12s, border-color 0.12s;
}
.check:hover .check-box { border-color: var(--success); }
.check.is-done .check-box { background: var(--success); border-color: var(--success); }
:root[data-theme="dark"] .check.is-done .check-box { color: #10241a; }
.check.is-locked .check-box { background: var(--track); border-color: var(--border); }
.check.is-locked:hover .check-box { border-color: var(--border); }
.progress { width: 100%; background: var(--track); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; transition: width 0.2s ease; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); white-space: nowrap;
}
.order-chip.is-on { color: var(--accent-text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cap-chip { display: inline-flex; gap: 5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
.cap-chip strong { font-weight: 600; }
.cap-chip.dashed { border-style: dashed; border-color: var(--adhoc-stripe); }
.budget { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.budget.compact { font-size: 12px; gap: 5px; }
.budget-row { display: flex; justify-content: space-between; gap: 8px; }
.budget-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-row strong { font-weight: 600; white-space: nowrap; }
.warn-line { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--warning-text); }
.adhoc-block {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 10px; border-radius: 10px; font-size: 12px; color: var(--muted);
  border: 1.2px dashed var(--adhoc-stripe);
  background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--adhoc-stripe) 18%, transparent) 0 4px, transparent 4px 10px);
}
.adhoc-block strong { color: var(--text); }
.adhoc-block strong.warn { color: var(--warning-text); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.hint-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.empty { display: grid; place-items: center; gap: 8px; padding: 48px 16px; color: var(--muted); text-align: center; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.kv .hint { display: block; }
.ok { display: inline-flex; align-items: center; gap: 5px; color: var(--success); font-weight: 600; font-size: 13px; }
.banner { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-size: 14px; }

/* ---- Overview ------------------------------------------------------------ */
.welcome { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.today-card { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.today-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.today-col { display: flex; flex-direction: column; gap: 10px; }
.attention-item {
  display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 12px; text-align: left; width: 100%;
  background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 12px;
}
.attention-item:hover { border-color: var(--faint); }
.attention-item .title { font-size: 14px; }
.attention-item .detail { font-size: 12.5px; color: var(--muted); }
.attention-item .detail.tone-late, .attention-item .detail.tone-overdue { color: var(--danger); }
.attention-item .detail.tone-startNow { color: var(--warning-text); }
.planned-list { display: flex; flex-direction: column; }
.planned-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.planned-text { display: flex; flex-direction: column; align-items: flex-start; flex: 1; min-width: 0; border: 0; background: none; padding: 2px 0; text-align: left; }
.planned-text .title { font-weight: 500; font-size: 14px; }
.planned-text .sub { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.is-done { text-decoration: line-through; color: var(--faint); }
.duration { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tiles-section { display: flex; flex-direction: column; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 12px; min-height: 210px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: border-color 0.12s, transform 0.12s;
}
.tile:hover { border-color: var(--faint); }
.tile.dragging { opacity: 0.4; }
.tile.drop-target { border-color: var(--accent); border-style: dashed; border-width: 2px; }
.tile-link { position: absolute; inset: 0; border-radius: var(--radius); z-index: 0; }
.tile > *:not(.tile-link) { position: relative; z-index: 1; pointer-events: none; }
.tile .more-btn, .tile .tile-head { pointer-events: auto; }
.tile-head { display: flex; align-items: center; gap: 8px; pointer-events: none !important; }
.tile-head .more-btn { pointer-events: auto; margin: -8px -8px -8px 0; }
.tile-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.kind-tag { font-size: 12px; color: var(--muted); background: var(--surface-subtle); padding: 2px 8px; border-radius: 999px; }
.tile-count { display: flex; align-items: baseline; gap: 6px; }
.tile-count strong { font-size: 40px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-count span { font-size: 12.5px; }
.tile-spacer { flex: 1; }
.tile-next { display: flex; align-items: center; gap: 2px; font-size: 12px; white-space: nowrap; overflow: hidden; }
.tile-next span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.add-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 210px;
  background: transparent; border: 1.5px dashed var(--border); box-shadow: none; color: var(--muted); font-weight: 600; font-size: 14px;
}
.add-tile:hover { color: var(--text); border-color: var(--faint); }
.add-tile > * { pointer-events: none; }
.search-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; width: 100%; color: var(--text); }
.search-item:hover { border-color: var(--faint); }
.search-item .grow { display: flex; flex-direction: column; }

/* ---- Area ---------------------------------------------------------------- */
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.crumbs a:hover { color: var(--text); }
.area-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.area-title h1 { display: flex; align-items: center; gap: 10px; }
.area-title p { margin-top: 4px; font-size: 14px; }
.area-side { display: flex; align-items: center; gap: 10px; }
.budget-card { width: 320px; padding: 14px; }
.quick-add {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
}
.quick-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inline-toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); width: fit-content; cursor: pointer; }
.groups { display: flex; flex-direction: column; gap: 24px; }
.group { display: flex; flex-direction: column; gap: 12px; }

.task-card { display: flex; flex-direction: column; padding: 20px; transition: border-color 0.12s; }
.task-card.is-open { border-color: color-mix(in srgb, var(--accent) 60%, transparent); border-width: 1.5px; }
.task-card.is-done { opacity: 0.72; }
.task-top { display: flex; align-items: center; gap: 8px; }
.task-top .more-btn { margin: -8px -10px -8px 0; }
.task-title-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.task-title { border: 0; background: none; padding: 0; text-align: left; font-size: 19px; font-weight: 600; color: var(--text); }
.task-title:hover { color: var(--accent-text); }
.task-title.is-done { color: var(--faint); }
.recurrence-line { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; font-weight: 500; color: var(--accent-text); }
.detail-line { margin-top: 4px; font-size: 14px; font-weight: 500; color: var(--muted); }
.task-card .warn-line { margin-top: 4px; }
.task-card > .progress { margin-top: 14px; }
.task-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.task-meta .next { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta .next strong { color: var(--text); }
.task-card .badges { margin-top: 10px; }
.expand-btn {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content; margin-top: 10px; padding: 6px 0;
  border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px;
}
.subtasks { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.subtasks-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.subtask-list { display: flex; flex-direction: column; gap: 1px; }
.subtask-row {
  --depth: 0; display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 8px; min-height: 38px;
}
.subtask-row.is-group { background: var(--surface-subtle); }
.subtask-row.drop-target { background: var(--accent-soft); box-shadow: inset 0 2px 0 var(--accent); }
.subtask-row .indent { width: calc(var(--depth) * 26px); flex: none; }
.collapse-btn { width: 24px; height: 30px; border-radius: 6px; }
.collapse-space { width: 24px; flex: none; }
.subtask-title { border: 0; background: none; padding: 4px 0; text-align: left; font-size: 14px; color: var(--text); min-width: 0; }
.subtask-title.strong { font-weight: 600; }
.subtask-title.is-locked { color: var(--muted); }
.subtask-title.is-done { color: var(--faint); }
.subtask-title:hover { color: var(--accent-text); }
.lock, .planned-icon { color: var(--faint); display: inline-flex; }
.planned-icon { color: var(--accent); }
.subtask-row .duration { min-width: 48px; text-align: right; }
.subtask-row .more-btn { width: 30px; height: 30px; }
.add-subtask {
  display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 5px 12px; border-radius: 10px; border: 1px dashed var(--border);
}
.add-subtask:focus-within { border-color: var(--accent); border-style: solid; }
.why { display: flex; flex-direction: column; gap: 12px; width: 300px; max-width: calc(100vw - 48px); }
.why-lines { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-variant-numeric: tabular-nums; }
.why-lines .strong { font-weight: 600; }

/* ---- Week ---------------------------------------------------------------- */
.week-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.week-head h1 { font-size: 28px; }
.week-head p { margin-top: 4px; font-size: 14px; }
.week-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.budget-tile { display: flex; flex-direction: column; gap: 8px; padding: 12px; font-size: 14px; }
.board { display: flex; gap: 10px; align-items: stretch; overflow-x: auto; padding-bottom: 10px; }
.backlog.framed { flex: 0 0 250px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; min-height: 480px; }
.backlog { display: flex; flex-direction: column; gap: 8px; }
.backlog.drop-target, .day-col.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 14px; min-height: 22px; }
.day-col {
  flex: 1 0 168px; display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 480px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.day-col.is-weekend { background: var(--surface-subtle); }
.day-col.is-today { background: var(--accent-soft); }
.day-col.is-past .col-head strong { color: var(--faint); }
.day-col.compact { min-height: 0; }
.today-tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); }
.cap-row { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.cap-row strong { color: var(--text); font-weight: 600; }
.cap-row strong.warn { color: var(--warning-text); font-weight: 700; }
.plan-card {
  display: flex; align-items: flex-start; gap: 6px; padding: 8px 4px 8px 6px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); cursor: grab;
}
.plan-card:active { cursor: grabbing; }
.plan-card.dragging { opacity: 0.4; }
.plan-card.is-done { opacity: 0.65; }
.plan-card .check { min-width: 24px; min-height: 24px; }
.plan-card .more-btn { width: 26px; height: 26px; margin-top: -2px; }
.plan-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; padding-top: 2px; }
.plan-context { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-title { font-size: 13px; font-weight: 600; line-height: 1.3; overflow-wrap: break-word; hyphens: auto; }
.plan-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-failure { font-size: 11px; font-weight: 600; color: var(--warning-text); }
.week-stack { display: flex; flex-direction: column; gap: 12px; }
.backlog-details { padding: 14px; }
.backlog-details summary { font-weight: 700; font-size: 16px; cursor: pointer; }
.backlog-details .backlog { margin-top: 10px; }

/* ---- Settings ------------------------------------------------------------ */
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.settings-group h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-left: 4px; }
.settings-group > .hint { padding: 0 4px; }
.settings-card { display: flex; flex-direction: column; gap: 14px; }
.avail-list { display: flex; flex-direction: column; margin: -6px 0; }
.avail-row + .avail-row { border-top: 1px solid var(--border); }
.avail-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 0; border: 0; background: none; text-align: left; }
.avail-head .muted { font-variant-numeric: tabular-nums; text-align: right; }
.avail-body { display: flex; flex-direction: column; gap: 6px; padding: 0 0 12px 22px; }
.slider-row { display: flex; align-items: center; gap: 14px; }
.slider { flex: 1; accent-color: var(--accent); }
.slider-value { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.link-list { display: flex; flex-direction: column; margin: -6px 0; }
.link-list li + li { border-top: 1px solid var(--border); }
.link-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 0; border: 0; background: none; text-align: left; }
.link-row:hover .grow { color: var(--accent-text); }
label.btn { cursor: pointer; }

/* ---- Forms (modals) ------------------------------------------------------ */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 12px; }
.form-group + .form-group { border-top: 1px solid var(--border); padding-top: 18px; }
.form-title { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.form-error { color: var(--danger); font-size: 14px; font-weight: 500; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }
.toggle-row label { cursor: pointer; }
.toggle-row .hint { display: block; }
.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.step-btn { width: 38px; height: 36px; border: 0; background: var(--surface-subtle); font-size: 18px; line-height: 1; color: var(--text); }
.step-btn:hover:not(:disabled) { background: var(--track); }
.step-btn:disabled { color: var(--faint); }
.step-value { min-width: 108px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; padding: 0 6px; }
.segmented { display: flex; padding: 3px; border-radius: 11px; background: var(--track); gap: 2px; }
.segmented button { flex: 1; min-height: 32px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; font-size: 13px; color: var(--muted); padding: 4px 8px; }
.segmented button.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.weekday-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekday { min-height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-subtle); font-weight: 600; font-size: 13px; }
.weekday.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.color-picker { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 0; box-shadow: 0 0 0 0 var(--text); transition: box-shadow 0.12s; }
.swatch.is-on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5.5px var(--text); }
.client-list { display: flex; flex-direction: column; gap: 6px; }
.client-row { display: flex; align-items: center; gap: 8px; }
.client-new { flex: 1; padding: 8px 12px; }
.inline-add { display: flex; gap: 8px; }
.confirm-text { color: var(--muted); }

/* ---- Overlays ------------------------------------------------------------ */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 0.35); display: grid; place-items: center; padding: 16px; animation: fade 0.12s ease; }
.scrim.clear { background: transparent; animation: none; z-index: 40; }
.modal {
  width: min(560px, 100%); max-height: min(92vh, 900px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-pop); border: 1px solid var(--border); animation: pop 0.14s ease;
}
.modal.confirm { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }
.menu, .popover {
  position: fixed; z-index: 45; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px;
}
.popover { padding: 16px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: 14px; color: var(--text); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--surface-subtle); outline: none; }
.menu-item:disabled { color: var(--faint); }
.menu-item.danger { color: var(--danger); }
.menu-item .icon { color: var(--muted); }
.menu-item.danger .icon { color: var(--danger); }
.menu-icon-space { width: 16px; flex: none; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-heading { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 11px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 500; font-size: 14px; box-shadow: var(--shadow-pop);
  animation: rise 0.18s ease;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---- Login --------------------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; padding: 28px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.login-brand img { border-radius: 10px; }
.login-card h1 { font-size: 24px; }
.code { background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 13px; overflow-x: auto; }

/* ---- Installed app: offline, install hint -------------------------------- */
.offline-bar {
  display: flex; align-items: center; gap: 8px; max-width: 1240px; margin: 0 auto 16px; padding: 10px 14px; border-radius: 12px;
  background: var(--warning-soft); color: var(--warning-text); font-size: 14px; font-weight: 500;
}
.install-hint {
  display: flex; align-items: center; gap: 12px; max-width: 1240px; margin: 0 auto 16px; padding: 12px 8px 12px 14px;
  border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-text);
}
.install-hint img { border-radius: 10px; flex: none; }
.install-hint strong { display: block; font-size: 15px; }
.install-hint p { font-size: 13px; margin-top: 2px; }
.install-steps { color: var(--muted); font-size: 14px; }
/* No text selection or callouts on controls when used as an app. */
.nav-item, .btn, .icon-btn, .menu-item, .brand { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
/* iOS zooms into fields with text under 16px; keep them at 16px on touch screens. */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}

/* ---- Small screens ------------------------------------------------------- */
@media (max-width: 960px) {
  .search { width: 180px; }
}
@media (max-width: 820px) {
  :root { --topbar-h: 54px; }
  body { font-size: 15px; }
  h1 { font-size: 26px; }
  /* No backdrop-filter here: it would make the fixed tab bar position against the top bar. */
  .topbar { padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); gap: 10px; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .brand span { display: none; }
  .search { flex: 1; width: auto; }
  .topbar-actions { flex: 1; }
  .tabs {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; justify-content: space-around; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border);
  }
  .nav-item { flex-direction: column; gap: 2px; font-size: 11px; padding: 5px 14px; }
  .nav-item.is-active { background: transparent; color: var(--accent); }
  .main { padding: 16px max(14px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .tile { min-height: 150px; padding: 14px; gap: 10px; }
  .tile .kind-tag, .tile .tile-next { display: none; }
  .tile-count strong { font-size: 32px; }
  .add-tile { min-height: 150px; }
  .area-side { width: 100%; flex-wrap: wrap; }
  .budget-card { width: 100%; }
  .task-card { padding: 16px; }
  .subtask-row .indent { width: calc(var(--depth) * 16px); }
  .wide-only { display: none; }
  .week-controls { width: 100%; }
  .budget-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .budget-tile { padding: 10px; font-size: 13px; }
  .week-controls > .btn { flex: 1; }
  .modal { max-height: 94vh; max-height: 94dvh; }
  .scrim:not(.clear) { align-items: end; padding: 0; }
  .scrim:not(.clear) .modal { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .step-value { min-width: 86px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
