/* ==========================================================================
   Design tokens ported from mattgrindsgerman.de so the two apps match.
   ========================================================================== */

@font-face {
  font-family: 'Aldrich';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/aldrich-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Code Pro';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/scp-latin.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: 'Source Code Pro';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/scp-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --sky: #daecff;
  --sky-2: #c5def5;
  --win: linear-gradient(90deg, #fafbfb 0%, #f7f7f7 50%, #fafbfb 100%);
  --inner: linear-gradient(90deg, #fff 0%, #fafafb 50%, #fff 100%);
  --border: #c9c9c9;
  --text: #5a6573;
  --muted: #9da7b3;
  --accent: #74a4db;
  --accent-hot: #81a1c8;
  --accent-soft: #93bdec;
  --good: #6aa88a;
  --good-dim: #6aa88a24;
  --bad: #d36a6a;
  --bad-dim: #d36a6a24;
  --warn: #c8a06a;
  --warn-dim: #c8a06a24;
  --gold: #74a4db;
  --gold-dim: #74a4db24;
  --line: #d5dbe3;
  --font-ui: Aldrich, 'Segoe UI', Verdana, sans-serif;
  --font-mono: 'Source Code Pro', Consolas, monospace;
  --radius: 22px;
  --fade: 0.18s ease;
  --tap: 48px;
}

* { box-sizing: border-box; }

html, body, #root { height: 100dvh; max-height: 100dvh; overflow: hidden; }
html { scrollbar-color: #b8c7d8 #eef5fc; scrollbar-width: thin; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
::selection { color: #fff; background: #8bb4ff; }
button, input, select, textarea, a { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

/* Drifting sky background, same treatment as the German app. */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(50% 40% at 20% 10%, #ffffffd9, transparent 60%),
    radial-gradient(40% 50% at 80% 80%, #8bb4ff59, transparent 60%),
    var(--sky);
  animation: sky-drift 18s ease-in-out infinite alternate;
}
@keyframes sky-drift {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(12deg); }
}

/* ==========================================================================
   Shell
   ========================================================================== */

.desktop {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100%;
  max-height: 100dvh;
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  grid-template-columns: 168px minmax(0, 1fr) 190px;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
}

.win {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background-image: var(--win);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: inset 0 -5px 5px -4px #dadada, 0 0 8px #d5e4f3;
}

.win-toolbar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 3px #5670a0;
  background: linear-gradient(90deg, #8bb4ff 0%, #e2fafb 78%, transparent 100%);
}
.win-toolbar-end { display: flex; align-items: center; gap: 8px; }
.win-x {
  width: 14px;
  height: 14px;
  border: 1px solid #c9c9c9;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #d7dde6 55%, #b8c0cb);
  box-shadow: inset 0 -1px 1px #fff;
}
.win-footer {
  flex: none;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid #e4e8ee;
}
.sfx-toggle {
  min-height: 0;
  padding: 0 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: lowercase;
  color: #fff;
  text-shadow: 0 0 3px #5670a0;
  background: none;
  border: none;
  box-shadow: none;
}

.navi, .dock, .main-win { min-width: 0; height: 100%; }
.navi-brand { padding: 10px 12px 4px; }
.navi-title {
  font-size: 26px;
  line-height: 0.9;
  letter-spacing: 2px;
  color: transparent;
  background: linear-gradient(#a7d5ff 45%, #81a1c8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  transform: scaleY(0.85);
  transform-origin: 0 0;
}
.navi-sub { margin-top: 2px; font-size: 13px; letter-spacing: 3px; color: #c9cfd6; }
.navi-links { display: flex; flex-direction: column; padding: 6px 14px 8px; }
.navi-links button {
  display: block;
  width: 100%;
  padding: 9px 4px;
  text-align: right;
  letter-spacing: 1px;
  color: #9da7b3;
  background: none;
  border: none;
  border-top: 1px solid transparent;
  box-shadow: 0 -1px #e3e8ef;
}
.navi-links button.active, .navi-links button:hover { color: #81a1c8; }
.navi-credit { margin-top: auto; padding: 8px 12px 12px; font-size: 10px; color: var(--muted); }

.dock-inner { padding: 14px 14px 16px; font-size: 13px; overflow: auto; }
.dock-inner p { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.dock-inner b { color: var(--accent-hot); }
.dock-h { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-soft); }

main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}
/* The gym pane scrolls, unlike the German app's fixed screens. */
.pane { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.pane-actions { display: flex; flex: none; flex-direction: column; gap: 8px; }
.pane-actions > button { width: 100%; }

/* ==========================================================================
   Surfaces and type
   ========================================================================== */

.card, .stat, .option, .text-input, select.text-input, .remember, .example,
.install-banner, .food-row, .set-row, .move-card, .insight {
  background-image: var(--inner);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  box-shadow: inset 0 0 5px #cacaca, 0 -3px 5px -3px #bbb, 0 4px 1px -3px #fff;
}
.card { padding: 14px; margin-bottom: 10px; }
.card:last-child { margin-bottom: 0; }

.page-title {
  margin: 0 0 6px;
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  line-height: 1.2;
  letter-spacing: 0.5px;
  color: #6d7a88;
}
.page-title.tight { margin-bottom: 2px; }
h2.sec-title { margin: 0 0 8px; font-size: 1rem; color: var(--accent-hot); }
h3.sub-title { margin: 0 0 6px; font-size: 0.95rem; color: var(--accent-hot); }
.lede { margin: 0 0 6px; color: #7b828b; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.step-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-soft);
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.small { font-size: 0.8rem; }
.nowrap { white-space: nowrap; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stat { padding: 10px; }
.stat.compact { padding: 8px; font-size: 0.8rem; }
.stat strong { display: block; font-size: 1.2rem; color: var(--accent-hot); }
.stat span { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ==========================================================================
   Buttons — larger hit targets than the German app for chalky hands
   ========================================================================== */

.primary-btn, .secondary-btn, .ghost-btn, .grade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 16px;
  font-size: 13px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border: 1px solid #c9d1dd;
  border-radius: 20px;
}
.primary-btn {
  color: #5d7ea8;
  background:
    radial-gradient(75% 50% at 50% 0, #f4f8ff, #fff),
    radial-gradient(75% 50% at 50% 70%, #fff, #fff);
  box-shadow: inset 0 -2px 4px #b0b3b8;
}
.secondary-btn, .ghost-btn {
  color: #8b939c;
  background: linear-gradient(#fff, #f4f6f9);
  box-shadow: inset 0 -2px 3px #d5d8de;
}
.primary-btn:hover, .secondary-btn:hover, .ghost-btn:hover:not(:disabled) {
  color: #81a1c8;
  background: #eef3f9;
}
.ghost-btn.tiny, .secondary-btn.tiny { min-height: 34px; padding: 4px 10px; font-size: 0.72rem; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grade-btn.correct {
  color: var(--good);
  border: 1px solid var(--good);
  background: var(--good-dim);
  box-shadow: inset 0 -2px 3px #6aa88a40;
}
.grade-btn.wrong {
  color: var(--bad);
  border: 1px solid var(--bad);
  background: var(--bad-dim);
  box-shadow: inset 0 -2px 3px #d36a6a40;
}

/* ==========================================================================
   Inputs
   ========================================================================== */

.text-input, select.text-input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  font-family: var(--font-mono);
  appearance: none;
}
.text-input:focus, select.text-input:focus { border-color: var(--accent); outline: none; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.num-input { text-align: center; font-size: 1.1rem; }

.stepper { display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); gap: 6px; align-items: stretch; }
.stepper button {
  min-height: var(--tap);
  font-size: 1.2rem;
  color: #8b939c;
  background: linear-gradient(#fff, #f4f6f9);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: inset 0 -2px 3px #d5d8de;
}
.stepper button:active { background: #eef3f9; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--muted);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 99px;
}
.chip.on { color: #fff; background: #8bb4ff; border-color: #8bb4ff; }
.chip.flag-on { color: var(--bad); background: var(--bad-dim); border-color: var(--bad); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }

/* ==========================================================================
   Progress, timers, session runner
   ========================================================================== */

.progress-track {
  flex: none;
  height: 8px;
  overflow: hidden;
  background: #eef3f8;
  border: 1.5px solid var(--border);
  border-radius: 99px;
}
.progress-fill { width: 0; height: 100%; background: linear-gradient(90deg, #8bb4ff, #cde8ff); transition: width 0.28s; }

.timer-face {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 16vw, 5.5rem);
  line-height: 1;
  text-align: center;
  color: var(--accent-hot);
  font-variant-numeric: tabular-nums;
}
.timer-face.rest { color: #6d7a88; }
.timer-face.hold { color: var(--accent); }
.timer-sub { text-align: center; color: var(--muted); font-size: 0.8rem; }

.set-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.set-row.done { background: var(--good-dim); border-color: var(--good); }
.set-index { font-family: var(--font-mono); font-weight: 600; color: var(--accent-hot); text-align: center; }
.set-result { font-family: var(--font-mono); font-size: 0.95rem; }
.set-target { font-size: 0.72rem; color: var(--muted); }

.move-card { padding: 12px; margin-bottom: 8px; }
.move-card .cues { margin: 6px 0 0; padding-left: 18px; font-size: 0.85rem; color: #7b828b; }
.move-card .cues li { margin-bottom: 3px; }
.caution {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--warn);
  background: var(--warn-dim);
  border: 1.5px solid var(--warn);
  border-radius: 14px;
}

.insight { padding: 10px 12px; margin-bottom: 8px; font-size: 0.88rem; }
.insight .insight-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.insight .tag {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  color: var(--accent-hot);
  background: var(--gold-dim);
  border: 1px solid var(--accent-soft);
}
.insight.good { background: var(--good-dim); border-color: var(--good); }
.insight.good .tag { color: var(--good); background: #fff; border-color: var(--good); }
.insight.warn { background: var(--warn-dim); border-color: var(--warn); }
.insight.warn .tag { color: var(--warn); background: #fff; border-color: var(--warn); }
.insight.bad { background: var(--bad-dim); border-color: var(--bad); }
.insight.bad .tag { color: var(--bad); background: #fff; border-color: var(--bad); }
.insight .why { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); }

.ladder-list { margin: 0; padding: 0; list-style: none; }
.ladder-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.ladder-list li:last-child { border-bottom: none; }
.ladder-list .n {
  flex: none;
  width: 24px;
  height: 24px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.ladder-list li.done { color: var(--muted); }
.ladder-list li.done .n { color: var(--good); background: var(--good-dim); border-color: var(--good); }
.ladder-list li.current { color: var(--accent-hot); }
.ladder-list li.current .n { color: #fff; background: #8bb4ff; border-color: #8bb4ff; }

/* ==========================================================================
   Nutrition
   ========================================================================== */

.food-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px; margin-bottom: 8px; }
.food-name { font-size: 0.9rem; }
.food-macros { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }
.food-grams { font-family: var(--font-mono); font-size: 1.05rem; color: var(--accent-hot); white-space: nowrap; }
.macro-bars { display: grid; gap: 6px; margin: 8px 0; }
.macro-bar { display: grid; grid-template-columns: 62px minmax(0, 1fr) 74px; align-items: center; gap: 8px; font-size: 0.75rem; }
.macro-bar .label { letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.macro-bar .val { font-family: var(--font-mono); text-align: right; color: var(--text); }
.plate-slot { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; align-items: center; margin-bottom: 8px; }
.plate-slot .slot-label { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ==========================================================================
   Charts / history
   ========================================================================== */

.spark { display: block; width: 100%; height: 54px; overflow: visible; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--accent-hot); }
.spark-zero { stroke: var(--line); stroke-width: 1; }
.hist-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.hist-row:last-child { border-bottom: none; }
.hist-date { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.badge {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  color: var(--accent-hot);
  background: var(--gold-dim);
  border: 1px solid var(--accent-soft);
}
.badge.good { color: var(--good); background: var(--good-dim); border-color: var(--good); }
.badge.warn { color: var(--warn); background: var(--warn-dim); border-color: var(--warn); }
.badge.bad { color: var(--bad); background: var(--bad-dim); border-color: var(--bad); }

/* ==========================================================================
   Toast / banners / modal
   ========================================================================== */

.toast {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 60;
  transform: translateX(-50%);
  padding: 10px 14px;
  color: var(--accent-hot);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  animation: fade-in 0.22s;
}
.install-banner { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; }
.install-banner p { margin: 0; font-size: 0.8rem; }
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: end center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: #5a657333;
  animation: fade-in 0.18s;
}
.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  overflow: auto;
  padding: 14px;
  background-image: var(--win);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 0 20px #b9cee4;
}
.fade-in { animation: fade-in 0.22s; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

a, button, .card, .stat, .option, .chip, .toast, .set-row {
  transition: color var(--fade), background-color var(--fade), border-color var(--fade),
    box-shadow var(--fade), opacity var(--fade);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Mobile — collapse to the single column layout the German app uses
   ========================================================================== */

@media (width <= 960px) {
  .desktop { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .dock { display: none; }
  .navi { flex-direction: row; align-items: center; height: auto; padding-bottom: 4px; }
  .navi .win-toolbar, .navi-brand, .navi-credit { display: none; }
  .navi-links { flex-direction: row; justify-content: space-around; width: 100%; padding: 4px 6px; }
  .navi-links button { padding: 10px 4px; font-size: 11px; text-align: center; box-shadow: none; }
  main { padding: 10px; }
  .field-grid { grid-template-columns: 1fr; }
}
@media (width <= 420px) {
  .navi-links button { font-size: 10px; letter-spacing: 0; }
  .stat-row { gap: 6px; }
  .stat { padding: 8px; }
  .stat strong { font-size: 1.05rem; }
}
