/*
 * Adaptora — the layer on top of Bootstrap (issues #70, #71).
 *
 * Bootstrap supplies behaviour: focus management, the navbar collapse,
 * dismissible alerts, the grid. This file supplies everything you can see.
 * The rule is unchanged from #69 — retune a Bootstrap variable rather than
 * re-implement a component, so we keep its accessibility work — but the token
 * set is now large enough to have a point of view rather than just avoid
 * looking unstyled.
 *
 * Two things are worth knowing before editing:
 *
 * 1. `:root` tokens reach Bootstrap's *utilities* and nothing else. Components
 *    (`.btn`, `.form-control`, `.nav-link`) are compiled from Sass into their
 *    own `--bs-<component>-*` variables holding literal hex. They are retuned
 *    by name in the COMPONENTS section, and forgetting that is how a green app
 *    ends up with blue buttons.
 * 2. Colour is declared once, as a semantic name, in the two palette blocks.
 *    Nothing below them contains a hex value. If you are typing `#` outside
 *    those blocks, the token you want is missing — add it there instead.
 */

/* --- Typeface ------------------------------------------------------------
 *
 * IBM Plex, vendored (ADR 0020). Sans is the variable file, so 400–700 is one
 * 39 KB download; Mono ships static weights and is subset to latin. 69 KB for
 * the set.
 *
 * Mono is not decoration here. This app is a log: weights, reps, RPE, macros,
 * times — columns of digits that have to line up and be comparable at a glance.
 * It carries every number and every label, and the sans carries every sentence.
 */

@font-face {
  font-family: "Plex Sans";
  src: url("../vendor/fonts/plex-sans.d28498895ed7.woff2") format("woff2-variations");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plex Mono";
  src: url("../vendor/fonts/plex-mono-400.814fe1615d4d.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plex Mono";
  src: url("../vendor/fonts/plex-mono-500.6708425c446b.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plex Mono";
  src: url("../vendor/fonts/plex-mono-600.e71a597e376e.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* --- Palette: light ------------------------------------------------------ */

:root {
  --ad-paper: #f1f4f0;
  --ad-surface: #ffffff;
  --ad-sunken: #e7ebe6;
  --ad-ink: #101e19;
  --ad-ink-muted: #59665f;
  --ad-ink-faint: #87948d;
  --ad-line: #d9dfd9;
  --ad-line-strong: #c3ccc4;

  /* One accent, for actions and the brand. */
  --ad-accent: #0e6b4a;
  --ad-accent-strong: #0a5138;
  --ad-accent-soft: #ddede5;
  --ad-on-accent: #ffffff;

  /* One signal, for "now" and for things that went well — a PR, today's
     column. Deliberately not the accent: if everything is green, nothing is. */
  --ad-signal: #b07208;
  --ad-signal-soft: #faf0dc;

  --ad-danger: #a93a2c;
  --ad-danger-soft: #f9e6e3;

  --ad-shadow-sm: 0 1px 2px rgba(16, 30, 25, 0.05);
  --ad-shadow-md: 0 2px 4px rgba(16, 30, 25, 0.04), 0 8px 20px rgba(16, 30, 25, 0.05);
  color-scheme: light;
}

/* --- Palette: dark -------------------------------------------------------
 *
 * Not a courtesy. Half of this app is read in a gym, one-handed, and a white
 * card at 06:00 is the reason people put their phone face-down. Only the
 * palette block changes; every component below is written in tokens and
 * inherits the swap for free.
 */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ad-paper: #0c1411;
    --ad-surface: #131e19;
    --ad-sunken: #0a110e;
    --ad-ink: #e6ede8;
    --ad-ink-muted: #97a69f;
    --ad-ink-faint: #6b7a73;
    --ad-line: #24322c;
    --ad-line-strong: #33443c;

    --ad-accent: #45c48d;
    --ad-accent-strong: #6ad6a6;
    --ad-accent-soft: #142c22;
    --ad-on-accent: #06231a;

    --ad-signal: #e4a63f;
    --ad-signal-soft: #2a2013;

    --ad-danger: #e57f6f;
    --ad-danger-soft: #2c1815;

    --bs-primary-rgb: 69, 196, 141;
    --bs-link-color-rgb: 69, 196, 141;
    --bs-link-hover-color-rgb: 106, 214, 166;

    --ad-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ad-shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 20px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

/* --- Scale --------------------------------------------------------------- */

:root {
  --ad-space-1: 0.25rem;
  --ad-space-2: 0.5rem;
  --ad-space-3: 0.75rem;
  --ad-space-4: 1rem;
  --ad-space-5: 1.5rem;
  --ad-space-6: 2rem;
  --ad-space-7: 3rem;
  --ad-space-8: 4rem;

  --ad-radius-sm: 0.375rem;
  --ad-radius: 0.625rem;
  --ad-radius-lg: 0.875rem;

  --ad-sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ad-mono: "Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ad-text-3xs: 0.6875rem;
  --ad-text-2xs: 0.75rem;
  --ad-text-xs: 0.8125rem;
  --ad-text-sm: 0.875rem;
  --ad-text-md: 1.125rem;
  --ad-text-lg: 1.375rem;
  --ad-text-xl: 1.75rem;
  --ad-text-2xl: 2.25rem;
}

/* --- Bootstrap, retuned -------------------------------------------------- */

:root {
  --bs-primary: var(--ad-accent);
  --bs-primary-rgb: 14, 107, 74;
  --bs-body-color: var(--ad-ink);
  --bs-body-bg: var(--ad-paper);
  --bs-secondary-color: var(--ad-ink-muted);
  --bs-border-color: var(--ad-line);
  /* 5.3 composes link colour from the *-rgb triple and an opacity, so setting
     only `--bs-link-color` leaves every link Bootstrap blue. */
  --bs-link-color: var(--ad-accent);
  --bs-link-color-rgb: 14, 107, 74;
  --bs-link-hover-color: var(--ad-accent-strong);
  --bs-link-hover-color-rgb: 10, 81, 56;
  --bs-border-radius: var(--ad-radius);
  --bs-body-font-family: var(--ad-sans);
  --bs-body-font-size: 1rem;
  --bs-body-line-height: 1.55;
  --bs-focus-ring-color: color-mix(in srgb, var(--ad-accent) 30%, transparent);
}

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ad-paper);
  color: var(--ad-ink);
  font-family: var(--ad-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .h1, .h2, .h3, .h4 {
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ad-ink);
}

h1, .h1 { font-size: var(--ad-text-xl); }
h2, .h2 { font-size: var(--ad-text-lg); }
h3, .h3 { font-size: var(--ad-text-md); }

a { text-decoration-thickness: 1px; text-underline-offset: 0.15em; }

/* Every number in the app, in one place. Tabular so a column of weights lines
   up, and the mono so 1 and 7 are never in doubt at arm's length. */
.ad-num {
  font-family: var(--ad-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "zero" 1;
}

/* The eyebrow. Used for section labels and table headers — the app's smallest
   voice, and the one that tells you what kind of thing you are looking at. */
.ad-eyebrow {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ad-ink-faint);
  margin: 0;
}

.ad-muted { color: var(--ad-ink-muted); }

/* Prose gets a measure. A card is as wide as its container, and on a laptop
   that is a 140-character line — legible word by word, and exhausting to
   read. Tables and grids are exempt: they want the width. */
.ad-prose { max-width: 68ch; }

/* --- Shell --------------------------------------------------------------- */

.ad-main {
  flex: 1 0 auto;
  padding-block: var(--ad-space-6);
}

.ad-topbar {
  background: var(--ad-surface);
  border-bottom: 1px solid var(--ad-line);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.ad-brand {
  font-family: var(--ad-mono);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--ad-ink);
  display: inline-flex;
  align-items: center;
  gap: var(--ad-space-2);
}

.ad-brand:hover { color: var(--ad-ink); }

/* The mark: a bar chart of one week, which is what the product is. */
.ad-brand-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 1rem;
}

.ad-brand-mark i {
  display: block;
  width: 3px;
  background: var(--ad-accent);
  border-radius: 1px;
}

.ad-brand-mark i:nth-child(1) { height: 45%; }
.ad-brand-mark i:nth-child(2) { height: 100%; }
.ad-brand-mark i:nth-child(3) { height: 30%; }
.ad-brand-mark i:nth-child(4) { height: 70%; background: var(--ad-signal); }

.ad-topnav .nav-link {
  color: var(--ad-ink-muted);
  font-size: var(--ad-text-sm);
  font-weight: 500;
  padding-inline: var(--ad-space-3);
  border-radius: var(--ad-radius-sm);
}

.ad-topnav .nav-link:hover { color: var(--ad-ink); background: var(--ad-sunken); }

.ad-topnav .nav-link.active { color: var(--ad-accent); background: var(--ad-accent-soft); }

.ad-account {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-faint);
}

.ad-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--ad-line);
  background: var(--ad-surface);
  color: var(--ad-ink-faint);
  font-size: var(--ad-text-xs);
  padding-block: var(--ad-space-4);
}

.ad-skip {
  position: absolute;
  left: -100vw;
  top: var(--ad-space-2);
  z-index: 1080;
  background: var(--ad-surface);
  color: var(--ad-ink);
  padding: var(--ad-space-2) var(--ad-space-4);
  border-radius: var(--ad-radius);
  box-shadow: var(--ad-shadow-md);
}

.ad-skip:focus { left: var(--ad-space-2); }

/* Bottom tabs on a phone. This app is used standing up, one-handed, between
   sets — a hamburger in the top-left corner is the furthest point on the
   screen from the thumb holding it. Desktop keeps the top bar and hides
   these; below `md` it is the reverse. */
.ad-tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  /* Seven sections fill exactly 375px. A narrower screen scrolls the bar
     rather than overlapping the labels. */
  overflow-x: auto;
  background: var(--ad-surface);
  border-top: 1px solid var(--ad-line);
  padding-bottom: env(safe-area-inset-bottom);
}

.ad-tabbar a {
  /* Sized to its label, not to an equal share: "Connections" is wider than
     one seventh of 375px and would otherwise clip. */
  flex: 1 0 auto;
  padding: var(--ad-space-2) var(--ad-space-1) var(--ad-space-3);
  text-align: center;
  text-decoration: none;
  color: var(--ad-ink-faint);
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  /* Measured at 375px: even 0.04em takes the seven tabs to 380px and the bar
     starts scrolling. */
  letter-spacing: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.ad-tabbar a.active { color: var(--ad-accent); }

.ad-tabbar svg { width: 20px; height: 20px; }

@media (min-width: 768px) {
  .ad-tabbar { display: none; }
}

@media (max-width: 767.98px) {
  .ad-main { padding-bottom: 5rem; }
  .ad-footer { display: none; }
}

/* --- Surfaces ------------------------------------------------------------ */

.ad-card {
  background: var(--ad-surface);
  border: 1px solid var(--ad-line);
  border-radius: var(--ad-radius-lg);
  padding: var(--ad-space-5);
}

.ad-card-tight { padding: var(--ad-space-4); }

.ad-card-flush { padding: 0; overflow: hidden; }

.ad-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ad-space-3);
  margin-bottom: var(--ad-space-3);
}

/* --- Page header --------------------------------------------------------- */

.ad-pagehead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--ad-space-3);
  margin-bottom: var(--ad-space-5);
}

.ad-pagehead h1 { margin: 0; }

.ad-pagehead .ad-eyebrow { margin-bottom: var(--ad-space-1); }

/* --- Stat tile -----------------------------------------------------------
 *
 * The number is the element; the label explains it and the note qualifies it.
 * `.ad-stat-note` exists because the vision asks for honest UX: an estimate
 * that does not say it is an estimate is a claim.
 */

.ad-stat { display: flex; flex-direction: column; gap: var(--ad-space-1); }

.ad-stat-value {
  font-family: var(--ad-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--ad-text-xl);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ad-ink);
}

.ad-stat-value small {
  font-size: var(--ad-text-sm);
  font-weight: 400;
  color: var(--ad-ink-faint);
  margin-left: 2px;
}

.ad-stat-empty { color: var(--ad-ink-faint); }

.ad-stat-note { font-size: var(--ad-text-2xs); color: var(--ad-ink-faint); }

/* --- Trend --------------------------------------------------------------- */

.ad-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--ad-mono);
  font-size: var(--ad-text-2xs);
  font-weight: 500;
}

.ad-trend-up { color: var(--ad-accent); }
.ad-trend-down { color: var(--ad-danger); }
.ad-trend-steady { color: var(--ad-ink-faint); }

/* --- Badge --------------------------------------------------------------- */

.ad-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ad-space-1);
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px var(--ad-space-2);
  border-radius: var(--ad-radius-sm);
  background: var(--ad-sunken);
  color: var(--ad-ink-muted);
  white-space: nowrap;
}

.ad-badge-ok { background: var(--ad-accent-soft); color: var(--ad-accent); }
.ad-badge-signal { background: var(--ad-signal-soft); color: var(--ad-signal); }
.ad-badge-error { background: var(--ad-danger-soft); color: var(--ad-danger); }

/* --- Week ribbon ---------------------------------------------------------
 *
 * The signature element, and the one screen that explains what Adaptora is:
 * seven days as vertical time axes, your calendar subtracted from them, and
 * what is left is when you can train. Every other fitness app asks you to
 * declare your availability; this one reads it and shows its working.
 *
 * Geometry (`top`/`height` percentages) is computed in the view, because the
 * day's span is a user preference and CSS cannot do the arithmetic.
 */

.ad-ribbon {
  display: grid;
  grid-template-columns: auto repeat(7, minmax(0, 1fr));
  gap: var(--ad-space-1);
  align-items: stretch;
}

.ad-ribbon-hours {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-block: 1.55rem var(--ad-space-4);
  padding-right: var(--ad-space-1);
}

.ad-ribbon-hour {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  color: var(--ad-ink-faint);
  line-height: 1;
}

.ad-ribbon-day { display: flex; flex-direction: column; gap: var(--ad-space-1); }

.ad-ribbon-label {
  text-align: center;
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ad-ink-faint);
  line-height: 1.3;
}

.ad-ribbon-label b { display: block; font-weight: 500; color: var(--ad-ink-muted); }

.ad-ribbon-day.is-today .ad-ribbon-label,
.ad-ribbon-day.is-today .ad-ribbon-label b { color: var(--ad-signal); }

/* The track is the day. Sunken, because free time is what is *left* after the
   calendar takes its share — the bars are added back into a hollow. */
.ad-ribbon-track {
  position: relative;
  flex: 1;
  min-height: 8.5rem;
  background: var(--ad-sunken);
  border-radius: var(--ad-radius-sm);
  overflow: hidden;
}

.ad-ribbon-day.is-today .ad-ribbon-track {
  box-shadow: inset 0 0 0 1.5px var(--ad-signal);
}

.ad-ribbon-window {
  position: absolute;
  inset-inline: 0;
  background: var(--ad-accent);
  border-radius: var(--ad-radius-sm);
  opacity: 0.9;
}

.ad-ribbon-day.is-past .ad-ribbon-window { opacity: 0.45; }

.ad-ribbon-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ad-space-4);
  margin-top: var(--ad-space-4);
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-muted);
}

.ad-ribbon-legend span { display: inline-flex; align-items: center; gap: var(--ad-space-2); }

.ad-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  display: inline-block;
}

.ad-swatch-free { background: var(--ad-accent); }
.ad-swatch-busy { background: var(--ad-sunken); border: 1px solid var(--ad-line-strong); }

/* A table is the one thing that legitimately wants more width than a phone
   has. It scrolls inside its own box rather than widening the card, because a
   page that scrolls sideways loses the reader's place in every other column. */
.ad-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ad-scroll-x table { margin-bottom: 0; }

.table {
  --bs-table-color: var(--ad-ink);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--ad-line);
  font-size: var(--ad-text-sm);
}

/* --- Week grid -----------------------------------------------------------
 *
 * Seven days across on a desktop, stacking to two and then one. Rest days keep
 * their column: a week with four sessions and three gaps is the shape of the
 * week, and collapsing the gaps hides the thing the plan was built around.
 */

.ad-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--ad-space-3);
}

@media (max-width: 1199.98px) {
  .ad-week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  .ad-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ad-day {
  display: flex;
  flex-direction: column;
  gap: var(--ad-space-2);
  min-height: 9rem;
}

.ad-day-head {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ad-ink-faint);
  text-align: center;
}

.ad-day-head b { display: block; font-weight: 500; color: var(--ad-ink-muted); }

.ad-day.is-today .ad-day-head,
.ad-day.is-today .ad-day-head b { color: var(--ad-signal); }

.ad-session {
  flex: 1;
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--ad-surface);
  border: 1px solid var(--ad-line);
  border-left: 3px solid var(--ad-accent);
  border-radius: var(--ad-radius);
  padding: var(--ad-space-3);
}

a.ad-session:hover { border-color: var(--ad-accent); color: inherit; }

.ad-session-focus { font-weight: 600; font-size: var(--ad-text-sm); margin-bottom: 2px; }

.ad-session-meta {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-faint);
}

.ad-session-blocks {
  margin: var(--ad-space-2) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-muted);
}

.ad-session-blocks li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* A rest day is a decision, not an absence. It gets a box so the week reads as
   seven deliberate days rather than four sessions floating in whitespace. */
.ad-rest {
  flex: 1;
  border: 1px dashed var(--ad-line-strong);
  border-radius: var(--ad-radius);
  display: grid;
  place-items: center;
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ad-ink-faint);
}

/* --- Meal ideas ----------------------------------------------------------
 *
 * A card per idea, and the macros are the second thing you read after the
 * name. `why_it_fits` is the model explaining itself, which is the difference
 * between a suggestion and an instruction.
 */

.ad-idea {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--ad-space-2);
  background: var(--ad-surface);
  border: 1px solid var(--ad-line);
  border-radius: var(--ad-radius);
  padding: var(--ad-space-3);
}

.ad-idea-head { display: flex; align-items: flex-start; gap: var(--ad-space-2); }

.ad-idea-head h3 { font-size: var(--ad-text-sm); font-weight: 600; margin: 0; flex: 1; }

.ad-macros {
  display: flex;
  gap: var(--ad-space-3);
  margin: 0;
  padding: var(--ad-space-2) 0;
  border-block: 1px solid var(--ad-line);
}

.ad-macros dt {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-3xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ad-ink-faint);
  font-weight: 400;
}

.ad-macros dd { margin: 0; font-size: var(--ad-text-sm); font-weight: 500; }

.ad-idea-why {
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-muted);
  margin: 0;
  flex: 1;
}

.ad-idea-foot { display: flex; align-items: center; gap: var(--ad-space-2); }

/* --- Day assembly --------------------------------------------------------- */

.ad-assembly {
  display: grid;
  grid-template-columns: 3rem minmax(0, 2fr) minmax(0, 1.4fr);
  gap: var(--ad-space-4);
  align-items: center;
  padding: var(--ad-space-4);
  border-bottom: 1px solid var(--ad-line);
}

.ad-assembly:last-child { border-bottom: 0; }

.ad-assembly.is-today { background: var(--ad-signal-soft); }

.ad-assembly-day {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-faint);
  text-align: center;
  line-height: 1.25;
}

.ad-assembly-day b { display: block; font-size: var(--ad-text-md); font-weight: 500; color: var(--ad-ink); }

.ad-assembly-picks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--ad-space-2);
}

.ad-pick { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.ad-assembly-totals {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ad-space-3);
  align-items: baseline;
}

.ad-assembly-total { display: flex; flex-direction: column; gap: 1px; }

.ad-assembly-total b { font-size: var(--ad-text-sm); font-weight: 500; }

@media (max-width: 991.98px) {
  .ad-assembly { grid-template-columns: 3rem minmax(0, 1fr); }
  .ad-assembly-totals { grid-column: 1 / -1; }
}

@media (max-width: 575.98px) {
  .ad-assembly-picks { grid-template-columns: 1fr; }
}

/* --- Onboarding ----------------------------------------------------------- */

.ad-onboarding {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: var(--ad-space-6);
  align-items: start;
}

@media (max-width: 767.98px) {
  .ad-onboarding { grid-template-columns: 1fr; gap: var(--ad-space-4); }
}

.ad-rail { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--ad-space-1); }

.ad-rail a,
.ad-rail li > span {
  display: block;
  padding: var(--ad-space-2) var(--ad-space-3);
  border-radius: var(--ad-radius-sm);
  border-left: 2px solid var(--ad-line);
  font-size: var(--ad-text-sm);
  color: var(--ad-ink-faint);
  text-decoration: none;
}

/* A step past the resume point cannot be opened yet (#177), so it renders as
   text rather than a link. */
.ad-rail li > span { border-left-style: dashed; }

.ad-rail a:hover { background: var(--ad-sunken); }

.ad-rail .is-current a {
  border-left-color: var(--ad-accent);
  color: var(--ad-ink);
  font-weight: 500;
  background: var(--ad-accent-soft);
}

.ad-rail .is-done a { border-left-color: var(--ad-accent); color: var(--ad-ink-muted); }

.ad-equipment {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: var(--ad-space-2);
}

.ad-equipment-item {
  display: flex;
  align-items: center;
  gap: var(--ad-space-2);
  padding: var(--ad-space-2) var(--ad-space-3);
  /* 2.75rem is the 44px touch target #74 asks for: the padding above and
     `--ad-text-sm` leave the row near 38px on their own. */
  min-height: 2.75rem;
  border: 1px solid var(--ad-line);
  border-radius: var(--ad-radius-sm);
  font-size: var(--ad-text-sm);
  cursor: pointer;
}

.ad-equipment-item:hover { border-color: var(--ad-line-strong); background: var(--ad-sunken); }

.ad-equipment-item input { margin: 0; flex-shrink: 0; }

/* `btn-sm` is about 31px, so a preset needs the same floor as a checkbox row. */
.ad-equipment-presets .btn { min-height: 2.75rem; }

.ad-equipment-group { margin-bottom: var(--ad-space-5); }

.ad-fieldlist {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--ad-space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--ad-space-2);
}

.ad-fieldlist li {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-2xs);
  padding: var(--ad-space-1) var(--ad-space-2);
  border: 1px dashed var(--ad-line-strong);
  border-radius: var(--ad-radius-sm);
  color: var(--ad-ink-muted);
}

/* --- Bars ----------------------------------------------------------------
 *
 * A bar chart in CSS. No charting library: this is four rows of one number
 * against a reference, and 90 KB of JavaScript to draw a rectangle is 90 KB
 * that has to be vendored, upgraded, and themed twice.
 */

.ad-bar {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) 3rem 1.5rem;
  gap: var(--ad-space-3);
  align-items: center;
  padding-block: var(--ad-space-2);
}

.ad-bar-label { font-size: var(--ad-text-sm); }

.ad-bar-track {
  height: 0.5rem;
  background: var(--ad-sunken);
  border-radius: 999px;
  overflow: hidden;
}

.ad-bar-fill { height: 100%; background: var(--ad-accent); border-radius: 999px; }

.ad-bar-value { text-align: right; font-size: var(--ad-text-sm); }

.ad-bar-trend { text-align: center; }

@media (max-width: 575.98px) {
  .ad-bar { grid-template-columns: 6rem minmax(0, 1fr) 2.5rem 1.25rem; gap: var(--ad-space-2); }
}

/* One set row in the logging form. */
.ad-setrow {
  border: 1px solid var(--ad-line);
  border-radius: var(--ad-radius);
  padding: var(--ad-space-4) var(--ad-space-4) var(--ad-space-1);
  margin-bottom: var(--ad-space-3);
}

/* --- Rows ---------------------------------------------------------------- */

.ad-row {
  display: flex;
  align-items: center;
  gap: var(--ad-space-3);
  padding: var(--ad-space-3) var(--ad-space-4);
  border-bottom: 1px solid var(--ad-line);
  text-decoration: none;
  color: inherit;
}

.ad-row:last-child { border-bottom: 0; }

a.ad-row:hover { background: var(--ad-sunken); color: inherit; }

.ad-row-date {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-faint);
  text-align: center;
  line-height: 1.25;
  flex-shrink: 0;
  min-width: 2.5rem;
}

.ad-row-date b { display: block; font-size: var(--ad-text-md); font-weight: 500; color: var(--ad-ink); }

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

.ad-row-title { font-weight: 500; font-size: var(--ad-text-sm); }

.ad-row-meta {
  font-family: var(--ad-mono);
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-faint);
}

/* --- Empty state ---------------------------------------------------------
 *
 * An empty screen is an invitation, not an apology. Every one of these says
 * what is missing and gives the single next action that fills it.
 */

.ad-empty {
  text-align: center;
  padding: var(--ad-space-6) var(--ad-space-4);
  color: var(--ad-ink-muted);
}

.ad-empty-mark {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto var(--ad-space-3);
  border-radius: var(--ad-radius);
  background: var(--ad-accent-soft);
  color: var(--ad-accent);
  display: grid;
  place-items: center;
}

.ad-empty h3 { font-size: var(--ad-text-sm); font-weight: 600; margin-bottom: var(--ad-space-1); }

.ad-empty p { font-size: var(--ad-text-sm); margin: 0 auto var(--ad-space-4); max-width: 40ch; }

/* --- Error panel --------------------------------------------------------- */

.ad-error {
  border: 1px solid var(--ad-danger);
  border-radius: var(--ad-radius);
  background: var(--ad-danger-soft);
  padding: var(--ad-space-4);
  font-size: var(--ad-text-sm);
}

.ad-error h3 { font-size: var(--ad-text-sm); font-weight: 600; color: var(--ad-danger); margin-bottom: var(--ad-space-1); }

.ad-error p { margin: 0; color: var(--ad-ink); }

.ad-error code { color: var(--ad-ink-muted); font-size: var(--ad-text-2xs); }

.ad-error-reasons { margin: var(--ad-space-2) 0 0; padding-left: var(--ad-space-4); color: var(--ad-ink); }

/* --- Caveat --------------------------------------------------------------
 *
 * The vision asks for "good honest UX", and this app does slow and imprecise
 * things. This is where that gets said, as a deliberate element rather than
 * grey text somebody shrinks later.
 */

.ad-caveat {
  font-size: var(--ad-text-xs);
  color: var(--ad-ink-muted);
  border-left: 2px solid var(--ad-signal);
  padding-left: var(--ad-space-3);
}

/* --- Sample data ---------------------------------------------------------
 *
 * Shown on a screen whose view fell back to `samples.py`. Signal-coloured
 * rather than danger — nothing is wrong, it just is not yours yet.
 */

.ad-sample {
  display: flex;
  align-items: flex-start;
  gap: var(--ad-space-3);
  padding: var(--ad-space-3) var(--ad-space-4);
  border: 1px dashed var(--ad-signal);
  border-radius: var(--ad-radius);
  background: var(--ad-signal-soft);
  font-size: var(--ad-text-sm);
  color: var(--ad-ink);
  margin-bottom: var(--ad-space-5);
}

/* --- Loading -------------------------------------------------------------
 *
 * A skeleton, not a spinner. A spinner says "wait"; a skeleton says what is
 * arriving. Sync and generation take seconds here, and the shape of the answer
 * is known before the answer is.
 */

.ad-skeleton {
  background: linear-gradient(90deg, var(--ad-sunken) 25%, var(--ad-line) 50%, var(--ad-sunken) 75%);
  background-size: 200% 100%;
  animation: ad-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--ad-radius-sm);
  height: 1rem;
}

@keyframes ad-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: block; }
.htmx-request.htmx-indicator { display: block; }

/* --- COMPONENTS: the Bootstrap parts that ignore `--bs-primary` ----------- */

.btn {
  --bs-btn-font-family: var(--ad-sans);
  --bs-btn-font-size: var(--ad-text-sm);
  --bs-btn-font-weight: 500;
  --bs-btn-border-radius: var(--ad-radius-sm);
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-padding-x: 0.9rem;
}

.btn-primary {
  --bs-btn-bg: var(--ad-accent);
  --bs-btn-border-color: var(--ad-accent);
  --bs-btn-color: var(--ad-on-accent);
  --bs-btn-hover-bg: var(--ad-accent-strong);
  --bs-btn-hover-border-color: var(--ad-accent-strong);
  --bs-btn-hover-color: var(--ad-on-accent);
  --bs-btn-active-bg: var(--ad-accent-strong);
  --bs-btn-active-border-color: var(--ad-accent-strong);
  --bs-btn-active-color: var(--ad-on-accent);
  --bs-btn-disabled-bg: var(--ad-accent);
  --bs-btn-disabled-border-color: var(--ad-accent);
  --bs-btn-disabled-color: var(--ad-on-accent);
  --bs-btn-focus-shadow-rgb: 14, 107, 74;
}

.btn-outline-primary {
  --bs-btn-color: var(--ad-accent);
  --bs-btn-border-color: var(--ad-accent);
  --bs-btn-hover-bg: var(--ad-accent);
  --bs-btn-hover-border-color: var(--ad-accent);
  --bs-btn-hover-color: var(--ad-on-accent);
  --bs-btn-active-bg: var(--ad-accent-strong);
  --bs-btn-active-border-color: var(--ad-accent-strong);
  --bs-btn-active-color: var(--ad-on-accent);
  --bs-btn-focus-shadow-rgb: 14, 107, 74;
}

.btn-quiet {
  --bs-btn-color: var(--ad-ink-muted);
  --bs-btn-border-color: var(--ad-line);
  --bs-btn-bg: var(--ad-surface);
  --bs-btn-hover-bg: var(--ad-sunken);
  --bs-btn-hover-border-color: var(--ad-line-strong);
  --bs-btn-hover-color: var(--ad-ink);
  --bs-btn-active-bg: var(--ad-sunken);
  --bs-btn-active-border-color: var(--ad-line-strong);
  --bs-btn-active-color: var(--ad-ink);
  --bs-btn-focus-shadow-rgb: 14, 107, 74;
}

.form-control,
.form-select {
  background-color: var(--ad-surface);
  border-color: var(--ad-line-strong);
  color: var(--ad-ink);
  border-radius: var(--ad-radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: var(--ad-text-sm);
}

.form-control::placeholder { color: var(--ad-ink-faint); }

/* A focused input is otherwise Bootstrap blue against a green app, which reads
   as a bug rather than as a theme. */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  background-color: var(--ad-surface);
  border-color: var(--ad-accent);
  color: var(--ad-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ad-accent) 22%, transparent);
}

.form-check-input:checked {
  background-color: var(--ad-accent);
  border-color: var(--ad-accent);
}

.form-label {
  font-size: var(--ad-text-xs);
  font-weight: 500;
  color: var(--ad-ink-muted);
  margin-bottom: var(--ad-space-1);
}

.form-text,
.helptext {
  display: block;
  font-size: var(--ad-text-2xs);
  color: var(--ad-ink-faint);
}

.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--ad-danger); }

.invalid-feedback { color: var(--ad-danger); font-size: var(--ad-text-2xs); }

.alert {
  border-radius: var(--ad-radius);
  border: 1px solid var(--ad-line);
  font-size: var(--ad-text-sm);
  padding: var(--ad-space-3) var(--ad-space-4);
}

.alert-success { background: var(--ad-accent-soft); border-color: var(--ad-accent); color: var(--ad-ink); }
.alert-danger { background: var(--ad-danger-soft); border-color: var(--ad-danger); color: var(--ad-ink); }
.alert-warning { background: var(--ad-signal-soft); border-color: var(--ad-signal); color: var(--ad-ink); }
.alert-info { background: var(--ad-sunken); color: var(--ad-ink); }

/* Django renders field errors as a <ul>; Bootstrap has no opinion about it. */
.errorlist {
  list-style: none;
  padding-left: 0;
  margin-bottom: var(--ad-space-2);
  color: var(--ad-danger);
  font-size: var(--ad-text-xs);
}

code {
  font-family: var(--ad-mono);
  font-size: 0.9em;
  color: var(--ad-accent);
  background: var(--ad-accent-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

hr { border-color: var(--ad-line); opacity: 1; }

::selection { background: var(--ad-accent-soft); color: var(--ad-ink); }

/* --- Auth ---------------------------------------------------------------- */

.ad-auth { max-width: 24rem; margin-inline: auto; }

.ad-auth-mark {
  display: flex;
  justify-content: center;
  margin-bottom: var(--ad-space-4);
}

.ad-auth-mark .ad-brand-mark { height: 2rem; gap: 4px; }
.ad-auth-mark .ad-brand-mark i { width: 6px; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
