:root {
  --bg: #0e1014; --surface: #171a21; --surface2: #20242d; --line: #2a2f3a;
  --text: #f2f4f7; --muted: #8d95a5; --accent: #ff5a36; --accent-ink: #1a0a05; --ok: #3ddc97;
  --lv1: #3ddc97; --lv2: #ffc145; --lv3: #ff5a36;
  --fg-near: #e6e9ef; --fg-far: #737c8d; --fg-hl: #ff5a36; --fg-hl-far: #a8452f;
  --fg-floor: #2a2f3a; --fg-prop: #303644; --fg-bar: #aab2c2; --fg-outline: #171a21;
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body.playing { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; text-wrap: balance; }
small { color: var(--muted); font-size: 12px; font-weight: 500; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

#view { max-width: 560px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.eyebrow::first-letter, .cal-h b::first-letter { text-transform: uppercase; }
.lead { color: var(--muted); margin-bottom: 18px; font-size: 15px; }
.sec { font-size: 15px; font-weight: 700; margin: 24px 0 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }

.streak { display: flex; align-items: center; gap: 6px; background: var(--surface); padding: 8px 12px; border-radius: 999px; }
.streak svg { width: 18px; height: 18px; fill: var(--accent); }
.streak b { font-size: 17px; font-variant-numeric: tabular-nums; }

.figure { width: 100%; height: auto; overflow: visible; }
.fig { line-height: 0; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface2); color: var(--text); }
.badge.lv1 { background: color-mix(in srgb, var(--lv1) 18%, transparent); color: var(--lv1); }
.badge.lv2 { background: color-mix(in srgb, var(--lv2) 18%, transparent); color: var(--lv2); }
.badge.lv3 { background: color-mix(in srgb, var(--lv3) 18%, transparent); color: var(--lv3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: #c9cfdb; }
.meta { display: flex; gap: 18px; color: var(--muted); font-size: 14px; margin: 10px 0 12px; }
.meta b { color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }
.note { background: var(--surface); border-radius: 12px; padding: 10px 14px; font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.note.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--bg)); }

.btn { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; min-height: 46px; padding: 0 20px; border-radius: 14px; font-weight: 700; width: 100%; transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { min-height: 54px; font-size: 17px; margin-top: 16px; }
.btn.ghost { background: var(--surface); color: var(--text); margin-top: 10px; }
.btn.danger { color: #ff8b73; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--surface2); flex: none; }
.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon.lg { width: 54px; height: 54px; }
.icon.lg svg { width: 22px; height: 22px; }

.hero { background: var(--surface); border-radius: var(--r); overflow: hidden; }
.hero-fig { background: radial-gradient(120% 90% at 50% 100%, #262b36 0%, var(--surface) 70%); padding: 6px 12% 0; }
.hero-body { padding: 14px 18px 18px; }
.hero-body h2 { margin-top: 10px; font-size: 28px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wk { background: var(--surface); border-radius: 12px; padding: 8px 2px; text-align: center; border: 1.5px solid transparent; min-width: 0; }
.wk small { display: block; font-size: 10px; }
.wk b { font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; }
.wk.cur { border-color: var(--accent); }
.wk.done { background: color-mix(in srgb, var(--ok) 16%, var(--bg)); }
.wk.done b { color: var(--ok); }

.exrow { display: flex; align-items: center; gap: 12px; width: 100%; background: var(--surface); border-radius: 14px; padding: 6px 14px 6px 6px; margin-bottom: 8px; }
.exrow:hover { background: var(--surface2); }
.thumb { width: 74px; flex: none; background: var(--bg); border-radius: 10px; --fg-outline: #0e1014; }
.exrow-txt { flex: 1; min-width: 0; }
.exrow-txt b { display: block; font-size: 15px; line-height: 1.25; }
.exrow-txt small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exrow-qty { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; color: #c9cfdb; }

.block { background: var(--surface); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.block-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.block-h p { color: var(--muted); font-size: 13px; margin-top: 6px; }
.block-n { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin: 12px 0; flex: 1; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.dgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dcell { aspect-ratio: 1 / 1.05; background: var(--surface2); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1.5px solid transparent; min-width: 0; }
.dcell b { font-size: 15px; font-variant-numeric: tabular-nums; }
.dcell small { font-size: 9.5px; }
.dcell.done { background: color-mix(in srgb, var(--ok) 20%, var(--surface)); }
.dcell.done b, .dcell.done small { color: var(--ok); }
.dcell.cur { border-color: var(--accent); }

.filters { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fchip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 600; color: var(--muted); }
.fchip.on { background: var(--text); color: var(--bg); }
.exgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.excard { background: var(--surface); border-radius: 16px; padding: 4px 12px 12px; min-width: 0; }
.excard b { display: block; font-size: 14.5px; line-height: 1.25; margin-top: 2px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stats.three { grid-template-columns: repeat(3, 1fr); width: 100%; }
.stats > div { background: var(--surface); border-radius: 14px; padding: 12px 6px; text-align: center; }
.stats b { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats small { font-size: 11px; }
.card { background: var(--surface); border-radius: var(--r); padding: 14px 16px; }
.cal-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-w span { color: var(--muted); font-size: 11px; font-weight: 700; padding-bottom: 4px; }
.cd { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-size: 14px; font-variant-numeric: tabular-nums; color: #c9cfdb; }
.cd.done { background: var(--ok); color: #06231a; font-weight: 800; }
.cd.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.hrow { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 14px; padding: 10px 10px 10px 14px; margin-bottom: 8px; }
.hdate { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ok); width: 46px; flex: none; }
.tog { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; cursor: pointer; }
.tog + .tog { border-top: 1px solid var(--line); }
.tog b { display: block; font-size: 15px; }
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.tog i { width: 46px; height: 28px; border-radius: 14px; background: var(--surface2); position: relative; flex: none; transition: background .15s; }
.tog i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.tog input:checked + i { background: var(--accent); }
.tog input:checked + i::after { transform: translateX(18px); }
.tog input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
#tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--accent); }
body.playing #tabs { display: none; }

#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.sheet-box { position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 22px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet-x { position: absolute; top: 14px; right: 14px; z-index: 2; }
.sheet-box h2 { margin: 10px 44px 4px 0; }
.sheet-fig { background: radial-gradient(120% 90% at 50% 100%, #232833 0%, var(--surface) 70%); border-radius: var(--r); padding: 0 14%; margin-bottom: 14px; }
.tip { color: #c9cfdb; font-size: 15.5px; }
.lvrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lvrow div { background: var(--surface); border-radius: 12px; padding: 10px; text-align: center; }
.lvrow b { display: block; font-size: 15px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

#player { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; --fg-outline: #0e1014; }
#player > * { width: 100%; max-width: 520px; flex: none; }
.pl-top { display: flex; align-items: center; gap: 12px; }
.pl-count { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.pl-phase { text-align: center; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; margin-top: 6px; }
#player .pl-stage { max-width: min(520px, 46dvh); margin: 0 auto; }
.pl-stage.pre { opacity: .75; }
.pl-info { text-align: center; }
.pl-info .chips { justify-content: center; margin-top: 8px; }
.pl-state { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--lv2); margin-bottom: 2px; }
.pl-state.go { color: var(--accent); }
#player .pl-clock { position: relative; width: 150px; height: 150px; margin: 14px auto 8px; }
.ring { width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--surface2); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.ring-fg.rest { stroke: var(--lv2); }
.pl-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pl-num b { font-size: 52px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pl-tip { text-align: center; color: var(--muted); font-size: 14px; text-wrap: pretty; }
.pl-next { text-align: center; font-size: 13.5px; color: var(--muted); min-height: 20px; margin-top: 8px; }
.pl-next b { color: var(--text); }
#player .pl-ctrl { display: flex; align-items: center; gap: 14px; margin-top: auto; padding-top: 14px; }
.pl-ctrl .btn.big { margin-top: 0; flex: 1; }
.pl-done { margin: auto; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.pl-done p { color: var(--muted); margin-bottom: 10px; }
.check { width: 84px; height: 84px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; margin-bottom: 8px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
.check svg { width: 44px; height: 44px; fill: none; stroke: #06231a; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); }

.login { max-width: 340px; margin: 22vh auto 0; padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }
.login p { color: var(--muted); margin-bottom: 8px; }
.login input { min-height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 0 16px; font: inherit; }
.login-err { color: #ff8b73; font-size: 14px; }

@media (max-width: 360px) { h1 { font-size: 29px; } .stats { grid-template-columns: repeat(2, 1fr); } }
@media (prefers-reduced-motion: reduce) { .sheet-box, .check { animation: none; } }

.livre { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin-top: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px dashed #3a4150; }
.livre:hover { background: var(--surface2); }
.livre b { display: block; font-size: 16px; }
.livre svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts .fchip { background: var(--surface); }
.opts .fchip.on { background: var(--accent); color: #fff; }
.livre-res { margin-top: 20px; padding-top: 4px; border-top: 1px solid var(--line); }
.livre-res .meta { margin-top: 16px; }
.sheet-box.still { animation: none; }
.search { width: 100%; min-height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 0 14px; font: inherit; font-size: 15px; margin-bottom: 12px; }
.search::placeholder { color: var(--muted); }
.planbox p b { display: block; }
.planbox p { margin-bottom: 4px; }
.planbox > small { display: block; margin-top: 10px; }
.inline { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 4px; }
.inline input { min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 14px; font: inherit; font-size: 15px; }
.inline .btn { margin-top: 0; }
.acct { color: var(--muted); font-size: 14.5px; } .acct b { color: var(--text); }
.urow { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
