/* Minshan base: tokens, reset, app shell, launching-soon page, tab bar, buttons, sheet, toast, review/daily/profile */

/* Metric-matched fallbacks (spec 8): text keeps its size and line boxes if a
   web font swaps in late. Overrides measured in Chrome against the loaded
   Outfit and JetBrains Mono (hhea ascent/descent, average advance width). */
@font-face {
  font-family: 'Outfit Fallback';
  src: local('Arial'), local('ArialMT');
  font-weight: 400 500;
  size-adjust: 97.37%;
  ascent-override: 102.7%;
  descent-override: 26.7%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Outfit Fallback';
  src: local('Arial Bold'), local('Arial-BoldMT');
  font-weight: 600 700;
  size-adjust: 92.7%;
  ascent-override: 107.52%;
  descent-override: 27.95%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'JetBrains Mono Fallback';
  src: local('Menlo Regular'), local('Menlo-Regular'), local('Menlo'), local('Courier New'), local('CourierNewPSMT');
  size-adjust: 99.66%;
  ascent-override: 102.35%;
  descent-override: 30.1%;
  line-gap-override: 0%;
}

:root {
  color-scheme: dark;
  --bg: #15162B;
  --mission-bg: #14152A;
  --ink-0: #0B0C14;
  --surface-1: #1B1C2E;
  --surface-2: #262838;
  --surface-glass: rgba(22, 23, 38, .78);
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #F4F3F8;
  --text-2: #C9CBD6;
  --muted: #A9ACBC;
  --dim: #8E91A0;
  --gold: #E6C36A;
  --gold-ink: #14161F;
  --gold-soft: rgba(230, 195, 106, .18);
  --good: #7CC9A2;  --good-soft: rgba(124, 201, 162, .14);
  --bad: #F0A07A;   --bad-soft: rgba(240, 160, 122, .14);
  --tab-bg: #11121A;  --tab-line: #1F2030;
  --code-bg: #0F1020;  --code-err: #FF7B7B;  --code-str: #E9CF8A;  --code-num: #9FC5E8;  --code-kw: #B9A7E8;  --code-punc: #8E91A0;
  --code-bg-clear: rgba(15, 16, 32, 0);
  --df-head-bg: #202134;
  --white-03: rgba(255, 255, 255, .03);  --white-05: rgba(255, 255, 255, .05);
  --white-10: rgba(255, 255, 255, .10);  --white-12: rgba(255, 255, 255, .12);
  --black-30: rgba(0, 0, 0, .3);  --black-40: rgba(0, 0, 0, .4);
  --scrim: rgba(6, 7, 14, .62);
  /* The win screen's own values in navy: its stat rings, and the lip of its gold button. */
  --win-ring: #3B3C4E;  --gold-lip: #B0924C;
  /* Graphite: not in use. The win screen's first look in design/win-screen/SPEC.md, kept to come back to. */
  --graphite-bg: #1C1D20;  --graphite-s1: #26272B;  --graphite-text: #F2F2F4;  --graphite-muted: #ADAFB6;
  --graphite-tok: #3A3B41;  --graphite-good: #34E38F;  --graphite-paper: #F4F4F6;  --graphite-ink: #1C1D20;  --graphite-lip: #B4B6BD;
  --font-ui: 'Outfit', 'Outfit Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-code: 'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 22px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-in: cubic-bezier(.55, 0, 1, .45);
  --ease-land: cubic-bezier(.32, .72, 0, 1);
  --ease-glide: cubic-bezier(.4, 0, .1, 1);
  --tabbar-h: 60px;
  --safe-t: env(safe-area-inset-top, 0px);  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}

/* Reset ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

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

html, body {
  height: 100%;
  background: var(--bg);
  /* Chrome reads the viewport's overscroll from body, WebKit from html. */
  overscroll-behavior: none;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

h1, h2, h3, h4, p, figure, blockquote, pre { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

code, pre, kbd, samp { font-family: var(--font-code); }

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
}

a, [role="button"], input, select, textarea { touch-action: manipulation; }

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

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon { flex: none; overflow: visible; }
.logo { flex: none; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  color: var(--text-2);
  font: 500 16px/1.5 var(--font-ui);
  text-align: center;
}

/* App shell --------------------------------------------------------- */

/* Fills .device__screen (css/launch.css): the whole viewport on a phone, a
   phone's screen on a Mac. */
#app {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app pre, #app code { -webkit-user-select: text; user-select: text; }

.screens {
  position: absolute;
  inset: 0;
}

.screen {
  position: absolute;
  inset: 0;
}

.screen--overlay { z-index: 50; }

/* Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  height: 48px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .005em;
  white-space: nowrap;
  text-align: center;
  transition: transform 120ms var(--ease-out);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn--primary {
  background: var(--gold);
  color: var(--gold-ink);
}

.btn--secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}

.btn--danger {
  background: transparent;
  border-color: var(--bad-soft);
  color: var(--bad);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  transition: transform 120ms var(--ease-out);
}

.btn:active,
.icon-btn:active { transform: scale(.97); }

.btn[disabled],
.icon-btn[disabled] {
  opacity: .4;
  pointer-events: none;
}

/* Launching-soon page ------------------------------------------------ */

.gate {
  --gate-ridges: clamp(120px, 26svh, 260px);
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding:
    max(56px, calc(var(--safe-t) + 16px))
    max(24px, var(--safe-r))
    calc(var(--safe-b) + 6px)
    max(24px, var(--safe-l));
  background:
    radial-gradient(90% 55% at 50% 100%, rgba(140, 106, 110, .16), transparent 70%),
    var(--bg);
}

.gate__ridges {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: var(--gate-ridges);
  display: block;
  pointer-events: none;
}

.gate__col {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Auto margins only take positive free space: centred when the column
     fits, pinned to the top padding (and scrollable) when it does not. */
  margin-block: auto;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.gate__mark .logo { display: block; }

.gate__phone {
  position: relative;
  flex: none;
  width: min(calc(100vw - 8px), 580px, 62vh);
  margin-top: -2%;
  margin-bottom: -6%;
}

.gate__phone img { display: block; width: 100%; height: auto; }
.gate__phone .gate__light,
.gate__phone .gate__note { position: absolute; left: 0; top: 0; }
.gate__note { transform-origin: 50.3% 52.2%; }





.gate__eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  line-height: 18px;
}

/* Sits at the middle of the lowercase letters, not the middle of the line. */
.gate__dot {
  flex: none;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #FFFFFF;
  transform: translateY(1.75px);
}

.gate__title {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.01em;
  text-wrap: balance;
  outline: none;
}

.gate__body {
  max-width: 380px;
  margin-top: 12px;
  color: var(--text-2);
  /* One line on every phone: narrower than the 402 px iPhone 17 Pro, the text
     shrinks with the column. It is 22 em wide, a little more than it needs. */
  font-size: min(16px, calc((100vw - 48px) / 22));
  line-height: 1.55;
  white-space: nowrap;
}

.gate__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-top: 24px;
}

.gate__actions .btn {
  flex: 1 1 50%;
  min-width: 0;
  max-width: 190px;
  padding-inline: 12px;
}

.gate__join {
  position: relative;
  display: flex;
  flex: 1 1 50%;
  min-width: 0;
  max-width: 190px;
}

.gate__actions .gate__join .btn { max-width: none; }

/* The count sits in the button's outline, like the label on a form field's border. The outline
   stops under it (the notch below), so nothing behind the number has to match the page. */
.gate__count {
  position: absolute;
  top: -8px;
  right: 12px;
  padding: 0 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.gate__actions .gate__join .btn {
  position: relative;
  border-color: transparent;
}

/* The button's outline, drawn here so it can leave a gap as wide as the count (--notch, from launch.js). */
.gate__actions .gate__join .btn::before {
  content: '';
  position: absolute;
  inset: -1px;
  border: 1px solid var(--line-strong);
  border-radius: inherit;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) right 12px top / var(--notch, 0px) 2px no-repeat, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) right 12px top / var(--notch, 0px) 2px no-repeat, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.gate__apple { display: block; flex: none; margin-top: -2px; }

.gate__try {
  background: var(--text);
  color: var(--ink-0);
}

/* Keeps the column where it sat before the footer: clear of the ridges. */
.gate__foot {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 10px;
  margin-top: max(20px, calc(var(--gate-ridges) * .55 - 18px - var(--safe-b)));
}

.gate__link {
  min-height: 44px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.gate.is-launching .gate__mark { visibility: hidden; }
.gate.is-stage .gate__col,
.gate.is-stage .gate__foot { display: none; }

/* Short phones with the browser's bars showing: the drawing gives way, so the
   text and both buttons stay on one screen. */
@media (max-height: 649px) {
  .gate__phone { display: none; }
}

/* A phone on its side: everything on one screen, ridges low. */
@media (max-height: 479px) {
  .gate {
    --gate-ridges: clamp(72px, 26svh, 120px);
    padding-top: max(12px, calc(var(--safe-t) + 8px));
  }
  .gate__col { max-width: none; }
  .gate__mark .logo { width: 56px; height: 56px; }
  .gate__eyebrow { margin-top: 12px; }
  .gate__title { margin-top: 4px; }
  .gate__body { max-width: none; margin-top: 8px; }
  .gate__actions { margin-top: 16px; }
}

/* The smallest phones: "Join the waitlist" stays on one line inside its button. */
@media (max-width: 374px) {
  .gate__actions .btn { padding-inline: 4px; }
}
@media (max-width: 339px) {
  .gate__actions .btn { font-size: 15px; }
}

/* 360 px Android phones: 6 px of gap keeps the three links on one row. */
@media (max-width: 374px) {
  .gate__foot { gap: 0 6px; }
}

/* Safari's shorter layouts: the phone gives up a little, so nothing scrolls. */
@media (max-height: 669px) {
  .gate__phone { width: min(calc(100vw - 8px), 56svh); }
}

/* The logo stands a little higher and larger above the phone. Its negative
   margin cancels the extra size, so everything below stays put. */
@media (min-height: 650px) {
  .gate__mark { position: relative; top: -28px; margin-bottom: -12px; }
  .gate__mark .logo { width: 84px; height: 84px; }
}

/* MacBook and up: the same column, one size larger for the bigger screen. */
@media (min-width: 1000px) and (min-height: 760px) {
  .gate__col { max-width: 500px; }
  .gate__mark { margin-bottom: -16px; }
  .gate__mark .logo { width: 104px; height: 104px; }
  .gate__eyebrow { gap: 9px; margin-top: 36px; font-size: 16px; line-height: 20px; }
  .gate__dot { transform: translateY(2px); }
  .gate__title { margin-top: 10px; font-size: 36px; }
  .gate__body { max-width: 460px; margin-top: 14px; font-size: 18px; }
  .gate__actions { margin-top: 28px; }
  .gate__actions .btn { max-width: 210px; height: 52px; }
  .gate__join { max-width: 210px; }
  .gate__count { top: -9px; font-size: 13px; line-height: 18px; }
  .gate__link { font-size: 15px; }
}

@media (hover: none) {
  .gate__link { transition: transform 120ms var(--ease-out); }
  .gate__link:active { transform: scale(.97); }
}

@media (hover: hover) {
  .gate__actions .btn--secondary:hover { background: rgba(255, 255, 255, .06); }
  .gate__try:hover { background: #FFFFFF; }
  .gate__link:hover { color: var(--text); }
}

/* Tab bar ----------------------------------------------------------- */

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--tab-bg);
  border-top: 1px solid var(--tab-line);
  transition: transform 260ms var(--ease-in-out);
}

#app.is-overlay .tabbar { transform: translateY(100%); }

.tabbar__grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.tabbar__track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 25%;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: translateX(calc(var(--tab-index, 0) * 100%));
  transition: transform 320ms var(--ease-out);
}

.tabbar__pill {
  width: 56px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
}

.tab {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  height: 100%;
  color: var(--dim);
}

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

.tab .icon { transition: transform 120ms var(--ease-out); }
.tab:active .icon { transform: scale(.9); }

.tab:focus-visible { outline-offset: -6px; border-radius: 14px; }

.tab__badge {
  position: absolute;
  top: calc(50% - 21px);
  left: calc(50% + 5px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--gold);
  color: var(--gold-ink);
  box-shadow: 0 0 0 2px var(--tab-bg);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

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

/* On the path toasts sit over the chapter card's progress row, under its
   title, so they cover neither the title nor the next lesson node, nor the
   tab bar. Overlay screens (lesson, win) have their own slot under their
   top bar; tab pages use .is-low above the bar. */
.toast-root {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--safe-t) + 114px);
  z-index: 90;
  height: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

#app.is-overlay .toast-root { top: calc(var(--safe-t) + 64px); }

.toast-root.is-low { top: auto; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
.toast-root.is-low .toast { top: auto; bottom: 0; }

.toast {
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(92vw, 360px);
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .42);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
}

.toast .icon { flex: none; color: var(--gold); }

/* Two lines at most; longer text is clipped with an ellipsis. */
.toast__text {
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-wrap: pretty;
}

/* Sheet ------------------------------------------------------------- */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 14, .62);
}

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  padding: 10px max(16px, var(--safe-r)) calc(20px + var(--safe-b)) max(16px, var(--safe-l));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface-2);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .4);
}

.sheet__panel::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 64px;
  background: var(--surface-2);
}

.sheet__grip {
  width: 36px;
  height: 4px;
  margin: 0 auto 18px;
  border-radius: 2px;
  background: var(--line-strong);
}

.sheet__title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  text-wrap: balance;
}

.sheet__body {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.5;
  text-wrap: pretty;
}

.sheet__actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

/* A sheet taller than the screen: the body scrolls, title and actions stay. */
.sheet--scroll .sheet__panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100% - var(--safe-t) - 24px);
}

.sheet__scroll {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 8px;
  padding-bottom: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-sm);
  scrollbar-width: none;
  /* The last lines fade into the actions, which says there is more below. */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent);
}

.sheet__scroll::-webkit-scrollbar { display: none; }

.sheet__scroll .sheet__body { margin-top: 0; }

.sheet--scroll .sheet__actions { flex: none; margin-top: 12px; }

.sheet--scroll .sheet__grip { flex: none; }

/* Pages (review, daily, profile) ------------------------------------ */

.page {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Opaque so the tab cross-fade dissolves one screen into the next
     instead of overlapping two screens of text. */
  background: var(--bg);
  padding:
    calc(var(--safe-t) + 20px)
    max(16px, var(--safe-r))
    calc(var(--tabbar-h) + var(--safe-b) + 16px)
    max(16px, var(--safe-l));
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.page__inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  margin: 0 auto;
}

.page__title {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.page__lede {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.5;
}

.pg-eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Inline code in prose, as M.lesson.prose writes it. */
.pg-prose .ic {
  padding: 1px 6px;
  border-radius: 7px;
  background: var(--code-bg);
  font-family: var(--font-code);
  font-size: .86em;
  font-weight: 500;
  white-space: pre-wrap;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.pg-prose .t-s { color: var(--code-str); }
.pg-prose .t-n { color: var(--code-num); }
.pg-prose .t-k { color: var(--code-kw); }
.pg-prose .t-p { color: var(--code-punc); }
.pg-prose .t-c { color: var(--dim); }
.pg-prose .t-e { color: var(--code-err); }

/* Review */

.rv-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: clamp(32px, 14vh, 120px);
  padding: 0 12px;
  text-align: center;
}

.rv-empty__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--text-2);
}

.rv-empty__title {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
}

.rv-empty__text {
  max-width: 300px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.5;
  text-wrap: balance;
}

.rv-list {
  display: grid;
  gap: 12px;
}

.rv-card {
  display: grid;
  /* One column that can never grow past the card: long code wraps
     inside it instead of pushing the right padding off the edge. */
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.rv-card > * { min-width: 0; }

.rv-card__prompt {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.rv-card__btn {
  justify-self: start;
  margin-top: 4px;
}

/* Daily question */

.dq-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.dq-card__title {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.dq-card__text {
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.5;
}

.dq-card .btn { margin-top: 8px; }

/* Code in a prompt reads as it does on the question it opens: its colours, no chip around it. */
.dq-card__title .ic,
.rv-card__prompt .ic {
  padding: 0;
  background: none;
  line-height: 1;
}

.dq-card__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: var(--good-soft);
  color: var(--good);
}

/* Profile */

.pf-id {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.pf-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  height: 56px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.pf-id__text { min-width: 0; }

.pf-name {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}

.pf-joined {
  margin-top: 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.pf-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pf-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.pf-stat .icon { flex: none; color: var(--text-2); }

.pf-stat__num {
  max-width: 100%;
  margin-top: 10px;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pf-stat__of {
  margin-left: 1px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
}

.pf-stat__label {
  max-width: 100%;
  margin-top: auto;
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pf-settings {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.pf-list {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.pf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 16px;
  font-size: 16px;
}

.pf-switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 44px;
  border-radius: 16px;
}

.pf-switch::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 32px;
  margin-top: -16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .16);
  transition: background 200ms var(--ease-out);
}

.pf-switch__knob {
  position: absolute;
  left: 2px;
  top: 50%;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
  transition: transform 240ms var(--ease-spring);
}

.pf-switch[aria-checked="true"]::before { background: var(--gold); }
.pf-switch[aria-checked="true"] .pf-switch__knob { transform: translateX(20px); }

.pf-fn {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  padding: 13px 16px;
}

.pf-fn + .pf-fn { border-top: 1px solid var(--line); }

.pf-fn__code {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.pf-fn__text {
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.pf-notes__empty {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.45;
}

.pf-restart {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.pf-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

/* Short screens: Profile with both Field Notes still fits above the tab bar. */
@media (max-height: 700px) {
  .page { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
  .pf-settings,
  .pf-restart { margin-top: 0; }
  .pf-stat { padding-block: 12px; }
  .pf-stat__num { margin-top: 6px; }
  .pf-fn { padding-block: 10px; }
}

/* Reduced motion ---------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .tabbar,
  .tabbar__track,
  .tab .icon,
  .btn,
  .icon-btn,
  .pf-switch::before,
  .pf-switch__knob,
  .gate__link { transition: none; }
}

/* Increase Contrast on iPhone: only these hairlines and quiet greys step up. */
@media (prefers-contrast: more) {
  :root {
    --line: rgba(255, 255, 255, .3);
    --line-strong: rgba(255, 255, 255, .55);
    --muted: var(--text-2);
    --dim: var(--text-2);
  }
}
