/* Hard Knock Life — design tokens and components */
@font-face { font-family: 'Bricolage'; src: url('/assets/fonts/bricolage.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'JB Mono'; src: url('/assets/fonts/jbmono.woff2') format('woff2'); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #100E0B; --bg-2: #17140F; --card: #1E1A14; --card-2: #262118; --line: #362E22; --line-2: #4A3F2E;
  --ink: #F5EEDF; --ink-2: #C5BAA5; --ink-3: #8F8571;
  --gold: #F2B33D; --gold-hi: #FFD27A; --gold-lo: #B97A14; --gold-deep: #3A2406; --gold-wash: rgba(242,179,61,.12);
  --red: #F27A5E; --red-wash: rgba(242,122,94,.12); --green: #86D6A0; --green-wash: rgba(134,214,160,.12);
  --font: 'Bricolage', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JB Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --r-s: 10px; --r: 16px; --r-l: 24px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--font); font-variation-settings: 'wdth' 100; -webkit-font-smoothing: antialiased; }
a { color: var(--gold); text-underline-offset: 3px; }
img, svg { display: block; }
h1, h2, h3 { line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 .5em; font-weight: 750; }
p { margin: 0 0 1em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--ink); font: 650 15px/1 var(--font); text-decoration: none; cursor: pointer; transition: transform .15s var(--ease), background .2s, border-color .2s; }
.btn:hover { border-color: var(--gold); }
.btn:active { transform: scale(.97); }
.btn-gold { background: var(--gold); color: var(--gold-deep); border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn-ghost { border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line); }
.btn-danger { border-color: rgba(242,122,94,.5); color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-wash); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }

/* App header (PWA pages) */
.app-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo-mark { width: 34px; height: 34px; }
.wordmark { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.wordmark b { color: var(--gold); font-weight: 800; }
.app-nav { display: flex; gap: 4px; }
.nav-btn { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; color: var(--ink-3); text-decoration: none; font-size: 14px; font-weight: 600; }
.nav-btn:hover { color: var(--ink); background: var(--card); }
.nav-btn.is-active { color: var(--gold); background: var(--gold-wash); }
.nav-btn .ico { width: 18px; height: 18px; }
@media (max-width: 520px) { .nav-btn span { display: none; } .nav-btn { padding: 9px; } .wordmark { font-size: 16px; } }

/* Page container for settings/stats/privacy */
.page { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(48px + var(--safe-b)); }
.page-title { font-size: clamp(28px, 6vw, 40px); margin: 16px 0 6px; }
.lede { color: var(--ink-2); font-size: 17px; max-width: 60ch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card + .card { margin-top: 14px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--gold-wash); color: var(--gold); }
.pill.red { background: var(--red-wash); color: var(--red); }
.pill.green { background: var(--green-wash); color: var(--green); }
.pill.grey { background: var(--card-2); color: var(--ink-2); }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font-size: 14px; font-weight: 650; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--ink-3); }
input[type=text], input[type=number], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink); font: 500 16px var(--font);
}
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); }
input[type=time]::-webkit-calendar-picker-indicator { filter: invert(.8) sepia(1) saturate(3) hue-rotate(5deg); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; pointer-events: none; }
.input-prefix > input { padding-left: 30px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg label { flex: 1 1 auto; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; text-align: center; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 650; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg input:checked + span { background: var(--gold); color: var(--gold-deep); }
.seg input:focus-visible + span { outline: 2px solid var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
button.chip { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span { display: inline-block; min-width: 46px; text-align: center; padding: 8px 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; font-weight: 650; color: var(--ink-2); cursor: pointer; }
.chip input:checked + span { background: var(--gold-wash); border-color: var(--gold); color: var(--gold); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; cursor: pointer; }
.switch input { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--gold); }
.switch input:checked::after { transform: translateX(20px); background: var(--gold-deep); }
.list-item { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); margin-bottom: 10px; }
.list-item .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--gold); }
.icon-btn .ico { width: 18px; height: 18px; }
.radio-default { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.radio-default input { accent-color: var(--gold); width: 18px; height: 18px; }
.error { color: var(--red); font-size: 13px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 650; font-size: 14px; transition: .3s var(--ease); pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Sheets (dialog) */
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: min(560px, 100%); max-height: 88dvh; background: var(--card); color: var(--ink); border-radius: 24px 24px 0 0; box-shadow: 0 -20px 60px rgba(0,0,0,.5); }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 24px; } }
dialog.sheet::backdrop { background: rgba(8,6,4,.7); backdrop-filter: blur(4px); }
dialog.sheet[open] { animation: sheetIn .35s var(--ease); }
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
.sheet-body { padding: 22px 20px calc(22px + var(--safe-b)); overflow: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { font-size: 22px; margin: 0; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.sheet-actions .btn { flex: 1 1 auto; }
.option-list { display: grid; gap: 8px; }
.option { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink); font: 600 15px var(--font); cursor: pointer; }
.option:hover { border-color: var(--gold); }
.option.is-on { border-color: var(--gold); background: var(--gold-wash); }
.option .price { margin-left: auto; font-family: var(--mono); color: var(--ink-2); }
.option .ico { color: var(--gold); }

/* ---------- LIVE ---------- */
body.live { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; background: radial-gradient(120% 70% at 50% 30%, #1C1810 0%, var(--bg) 60%); }
.live-main { flex: 1; display: grid; grid-template-rows: 2fr 1fr; min-height: 0; padding: 0 12px calc(12px + var(--safe-b)); gap: 8px; max-width: 620px; width: 100%; margin: 0 auto; }
.dial-wrap { position: relative; min-height: 0; display: grid; place-items: center; container-type: size; }
.dial { position: relative; width: min(100cqw, max(60cqh, 100cqh - 110px)); aspect-ratio: 1; }
.dial svg.face { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.dial .center { position: absolute; inset: 22%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border-radius: 50%; cursor: pointer; -webkit-tap-highlight-color: transparent; background: none; border: 0; color: inherit; font: inherit; }
.center .kicker { font-size: clamp(11px, 3.2cqmin, 15px); color: var(--ink-3); font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.amount { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; font-size: clamp(34px, 13cqmin, 92px); line-height: 1; letter-spacing: -0.05em; margin: 6px 0 4px; color: var(--ink); transition: color .4s; white-space: nowrap; }
.amount .p { color: var(--gold); }
.amount .mp { font-size: .42em; color: var(--ink-3); letter-spacing: -0.02em; vertical-align: .9em; margin-left: 2px; }
.amount.neg { color: var(--red); }
.amount.neg .p { color: var(--red); }
.center .rate { font-family: var(--mono); font-size: clamp(11px, 3.2cqmin, 15px); color: var(--ink-2); }
.center .elapsed { margin-top: 6px; font-size: clamp(11px, 3cqmin, 14px); color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.center .elapsed .ico { width: 14px; height: 14px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(134,214,160,.6); animation: pulse 2s infinite; }
.state-dot.paused { background: var(--ink-3); animation: none; }
.state-dot.done { background: var(--gold); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(134,214,160,0); } 100% { box-shadow: 0 0 0 0 rgba(134,214,160,0); } }

.corner { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; width: clamp(64px, 20cqmin, 108px); padding: 6px 0; background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent; z-index: 2; }
.corner .bubble { display: grid; place-items: center; width: clamp(44px, 12cqmin, 60px); height: clamp(44px, 12cqmin, 60px); border-radius: 50%; background: var(--card); border: 1px solid var(--line-2); transition: transform .2s var(--ease), border-color .2s, background .2s; }
.corner:hover .bubble { border-color: var(--gold); }
.corner:active .bubble { transform: scale(.92); }
.corner .ico { color: var(--gold); }
.corner .c-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.corner .c-val { font-family: var(--mono); font-size: clamp(12px, 3.4cqmin, 15px); font-weight: 600; color: var(--ink); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.corner.tl { top: 0; left: 0; } .corner.tr { top: 0; right: 0; } .corner.bl { bottom: 0; left: 0; } .corner.br { bottom: 0; right: 0; }

.status { display: flex; flex-direction: column; justify-content: center; gap: 12px; min-height: 0; padding: 18px 20px; border-radius: var(--r-l); background: var(--card); border: 1px solid var(--line); position: relative; overflow: hidden; }
.status::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--gold); }
.status.neg::before { background: var(--red); }
.status.free::before, .status.good::before { background: var(--green); }
.status-top { display: flex; align-items: center; gap: 8px; }
.status-msg { font-size: clamp(17px, 4.6vw, 24px); font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.status-msg.enter { animation: msgIn .6s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } }
.next { display: grid; gap: 6px; }
.next-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-3); }
.next-row b { color: var(--ink-2); font-weight: 650; }
.bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold)); border-radius: inherit; transition: width .9s linear; }
.jar { font-size: 12px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.jar .ico { width: 14px; height: 14px; color: var(--gold); }
@media (max-height: 640px) { .next-row:last-child, .jar { display: none; } .status { padding: 12px 16px; gap: 8px; } }

.coin-burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 3; }
.coin-burst i { position: absolute; width: 14px; height: 14px; margin: -7px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--gold-hi), var(--gold) 55%, var(--gold-lo)); animation: burst 1.1s var(--ease) forwards; }
@keyframes burst { to { transform: translate(var(--x), var(--y)) scale(.4); opacity: 0; } }

/* ---------- STATS ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--ink-3); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: var(--mono); font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -0.03em; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.chart .b { width: 100%; max-width: 36px; border-radius: 6px 6px 2px 2px; background: var(--gold); min-height: 3px; }
.chart .b.neg { background: var(--red); }
.chart .l { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log .it { font-weight: 650; }
.log .pr { font-family: var(--mono); color: var(--gold); text-align: right; }
.log .meta { font-size: 13px; color: var(--ink-3); grid-column: 1 / -1; }
.log-day { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; margin: 18px 0 2px; }
.tabs { display: flex; gap: 6px; margin: 8px 0 4px; }
.empty { text-align: center; padding: 30px 10px; color: var(--ink-3); }

/* ---------- SETTINGS ---------- */
.wizard-progress { display: flex; gap: 6px; margin: 10px 0 18px; }
.wizard-progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.wizard-progress i.on { background: var(--gold); }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 22px; margin-bottom: 4px; }
.step-title .n { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--gold-deep); font-size: 15px; font-weight: 800; flex: none; }
.step-intro { color: var(--ink-2); margin-bottom: 18px; }
.wizard .step { display: none; }
.wizard .step.on { display: block; animation: msgIn .4s var(--ease); }
.edit .step { display: block; }
.edit .step + .step { margin-top: 14px; }
.wizard-nav { display: flex; gap: 10px; justify-content: space-between; margin-top: 18px; position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 30%); }
.summary { position: relative; }
.summary dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; font-size: 15px; }
.summary dt { color: var(--ink-2); }
.summary dd { margin: 0; font-family: var(--mono); text-align: right; }
.summary .total dt, .summary .total dd { font-weight: 750; color: var(--gold); font-size: 17px; padding-top: 8px; border-top: 1px solid var(--line); }
.summary .neg { color: var(--red); }
.big-rate { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.big-rate div { flex: 1 1 120px; background: var(--bg-2); border-radius: 12px; padding: 10px 12px; }
.big-rate b { display: block; font-family: var(--mono); font-size: 18px; color: var(--ink); }
.big-rate span { font-size: 12px; color: var(--ink-3); }
details.adv { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
details.adv summary { cursor: pointer; font-weight: 650; color: var(--gold); padding: 8px 0; }
.disclaimer { font-size: 13px; color: var(--ink-3); border-left: 3px solid var(--line-2); padding: 8px 12px; margin: 14px 0; }

/* ---------- PROSE (privacy) ---------- */
.prose h2 { font-size: 22px; margin-top: 28px; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul { padding-left: 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
