/* Shell and shared primitives. View-specific rules live in views.css. */

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Contract §2 — headings 800, card titles 600, body 400/500. */
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 800; letter-spacing: -0.02em; }
p { margin: 0; }
span, div { text-wrap: pretty; }
a { color: var(--accent-deep); text-underline-offset: 3px; transition: color .18s ease; }
a:hover { color: var(--accent-deeper); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-tint); }

/* The five surfaces are desktop views drawn at 1440x900. They stretch, but
   below --app-min-w the app scrolls sideways instead of reflowing. */
.app {
  min-width: var(--app-min-w);
  max-width: var(--content-max);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--ground);
  display: grid;
  grid-template-columns: 1fr;
}
.app--railed { grid-template-columns: var(--rail-w) 1fr; }

/* ─────────────────────────────  left rail  ───────────────────────────── */

.rail {
  background: var(--rail);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 4px;
  height: 100vh;
  position: sticky;
  top: 0;
}
.rail__brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 0 10px 18px;
}
.rail__brand span { color: var(--ink-40); font-size: 13px; font-weight: 400; }
.rail__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-lg);
  color: var(--ink-60);
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.rail__item i { font-size: 18px; }
.rail__item:hover { background: rgba(62, 58, 47, 0.04); color: var(--ink); }
.rail__item.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.rail__item.is-active:hover { background: var(--accent-soft); color: var(--accent-deep); }
.rail__count { margin-left: auto; font-size: 13px; color: var(--ink-45); }
.rail__badge {
  margin-left: auto;
  font-size: 13px;
  padding: 1px 7px;
  border-radius: var(--r-xs);
  background: var(--accent-tint);
  color: var(--accent-deeper);
}
.rail__foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail__seats {
  padding: 10px;
  border-radius: var(--r-lg);
  background: var(--surface-sunk);
  font-size: 13px;
  color: var(--ink-50);
  line-height: 1.5;
}

/* ─────────────────────────────  primitives  ──────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 13px;
  border-radius: var(--r-lg);
  /* Filled, not transparent — a bare .btn is the plain/secondary tier and
     needs to read as heavier than .btn--dashed's additive affordance and
     .btn--accent's outline, not tie with them at the same flat weight. */
  background: var(--surface);
  border: 1px solid var(--line-btn);
  color: var(--ink-85);
  font-family: inherit;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.btn:hover { background: rgba(62, 58, 47, 0.05); }
.btn:active { background: rgba(62, 58, 47, 0.09); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { background: transparent; }

.btn--accent { border-color: var(--accent); color: var(--accent-deep); }
.btn--accent:hover { background: var(--accent-soft); }
.btn--accent:active { background: rgba(126, 146, 105, 0.22); }

.btn--solid {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}
.btn--solid:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--solid:active { background: var(--accent-deeper); border-color: var(--accent-deeper); }

/* Same structure as .btn--solid, keyed off --danger — tokens.css has no
   --danger-deep/--danger-deeper counterpart to --accent's (this file does not
   own tokens.css), so hover/active are computed at roughly the same
   darkening ratio --accent-deep/--accent-deeper sit at against --accent
   (~68% / ~50% toward black) rather than hand-picked. For the actual
   destructive confirm — delete-day-confirm, delete-week-confirm. */
.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}
.btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 68%, black);
  border-color: color-mix(in srgb, var(--danger) 68%, black);
}
.btn--danger:active {
  background: color-mix(in srgb, var(--danger) 50%, black);
  border-color: color-mix(in srgb, var(--danger) 50%, black);
}

.btn--dashed { border-style: dashed; border-color: rgba(62, 58, 47, 0.2); color: var(--ink-60); }

/* Lowest-emphasis neutral tier — a borderless, backgroundless button for a
   row-level action (a menu trigger, a row's own icon control) that should not
   compete with the row it sits in. Not used anywhere yet; it exists so
   .ex__row .admin__menu i's descendant-selector color hack (views.css ~:381)
   can eventually move onto the button itself instead of onto a bare <i>. */
.btn--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-45);
}
.btn--quiet:hover { background: rgba(var(--ink-rgb), 0.06); color: var(--ink); }
.btn--quiet:active { background: rgba(var(--ink-rgb), 0.1); }

/* Same tier, keyed off --danger — for a row-level destructive trigger
   (remove-exercise, remove-target, remove-item, delete-note) that should
   read as the odd one out at rest, same intent as the .ex__row workaround,
   as a class instead of a specificity fight. */
.btn--danger-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--danger-tint);
}
.btn--danger-quiet:hover { background: var(--danger-soft); color: var(--danger); }
.btn--danger-quiet:active { background: rgba(var(--danger-rgb), 0.16); }

.btn--sm { height: 34px; padding: 0 10px; font-size: 13px; border-radius: var(--r-md); }
.btn--md { height: 38px; padding: 0 12px; }
.btn--icon { width: 38px; padding: 0; }
.btn--block { width: 100%; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 0;
  font-family: inherit;
  color: var(--ink-60);
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease;
}
.chip:hover { background: #fff; color: var(--ink); }
.chip.is-on { background: var(--accent); color: var(--surface); }
.chip.is-on:hover { background: var(--accent-deep); color: var(--surface); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: var(--chip);
  color: var(--chip-ink);
  white-space: nowrap;
}
.tag--accent { background: var(--accent-tint); color: var(--accent-deeper); }
.tag--warn { background: var(--warn-bg); color: var(--warn-ink); }
.tag--edge { background: var(--edge); color: var(--chip-ink); }
.tag--lg { font-size: 13px; padding: 5px 10px; border-radius: var(--r-md); }
.tag--dashed {
  background: transparent;
  border: 1px dashed rgba(62, 58, 47, 0.2);
  color: var(--ink-50);
  cursor: pointer;
  font-family: inherit;
}

.field label,
.field__label {
  display: block;
  font-size: 13px;
  color: var(--ink-60);
  margin-bottom: 5px;
}
.field__label .hint { color: var(--ink-35); }

.input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line-field);
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  caret-color: var(--accent-deep);
  transition: border-color .18s ease;
}
.input::placeholder { color: var(--ink-35); }
.input:hover { border-color: rgba(62, 58, 47, 0.28); }
.input:focus-visible { border-color: var(--accent); outline: none; }
.input--sm { height: 38px; font-size: 14px; padding: 0 10px; }
textarea.input { height: auto; padding: 9px 11px; line-height: 1.55; resize: vertical; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line-field);
  color: var(--ink-40);
  transition: border-color .18s ease;
}
.search:focus-within { border-color: var(--accent); }
.search i { font-size: 16px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
.search input::placeholder { color: var(--ink-40); }
.search input:focus-visible { outline: none; }

.seg {
  display: inline-flex;
  border-radius: var(--r-lg);
  border: 1px solid rgba(62, 58, 47, 0.14);
  overflow: hidden;
}
.seg button {
  padding: 7px 11px;
  font-family: inherit;
  font-size: 13px;
  background: transparent;
  border: 0;
  border-left: 1px solid rgba(62, 58, 47, 0.14);
  color: var(--ink-60);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .25s ease;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: rgba(62, 58, 47, 0.05); }
.seg button.is-on {
  color: var(--accent-deep);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--edge-ring);
  padding: 16px;
}
.card--flag { box-shadow: var(--edge-ring-accent); }

.kicker {
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-45);
}

.avatar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 13px;
  background: var(--chip);
  color: var(--chip-ink);
}
.avatar--accent {
  background: var(--accent-wash);
  border: 1px solid var(--accent-tint);
  color: var(--accent-deeper);
}
.avatar--sm { width: 30px; height: 30px; font-size: 13px; }
.avatar--md { width: 34px; height: 34px; }
.avatar--lg { width: 40px; height: 40px; font-size: 15px; }
.avatar--xl { width: 46px; height: 46px; font-size: 16px; }
/* dom.js's avatarNode() — a real photo (0029) instead of the initials div,
   same box, same circle. */
.avatar--photo { object-fit: cover; }

.bar {
  height: 3px;
  background: var(--track);
  border-radius: 2px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.bar--warn > i { background: var(--warn); }

.divider { height: 1px; background: var(--line); }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--ink-45);
  text-decoration: none;
  background: transparent;
  border: 0;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
  transition: color .18s ease;
}
.backlink:hover { color: var(--ink); }
.backlink i { font-size: 14px; }

.tabs {
  display: flex;
  gap: 22px;
  font-size: 15px;
}
.tabs button {
  padding: 0 0 11px;
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink-60);
  cursor: pointer;
  transition: color .18s ease, box-shadow .25s ease;
}
.tabs button:hover { color: var(--ink); }
.tabs button.is-on {
  color: var(--accent-deep);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.thead {
  display: grid;
  padding: 0 14px 9px;
  font-size: 13px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-45);
  border-bottom: 1px solid var(--line-strong);
}
.thead button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  justify-self: start;
  transition: color .18s ease;
}
.thead button:hover { color: var(--ink); }
.thead button i { font-size: 13px; }

.tfoot {
  padding: 14px;
  font-size: 13px;
  color: var(--ink-40);
}

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-45);
  font-size: 14px;
  line-height: 1.6;
}
.empty i { font-size: 24px; display: block; margin-bottom: 8px; color: var(--ink-35); }

.note {
  font-size: 13px;
  color: var(--ink-40);
  line-height: 1.55;
}

/* Surfaces this pass does not cover get an honest panel, not a dead link. */
.stub {
  margin: 28px;
  padding: 40px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--edge-ring);
  max-width: 620px;
}
.stub h2 { font-size: 22px; margin-bottom: 8px; }
.stub p { font-size: 14px; color: var(--ink-60); line-height: 1.6; }

/* ─────────────────────────────  toasts  ──────────────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  background: var(--ink);
  color: #F4F1E7;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(62, 58, 47, 0.28);
  animation: toast-in 140ms ease-out;
}
.toast button {
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 14px;
  color: var(--accent-tint);
  cursor: pointer;
  padding: 0;
}
.toast button:hover { color: #fff; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* A link inside a row that is itself a button: styled as a link, not nested
   interactive markup. */
.linkish {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color .18s ease;
}
.linkish:hover { color: var(--accent-deeper); }

/* Sample-data marker — contract §1: seeded data is labelled as such, always. */
.rail__sample {
  display: flex;
  gap: 8px;
  padding: 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-45);
}
.rail__sample i { font-size: 14px; flex: none; margin-top: 1px; }
.rail__sample .linkish { font-size: 13px; }

.card--button {
  width: 100%;
  text-align: left;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: box-shadow .25s ease;
}
.card--button:hover { box-shadow: var(--edge-ring-accent); }

.warn-note {
  display: flex;
  gap: 8px;
  padding: 10px 11px;
  border-radius: var(--r-lg);
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 13px;
  line-height: 1.5;
}
.warn-note i { font-size: 16px; flex: none; margin-top: 1px; }

/* Same shape, opposite news. A confirmation that borrows the warning's styling
   reads as a warning at a glance, which is the wrong first impression for
   "that worked". */
.warn-note--ok {
  background: var(--accent-bg, rgba(98, 122, 74, 0.12));
  color: var(--accent-deeper, #41522F);
}

.admin__audit { padding: 4px 12px 16px; background: var(--surface-sunk); }
/* A coach's real coach_profiles row, on the same audit panel as the "what
   this account records" list above it — admin already has read access
   (coach_profiles_public_read grants is_admin() every row), just never
   showed it. .card, not a bare block: it's a different kind of fact
   (curated marketplace content, not stored account fields) and reads as
   one at a glance rather than blending into the list above it. */
.admin__coachsnap { margin-top: 12px; }
.admin__coachsnap .kicker { margin: 0; }

.stat__val--none { color: var(--ink-35); }
.pcard__bio.is-placeholder { color: var(--ink-40); }

.lead {
  font-size: 14px;
  color: var(--ink-60);
  line-height: 1.6;
  margin-top: 6px;
  max-width: 620px;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-sunk);
  padding: 1px 5px;
  border-radius: 4px;
}

/* The inspector title doubles as the control that changes the exercise. */
.inspector__title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 2px 6px;
  margin-left: -6px;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 15px;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .18s ease, color .18s ease;
}
.inspector__title i { font-size: 13px; color: var(--ink-40); }
.inspector__title:hover { background: var(--accent-soft); color: var(--accent-deeper); }

.app--gate { display: block; min-width: 0; max-width: none; background: var(--canvas); }

.rail__me {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-lg);
  background: var(--surface-sunk);
}
.rail__me-who { flex: 1; min-width: 0; }
.rail__me-who div:first-child {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail__me-who div:last-child { font-size: 12px; color: var(--ink-45); }
.rail__me .linkish { font-size: 17px; text-decoration: none; }
