:root {
  /* graphite ramp + one tomato accent taken from Misty's face */
  --deep: #0f0f10; --bg: #141415; --card: #19191b; --raised: #232325;
  --ink: #ededed; --ink2: #a1a1a6; --muted: #8a8a90;
  --line: rgba(237,237,237,.08); --line2: rgba(237,237,237,.14);
  --accent: #ff6a4d; --on-accent: #1d0c08;
  --good: #4cc38a; --warn: #e0a84a; --bad: #ef6a6e;
  --r: 16px; --ctl: 12px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color-scheme: dark; }
body { color: var(--ink); font: 400 16px/1.45 var(--font); overscroll-behavior: none; overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink2); } .small { font-size: 13px; line-height: 1.4; } .err { color: var(--bad); min-height: 1.2em; }
.good { color: var(--good); } .bad { color: var(--bad); }
::selection { background: rgba(255,106,77,.35); }
::-webkit-scrollbar { width: 0; height: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: min(340px, 100%); display: grid; gap: 16px; text-align: center; padding: 32px 24px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); }
.login h1 { font: 600 28px/1.15 var(--font); }

.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: block; }
.avatar.big { width: 96px; height: 96px; margin: 0 auto; }

input, select, textarea { background: var(--raised); border: 1px solid var(--line); border-radius: var(--ctl); padding: 12px 16px; min-height: 44px; width: 100%; outline: none; transition: border-color .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=date], input[type=time] { color-scheme: dark; }
input[type=checkbox] { width: 20px; min-height: 20px; accent-color: var(--accent); }
.btn { min-height: 44px; border: 1px solid var(--line2); background: var(--raised); border-radius: var(--ctl); padding: 10px 16px; font-weight: 500; cursor: pointer; transition: background-color .15s, transform .1s; }
.btn:hover { background: #2b2b2e; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #ff7a5f; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- shell ---------- */
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; position: relative; background: var(--bg); }
.top { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
.top .grow { flex: 1; min-width: 0; }
.title { font: 600 20px/1.2 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.status.off::before { background: var(--warn); }
@media (max-width: 460px) { .status { font-size: 0; gap: 0; padding: 8px; } }
#app[data-tab=today] #avatar { display: none; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: rise .24s var(--ease) both; }
.view.scroll { overflow-y: auto; padding: 4px 16px 24px; display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* tab bar: solid, in flow, one accent on the selected tab */
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); background: var(--deep); border-top: 1px solid var(--line); }
.tabs button { background: none; border: 0; min-height: 52px; padding: 8px 0 4px; color: var(--muted); font-size: 12px; font-weight: 500; display: grid; justify-items: center; align-content: center; gap: 4px; cursor: pointer; border-radius: 8px; transition: color .15s; }
.tabs svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tabs button:hover { color: var(--ink2); }
.tabs button.on { color: var(--accent); }
.tabs button.on svg { fill: currentColor; fill-opacity: .16; }

/* ---------- chat ---------- */
.msgs { flex: 1; overflow-y: auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 12px 16px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; animation: rise .2s var(--ease) both; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant.pro { border-left: 3px solid var(--accent); }
.msg ul { margin: 4px 0; padding-left: 20px; } .msg li { margin: 4px 0; }
.msg b { font-weight: 600; } .msg code { background: rgba(237,237,237,.1); padding: 0 4px; border-radius: 4px; font-size: .92em; }
.msg .when { display: block; font-size: 12px; margin-top: 4px; opacity: .6; }
.dots { align-self: flex-start; display: flex; gap: 4px; padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: blink 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .25; } }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px; scrollbar-width: none; }
.chip { flex: none; min-height: 36px; border: 1px solid var(--line2); background: transparent; border-radius: 999px; padding: 4px 16px; font-size: 14px; color: var(--ink2); cursor: pointer; transition: background-color .15s, color .15s; }
.chip:hover, .chip:active { background: var(--raised); color: var(--ink); }
.composer { display: flex; gap: 8px; padding: 4px 16px 12px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; border-radius: 22px; padding: 12px 16px; }
.send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); font-size: 18px; cursor: pointer; transition: transform .1s; }
.send:active { transform: scale(.94); } .send:disabled { opacity: .4; }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card h3 { font: 500 13px/1.3 var(--font); color: var(--ink2); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 32px; }
.hero { padding: 20px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { overflow-wrap: anywhere; }
.row.done .t { text-decoration: line-through; color: var(--muted); }
.row .x { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; min-width: 40px; min-height: 40px; border-radius: 8px; transition: color .15s; }
.row .x:hover { color: var(--bad); }
.check { position: relative; flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--muted); background: none; display: grid; place-items: center; cursor: pointer; color: var(--on-accent); font-size: 14px; transition: background-color .15s, border-color .15s; }
.check::after { content: ''; position: absolute; inset: -10px; }
.row.done .check { background: var(--good); border-color: var(--good); }
.pill { font-size: 12px; font-weight: 500; padding: 0 8px; border-radius: 6px; background: rgba(237,237,237,.08); color: var(--ink2); white-space: nowrap; }
.pill.bad { background: rgba(239,106,110,.14); color: var(--bad); }
.pill.warn { background: rgba(224,168,74,.14); color: var(--warn); }
.pill.p1 { background: rgba(255,106,77,.14); color: var(--accent); }
.pill.ok { background: rgba(76,195,138,.14); color: var(--good); }
.time { flex: none; width: 48px; font: 400 13px/1.25 var(--font); font-variant-numeric: tabular-nums; color: var(--muted); }
.row.now { border-radius: 12px; padding: 12px; margin: 0 -12px; background: var(--raised); border-top-color: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.empty { color: var(--muted); padding: 4px 0; font-size: 14px; }
.add { display: flex; gap: 8px; margin-top: 12px; }
.add input { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { padding: 12px; border-radius: 12px; background: var(--raised); }
.stat b { display: block; font: 500 24px/1.2 var(--font); font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 4px; margin: 12px 0; }
.field label { font-size: 13px; color: var(--ink2); }
.seg { display: flex; padding: 4px; gap: 4px; background: var(--raised); border-radius: var(--ctl); }
.seg button { flex: 1; min-height: 36px; border: 0; background: none; padding: 4px 8px; font-weight: 500; color: var(--ink2); cursor: pointer; border-radius: 8px; transition: background-color .15s, color .15s; }
.seg button.on { background: var(--bg); color: var(--ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.1); }

/* today hero: progress ring + Misty's face, the one bright element */
.heroRow { display: flex; align-items: center; gap: 16px; }
.heroRow .face { flex: none; width: 88px; height: 88px; border-radius: 50%; margin-left: auto; }
.ring { flex: none; position: relative; width: 88px; height: 88px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring .bg { stroke: rgba(237,237,237,.1); }
.ring .fg { stroke: var(--accent); transition: stroke-dashoffset .6s var(--ease); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 500 20px var(--font); font-variant-numeric: tabular-nums; }
.big { font: 500 28px/1.15 var(--font); font-variant-numeric: tabular-nums; }
.big .dim { color: var(--muted); }
.next { margin-top: 4px; font-size: 14px; color: var(--ink2); }
.donutWrap { display: flex; align-items: center; gap: 16px; }
.donut { flex: none; width: 128px; height: 128px; position: relative; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 14; }
.donut .mid { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--ink2); line-height: 1.2; }
.donut .mid b { display: block; font: 500 17px var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.legend { flex: 1; min-width: 0; display: grid; gap: 8px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.legend span { margin-left: auto; color: var(--ink2); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 99px; background: var(--raised); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--ink2); border-radius: 99px; transition: width .6s var(--ease); }
.bar i.over { background: var(--bad); } .bar i.near { background: var(--warn); }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--raised); border: 1px solid var(--line2); color: var(--ink); padding: 12px 16px; border-radius: var(--ctl); font-size: 14px; max-width: 90%; z-index: 9; animation: rise .2s var(--ease) both; }

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