* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-m)/1.45 var(--font); min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
.hidden { display: none !important; }
header.top { padding: calc(var(--s-4) + env(safe-area-inset-top)) var(--s-4) var(--s-2); display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
header.top h1 { margin: 0; font: 600 var(--fs-xl)/1.1 var(--font-display); letter-spacing: -.01em; }
header.top .date { color: var(--muted); font-size: var(--fs-s); }
main { padding: 0 var(--s-4) var(--s-5); max-width: 640px; margin: 0 auto; }
section.view { display: none; } section.view.active { display: block; animation: fade var(--dur) ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
h2 { font: 600 var(--fs-s)/1.2 var(--font); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: var(--s-5) 0 var(--s-3); }
.card { background: var(--surface); border-radius: var(--r-m); padding: var(--s-4); box-shadow: var(--shadow); margin-bottom: var(--s-3); }
.card.accent { border-left: 4px solid var(--accent); }
.card.amber { background: var(--amber-soft); border-left: 4px solid var(--amber); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 6px; }
.card .kicker { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: var(--s-1); }
.card .big { font: 600 var(--fs-xxl)/1 var(--font-display); font-variant-numeric: tabular-nums; }
.card .title { font-weight: 600; font-size: var(--fs-l); margin-top: var(--s-1); }
.card .body { color: var(--muted); margin-top: var(--s-1); }
.muted { color: var(--muted); } .small { font-size: var(--fs-s); }
.empty { color: var(--muted); padding: var(--s-5) var(--s-3); text-align: center; }
.actions { display: flex; gap: var(--s-2); margin-top: var(--s-3); flex-wrap: wrap; }
.btn { min-height: var(--tap); min-width: var(--tap); padding: 0 var(--s-4); border-radius: var(--r-s); background: var(--surface-2); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); transition: transform var(--dur), background var(--dur); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 66px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 52px 28px 1fr; align-items: start; min-height: var(--tap); padding: var(--s-2) 0; }
.timeline .t { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; padding-top: 2px; }
.timeline .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); margin: 6px auto 0; position: relative; z-index: 1; }
.timeline li[data-kind="commitment"] .dot { background: var(--accent); }
.timeline li[data-kind="bed"] .dot, .timeline li[data-kind="wake"] .dot { border-color: var(--amber); }
.timeline li[data-kind="leave"] .dot { border-color: var(--danger); }
.timeline .what { padding-left: var(--s-2); }
.timeline .what .n { font-weight: 600; }
.timeline .what .why { color: var(--muted); font-size: var(--fs-s); }
.timeline li.past { opacity: .45; }
.timeline li.now { grid-template-columns: 52px 28px 1fr; min-height: 0; padding: 0; }
.timeline li.now .t { color: var(--accent); font-size: var(--fs-xs); }
.timeline li.now .line { grid-column: 2 / 4; height: 2px; background: var(--accent); margin-top: 8px; border-radius: 2px; }
.nudges { list-style: none; margin: 0; padding: 0; }
.nudges li { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-2) 0; border-bottom: 1px solid var(--line); min-height: var(--tap); }
.nudges .t { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 52px; }
.nudges .s { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
/* capture */
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding: var(--s-6) 0 var(--s-4); }
.mic { width: 120px; height: 120px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: var(--shadow); position: relative; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform var(--dur); }
.mic svg { width: 48px; height: 48px; }
.mic.rec { background: var(--danger); transform: scale(1.06); }
.mic.rec::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 3px solid var(--danger); opacity: .6; animation: pulse 1.2s ease-out infinite; }
@keyframes pulse { from { transform: scale(.9); opacity: .7; } to { transform: scale(1.25); opacity: 0; } }
.hint { color: var(--muted); text-align: center; font-size: var(--fs-s); max-width: 34ch; }
textarea { width: 100%; min-height: 96px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); padding: var(--s-3) var(--s-4); resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-s); font-weight: 600; min-height: 36px; }
.chip.type { background: var(--surface-2); color: var(--text); min-height: var(--tap); padding: 0 var(--s-4); }
.chip.type.on { background: var(--accent); color: var(--accent-ink); }
.typebar { display: flex; gap: var(--s-2); overflow-x: auto; padding: var(--s-1) 0 var(--s-3); scrollbar-width: none; }
.typebar::-webkit-scrollbar { display: none; }
/* memory cards */
.mem { display: flex; flex-direction: column; gap: var(--s-2); }
.mem .txt { white-space: pre-wrap; }
.mem .meta { color: var(--muted); font-size: var(--fs-xs); display: flex; gap: var(--s-2); align-items: center; }
.mem .sal { flex: 0 0 48px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.mem .sal i { display: block; height: 100%; background: var(--accent); }
.mem .row { display: flex; gap: var(--s-2); justify-content: flex-end; }
/* settings */
.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s-3); min-height: var(--tap); padding: var(--s-2) 0; border-bottom: 1px solid var(--line); }
.field label { font-weight: 500; }
.field input, .field select { border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); padding: 0 var(--s-3); min-height: 44px; width: 136px; max-width: 45vw; text-align: right; }
.field.block { grid-template-columns: 1fr; }
.field.block input { width: 100%; max-width: none; text-align: left; }
.field select { width: auto; text-align: left; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); font-size: var(--fs-xs); font-weight: 600; }
.days button.on { background: var(--accent); color: var(--accent-ink); }
.switch { width: 52px; height: 32px; border-radius: 16px; background: var(--surface-2); position: relative; transition: background var(--dur); }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); transition: transform var(--dur); }
.switch.on { background: var(--accent); } .switch.on::after { transform: translateX(20px); }
code.url { display: block; word-break: break-all; font-size: var(--fs-xs); background: var(--surface-2); padding: var(--s-2); border-radius: var(--r-s); }
pre.ctx { white-space: pre-wrap; font-size: var(--fs-xs); background: var(--surface-2); padding: var(--s-3); border-radius: var(--r-s); max-height: 40vh; overflow: auto; }
details summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 500; }
/* nav */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); z-index: 10; }
nav.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; min-height: var(--nav-h); }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--s-4) + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: var(--s-3) var(--s-4); border-radius: var(--r-s); font-size: var(--fs-s); z-index: 20; box-shadow: var(--shadow); max-width: 90vw; }
.login { display: flex; flex-direction: column; gap: var(--s-4); padding: 10vh var(--s-4) var(--s-4); max-width: 34rem; margin: 0 auto; }
.login h1 { font: 600 var(--fs-xxl)/1 var(--font-display); margin: 0; }
.login .lead { font-size: var(--fs-l, 1.15rem); margin: 0; }
.login .pitch { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s-2); }
.login input { border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); padding: 0 var(--s-3); min-height: var(--tap); }
.offline { background: var(--amber-soft); color: var(--text); padding: var(--s-2) var(--s-4); font-size: var(--fs-s); text-align: center; }
.tpl { max-width: 42rem; margin: 0 auto; padding: var(--s-5, 1.5rem) var(--s-4, 1rem); line-height: 1.5; }
.tpl ul { padding-left: 1.2em; display: grid; gap: var(--s-2); }
.tpl a.btn { text-decoration: none; display: inline-flex; align-items: center; }
