/* Inter, self-hosted so the PWA never falls back to the system font when the
   phone can't reach Google's servers — same files and rationale as the rest
   of the Trek family (see KeyTrek). One static woff2 per weight. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/inter-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/inter-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/inter-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/inter-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/static/fonts/inter-800.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* RideTrek — visual language inherited from the Trek family (BookTrek/
   MoneyTrek/TripTrek/KeyTrek): neutral canvas, white bordered cards, quiet
   compact type, fixed standard topbar, one restrained accent per app.
   RideTrek's accent is a road-sign blue. Tap targets on the mid-ride
   controls (battery cells, PAS, save) stay glove-sized — functional. */

:root {
  color-scheme: light;
  --bg: #f8f9fa;
  --bg-gradient: none;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --accent: #0b6bcb;
  --accent-dark: #075985;
  --accent-soft: #e0f2fe;
  --accent-grad: linear-gradient(135deg, #0b6bcb, #0e87ae);
  --sub: #475569;
  --danger: #b3261e;
  --ok: #047857;
  --track: #eef2f6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --content-max: 34rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #151719;
    --bg-gradient: radial-gradient(circle at 15% 0%, #1d2427 0%, #151719 40%);
    --card: #22282b;
    --text: #edf1ef;
    --muted: #93a09b;
    --border: #3b4649;
    --border-soft: #2b3336;
    --accent: #63b3f5;
    --accent-dark: #7dd3fc;
    --accent-soft: #0c3149;
    --accent-grad: linear-gradient(135deg, #2178c9, #0e87ae);
    --sub: #b4c0bb;
    --danger: #f2a8a2;
    --ok: #6ee7b7;
    --track: #2b3336;
    --shadow-sm: none;
    --shadow-md: none;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: calc(3.6rem + env(safe-area-inset-top)) 1rem calc(5.5rem + env(safe-area-inset-bottom));
}

.placeholder {
  color: var(--muted);
  text-align: center;
  margin-top: 3rem;
  font-size: 0.92rem;
}

/* --- topbar: fixed, standard family height, covers the status-bar area ---- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 15;
  background: var(--card);
  border-bottom: 1px solid var(--border-soft);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  height: 2.9rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.wordmark-trek { color: var(--accent); }

.wordmark-bike { margin-left: 0.25rem; font-size: 0.95rem; }

/* Who's signed in — initial circle beside the wordmark, family pattern. */
.user-initial {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-left: auto;
  margin-right: 0.6rem;
}

@media (prefers-color-scheme: dark) {
  .user-initial { color: var(--accent-dark); }
}

.topbar-actions { display: flex; align-items: center; gap: 0.55rem; }

.topbar-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  color: var(--muted);
  border-radius: 8px;
}

.topbar-gear.on { color: var(--accent); }

.topbar-gear svg { width: 1.15rem; height: 1.15rem; }

.topbar-signout {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
}

/* --- auth (login / totp / setup) ------------------------------------------ */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 24rem;
  padding: 1.4rem 1.3rem;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.auth-card label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0.8rem 0 0.25rem;
}

.auth-card input { width: 100%; }

.auth-card input#code {
  font-size: 1.3rem;
  letter-spacing: 0.35em;
  text-align: center;
}

.auth-title { margin-bottom: 0.3rem; }
.auth-title .wordmark { font-size: 1.3rem; }

.auth-subtitle { color: var(--sub); font-size: 0.9rem; margin: 0 0 1rem; }
.auth-subtitle.small { font-size: 0.78rem; margin: 0.4rem 0 0; line-height: 1.45; }

.auth-error {
  background: rgba(179, 38, 30, 0.08);
  color: var(--danger);
  border: 1px solid rgba(179, 38, 30, 0.25);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  font-size: 0.85rem;
}

.check-label input { width: auto; }

.submit-row { margin-top: 1.2rem; }
.submit-row .btn-primary { width: 100%; }

.btn-primary {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 11px;
  background: var(--accent-grad);
  color: #fff;
  min-height: 46px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.totp-qr {
  display: block;
  margin: 0 auto 0.6rem;
  border-radius: 12px;
  max-width: 200px;
  width: 100%;
  background: #fff;
  padding: 8px;
}

/* --- tab bar --------------------------------------------------------------- */

#tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border-soft);
  padding: 0.25rem 0.3rem calc(0.25rem + env(safe-area-inset-bottom));
  gap: 0.2rem;
}

#tabbar .tab {
  flex: 1;
  min-height: 48px;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
}

#tabbar .tab svg {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}

#tabbar .tab[aria-current="page"] { color: var(--accent); }

.nav-fab {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  align-self: center;
  text-decoration: none;
  transform: translateY(-17px);
  box-shadow: 0 0 0 4px var(--card), 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease;
}

.nav-fab:active { transform: translateY(-17px) scale(0.95); }

.nav-fab svg { width: 24px; height: 24px; }

@media (prefers-color-scheme: dark) {
  .nav-fab {
    background: #f1f5f9;
    color: #020617;
    box-shadow: 0 0 0 4px var(--card), 0 6px 16px rgba(0, 0, 0, 0.5);
  }
}

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

.card,
.insight-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.9rem;
}

.card-title,
.insight-card h2 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.55rem;
}

.live-line {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.live-line:empty { display: none; }

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

.row {
  display: flex;
  gap: 0.6rem;
}

.row .field { flex: 1; min-width: 0; }

.field { margin-bottom: 0.55rem; }

label, .field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.45rem 0.6rem;
  min-height: 2.35rem;
  min-width: 0;
}

input::placeholder { color: var(--muted); opacity: 0.75; }

/* The family's standard iOS date-input fix (same quirk BookTrek hit): strip
   the native appearance so the explicit height matches sibling fields. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  height: 2.35rem;
  line-height: 2.35rem;
  padding-top: 0;
  padding-bottom: 0;
  text-align: left;
  overflow: hidden;
}

input[type="date"]::-webkit-date-and-time-value { text-align: left; }

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

/* Inline unit badge inside an input ("mi" / "Wh"). */
.suffix-wrap { position: relative; }

.suffix-wrap input { padding-right: 2.2rem; }

.suffix-wrap .suffix {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
}

/* --- segmented controls ----------------------------------------------------
   Connected strip on a shared muted track. Kept tall enough for gloves. */

.segments {
  display: flex;
  gap: 2px;
  background: var(--track);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
}

.segments button {
  flex: 1;
  min-height: 40px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.segments button:hover:not(.selected) { background: rgba(127, 127, 127, 0.08); }

.segments button.selected {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Battery cells: tapping a level fills every cell up to it, like the bars
   on the handlebar display. Ghost charge tints + the cap nub make it read
   as a battery gauge before anything is tapped. */
.battery-cells {
  position: relative;
  margin-right: 8px; /* room for the battery cap */
}

.battery-cells::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 32%;
  height: 36%;
  width: 5px;
  background: var(--border);
  border-radius: 0 3px 3px 0;
}

.battery-cells button {
  min-height: 40px;
  border: 1px solid rgba(127, 127, 127, 0.10);
  font-weight: 700;
}

.battery-cells button[data-value="1"] { background: rgba(224, 79, 22, 0.10); }
.battery-cells button[data-value="2"] { background: rgba(220, 138, 6, 0.10); }
.battery-cells button[data-value="3"] { background: rgba(143, 168, 10, 0.12); }
.battery-cells button[data-value="4"] { background: rgba(63, 156, 37, 0.12); }
.battery-cells button[data-value="5"] { background: rgba(22, 163, 74, 0.14); }

.battery-cells[data-level="1"] button.filled { background: #e04f16; color: #fff; }
.battery-cells[data-level="2"] button.filled { background: #dc8a06; color: #fff; }
.battery-cells[data-level="3"] button.filled { background: #8fa80a; color: #fff; }
.battery-cells[data-level="4"] button.filled { background: #3f9c25; color: #fff; }
.battery-cells[data-level="5"] button.filled { background: #16a34a; color: #fff; }

.battery-cells button.selected,
.battery-cells button.filled.selected {
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* PAS: same strip, with power badges. */
.pas-buttons {
  display: flex;
  gap: 2px;
  background: var(--track);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
}

.pas-buttons .pas {
  flex: 1;
  min-height: 44px;
  font: inherit;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}

.pas-buttons .pas:hover:not(.selected) { background: rgba(127, 127, 127, 0.08); }

.pas-buttons .pas b { font-size: 0.95rem; font-weight: 700; }

.pas-buttons .pas small {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pas-buttons .pas.selected {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.pas-buttons .pas.selected small { color: rgba(255, 255, 255, 0.85); }

/* --- context chips ---------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0.45rem;
}

.chip {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}

.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .chip.on { color: var(--accent-dark); }
}

/* --- save button, errors, toast -------------------------------------------- */

#save-btn {
  width: 100%;
  min-height: 46px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 11px;
  background: var(--accent-grad);
  color: #fff;
  cursor: pointer;
  margin-top: 0.1rem;
  box-shadow: var(--shadow-md);
}

#save-btn:active { transform: translateY(1px); }

#form-error {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.5rem 0;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(5rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ok);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  z-index: 30;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

@media (prefers-color-scheme: dark) {
  #toast { color: #06281c; }
}

/* --- home dashboard ---------------------------------------------------------- */

.stat-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.stat-tile {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 0.85rem 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* The daily nudge is a pill badge, not loose body text between cards. */
.home-nudge-row { margin: 0 0 0.9rem; }

.home-nudge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}

@media (prefers-color-scheme: dark) {
  .home-nudge { color: var(--accent-dark); }
}

.home-lede { font-size: 0.9rem; margin: 0; }

.weather-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.weather-emoji { font-size: 1.7rem; line-height: 1; }

.weather-main { display: flex; flex-direction: column; gap: 0.1rem; }

.weather-words { font-size: 0.95rem; font-weight: 700; }

.weather-detail { font-size: 0.78rem; color: var(--sub); }

/* Verdict as a separated footer note under the reading. */
.weather-note {
  margin: 0.65rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 0.78rem;
}

.home-recent { margin-bottom: 0.2rem; }

.home-recent .history-row {
  border: none;
  box-shadow: none;
  border-radius: 10px;
  min-height: 44px;
  margin-bottom: 0;
  padding: 0.4rem 0.3rem;
  border-top: 1px solid var(--border-soft);
}

.home-recent li:first-child .history-row { border-top: none; }

.mini-pill {
  display: inline-block;
  background: var(--track);
  color: var(--sub);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.16rem 0.5rem;
}

/* Range-verdict progress module — the dashboard's second act. */
.goal-card { display: block; text-decoration: none; color: var(--text); }

.goal-text { font-size: 0.88rem; line-height: 1.45; margin: 0; }

.goal-progress {
  height: 8px;
  background: var(--track);
  border-radius: 4px;
  margin-top: 0.6rem;
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  background: var(--accent-grad);
  border-radius: 4px;
}

.goal-sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.all-rides-link {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-top: 0.3rem;
}

.basis a { color: var(--accent); font-weight: 600; }

/* --- history ---------------------------------------------------------------- */

.history-head,
.history-row {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr 1fr 1fr;
  gap: 0.4rem;
  align-items: center;
}

.history-head {
  padding: 0.2rem 0.75rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-row {
  text-decoration: none;
  width: 100%;
  min-height: 50px;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.5rem;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.history-row .num { font-variant-numeric: tabular-nums; }

.history-row .date { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.history-row .err-over { color: var(--danger); font-weight: 600; }
.history-row .err-under { color: var(--ok); font-weight: 600; }

/* A ride that absorbed an unlogged gap: visibly marked, clearly "not counted". */
.history-row.gap { opacity: 0.6; }

.baseline-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gap-badge {
  display: inline-block;
  font-size: 0.64rem;
  font-weight: 700;
  color: #fff;
  background: #b45309;
  border-radius: 6px;
  padding: 0.14rem 0.4rem;
}

/* --- insights ---------------------------------------------------------------- */

#insight-headline-card {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-md);
}

#insight-headline {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
}

#insight-headline-card .basis { color: rgba(255, 255, 255, 0.85); }

.basis {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0.5rem 0 0;
}

#insight-progress {
  height: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  margin-top: 0.7rem;
  overflow: hidden;
}

#insight-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 4px;
}

#insight-wh-overall {
  font-size: 0.92rem;
  margin: 0 0 0.5rem;
}

.pas-stat {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border-soft);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.pas-stat .lvl { font-weight: 600; }
.pas-stat .val { color: var(--muted); }

/* --- settings ---------------------------------------------------------------- */

.capacity-row { align-items: flex-start; }

.data-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  margin: 0 0 0.7rem;
}

@media (prefers-color-scheme: dark) {
  .data-status { color: var(--accent-dark); }
}

.data-actions {
  display: flex;
  gap: 0.6rem;
}

.data-actions .action-form { flex: 1; display: flex; }

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}

.action-btn svg { width: 16px; height: 16px; }

.action-btn:hover { border-color: var(--accent); color: var(--accent); }

.helper {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
  margin: 0.6rem 0 0;
}

.quiet-btn, .danger-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  min-height: 40px;
  flex: 1;
}

.quiet-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}

.quiet-btn.block {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
}

.capacity-row .capacity-save,
.capacity-row .quiet-btn {
  flex: 0 0 auto;
  min-width: 5rem;
  min-height: 2.35rem;
}

.danger-btn {
  border: 1px solid rgba(179, 38, 30, 0.4);
  background: var(--card);
  color: var(--danger);
}

.linkbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}

#mode-buttons button { font-size: 0.85rem; }

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.6rem 0 0;
}

/* --- edit mode extras -------------------------------------------------------- */

.gap-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  margin: 0.8rem 0;
}

.gap-toggle input {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  accent-color: var(--accent);
}

/* --- modals ------------------------------------------------------------------ */

.overlay[hidden] { display: none; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 30, 0.5);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  max-width: 24rem;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal p:first-child {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;
  margin-top: 0;
}

#modal-detail, #confirm-detail { color: var(--muted); font-size: 0.85rem; }

.modal button {
  display: block;
  width: 100%;
  min-height: 44px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent-grad);
  color: #fff;
  cursor: pointer;
  margin-top: 0.55rem;
}

.modal button.quiet {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.modal button.danger-fill { background: #b3261e; }

/* --- pull-to-refresh indicator (family pattern from KeyTrek) ----------------- */

.pull-refresh {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  --pull: 0px;
  transform: translate(-50%, calc(-46px + var(--pull)));
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 220;
  opacity: 0;
  pointer-events: none;
}

.pull-refresh.active { opacity: 1; }
.pull-refresh.settling { transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease; }
.pull-refresh.refreshing { opacity: 1; }

.pull-refresh-spin {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.pull-refresh.ready .pull-refresh-spin { transform: rotate(180deg); border-top-color: var(--accent-dark); }
.pull-refresh.refreshing .pull-refresh-spin { animation: pull-refresh-spin 0.7s linear infinite; }
@keyframes pull-refresh-spin { to { transform: rotate(360deg); } }
