/* styles.css — dark, phase-tinted. The active phase colour is published as
   --accent on :root by app.js, and every accented surface reads from it. */

:root {
  --bg:        #0b0f14;
  --bg-raise:  #121821;
  --bg-raise2: #172030;
  --line:      #24303f;
  --text:      #e8eef6;
  --muted:     #8fa1b6;
  --accent:    #64748b;
  --accent-glow: rgba(100,116,139,.45);
  --good:      #3fbf6a;
  --warn:      #f5a524;
  --bad:       #ef4444;
  --radius:    16px;
  --pad:       16px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  /* Soft wash of the active phase colour behind everything. */
  background-image: radial-gradient(120% 55% at 50% -10%, var(--accent-glow), transparent 68%);
  background-repeat: no-repeat;
  transition: background-image .8s ease;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 10px; }
ul { margin: 0; padding-left: 18px; }
li { margin: 0 0 8px; }
code { background: var(--bg-raise2); padding: 1px 5px; border-radius: 5px; font-size: .88em; }

.muted { color: var(--muted); }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad) 10px;
  background: rgba(11,15,20,.82);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-size: 13px; letter-spacing: .28em; color: var(--muted);
  font-weight: 700; margin-bottom: 10px;
}

.tabs { display: flex; gap: 6px; }

.tab {
  flex: 1; padding: 9px 8px; border: 0; border-radius: 10px;
  background: var(--bg-raise); color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab.is-active { background: var(--accent); color: #0b0f14; }

/* ---------- layout ---------- */

main { max-width: 620px; margin: 0 auto; padding: 16px var(--pad) 64px; }
.view { display: none; }
.view.is-active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.panel { display: flex; flex-direction: column; gap: 18px; }

/* ---------- form bits ---------- */

.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .collapse > summary {
  font-size: 13px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.collapse > summary { cursor: pointer; list-style: none; }
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary::before { content: '＋ '; }
.collapse[open] > summary::before { content: '－ '; }
.collapse > * { margin-top: 10px; }

.input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-raise); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; -webkit-appearance: none; appearance: none;
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea.input { resize: vertical; line-height: 1.5; }

.hint { font-size: 13px; color: var(--muted); margin: 0; }

.weigh-row { display: flex; gap: 8px; align-items: center; }
.weigh-row .input { flex: 1; }
.unit { width: 84px; flex: 0 0 auto; }
.unit-label { color: var(--muted); font-weight: 600; width: 30px; }
.weigh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 13px; border-radius: 999px;
  background: var(--bg-raise); border: 1px solid var(--line);
  color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #0b0f14; }

/* ---------- buttons ---------- */

.btn {
  padding: 11px 16px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 650; cursor: pointer;
  transition: filter .14s, background .14s;
}
.btn:active { filter: brightness(.9); }
.btn-lg { padding: 16px; font-size: 16px; width: 100%; }
.btn-primary { background: var(--accent); color: #0b0f14; }
.btn-danger  { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-ghost   { background: var(--bg-raise); border-color: var(--line); color: var(--text); }
.btn-quiet   { color: var(--bad); }
.link {
  background: none; border: 0; padding: 0; color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer;
  border-bottom: 1px dashed var(--line);
}

/* ---------- ring ---------- */

.ring-wrap { position: relative; width: min(320px, 82vw); margin: 8px auto 4px; }
.ring { width: 100%; height: auto; transform: rotate(-90deg); }
.ring-track  { fill: none; stroke: var(--bg-raise); stroke-width: 16; }
.ring-band   { fill: none; stroke-width: 16; opacity: .30; }
.ring-progress {
  fill: none; stroke: var(--accent); stroke-width: 16; stroke-linecap: round;
  filter: drop-shadow(0 0 10px var(--accent-glow));
  transition: stroke-dasharray .6s ease, stroke .6s ease;
}

.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; text-align: center;
}
.elapsed {
  font-size: clamp(34px, 11vw, 46px); font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.elapsed-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.phase-pill {
  margin-top: 4px; padding: 5px 11px; border-radius: 999px;
  background: var(--accent); color: #0b0f14;
  font-size: 12px; font-weight: 700; max-width: 82%;
  transition: background .6s ease;
}

.ring-progress.is-over { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .62; } }

/* ---------- meta ---------- */

.meta-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.meta-value { font-size: 14px; font-weight: 650; text-align: left; }

/* ---------- cards ---------- */

.phase-card, .booster, .card {
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--pad);
}
.phase-card { border-left: 4px solid var(--accent); transition: border-color .6s ease; }
.phase-card h3 { margin-bottom: 6px; font-size: 17px; }

.markers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.marker {
  background: var(--bg-raise2); border-radius: 10px; padding: 9px 11px;
}
.marker-k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.marker-v { font-size: 13.5px; font-weight: 620; }

.booster {
  background: linear-gradient(180deg, var(--bg-raise2), var(--bg-raise));
  border-color: var(--accent);
  transition: border-color .6s ease;
}
.booster-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.booster-head h3 { font-size: 15px; }
.booster-icon { font-size: 18px; }
.booster-list li::marker { color: var(--accent); }
.avoid {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.avoid h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--bad); margin-bottom: 8px;
}
.avoid li::marker { color: var(--bad); }

/* ---------- timeline strip ---------- */

.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-row {
  display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 12px;
  background: var(--bg-raise); border: 1px solid var(--line);
  opacity: .5;
}
.tl-row.is-done { opacity: .78; }
.tl-row.is-now  { opacity: 1; border-color: var(--tl-color); background: var(--bg-raise2); }
.tl-hours { font-size: 12px; font-weight: 700; color: var(--tl-color); font-variant-numeric: tabular-nums; }
.tl-name  { font-size: 13.5px; font-weight: 600; }
.tl-mark  { font-size: 12px; color: var(--muted); }

/* ---------- log ---------- */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; text-align: center;
}
.stat-v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.log-actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.log-actions .btn { flex: 1; font-size: 13.5px; padding: 9px 10px; }

.entry {
  background: var(--bg-raise); border: 1px solid var(--line);
  border-left: 4px solid var(--entry-color, var(--line));
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  cursor: pointer;
}
.entry-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.entry-dur { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-date { font-size: 13px; color: var(--muted); }
.entry-phase {
  display: inline-block; margin-top: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: var(--entry-color); color: #0b0f14;
}
.entry-times { font-size: 13px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.entry-weight { font-size: 13px; margin-top: 5px; }
.entry-weight .down { color: var(--good); }
.entry-notes {
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line);
  font-size: 13.5px; color: #c6d3e2; white-space: pre-wrap;
}
.empty { text-align: center; color: var(--muted); padding: 44px 16px; }

/* ---------- guide ---------- */

.guide-sec {
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
}
.guide-sec > summary {
  padding: 15px var(--pad); cursor: pointer; font-weight: 650; font-size: 15.5px;
  display: flex; align-items: center; gap: 10px; list-style: none;
}
.guide-sec > summary::-webkit-details-marker { display: none; }
.guide-sec > summary::after { content: '›'; margin-left: auto; color: var(--muted); font-size: 20px; transition: transform .2s; }
.guide-sec[open] > summary::after { transform: rotate(90deg); }
.guide-body { padding: 0 var(--pad) var(--pad); }

.grp { margin-top: 14px; }
.grp-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 7px; display: flex; align-items: center; gap: 7px;
}
.grp-label::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.grp.good .grp-label { color: var(--good); }
.grp.warn .grp-label { color: var(--warn); }
.grp.bad  .grp-label { color: var(--bad); }
.grp ul { font-size: 14px; }

table { width: 100%; border-collapse: collapse; margin: 14px 0 4px; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }

.disclaimer {
  font-size: 12.5px; color: var(--muted); text-align: center;
  padding: 18px 10px 0; line-height: 1.6;
}

/* ---------- sheets ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.62); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 22px var(--pad) calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
  animation: rise .26s cubic-bezier(.22,.8,.3,1);
}
@keyframes rise { from { transform: translateY(24px); opacity: .4; } }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; }
}

.end-summary {
  background: var(--bg-raise2); border-radius: 12px; padding: 14px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 12px;
}
.sheet-actions { display: flex; gap: 10px; align-items: center; }
.sheet-actions .btn-primary, .sheet-actions .btn-ghost:not(.btn-quiet) { flex: 1; }

/* ---------- bottom banner (install hint / update prompt) ---------- */

.banner {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 80; max-width: 596px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-raise2); border: 1px solid var(--accent);
  border-radius: 14px; padding: 12px 12px 12px 15px;
  box-shadow: 0 10px 34px rgba(0,0,0,.55);
  animation: rise .26s cubic-bezier(.22,.8,.3,1);
}
.banner-text { flex: 1; font-size: 13.5px; line-height: 1.45; }
.banner-btn {
  flex: 0 0 auto; padding: 8px 14px; border: 0; border-radius: 9px;
  background: var(--accent); color: #0b0f14;
  font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.banner-btn:empty { display: none; }
.banner-close {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0;
  background: none; border: 0; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer;
}

#welcome-sheet .sheet p { font-size: 14px; line-height: 1.6; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 90;
  background: var(--bg-raise2); border: 1px solid var(--line);
  color: var(--text); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 28px rgba(0,0,0,.5);
  animation: rise .2s ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
