/* Now: calm, high contrast, big targets. Dark is the default; light is a switch in Settings. */
:root {
  --bg: #0e1013; --surface: #171a20; --surface2: #222731; --text: #f3f5f8; --muted: #aab3c0; --line: #2f3641;
  --accent: #5eead4; --accent-ink: #032a25; --focus: #fde68a; --good: #86efac; --warm: #fcd34d; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 18px; --tab: 62px; --done-h: 80px; --btn-h: 56px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f2ea; --surface: #ffffff; --surface2: #ebe7dc; --text: #14171c; --muted: #4a5360; --line: #d3cdbf;
  --accent: #0d6b62; --accent-ink: #ffffff; --focus: #7c3aed; --good: #166534; --warm: #92400e; --shadow: 0 10px 30px rgba(20, 23, 28, .15);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 640px; margin: 0 auto; }
.main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 16px 18px; padding-top: max(14px, env(safe-area-inset-top)); -webkit-overflow-scrolling: touch; }
.page-title { margin: 4px 0 2px; font-size: 1.7rem; line-height: 1.15; font-weight: 800; }
.sub { margin: 0 0 14px; color: var(--muted); }
.muted { color: var(--muted); }

/* ---- bottom dock: brain dump and tabs */
.dock { flex: none; background: var(--bg); border-top: 1px solid var(--line); padding: 8px 12px 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; align-items: center; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 48px; padding: 0 16px; border-radius: 999px; background: var(--surface2); border: 2px solid transparent;
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap;
}
.chip[aria-pressed="true"], .chip[aria-checked="true"] { border-color: var(--accent); background: var(--surface); }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vc, var(--muted)); flex: none; }
.chip-sep { flex: none; width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.when-input { flex: none; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); padding: 0 10px; }
.capture-row { display: flex; gap: 8px; }
.capture-row input[type="text"] {
  flex: 1; min-width: 0; min-height: 52px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface);
  padding: 0 16px; font-size: 1.05rem;
}
.capture-row input::placeholder { color: var(--muted); opacity: 1; }
.capture-row input:focus { border-color: var(--accent); outline: none; }
.btn-add svg { width: 28px; height: 28px; }
.empty .icon-wrap svg { width: 100%; height: 100%; }
.btn-add { flex: none; width: 52px; min-height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); margin-top: 4px; }
.tab { min-height: var(--tab); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 14px; font-weight: 600; position: relative; }
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; display: grid; place-items: center; }

/* ---- buttons */
.btn {
  min-height: var(--btn-h); padding: 0 18px; border-radius: 16px; font-weight: 700; font-size: 1.05rem; display: inline-flex; align-items: center;
  justify-content: center; gap: 10px; background: var(--surface2); color: var(--text); width: 100%;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-quiet { background: transparent; border: 2px solid var(--line); }
.btn-small { min-height: 48px; width: auto; font-size: 1rem; padding: 0 16px; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn svg { width: 24px; height: 24px; }

/* ---- NOW */
.energy { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; flex: none; }
.energy .label { color: var(--muted); font-weight: 600; flex: none; }
.seg { display: flex; flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 48px; border-radius: 11px; font-weight: 700; color: var(--muted); }
.seg button[aria-checked="true"], .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 20px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; min-height: 48px; }
.vtag {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: .95rem;
  background: color-mix(in srgb, var(--vc, #98a2b3) 20%, transparent); border: 1px solid color-mix(in srgb, var(--vc, #98a2b3) 60%, transparent);
}
.vtag { font-size: 1rem; }
.vtag .dot, .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vc, #98a2b3); flex: none; }
.task-title { margin: 4px 0 10px; font-size: clamp(1.75rem, 8vw, 2.45rem); line-height: 1.12; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.why { margin: 0 0 12px; color: var(--muted); font-style: italic; font-size: 1.05rem; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 1rem; font-weight: 600; }
.pill.calm { color: var(--warm); }
.pill.src { color: var(--text); }
.linkbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 14px; background: var(--surface2); color: var(--accent); font-weight: 700; text-decoration: none; max-width: 100%; }
.linkbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-note { margin: 0 0 6px; color: var(--muted); font-size: 1rem; }
.task-title.long { font-size: clamp(1.45rem, 6.4vw, 2rem); }
.notes { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); background: var(--surface2); border-radius: 12px; padding: 10px 12px; }
.notes.clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.notes-wrap { margin-bottom: 10px; }
.notes-wrap .notes { margin-bottom: 0; }
.linkish { min-height: 48px; padding: 0 4px; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: none; }
.actions .btn { padding: 0 10px; gap: 8px; white-space: nowrap; }
.actions .btn-done { grid-column: 1 / -1; min-height: var(--done-h); font-size: 1.5rem; border-radius: 20px; }
/* The card scrolls inside itself; the buttons under it never move, so Done is always on screen. */
.main.is-now { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 10px; }
.now-wrap { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.now-scroll { flex: 0 1 auto; min-height: 96px; overflow-y: auto; overscroll-behavior: contain; margin-bottom: 10px; position: relative; -webkit-overflow-scrolling: touch; }
.now-scroll.more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent); }
.now-wrap .actions { margin-top: auto; }
.note { margin: 0 0 8px; font-size: 1rem; }
@media (max-height: 740px) { :root { --tab: 54px; --done-h: 68px; --btn-h: 52px; } .card { padding: 14px 14px 16px; } .task-title { margin-bottom: 6px; } }
.empty { text-align: center; padding: 36px 12px; }
.empty h2 { margin: 12px 0 6px; font-size: 1.5rem; }
.empty p { margin: 0 0 16px; color: var(--muted); }
.empty .btn { max-width: 320px; margin: 8px auto 0; }

.timer { background: var(--surface2); border-radius: 16px; padding: 14px; margin: 4px 0 12px; text-align: center; }
.timer .digits { font-size: 3.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; line-height: 1.1; }
.timer .bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 10px 0 12px; }
.timer .bar i { display: block; height: 100%; width: calc(var(--p, 0) * 1%); background: var(--accent); transition: width .25s linear; }
.timer .chips { justify-content: center; padding-bottom: 0; flex-wrap: wrap; }
.timer .unit { color: var(--muted); font-weight: 600; margin-left: 2px; }
.timer .chip { min-width: 56px; justify-content: center; padding: 0 12px; }
.timer .up { font-size: 1.6rem; font-weight: 800; color: var(--good); }

/* ---- celebration */
.burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: var(--radius); display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 82%, transparent); }
.burst .msg { font-size: 2rem; font-weight: 800; color: var(--accent); animation: rise .5s ease-out both; text-align: center; padding: 0 12px; }
.burst .tick { width: 84px; height: 84px; color: var(--accent); animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.burst .stack { display: grid; place-items: center; gap: 8px; }
.burst .bit { position: absolute; left: 50%; top: 45%; width: 12px; height: 12px; border-radius: 3px; background: var(--c); animation: fly .8s ease-out forwards; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@keyframes slide { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toastin { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drain { from { width: 100%; } to { width: 0; } }

/* ---- lists */
.list { display: grid; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
.row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 6px 8px 6px 12px; min-height: 64px; }
.row .grow { flex: 1; min-width: 0; text-align: left; min-height: 48px; display: flex; flex-direction: column; justify-content: center; }
.row .t { font-weight: 700; overflow-wrap: anywhere; }
.row .s { color: var(--muted); font-size: 1rem; }
.row.done .t { text-decoration: line-through; color: var(--muted); }
.row .tickmark { width: 26px; height: 26px; color: var(--good); flex: none; margin-right: 8px; }
.row.slot { border-style: dashed; background: transparent; color: var(--muted); justify-content: center; font-weight: 600; width: 100%; }
.row.dragging { opacity: .35; }
.drop-marker { list-style: none; height: 6px; border-radius: 3px; background: var(--accent); margin: -8px 4px; }
.ghost { position: fixed; z-index: 60; pointer-events: none; box-shadow: var(--shadow); opacity: .96; }
.handle { width: 48px; height: 48px; display: grid; place-items: center; color: var(--muted); touch-action: none; cursor: grab; flex: none; border-radius: 10px; }
.handle svg { width: 22px; height: 22px; }
.picks.drop-ok { outline: 3px dashed var(--accent); outline-offset: 4px; border-radius: 18px; }
details.rest { margin-top: 8px; }
details.rest > summary { list-style: none; min-height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; font-weight: 700; cursor: pointer; }
details.rest > summary::-webkit-details-marker { display: none; }
details.rest[open] > summary { margin-bottom: 10px; }
.group-title { margin: 14px 0 6px; font-size: 1rem; color: var(--muted); font-weight: 700; }
.inbox-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.inbox-card .task-title { font-size: 1.35rem; margin: 0; text-align: left; width: 100%; min-height: 48px; display: block; }
.inbox-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

/* ---- wins */
.big-number { font-size: 4.5rem; font-weight: 800; line-height: 1; color: var(--accent); }
.streak { display: inline-flex; margin-top: 10px; padding: 8px 16px; border-radius: 999px; background: var(--surface2); font-weight: 700; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 140px; margin: 16px 0 6px; }
.week .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; font-weight: 700; font-size: 1rem; }
.week .col .bar { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: var(--surface2); height: calc(var(--h, 0) * 1%); min-height: 6px; }
.week .col.today .bar { background: var(--accent); }
.week .col .n { color: var(--muted); min-height: 1.4em; }
.week .col .d { color: var(--muted); font-weight: 600; }
.week .col.today .d { color: var(--text); }

/* ---- settings */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.setting label, .setting .name { font-weight: 600; flex: 1; }
.setting.wide { flex-direction: column; align-items: stretch; gap: 6px; }
.setting .chips { flex-wrap: wrap; overflow: visible; padding: 0; }
.setting small { display: block; color: var(--muted); font-weight: 400; }
.setting input[type="time"] { min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); padding: 0 10px; }
.switch { width: 84px; height: 48px; border-radius: 24px; background: var(--surface2); border: 2px solid var(--line); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 36px; height: 36px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(36px); background: var(--accent-ink); }
.switch-wrap { min-width: 84px; min-height: 48px; display: grid; place-items: center; }
.stack { display: grid; gap: 10px; margin-top: 18px; }

/* ---- sheet, toast, login */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: slide .22s ease-out; box-shadow: var(--shadow); }
.sheet h2 { margin: 0 0 4px; font-size: 1.4rem; }
.sheet-hint { margin: 0; color: var(--warm); font-weight: 600; }
.sheet-hint:empty { display: none; }
.sheet-hint:not(:empty) { margin: 0 0 12px; }
.sheet .sub { margin-bottom: 14px; }
.sheet .stack { margin-top: 8px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 700; font-size: 1rem; color: var(--muted); }
.field input, .field textarea { min-height: 52px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); padding: 10px 14px; width: 100%; }
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.field .chips { padding-bottom: 0; flex-wrap: wrap; overflow: visible; }
.snooze-opt { display: flex; justify-content: space-between; align-items: center; text-align: left; }
.snooze-opt small { color: var(--muted); font-weight: 500; }
#toasts { position: fixed; z-index: 90; left: 0; right: 0; top: max(10px, env(safe-area-inset-top)); display: flex; justify-content: center; padding: 0 12px; pointer-events: none; }
#toasts:empty { display: none; padding: 0; }
#toasts .toast { pointer-events: auto; }
.timer-strip { flex: none; display: flex; align-items: center; gap: 10px; min-height: 52px; margin: 0 12px 6px; padding: 0 16px; border-radius: 14px; background: var(--surface2); border: 2px solid var(--accent); font-weight: 700; text-align: left; }
.timer-strip .strip-time { font-variant-numeric: tabular-nums; color: var(--accent); }
.timer-strip .strip-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { width: 100%; max-width: 480px; background: #e9edf3; color: #11151b; border-radius: 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 16px; min-height: 56px; position: relative; overflow: hidden; animation: toastin .18s ease-out; font-weight: 600; }
:root[data-theme="light"] .toast { background: #1b2028; color: #f3f5f8; }
.toast span { flex: 1; }
.toast button { min-height: 48px; padding: 0 16px; border-radius: 12px; font-weight: 800; color: #0b6b61; }
:root[data-theme="light"] .toast button { color: #5eead4; }
.toast i { position: absolute; left: 0; bottom: 0; height: 4px; background: #14b8a6; animation: drain 8s linear forwards; }
.login { max-width: 420px; margin: 0 auto; padding: 18vh 20px 20px; }
.login h1 { font-size: 2.6rem; margin: 0 0 6px; font-weight: 800; }
.login form { display: grid; gap: 12px; margin-top: 18px; }
.login input { min-height: 56px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); padding: 0 16px; }
.msg-error { color: var(--warm); min-height: 1.4em; margin: 0; }
.offline-note { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface2); color: var(--warm); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .burst .bit { display: none; }
  .toast i { display: none; }
}
@media (max-width: 340px) { .tab { font-size: 12.5px; } .actions .btn-done { font-size: 1.3rem; } }
