/* Prodigy client app. Mobile first; black and gold, matching the brand. */
:root {
  --bg: #0b0b0b;
  --card: #161616;
  --card-2: #1e1e1e;
  --line: #2a2a2a;
  --gold: #cea952;
  --gold-pale: #e6c874;
  --text: #f3f1ea;
  --muted: #a09b8f;
  --ok: #74c391;
  --bad: #ec8f80;
  --radius: 16px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

:focus-visible { outline: 2px solid var(--gold-pale); outline-offset: 2px; }

/* ── top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 6px;
}
.brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--gold);
}
.topbar h1 { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.topbar .sub { color: var(--muted); font-size: 15px; margin-top: 2px; }

.back {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; padding: 8px 8px 8px 0; margin: 0 0 2px -2px;
  color: var(--gold-pale); font-weight: 600; font-size: 15px; cursor: pointer;
}

/* ── screen ──────────────────────────────────────────────────────────────── */
.screen {
  flex: 1;
  padding: 14px 16px calc(var(--tab-h) + var(--safe-b) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen.no-tabs { padding-bottom: calc(var(--safe-b) + 28px); }

.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-top: 6px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 14px; }
.prewrap { white-space: pre-line; overflow-wrap: anywhere; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 12px 18px;
  border-radius: 14px; border: 1px solid transparent;
  background: var(--gold); color: #141109; font-weight: 700; font-size: 16px;
  cursor: pointer;
}
.btn:active { background: var(--gold-pale); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); font-weight: 600; }
.link-btn {
  background: none; border: 0; padding: 8px 4px; color: var(--gold-pale);
  font-weight: 600; font-size: 15px; cursor: pointer;
}

/* ── forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; color: var(--muted); }
.input, .textarea {
  width: 100%; background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; font-size: 16px; /* 16px stops iOS zoom */
}
.input:focus, .textarea:focus { outline: none; border-color: var(--gold); }
.textarea { resize: none; min-height: 84px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.error { color: var(--bad); font-size: 15px; min-height: 22px; }

/* ── sign in ─────────────────────────────────────────────────────────────── */
.auth {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 22px calc(var(--safe-b) + 32px); gap: 22px;
}
.auth .brand { font-size: 14px; }
.auth h1 { font-size: 28px; line-height: 1.2; margin-top: 8px; }
.auth h1 + p { margin-top: 8px; overflow-wrap: anywhere; }
.auth strong { color: var(--text); }

/* ── today ───────────────────────────────────────────────────────────────── */
.workout-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer;
}
.workout-card:active { background: var(--card-2); }
.workout-card .body { flex: 1; min-width: 0; }
.workout-card h3 { font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.workout-card .meta { color: var(--muted); font-size: 14px; margin-top: 3px; }
.workout-card .chev { color: var(--muted); flex: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  padding: 4px 9px; border-radius: 999px; margin-bottom: 8px;
  background: rgba(206, 169, 82, 0.14); color: var(--gold-pale);
}
.pill.done { background: rgba(116, 195, 145, 0.14); color: var(--ok); }

.upcoming-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.upcoming-row:last-child { border-bottom: 0; padding-bottom: 0; }
.upcoming-row:first-child { padding-top: 0; }
.upcoming-row .when { color: var(--muted); flex: none; }

.account { margin-top: auto; padding-top: 10px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── workout ─────────────────────────────────────────────────────────────── */
.block {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.block-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--card-2); border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.letter {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(206, 169, 82, 0.16); color: var(--gold-pale); font-size: 14px; font-weight: 800;
  letter-spacing: 0;
}
.exercise { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.exercise:last-child { border-bottom: 0; }
.exercise .body { flex: 1; min-width: 0; }
.exercise h3 { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.exercise .target { color: var(--text); opacity: 0.86; font-size: 15px; margin-top: 3px; overflow-wrap: anywhere; }
.exercise .note { color: var(--gold-pale); font-size: 14px; margin-top: 6px; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 8px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
}
.howto { margin-top: 8px; }
.howto summary {
  display: inline-block; cursor: pointer; list-style: none; padding: 4px 0;
  color: var(--gold-pale); font-size: 14px; font-weight: 600;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: " +"; }
.howto[open] summary::after { content: " \2212"; }
.howto p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.dot { flex: none; width: 26px; display: flex; justify-content: center; padding-top: 7px; }
.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }

.rpe { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.rpe button {
  min-height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card-2); font-weight: 700; font-size: 15px; cursor: pointer; padding: 0;
}
.rpe button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #141109; }

.done-banner { display: flex; align-items: center; gap: 12px; }
.done-banner .check {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(116, 195, 145, 0.16); color: var(--ok);
}

/* ── messages ────────────────────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.day-divider { align-self: center; font-size: 12px; color: var(--muted); margin: 8px 0 2px; }
.bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 18px;
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px;
}
.bubble.coach { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.me { align-self: flex-end; background: var(--gold); color: #141109; border-bottom-right-radius: 6px; }
.stamp { font-size: 11px; color: var(--muted); margin: -2px 6px 2px; }
.stamp.me { align-self: flex-end; }
.stamp.coach { align-self: flex-start; }

.composer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b));
  z-index: 5; background: var(--bg); border-top: 1px solid var(--line);
}
.composer .inner {
  max-width: 520px; margin: 0 auto; padding: 10px 12px;
  display: flex; gap: 8px; align-items: flex-end;
}
.composer textarea {
  flex: 1; background: var(--card-2); border: 1px solid var(--line); border-radius: 20px;
  padding: 11px 14px; font-size: 16px; resize: none; max-height: 120px; min-height: 46px; line-height: 1.35;
}
.composer textarea:focus { outline: none; border-color: var(--gold); }
.send {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--gold); color: #141109; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.send[disabled] { opacity: 0.45; cursor: default; }
.screen.has-composer { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 84px); }

/* ── tab bar ─────────────────────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar .inner { max-width: 520px; margin: 0 auto; display: flex; height: var(--tab-h); }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer;
  position: relative; text-decoration: none;
}
.tab[aria-current="page"] { color: var(--gold-pale); }
.badge {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #1a0d0a; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* ── misc ────────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 26px 16px; }
.empty h3 { font-size: 17px; }
.empty p { color: var(--muted); margin-top: 4px; font-size: 15px; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 20;
  background: #2a1512; border: 1px solid #5a2a22; color: #ffd9d1;
  padding: 11px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px);
}
.noscript { padding: 40px 20px; text-align: center; }
svg { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .workout-card, .rpe button { transition: background-color 0.12s ease; }
}
