/* 워치 앱의 기본(주황) 테마와 같은 색. 폰 설정에 따라 밝게/어둡게 */
:root {
  color-scheme: dark light;
  --bg: #16110e;
  --surface: #221b17;
  --surface-high: #2f2621;
  --text: #f5e7de;
  --muted: #bda89b;
  --line: #3d322b;
  --accent: #ff8a3d;
  --on-accent: #2a1200;
  --accent-soft: rgba(255, 138, 61, 0.16);
  --good: #7bd88f;
  --bad: #ff8a80;
  --bar: #6b5a4f;
  --radius: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbf6f2;
    --surface: #ffffff;
    --surface-high: #f3ebe5;
    --text: #231a14;
    --muted: #7a6558;
    --line: #eadfd7;
    --accent: #e0661a;
    --on-accent: #ffffff;
    --accent-soft: rgba(224, 102, 26, 0.12);
    --good: #1f8a3b;
    --bad: #c62828;
    --bar: #cdbdb2;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

h1, h2, p, ol { margin: 0; }

/* 좌측 상단 앱 아이콘과 이름 */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.topbar img { display: block; flex-shrink: 0; }

.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }

.report {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 16px calc(env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- 머리 ---- */

.hero { padding: 8px 4px 12px; }

.eyebrow {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero h1 {
  margin-top: 6px;
  font-size: 1.75rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.date { margin-top: 4px; color: var(--muted); font-size: 0.9375rem; }

.score {
  margin-top: 20px;
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.chips { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-high);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.chip-time_capped { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip-aborted { color: var(--bad); font-weight: 600; }

/* ---- 카드 ---- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card h2 { font-size: 1rem; font-weight: 700; }

.summary { color: var(--muted); font-size: 0.9375rem; }

/* 항목 중간에서 줄이 바뀌지 않게 항목 단위로 감싼다. */
.stats { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 0.9375rem; }
.stats span { white-space: nowrap; }
.stats .good { color: var(--good); }
.stats .bad { color: var(--bad); }

.badge {
  align-self: flex-start;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 0.9375rem;
}

.delta { font-size: 1.0625rem; font-weight: 600; }
.delta.better { color: var(--good); }
.delta.worse { color: var(--bad); }

.compare-row, .total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9375rem;
}

/* ---- 차트 ---- */

.chart { width: 100%; min-height: 150px; }
.chart svg { display: block; overflow: visible; }

.axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.grid { stroke: var(--line); stroke-width: 1; }
.lap { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.prepare { fill: var(--surface-high); opacity: 0.6; }
.hr-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.hr-peak { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

.bar { fill: var(--bar); }
.bar.fastest { fill: var(--good); }
.bar.slowest { fill: var(--bad); }
.bar.partial { fill: var(--bar); opacity: 0.4; }
.average { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; }

/* ---- 라운드 ---- */

.splits { list-style: none; padding: 0; }

.split {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
}

.split.fastest span:nth-child(2) { color: var(--good); font-weight: 700; }
.split.slowest span:nth-child(2) { color: var(--bad); font-weight: 700; }

/* ---- HYROX ---- */

.totals { display: flex; flex-direction: column; gap: 8px; }

.blocks { list-style: none; padding: 0; }

.block {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.block-name { font-weight: 600; }
.block.run .block-name { color: var(--accent); }
.block.roxzone .block-name { color: var(--muted); font-size: 0.875rem; }
.block-time { text-align: right; flex-shrink: 0; }
.block.slowest .block-time > p:first-child { color: var(--bad); font-weight: 700; }
.block.not-done { opacity: 0.45; }

/* ---- 바닥 ---- */

footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.share {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.share:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }

.toast:empty { display: none; }
.toast { color: var(--good); font-size: 0.875rem; }

.brand { color: var(--muted); font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; }

.error .hero { padding-top: 40px; display: flex; flex-direction: column; gap: 12px; }

.noscript { padding: 24px; text-align: center; }
