/* Discipliner – dark, mobile-first. Ember orange = body, calm blue = mind. */
:root {
  --bg: #0f1115;
  --card: #171a21;
  --card-2: #1f232c;
  --line: #2a2f3a;
  --text: #eef0f4;
  --muted: #9aa3b2;
  --ember: #f97316;
  --ember-2: #fb923c;
  --mind: #60a5fa;
  --ok: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small-print { font-size: 0.8rem; margin-top: 12px; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + var(--safe-bottom));
}
.wrap.setup { padding-bottom: 32px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* ---------- brand / header ---------- */
.brand { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.brand-name { margin: 0; font-size: 1.6rem; letter-spacing: 0.02em; }
.top { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.date { margin: 0; font-weight: 600; }
.date::first-letter { text-transform: uppercase; }
.streak { margin: 0; color: var(--ember-2); font-size: 0.9rem; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.phase {
  font-size: 0.75rem; color: var(--ember-2);
  border: 1px solid rgba(249, 115, 22, 0.4); border-radius: 999px; padding: 2px 10px;
}

/* ---------- body / big button ---------- */
.round-label { font-weight: 600; margin: 4px 0 8px; }
.moves { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.moves li {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--card-2); border-radius: 10px; padding: 8px 10px; min-width: 0;
}
.moves li span { flex: 1; font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moves li strong { font-size: 1.25rem; color: var(--text); }
.moves li small { font-size: 0.7rem; }

.press-wrap { position: relative; width: min(64vw, 240px); aspect-ratio: 1; margin: 16px auto 8px; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--card-2); stroke-width: 10; }
.ring-fill { fill: none; stroke: var(--ember); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.press {
  position: absolute; inset: 16px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--ember-2), var(--ember) 55%, #c2410c);
  color: #fff; box-shadow: 0 10px 30px rgba(249, 115, 22, 0.35), inset 0 -6px 0 rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.08s ease, box-shadow 0.2s ease;
  font: inherit;
}
.press:active:not(:disabled) { transform: scale(0.96); box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.18); }
.press:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.press-main { font-size: 2rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.press-sub { font-size: 0.95rem; opacity: 0.9; }
.press.done { background: radial-gradient(circle at 35% 30%, #4ade80, var(--ok) 60%, #15803d); box-shadow: 0 10px 30px rgba(34, 197, 94, 0.3); cursor: default; }
.press.done .press-main { font-size: 3.2rem; }

/* ---------- reading ---------- */
.mind .section-head h2 { color: var(--mind); }
.dots { display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--mind); }
.dot.on { background: var(--mind); }
.timer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.countdown { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--mind); }
.link { display: inline-block; margin-top: 12px; color: var(--mind); text-decoration: none; font-size: 0.9rem; }
.link:hover { text-decoration: underline; }

/* ---------- rest ---------- */
.rest-card { text-align: center; padding: 40px 16px; }
.rest-emoji { font-size: 4rem; margin-bottom: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 12px; border: 1px solid transparent; padding: 12px 16px;
  font: inherit; font-weight: 600; cursor: pointer; color: var(--text); background: var(--card-2);
  min-height: 44px;
}
.btn.primary { background: var(--ember); color: #fff; }
.btn.secondary { background: rgba(96, 165, 250, 0.15); border-color: rgba(96, 165, 250, 0.5); color: #cfe3ff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.danger { background: transparent; border-color: rgba(239, 68, 68, 0.6); color: #fca5a5; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 0.85rem; }
.btn.wide { width: 100%; }
.center-block { display: flex; margin: 4px auto 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- forms ---------- */
.move-row { display: grid; grid-template-columns: 1fr 84px 84px; gap: 8px; align-items: center; margin-bottom: 8px; }
.move-row.head span { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.move-name { font-size: 0.95rem; }
input[type="number"] {
  width: 100%; background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; font: inherit; font-size: 1rem; min-height: 44px;
}
input[type="number"]:focus { outline: none; border-color: var(--ember); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field > span, .field-inline > span { font-size: 0.9rem; font-weight: 600; }
.field-inline { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0 16px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; color: var(--muted); }
.seg input:checked + span { background: var(--ember); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid #fff; }
.saved-msg { color: var(--ok); margin-top: 8px; }

/* ---------- history ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 8px 0 12px; }
.cal-head { text-align: center; font-size: 0.75rem; color: var(--muted); }
.cal {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1; min-width: 0;
  border-radius: 8px; font-size: 0.8rem; background: var(--card-2); color: var(--muted);
}
.cal.done { background: var(--ok); color: #052e16; font-weight: 700; }
.cal.partial { background: rgba(234, 179, 8, 0.35); color: #fef9c3; }
.cal.missed { background: rgba(239, 68, 68, 0.25); color: #fecaca; }
.cal.rest { background: transparent; border: 1px dashed var(--line); }
.cal.today { outline: 2px solid var(--ember); color: var(--text); }
.cal.future, .cal.before { opacity: 0.35; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 14px; display: inline-block; border-radius: 4px; background: var(--card-2); }
.sw.done { background: var(--ok); }
.sw.partial { background: rgba(234, 179, 8, 0.35); }
.sw.missed { background: rgba(239, 68, 68, 0.25); }
.sw.rest { background: transparent; border: 1px dashed var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats div { background: var(--card-2); border-radius: 12px; padding: 12px 6px; }
.stats strong { display: block; font-size: 1.4rem; }
.stats small { color: var(--muted); font-size: 0.75rem; }

/* ---------- about / faq ---------- */
.faq { border-top: 1px solid var(--line); padding: 10px 0; }
.faq:first-of-type { border-top: 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--ember-2); font-size: 1.2rem; line-height: 1; }
.faq[open] summary::after { content: '−'; }
.faq p { color: var(--muted); margin: 8px 0 0; }
a.btn { text-decoration: none; }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: rgba(15, 17, 21, 0.96); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-bottom)); backdrop-filter: blur(8px);
}
.tab {
  flex: 1; max-width: 180px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.8rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; cursor: pointer; min-height: 48px;
}
.tab span { font-size: 1.2rem; }
.tab.active { color: var(--ember-2); }

/* ---------- celebration ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 6, 9, 0.75); padding: 16px; overflow: hidden; animation: fade 0.2s ease;
}
.celebrate-card {
  position: relative; z-index: 2; background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  padding: 28px 24px; text-align: center; max-width: 340px; width: 100%; animation: pop 0.45s cubic-bezier(.2, 1.4, .4, 1);
}
.celebrate-emoji { font-size: 5rem; line-height: 1; animation: wave 0.9s ease 0.3s 2; display: inline-block; transform-origin: 70% 80%; }
.celebrate-card h2 { font-size: 1.6rem; margin-top: 12px; }
.celebrate-card .btn { margin-top: 12px; min-width: 140px; }
.confetti {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; z-index: 1;
  animation: fall 2.4s linear forwards;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-18deg); } 75% { transform: rotate(18deg); } }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: 0.8; } }

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

@media (max-width: 360px) {
  .moves { grid-template-columns: 1fr; }
  .move-row { grid-template-columns: 1fr 70px 70px; }
}
