:root {
  --ink: #0b0b0b; --gold: #b08d57; --bg: #faf9f7; --line: #e7e5e1; --card: #fff;
  --ok: #1f7a4d; --warn: #bf7800; --bad: #a3261c; --info: #405c9e; --muted: #77736c;
  --serif: "Didot", "Bodoni 72", "Bodoni Moda", "Playfair Display", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabh: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--sans); }
body { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* layout */
#app { max-width: 620px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 12px); }
header.top { position: sticky; top: 0; z-index: 5; background: rgba(250,249,247,.92); backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; }
header.top h1 { font: 700 26px/1.1 var(--serif); margin: 0; flex: 1; letter-spacing: .2px; }
header.top .back { font-size: 26px; padding: 0 6px 0 0; background: none; border: 0; cursor: pointer; }
header.top .tools { display: flex; gap: 6px; }
main { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.sub { color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }

/* tabs */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: rgba(255,255,255,.96); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs .in { max-width: 620px; margin: 0 auto; display: flex; height: var(--tabh); }
nav.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: #9a968f; }
nav.tabs a svg { width: 24px; height: 24px; }
nav.tabs a.on { color: var(--ink); }
nav.tabs a.on svg { color: var(--gold); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.card.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.card.flush { padding: 0; overflow: hidden; }
.card h2, .h2 { font: 700 20px/1.2 var(--serif); margin: 0 0 6px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 6px 4px -6px; }
.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; }
.item:active { background: #f3f1ed; }
.item .t { font-weight: 600; }
.item .s { font-size: 13px; color: var(--muted); }
.chev { color: #c4c0b8; font-size: 20px; }
.empty { color: var(--muted); padding: 18px 16px; text-align: center; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font: 700 26px/1.1 var(--serif); }
.stat span { font-size: 12px; color: var(--muted); }
.big { font: 700 44px/1 var(--serif); }
.serif { font-family: var(--serif); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 14px 18px;
  background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; width: 100%; }
.btn.gold { background: var(--gold); }
.btn.outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid #ecd2cf; }
.btn.small { width: auto; padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { background: #fff; border: 1px solid var(--line); border-radius: 12px; width: 38px; height: 38px; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; font-size: 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg { display: flex; background: #efede9; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px; font-size: 14px; cursor: pointer; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }

/* pills */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: #e3f1ea; color: var(--ok); } .pill.warn { background: #f8ecd7; color: var(--warn); }
.pill.bad { background: #f5e1df; color: var(--bad); } .pill.info { background: #e3e8f4; color: var(--info); }
.pill.mute { background: #efede9; color: var(--muted); } .pill.gold { background: #f3ebdd; color: #8a6a37; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
input.i, select.i, textarea.i { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 16px; color: var(--ink); font-weight: 400; }
textarea.i { min-height: 90px; resize: vertical; }
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.err { color: var(--bad); font-size: 14px; }
.note { font-size: 13px; color: var(--muted); }

/* avatar */
.av { width: 40px; height: 40px; border-radius: 50%; background: #f3ebdd; color: #8a6a37; display: inline-flex; align-items: center;
  justify-content: center; font: 700 15px var(--serif); flex: none; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet .bar { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; gap: 8px; padding: 14px 0 10px; z-index: 1; }
.sheet .bar h3 { flex: 1; margin: 0; font: 700 20px var(--serif); }
.sheet .bar button { background: none; border: 0; font-size: 16px; cursor: pointer; padding: 6px; }
.sheet .bar .save { font-weight: 700; color: var(--gold); }
.sheet form { display: flex; flex-direction: column; gap: 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + 24px + env(safe-area-inset-bottom)); background: var(--ink);
  color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; z-index: 30; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: fade .2s; }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 22px; gap: 16px; max-width: 440px; margin: 0 auto; }
.login img { width: 150px; align-self: center; margin-bottom: 8px; }
.login h1 { font: 700 30px var(--serif); text-align: center; margin: 0; }

/* today */
.clock { font: 700 52px/1 var(--serif); letter-spacing: -1px; }
.hero .meta { color: rgba(255,255,255,.65); font-size: 14px; }
.hero .pill { background: rgba(255,255,255,.14); color: #fff; }
.timeline > div { display: flex; justify-content: space-between; padding: 8px 0; font-size: 15px; }
.timeline > div + div { border-top: 1px dashed var(--line); }
.banner { border-radius: 14px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.banner.ok { background: #e3f1ea; color: #155c39; } .banner.warn { background: #f8ecd7; color: #7a4d00; }
.banner.bad { background: #f5e1df; color: #7d1d15; } .banner.gold { background: #f3ebdd; color: #6f5428; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal .dow { font-size: 11px; color: var(--muted); padding-bottom: 4px; }
.cal .d { aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; cursor: pointer; position: relative; }
.cal .d.today { outline: 2px solid var(--gold); }
.cal .d .dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 3px; }
.cal .d.ev::after { content: "★"; position: absolute; top: 2px; right: 4px; font-size: 9px; color: var(--gold); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* scores */
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .v { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .v b { font: 700 34px/1 var(--serif); }
.ring .v span { font-size: 11px; opacity: .7; }
.bar-track { height: 8px; background: #efede9; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.part { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; }
.part + .part { border-top: 1px solid var(--line); }
.part .ic { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.hist { display: flex; align-items: flex-end; gap: 8px; height: 110px; }
.hist div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; color: var(--muted); height: 100%; }
.hist i { width: 100%; background: var(--gold); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.stars { display: flex; gap: 6px; font-size: 28px; }
.stars button { background: none; border: 0; cursor: pointer; color: #d9d4ca; padding: 0; }
.stars button.on { color: var(--gold); }
.rank { font: 700 18px var(--serif); width: 28px; text-align: center; color: var(--gold); }

/* tasks */
.prio { width: 4px; align-self: stretch; border-radius: 4px; flex: none; }
audio { width: 100%; height: 40px; }
.rec { display: flex; align-items: center; gap: 10px; }
.rec .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.bubble.me { background: #f3ebdd; border-color: #eadcc4; }

@media (min-width: 700px) {
  body { background: #f1efeb; }
  #app { background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
}
