:root {
  --paper: #F3F0E8; --ink: #151515; --accent: #C8102E; --slate: #5B6470; --moss: #2F7D4A;
  --card: #FFFFFF; --line: #DDD8CC; --soft: #E9E5DA; --shadow: 0 1px 2px rgba(0,0,0,.06);
  --head: "Oswald", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #121212; --ink: #EDE9DF; --card: #1C1C1C; --line: #2E2E2E; --soft: #242424; --slate: #9AA3AE; --moss: #5FBF75; --shadow: none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.app { max-width: 480px; margin: 0 auto; padding: env(safe-area-inset-top) 16px calc(88px + env(safe-area-inset-bottom)); }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 4px; }
.brand { font-family: var(--head); font-weight: 600; font-size: 26px; letter-spacing: .06em; text-transform: uppercase; }
.brand .x { color: var(--accent); margin-right: 2px; }
.sync { font-size: 12px; color: var(--slate); display: inline-flex; align-items: center; gap: 6px; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--slate); }
.sync.ok i { background: var(--moss); }
.say { font-family: var(--head); font-size: 21px; font-weight: 500; margin: 8px 0 16px; min-height: 1.4em; }

.date { font-family: var(--head); font-size: 18px; margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.date .wk { font-family: var(--body); font-size: 13px; color: var(--slate); }
.intro, .hint, .how { color: var(--slate); font-size: 14px; margin: 4px 0 10px; }
.focus { font-size: 17px; font-weight: 600; margin: 4px 0 8px; }
.label { font-family: var(--head); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--slate); margin: 18px 0 6px; }
.empty { color: var(--slate); padding: 24px 0; }
.chip { display: inline-block; font-size: 13px; background: var(--soft); border-radius: 999px; padding: 4px 10px; margin: 0 0 12px; border: 0; }

.daynav { display: grid; grid-template-columns: 22px minmax(0, 1fr) 22px; gap: 4px; align-items: stretch; margin: 0 0 10px; }
.dn-arrow { border: 0; background: none; color: var(--slate); font-size: 28px; line-height: 1; padding: 0; cursor: pointer; }
span.dn-arrow { cursor: default; }
.dn-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dn { display: grid; justify-items: center; gap: 1px; padding: 6px 0 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font-family: var(--head); font-size: 14px; line-height: 1.2; cursor: pointer; }
.dn small { font-family: var(--body); font-size: 11px; color: var(--slate); }
.dn.off { background: transparent; border-style: dashed; color: var(--slate); }
.dn.part small { color: var(--ink); font-weight: 600; }
.dn.behind small { color: var(--accent); font-weight: 600; }
.dn.closed { border-style: dashed; }
.dn.full { background: var(--moss); border-color: var(--moss); color: #fff; }
.dn.full small { color: #fff; }
@media (prefers-color-scheme: dark) { .dn.full, .dn.full small { color: #0F1A12; } }
.dn.cal > span { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.dn.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.dn-hint { margin: 0 0 12px; }
.catchup { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; padding: 8px 10px 8px 12px; margin: 0 0 12px; font-size: 14px; }
.catchup p { margin: 0; }
.daily { display: flex; gap: 10px; margin: 0 0 12px; }
.stat-in { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.stat-in span { font-size: 12px; color: var(--slate); }
.stat-in em { font-style: normal; }
.stat-in input { border: 0; background: transparent; font-size: 22px; font-family: var(--head); padding: 0; width: 100%; }

.group h2 { font-family: var(--head); font-size: 14px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--slate); margin: 16px 0 6px; }
.step { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 0 0 8px; box-shadow: var(--shadow); }
.step.on { opacity: .62; }
.step.on .text { text-decoration: line-through; text-decoration-color: var(--moss); }
.tick { flex: 0 0 28px; height: 28px; margin-top: 1px; border-radius: 8px; border: 2px solid var(--ink); background: transparent; position: relative; cursor: pointer; padding: 0; }
.tick[aria-pressed="true"] { background: var(--moss); border-color: var(--moss); }
.tick[aria-pressed="true"]::after { content: ""; position: absolute; left: 8px; top: 3px; width: 7px; height: 13px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.step .body { flex: 1; min-width: 0; }
.step .text { display: block; margin: 0; font-size: 16px; line-height: 1.4; }
.meta { display: flex; gap: 8px; align-items: center; margin: 6px 0 0; font-size: 12px; color: var(--slate); }
.dom { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--soft); font-weight: 600; font-size: 12px; }
.dom-craft { background: #E3E8F5; color: #2B3F80; } .dom-body { background: #E4F2E7; color: #1F5C34; } .dom-mind { background: #F2E7F5; color: #5B2A6A; }
.dom-family { background: #FBE8E0; color: #8A3A1A; } .dom-play { background: #FFF2CC; color: #7A5A00; } .dom-finish { background: #EDEDED; color: #333; }
.dom-job { background: #DCEBF7; color: #1C4E80; } .dom-money { background: #FFF0D6; color: #7A4B00; } .dom-papers { background: #EAE6F7; color: #3F2E86; } .dom-voice { background: #E0F4F1; color: #0F5C56; }
@media (prefers-color-scheme: dark) {
  .dom-craft { background: #26324F; color: #C9D4F5; } .dom-body { background: #1F3A2A; color: #BFE8CB; } .dom-mind { background: #3A2542; color: #E3C9EE; }
  .dom-family { background: #4A2A1D; color: #F5CDBB; } .dom-play { background: #4A3D12; color: #F5E3A0; } .dom-finish { background: #333; color: #DDD; }
  .dom-job { background: #1E3448; color: #BFDDF5; } .dom-money { background: #4A3A14; color: #F5DFA8; } .dom-papers { background: #2E2750; color: #D6CCF5; } .dom-voice { background: #143C38; color: #B5E8E0; }
}
.more { margin-top: 8px; }
.note { font-size: 14px; color: var(--slate); margin: 0 0 4px; white-space: pre-line; }
.note b { color: var(--ink); font-weight: 600; }
.link { display: inline-block; font-size: 14px; margin: 0 12px 6px 0; }
.flag { background: none; border: 0; padding: 0; color: var(--slate); font-size: 13px; text-decoration: underline; cursor: pointer; }
.flagged { font-size: 12px; color: var(--accent); margin: 4px 0 0; }

.dayend { display: flex; justify-content: space-between; align-items: center; margin: 18px 0; color: var(--slate); }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; cursor: pointer; background: var(--soft); color: var(--ink); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin: 12px 0; }

.summary { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; }
.summary p { margin: 4px 0; }
.dots { display: flex; gap: 6px; margin: 14px 0; }
.dot { flex: 1; aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--line); background: var(--card); display: grid; place-items: center; font-family: var(--head); font-size: 15px; cursor: pointer; padding: 0; }
.dot.part { border-color: var(--slate); background: var(--soft); }
.dot.done { border-color: var(--moss); background: var(--moss); color: #fff; }
.dot.today { outline: 2px solid var(--accent); outline-offset: 2px; }
.domlist { list-style: none; padding: 0; margin: 0; }
.domlist li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.goals { list-style: none; padding: 0; margin: 0; }
.goals li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.goal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.goal-head .hint { margin: 0; }
.goal-text { margin: 6px 0 0; font-size: 14px; }
.note.goal { color: var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; box-shadow: var(--shadow); }
.card header { display: flex; justify-content: space-between; align-items: center; }
.card h2 { margin: 0; font-size: 16px; }
.pct { font-family: var(--head); font-size: 18px; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; margin: 8px 0 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--moss); }
details summary { cursor: pointer; color: var(--slate); font-size: 14px; }
details p { font-size: 14px; color: var(--slate); }
.stats { list-style: none; padding: 0; margin: 8px 0 0; }
.stat { padding: 10px 0; border-top: 1px solid var(--line); }
.stat-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stat-label { font-weight: 600; }
.stat-vals { font-size: 13px; color: var(--slate); text-align: right; }
.stat-vals b { font-family: var(--head); font-size: 18px; color: var(--ink); }
.stat-vals em { font-style: normal; }
.log { margin: 8px 0 0; }
.pick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pk { min-width: 36px; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font-family: var(--head); font-size: 16px; cursor: pointer; }
.pk.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pick select { -webkit-appearance: none; appearance: none; min-width: 88px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 30px 6px 10px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238A8F98' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 10px center; color: var(--ink); font-family: var(--head); font-size: 18px; cursor: pointer; }
.pick select.pk-tenth { min-width: 64px; }
.pk-dot { font-style: normal; font-family: var(--head); font-size: 20px; margin: 0 -2px; }
.stat-in .pick select { border: 0; padding-left: 0; background-color: transparent; font-size: 22px; min-width: 96px; }
.grid .wide { grid-column: 1 / -1; }
.was { color: var(--slate); }

.field { display: block; margin: 0 0 12px; }
.field span { display: block; font-size: 13px; color: var(--slate); margin: 0 0 4px; }
.field span em { font-style: normal; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--card); }
.field textarea { resize: vertical; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.field.small input { padding: 8px; }
.past { margin: 0 0 8px; }
.past summary { font-family: var(--head); color: var(--ink); }
.past p { margin: 6px 0; font-size: 14px; }
pre.report { white-space: pre-wrap; font-size: 12px; background: var(--soft); padding: 10px; border-radius: 10px; }

.budget-table td:last-child { text-align: right; white-space: nowrap; }
.paid { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0; font-size: 14px; }
.paid label { display: inline-flex; align-items: center; gap: 6px; }
.empty-month header h2 { color: var(--slate); }
.card .pct em { font-size: 12px; margin-left: 4px; }
.rules li { margin: 0 0 8px; }
.rules b { display: block; }
table.rhythm { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rhythm td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.rhythm td:first-child { font-weight: 600; white-space: nowrap; }
.status { font-size: 14px; color: var(--slate); }

.login { padding: 24px 0; }
.login .err { color: var(--accent); }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet-card { width: 100%; max-width: 480px; background: var(--card); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-step { font-weight: 600; margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip-btn { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chip-btn.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs-inner { max-width: 480px; margin: 0 auto; display: flex; }
.tabbtn { flex: 1; background: none; border: 0; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--slate); font-size: 11px; cursor: pointer; }
.tabbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbtn.active { color: var(--accent); }

@media (min-width: 900px) {
  body { display: flex; flex-direction: column; min-height: 100vh; }
  .tabs { order: 0; position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); padding-bottom: 0; }
  .tabs-inner { max-width: 1160px; padding: 0 32px; justify-content: flex-start; gap: 4px; }
  .tabbtn { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 12px 14px; font-size: 14px; border-bottom: 2px solid transparent; }
  .tabbtn.active { border-bottom-color: var(--accent); }
  .tabbtn svg { width: 18px; height: 18px; }
  .app { order: 1; max-width: 1160px; padding: 0 32px 48px; }
  .top { padding: 22px 0 4px; }
  .brand { font-size: 30px; }
  .say { font-size: 26px; margin: 10px 0 20px; }
  .date { font-size: 22px; }

  #tab-today, #tab-stats, #tab-budget, #tab-week, #tab-sync { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
  #tab-today > .date, #tab-today > .daily, #tab-today > .intro, #tab-today > .summary, #tab-today > .dayend, #tab-today > .chip, #tab-today > .empty, #tab-today > .daynav, #tab-today > .dn-hint, #tab-today > .catchup,
  #tab-week > .chip, #tab-stats > .chip, #tab-sync > .chip,
  #tab-stats > .date, #tab-budget > .date, #tab-budget > .chips, #tab-budget > .card:first-of-type, #tab-budget > .label, #tab-budget > .rules,
  #tab-week > .date, #tab-week > .focus, #tab-week > .intro, #tab-week > .hint, #tab-week > .dots, #tab-week > .label, #tab-week > .empty,
  #tab-sync > .date, #tab-sync > .intro, #tab-sync > form, #tab-sync > .report, #tab-sync > .label, #tab-sync > .rules, #tab-sync > .past { grid-column: 1 / -1; }
  #tab-today > .group { min-width: 0; }
  #tab-today > .group h2 { margin-top: 8px; }
  #tab-today > .daily { max-width: 320px; }
  #tab-today > .daynav, #tab-today > .catchup { max-width: 560px; }
  #tab-today > .chip, #tab-week > .chip, #tab-stats > .chip, #tab-sync > .chip { justify-self: start; }
  #tab-today > .dayend { justify-content: flex-end; gap: 16px; }
  #tab-week > .goals { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; }
  #tab-week > .dots { max-width: 520px; }
  #tab-budget > .card:first-of-type { max-width: 560px; }
  #tab-sync .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #tab-sync .grid .wide { grid-column: span 2; }
  #tab-sync form .field:not(.small) { max-width: 760px; }
  #tab-notes { max-width: 760px; }
  .sheet { align-items: center; }
  .sheet-card { border-radius: 18px; }
}
@media (min-width: 1400px) {
  #tab-stats, #tab-budget { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  .tick, .step, .dot, .dn, .pk { transition: background .15s, border-color .15s, opacity .2s; }
}
