/* Halbere și Sticlism — one design language on every device.
 * Metro: content-first typography, light large headings, bold numbers, strict left grid,
 *        flat asymmetric status tiles with crisp corners.
 * iOS:   subtle translucent navigation, safe areas, gentle transitions.
 * Material: 44px+ controls, clear pressed/focus feedback, reusable layout blocks.
 * Palette: graphite, cool white, electric blue, violet, cyan. No external assets. */

:root {
  color-scheme: light dark;

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;

  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #EEF1F5;
  --text: #0A0C10;
  --text-2: #353B48;
  --text-muted: #5A6170;
  --line: #DFE3EA;
  --line-strong: #C3C9D4;

  --blue: #1F5BFF;
  --blue-press: #1748D6;
  --violet: #6C2FE0;
  --cyan: #00A3C4;
  --cyan-text: #006F86;
  --graphite: #1C1F26;
  --on-tile: #FFFFFF;
  --on-tile-2: rgb(255 255 255 / 82%);
  --accent-text: #1E4FE0;
  --accent-soft: #E6ECFF;

  --ok: #006F86;      --ok-bg: #DFF4F8;
  --warn: #A8204F;    --warn-bg: #FBE8EF;
  --info: #1E4FE0;    --info-bg: #E6ECFF;
  --danger: #B42020;  --danger-bg: #FCEBEB;
  --muted-tone: #474E5E; --muted-bg: #E9ECF1;
  --perfect: #5A22C8; --perfect-bg: #EFE8FD;

  --s1: #1F5BFF;
  --s2: #6C2FE0;
  --s3: #00A3C4;
  --s4: #C8326E;

  --glass: rgb(244 246 249 / 80%);
  --glass-line: rgb(10 12 16 / 10%);
  --focus: #1F5BFF;

  --r-tile: 3px;
  --r-ctl: 6px;
  --tabbar-h: 60px;
  --gap: 12px;
  --ease: cubic-bezier(.1, .9, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0C10;
    --surface: #15171D;
    --surface-2: #1C1F26;
    --text: #F4F6FA;
    --text-2: #D0D5DF;
    --text-muted: #9AA2B2;
    --line: #262A33;
    --line-strong: #3A3F4A;

    --blue: #2F6BFF;
    --blue-press: #4A7EFF;
    --violet: #7B44EC;
    --cyan: #20C4E4;
    --cyan-text: #5FDCF3;
    --graphite: #22262F;
    --accent-text: #8EABFF;
    --accent-soft: #18213D;

    --ok: #5FDCF3;      --ok-bg: #0D2A31;
    --warn: #FF8DB3;    --warn-bg: #33121E;
    --info: #8EABFF;    --info-bg: #18213D;
    --danger: #FF8A8A;  --danger-bg: #351313;
    --muted-tone: #B3BACB; --muted-bg: #1F2229;
    --perfect: #C4A8FF; --perfect-bg: #221A3B;

    --s1: #6E95FF;
    --s2: #B18CFF;
    --s3: #3FD6F2;
    --s4: #FF7BAA;

    --glass: rgb(11 12 16 / 78%);
    --glass-line: rgb(255 255 255 / 9%);
    --focus: #8EABFF;
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-family: var(--font-display); color: var(--text); text-wrap: balance; }
h1 { font-size: clamp(2rem, 8vw, 3rem); font-weight: 300; line-height: 1.08; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 400; line-height: 1.2; letter-spacing: -0.005em; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent-text); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 14px; margin: 0; font-family: ui-monospace, Consolas, "SF Mono", Menlo, monospace; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -80px; z-index: 60;
  background: var(--blue); color: #fff; padding: 12px 16px; border-radius: var(--r-ctl);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: calc(12px + env(safe-area-inset-top)); }

.wrap {
  width: 100%; max-width: 1120px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
@media (min-width: 900px) { .wrap { padding-left: 32px; padding-right: 32px; } }

/* ---------- Top bar (translucent, iOS-like) ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: env(safe-area-inset-top);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  border-bottom: 1px solid var(--glass-line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; min-width: 0; min-height: 44px; }
.brand-mark {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-tile);
  background: var(--blue); color: #fff; font-family: var(--font-num); font-weight: 700; font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 600; font-size: 16px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tag { font-size: 14px; color: var(--text-muted); white-space: nowrap; }
@media (max-width: 360px) { .brand-tag { display: none; } }

.userbox { display: flex; align-items: center; gap: 8px; flex: none; }
.userbox .who { font-size: 14px; color: var(--text-muted); display: none; }
.userbox .who strong { color: var(--text); font-weight: 600; }
.userbox .btn { min-height: 44px; padding: 8px 12px; font-size: 15px; background: transparent; border-color: transparent; color: var(--accent-text); }
.userbox .btn:hover { background: var(--accent-soft); }
@media (min-width: 640px) { .userbox .who { display: inline; } }

/* ---------- Navigation: translucent bar, Metro accent rule on the selected item ---------- */

.tabs {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  border-top: 1px solid var(--glass-line);
}
.tabs-inner { display: flex; gap: 0; max-width: 560px; }
.tab {
  position: relative; flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabbar-h); min-width: 44px;
  text-decoration: none; color: var(--text-muted);
  font-size: 14px; font-weight: 600;
  transition: color .15s var(--ease), background-color .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tab::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  background: var(--blue); transform: scaleX(0); transition: transform .2s var(--ease);
}
.tab-icon { display: grid; place-items: center; width: 28px; height: 28px; }
.tab-svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab-label { font-size: 14px; line-height: 1.1; }
.tab:hover { color: var(--text); }
.tab:active { background: var(--surface-2); }
.tab[aria-current="page"] { color: var(--blue); }
.tab[aria-current="page"]::before { transform: scaleX(1); }
.tab[aria-current="page"] .tab-svg { stroke-width: 2.2; }

@media (min-width: 900px) {
  .tabs { position: sticky; top: calc(57px + env(safe-area-inset-top)); bottom: auto; padding-bottom: 0; border-top: 0; border-bottom: 1px solid var(--glass-line); }
  .tabs-inner { max-width: 1120px; justify-content: flex-start; gap: 28px; }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 8px; min-height: 52px; padding: 0 2px; font-size: 18px; font-weight: 400; }
  .tab-label { font-size: 18px; }
  .tab-icon { display: none; }
  .tab::before { top: auto; bottom: -1px; left: 0; right: 0; }
  .tab[aria-current="page"] { color: var(--text); font-weight: 600; }
}

.main {
  padding-top: 24px;
  padding-bottom: calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  outline: none;
}
@media (min-width: 900px) { .main { padding-top: 32px; padding-bottom: 64px; } }

/* ---------- Layout ---------- */

.stack { display: grid; gap: 24px; }
.stack-lg { gap: 32px; }
.stack-sm { display: grid; gap: 10px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

.round-grid { display: grid; gap: 24px; }
.round-grid > .col { display: grid; gap: 24px; min-width: 0; align-content: start; }
@media (min-width: 900px) { .round-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 32px; align-items: start; } }

.page-head { display: grid; gap: 8px; }
.page-head p { color: var(--text-muted); max-width: 60ch; }

/* ---------- Panels (content blocks; flat, crisp) ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-tile);
  padding: 20px;
  min-width: 0;
}
@media (min-width: 640px) { .card { padding: 24px; } }
.card > * + * { margin-top: 14px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-muted { background: transparent; }

.eyebrow { font-size: 14px; font-weight: 600; color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.meta { font-size: 14px; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.small { font-size: 14px; }

/* ---------- Round summary: Metro tiles ---------- */

.round-summary { display: grid; gap: 20px; }
.round-head { display: grid; gap: 6px; }
.round-title { font-size: clamp(2.1rem, 9vw, 3.25rem); }

.tiles {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas: "score points" "deadline deadline";
}
@media (min-width: 720px) {
  .tiles { grid-template-columns: 2fr 1fr 1.6fr; grid-template-areas: "score points deadline"; }
}
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  min-height: 140px; padding: 14px 16px 16px; border-radius: var(--r-tile);
  color: var(--on-tile); min-width: 0; overflow: hidden;
  animation: tile-in .45s var(--ease) both;
}
.tile-score { grid-area: score; background: var(--blue); }
.tile-score.is-perfect { background: var(--violet); }
.tile-points { grid-area: points; background: var(--violet); animation-delay: .04s; }
.tile-deadline { grid-area: deadline; background: var(--graphite); animation-delay: .08s; min-height: 112px; }
@media (prefers-color-scheme: dark) { .tile-deadline { border: 1px solid var(--line-strong); } }
.tile-label { font-size: 14px; font-weight: 600; color: var(--on-tile-2); line-height: 1.25; }
.tile-value {
  font-family: var(--font-num); font-weight: 700; line-height: .95; letter-spacing: -0.03em;
  font-size: clamp(2.6rem, 13vw, 4rem); font-variant-numeric: tabular-nums; color: var(--on-tile);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-points .tile-value { font-size: clamp(2rem, 9vw, 3rem); }
.tile-deadline .tile-value { font-size: clamp(2rem, 10vw, 3rem); }
.tile-sub { font-size: 14px; color: var(--on-tile-2); line-height: 1.3; }
.tile-bar { display: block; height: 4px; background: rgb(255 255 255 / 25%); }
.tile-bar-fill { display: block; height: 100%; background: var(--cyan); transform-origin: left; animation: bar-in .8s var(--ease) both .1s; }
@media (prefers-color-scheme: light) { .tile-bar-fill { background: #7FE7FA; } }
@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bar-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.round-action { display: grid; gap: 12px; justify-items: start; }
.round-action .btn-big { width: 100%; }
@media (min-width: 640px) { .round-action .btn-big { width: auto; min-width: 280px; } }
.my-status { font-size: 16px; color: var(--text-2); }
.my-status strong { color: var(--text); font-weight: 600; }
.quip { font-size: 14px; color: var(--text-muted); }
.rules-line { font-size: 14px; color: var(--text-muted); max-width: 70ch; }

/* ---------- Buttons (Material feedback, 6px corners) ---------- */

.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 11px 18px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; font-weight: 600; line-height: 1.2;
  text-decoration: none; text-align: center; cursor: pointer; overflow: hidden;
  transition: background-color .12s var(--ease), border-color .12s var(--ease), transform .08s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity .12s var(--ease); pointer-events: none; }
.btn:hover::after { opacity: .06; }
.btn:active::after { opacity: .14; }
.btn:active { transform: scale(.985); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn[disabled]::after { opacity: 0; }

.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-big { min-height: 52px; font-size: 17px; padding-left: 24px; padding-right: 24px; }
.btn-block { width: 100%; }
.btn-secondary { background: var(--surface); color: var(--accent-text); border-color: var(--line-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent-text); padding-left: 10px; padding-right: 10px; }
.btn-quiet-danger { background: transparent; color: var(--danger); border-color: var(--line-strong); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions .btn { flex: 1 1 auto; }
@media (min-width: 640px) { .actions .btn { flex: 0 0 auto; } }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 2px;
  font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  background: var(--muted-bg); color: var(--muted-tone);
}
.badge.tone-ok, .notice.tone-ok { background: var(--ok-bg); color: var(--ok); }
.badge.tone-warn, .notice.tone-warn { background: var(--warn-bg); color: var(--warn); }
.badge.tone-info, .notice.tone-info { background: var(--info-bg); color: var(--info); }
.badge.tone-danger, .notice.tone-danger { background: var(--danger-bg); color: var(--danger); }
.badge.tone-gold, .badge.tone-violet { background: var(--perfect-bg); color: var(--perfect); }
.badge.tone-muted { background: var(--muted-bg); color: var(--muted-tone); }

/* ---------- Rings (avatars only; flat strokes, no gradient) ---------- */

.ring-wrap { position: relative; display: inline-grid; place-items: center; width: var(--ring-size); height: var(--ring-size); flex: none; }
.ring { display: block; overflow: visible; }
.ring-track { stroke: var(--surface-2); }
.ring-track.is-dashed { stroke: var(--line-strong); stroke-dasharray: 2 6; stroke-linecap: round; }
.ring-stop-a, .ring-stop-b { stop-color: var(--blue); }
.ring-perfect .ring-stop-a, .ring-perfect .ring-stop-b { stop-color: var(--violet); }
.ring-progress { animation: ring-fill .8s var(--ease) both; }
@keyframes ring-fill { from { stroke-dashoffset: var(--ring-c); } }
.ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }

/* ---------- Check-ins (left-aligned list) ---------- */

.checkins { display: grid; gap: 0; list-style: none; padding: 0; margin: 0; }
.checkin {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; column-gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0;
}
.checkin:first-child { border-top: 0; padding-top: 4px; }
.checkin-who { display: grid; gap: 2px; min-width: 0; }
.checkin-name { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checkin-away { font-size: 14px; color: var(--text-muted); }
.checkin-status { font-size: 14px; font-weight: 600; color: var(--text-muted); text-align: right; }
.checkin.is-me .checkin-name::after { content: " · tu"; font-weight: 400; color: var(--text-muted); font-size: 14px; }
.avatar { position: relative; display: inline-grid; }
.avatar .ring-center { font-family: var(--font-num); font-weight: 700; font-size: 17px; color: var(--text); }
.avatar .mark {
  position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--surface-2); color: var(--muted-tone); box-shadow: 0 0 0 2px var(--surface);
}
.checkin.tone-ok .mark { background: var(--blue); color: #fff; }
.checkin.tone-ok .checkin-status { color: var(--accent-text); }
.checkin.tone-info .mark { background: var(--cyan); color: #fff; }
.checkin.tone-info .checkin-status { color: var(--cyan-text); }
.checkin.tone-gold .mark { background: var(--violet); color: #fff; }
.checkin.tone-gold .checkin-status { color: var(--perfect); }
.checkin.tone-warn .mark { background: var(--warn-bg); color: var(--warn); }
.checkin.tone-warn .checkin-status { color: var(--warn); }
.checkin.pop .avatar { animation: pop .35s var(--ease) both; }
@keyframes pop { from { transform: scale(.9); } to { transform: scale(1); } }

/* ---------- Podium ---------- */

.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.podium.count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 380px; }
.podium-slot { display: grid; justify-items: start; gap: 2px; min-width: 0; }
.podium-medal { font-size: 15px; line-height: 1; }
.podium-name { font-weight: 600; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-points { font-family: var(--font-num); font-weight: 700; font-size: 26px; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin-bottom: 6px; }
.podium-block {
  width: 100%; border-radius: var(--r-tile) var(--r-tile) 0 0; display: flex; align-items: flex-end; padding: 6px 8px;
  font-family: var(--font-num); font-weight: 300; font-size: 26px; color: #fff; line-height: 1;
  transform-origin: bottom; animation: rise .5s var(--ease) both;
}
.rank-1 .podium-block { height: 76px; background: var(--blue); }
.rank-2 .podium-block { height: 56px; background: var(--violet); animation-delay: .04s; }
.rank-3 .podium-block { height: 40px; background: var(--cyan); animation-delay: .08s; }
@keyframes rise { from { transform: scaleY(.2); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }

.podium-empty { color: var(--text-muted); font-size: 15px; }
.side-badges { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.perfect { display: flex; align-items: center; gap: 8px; color: var(--perfect); font-weight: 600; font-size: 14px; }

/* ---------- Outcome & meetup ---------- */

.outcome { border-left: 4px solid var(--blue); }
.outcome.kind-pending { border-left-color: var(--line-strong); }
.outcome.kind-own { border-left-color: var(--cyan); }
.outcome.kind-cancelled { border-left-color: var(--line-strong); }
.outcome-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 300; letter-spacing: -0.01em; line-height: 1.2; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 10px; border-radius: 2px; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; font-size: 14px; }

.meetup-cancelled { background: var(--surface); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0 0; }
.away-list { font-size: 15px; color: var(--text-2); }

/* ---------- Disclosure ---------- */

details.card > summary, details.fold > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; font-weight: 600; font-size: 16px;
}
details.card { padding-top: 10px; padding-bottom: 10px; }
details.card[open] { padding-bottom: 20px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; font-size: 22px; font-weight: 300; color: var(--text-muted); line-height: 1; width: 16px; text-align: center; }
details[open] > summary::after { content: "−"; }

.formula { font-size: 14px; color: var(--text-2); font-family: ui-monospace, Consolas, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
.explain-list { list-style: none; margin: 0; padding: 0; }
.explain-item { display: grid; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Forms ---------- */

.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label, fieldset > legend { font-size: 14px; font-weight: 600; color: var(--text-2); }
.help { font-size: 14px; color: var(--text-muted); }
.input, .select select, textarea.input {
  width: 100%; min-height: 46px; padding: 11px 12px; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
textarea.input { min-height: 84px; resize: vertical; }
.input:hover, .select select:hover { border-color: var(--text-muted); }
.input:focus, .select select:focus { outline: none; border-color: var(--blue); box-shadow: inset 0 -2px 0 var(--blue); }
.input-score { font-family: var(--font-num); font-size: 30px; font-weight: 700; max-width: 160px; font-variant-numeric: tabular-nums; }

.select { position: relative; display: block; }
.select select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.select::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg); pointer-events: none;
}

.unit-input { position: relative; display: block; }
.unit-input .input { padding-right: 60px; }
.unit-input .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--text-muted); pointer-events: none; }

fieldset { border: 0; padding: 16px 0 0; margin: 0; min-width: 0; border-top: 1px solid var(--line); }
fieldset > legend { float: left; width: 100%; padding: 0; margin-bottom: 4px; }
fieldset > legend + * { clear: both; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 12px; }

.check { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }

.file-drop {
  position: relative; display: grid; justify-items: start; gap: 4px; padding: 22px 18px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-ctl); cursor: pointer;
  transition: border-color .12s var(--ease), background-color .12s var(--ease);
}
.file-drop:hover { border-color: var(--blue); background: var(--accent-soft); }
.file-drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-drop strong { color: var(--accent-text); font-size: 18px; font-weight: 600; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.review-grid { display: grid; gap: 24px; }
@media (min-width: 860px) { .review-grid.has-preview { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); align-items: start; } }
.preview { margin: 0; border-radius: var(--r-tile); overflow: hidden; border: 1px solid var(--line); }
.preview img { width: 100%; max-height: 70vh; object-fit: contain; background: var(--surface-2); }
.preview figcaption { font-size: 14px; color: var(--text-muted); padding: 8px 10px; overflow-wrap: anywhere; }
@media (min-width: 860px) { .preview { position: sticky; top: calc(124px + env(safe-area-inset-top)); } }

.notice { padding: 10px 12px; border-radius: var(--r-tile); font-size: 15px; border-left: 3px solid currentColor; }
.timestamps { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Charts ---------- */

.chart-controls { display: grid; gap: 12px; }
@media (min-width: 560px) { .chart-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chart { width: 100%; min-height: 240px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-size: 14px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .unit-label { font-size: 14px; font-weight: 600; fill: var(--text-2); }
.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .s1 { stroke: var(--s1); } .chart .dot.s1 { fill: var(--s1); }
.chart .s2 { stroke: var(--s2); } .chart .dot.s2 { fill: var(--s2); }
.chart .s3 { stroke: var(--s3); } .chart .dot.s3 { fill: var(--s3); }
.chart .s4 { stroke: var(--s4); } .chart .dot.s4 { fill: var(--s4); }
.chart .dot.s1, .chart .dot.s2, .chart .dot.s3, .chart .dot.s4 { stroke: var(--surface); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; padding: 0; margin: 0; font-size: 14px; }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend .sw { width: 12px; height: 12px; border-radius: 1px; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); } .sw.s3 { background: var(--s3); } .sw.s4 { background: var(--s4); }

.latest { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.latest-item { display: grid; gap: 2px; padding: 4px 16px; border-left: 1px solid var(--line); }
.latest-item:first-child { border-left: 0; padding-left: 0; }
.latest-value { font-family: var(--font-num); font-weight: 700; font-size: 32px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--text-muted); }
tbody tr:last-child td { border-bottom: 0; }

/* ---------- History ---------- */

.round-list { list-style: none; margin: 0; padding: 0; }
.round-item { display: grid; gap: 4px; padding: 14px 0; border-top: 1px solid var(--line); }
.round-item:first-child { border-top: 0; padding-top: 4px; }
.measure-list { list-style: none; margin: 0; padding: 0; }
.measure { display: grid; gap: 10px; padding: 18px 0; border-top: 1px solid var(--line); }
.measure-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.measure-score { text-align: right; }
.measure-score .value { font-family: var(--font-num); font-weight: 700; font-size: 34px; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--accent-text); }
.measure-score .cap { font-size: 14px; color: var(--text-muted); }
.metric-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 6px 24px; margin: 0; font-size: 14px; }
.metric-dl div { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.metric-dl dt { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-dl dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Gate / empty ---------- */

.gate { max-width: 440px; margin: 40px 0; display: grid; gap: 16px; justify-items: start; padding: 28px 24px; }
.gate > * + * { margin-top: 0; }
.gate-title { font-family: var(--font-display); font-size: 2.25rem; font-weight: 300; letter-spacing: -0.02em; line-height: 1.1; }
.gate .btn { min-width: 220px; }
.empty { padding: 16px 0; color: var(--text-muted); display: grid; gap: 4px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  max-width: min(520px, calc(100vw - 32px)); width: max-content;
  padding: 12px 16px; border-radius: var(--r-tile); font-weight: 600; font-size: 15px;
  background: var(--graphite); color: #fff; border-left: 4px solid var(--blue);
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
  animation: toast-in .25s var(--ease) both;
}
.toast.tone-error { border-left-color: #FF6B6B; }
@media (min-width: 900px) { .toast { bottom: 28px; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

body.is-busy { cursor: progress; }

/* Page entrance: short Metro-style slide from the right */
.main > * { animation: view-in .3s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar, .tabs { background: var(--surface); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .tabs { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

@media print {
  .topbar, .tabs, .toast, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}
