:root {
  --bg: #140f24;
  --card: #1f1836;
  --card-2: #2a2148;
  --text: #f3eefc;
  --muted: #a99cc8;
  --flame: #ff8a3d;
  --flame-2: #ffc94d;
  --ok: #47d18c;
  --accent: #9b7bff;
  --danger: #ff6b7a;
  --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
main { max-width: 560px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.loading { text-align: center; padding: 40vh 0; color: var(--muted); }
.stack > * + * { margin-top: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }

.hero { text-align: center; padding: 26px 18px 22px; background: radial-gradient(120% 90% at 50% 0%, #3a2366 0%, var(--card) 70%); }
.flame { font-size: 64px; line-height: 1; filter: drop-shadow(0 6px 24px rgba(255, 138, 61, .45)); }
.flame.cold { filter: grayscale(1) opacity(.5); }
.streak-num { font-size: 56px; font-weight: 800; letter-spacing: -0.03em; background: linear-gradient(180deg, var(--flame-2), var(--flame)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.streak-label { color: var(--muted); font-weight: 600; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 92px; }
.week .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week .bar { width: 100%; max-width: 30px; border-radius: 8px; background: var(--card-2); min-height: 8px; }
.week .bar.on { background: linear-gradient(180deg, var(--flame-2), var(--flame)); }
.week .lbl { font-size: 12px; color: var(--muted); }
.week .today .lbl { color: var(--text); font-weight: 700; }

.btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
button { font: inherit; border: 0; cursor: pointer; color: inherit; }
.btn { background: var(--card-2); border-radius: 14px; padding: 14px 10px; font-weight: 700; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--flame-2), var(--flame)); color: #2a1300; }
.btn.ghost { background: transparent; border: 1px solid var(--card-2); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; }
.done-banner { background: rgba(71, 209, 140, .12); color: var(--ok); border-radius: 14px; padding: 12px 14px; font-weight: 600; text-align: center; }

.progress { height: 10px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--flame)); border-radius: 99px; transition: width .4s; }
.phase-chip { display: inline-block; font-size: 12px; font-weight: 700; color: var(--accent); background: rgba(155, 123, 255, .14); padding: 3px 9px; border-radius: 99px; }
.res { list-style: none; padding: 0; margin: 0; }
.res li + li { margin-top: 8px; }
.res a { text-decoration: none; }

details.phase { background: var(--card); border-radius: var(--radius); overflow: hidden; }
details.phase + details.phase { margin-top: 12px; }
details.phase summary { list-style: none; padding: 16px 18px; cursor: pointer; }
details.phase summary::-webkit-details-marker { display: none; }
.phase-body { padding: 0 18px 18px; }
.cp { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--card-2); }
.cp .box { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted); display: grid; place-items: center; font-size: 15px; background: transparent; }
.cp.done .box { background: var(--ok); border-color: var(--ok); color: #06210f; }
.cp.gate .title { font-weight: 700; }
.cp .proof { font-size: 13px; color: var(--muted); margin-top: 4px; }
.proof-form { margin-top: 10px; }
textarea, input[type=password] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--card-2);
  border-radius: 12px; padding: 12px; font-size: 16px;
}
textarea { min-height: 72px; resize: vertical; }
.err { color: var(--danger); font-size: 14px; min-height: 1.2em; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: rgba(20, 15, 36, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--card-2); padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
#tabs button { background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); padding: 4px 18px; }
#tabs button span { font-size: 22px; }
#tabs button.active { color: var(--text); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto;
  background: var(--card-2); border-radius: 14px; padding: 14px 16px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }
