/* ============================================================================
   Component recipes — docs/design-system.md §9

   Each block is the §9 recipe translated from its Tailwind utility string to
   the same values as a CSS class. The class names match the recipe names so a
   template can be read against the spec.

   Recurring decisions encoded here, easy to get subtly wrong:
     · transitions name explicit properties, never `all`
     · disabled sits at 45% opacity
     · solid fills use -strong (white type at 4.5:1), never the base tone
     · a loading button keeps its label in place so its width never jumps
   ========================================================================= */

/* ── 9.1 Button ──────────────────────────────────────────────────────────── */

.btn {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  user-select: none;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease),
              box-shadow 160ms var(--ease), color 160ms var(--ease);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.45;
}

.btn .icon { flex-shrink: 0; }

/* Sizes */
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--text-xs); gap: 6px; border-radius: var(--radius-sm); }
.btn-md { height: 36px; padding: 0 14px; font-size: var(--text-sm); gap: 8px; border-radius: var(--radius-md); }
.btn-icon.btn-sm { width: 28px; padding: 0; }
.btn-icon.btn-md { width: 36px; padding: 0; }

/* Variants — one `primary` per view. `secondary` (teal) is a positive parallel
   action. `ghost` is the default for anything else. `quiet` is for icon buttons
   in dense chrome. `danger` only for irreversible destruction. */
.btn-primary {
  background-color: var(--coral-strong);
  color: #fff;
}
.btn-primary:hover, .btn-primary:active {
  background-color: var(--coral-hover);
  box-shadow: var(--shadow-raise);
  color: #fff;
}

.btn-secondary {
  background-color: var(--teal-strong);
  color: #fff;
}
.btn-secondary:hover, .btn-secondary:active {
  background-color: var(--teal-hover);
  box-shadow: var(--shadow-raise);
  color: #fff;
}

.btn-ghost {
  background-color: var(--surface);
  color: var(--ink);
  border-color: var(--rule);
}
.btn-ghost:hover {
  border-color: var(--rule-strong);
  background-color: var(--surface-alt);
  box-shadow: var(--shadow-raise);
  color: var(--ink);
}

.btn-quiet {
  background-color: transparent;
  color: var(--ink-soft);
}
.btn-quiet:hover {
  color: var(--ink);
  background-color: var(--surface-alt);
}

/* Quiet buttons whose intent shows on hover, rather than sitting coloured in
   a table of forty rows. Same idea as the sign-out item in the user menu. */
.btn-quiet-positive:hover {
  background-color: var(--teal-soft);
  color: var(--teal-strong);
}
.btn-quiet-warning:hover {
  background-color: var(--amber-soft);
  color: var(--amber-strong);
}

.btn-danger {
  background-color: var(--crimson-strong);
  color: #fff;
}
.btn-danger:hover, .btn-danger:active {
  background-color: var(--crimson-hover);
  box-shadow: var(--shadow-raise);
  color: #fff;
}

/* Loading keeps the label in place and overlays a spinner, so the width of the
   button never jumps mid-submit. */
.btn[data-loading="true"] > * { visibility: hidden; }
.btn[data-loading="true"]::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 9999px;
  animation: spin 0.7s linear infinite;
  visibility: visible;
}

/* ── 9.2 Badge — tint ground + tint border + strong text. Never a solid fill:
      forty solid badges in a table turn the page into confetti. ─────────── */

.badge {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  white-space: nowrap;
  border: 1px solid;
  font-weight: 500;
  gap: 6px;
  border-radius: var(--radius-sm);
}
.badge-sm {
  height: 18px; padding: 0 6px;
  font-size: var(--text-label);
  letter-spacing: var(--text-label-ls);
  text-transform: uppercase;
  font-weight: 600;
}
.badge-md { height: 22px; padding: 0 8px; font-size: var(--text-xs); }

/* The dot uses the *base* tone — it is a graphic, not text. */
.badge-dot { width: 5px; height: 5px; flex-shrink: 0; border-radius: 9999px; }

/* ── 9.3 Panel — the workhorse container ─────────────────────────────────── */

.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  background-color: var(--surface);
}

.panel-interactive {
  transition: box-shadow 160ms var(--ease), border-color 160ms var(--ease);
}
.panel-interactive:hover {
  border-color: var(--rule-strong);
  box-shadow: var(--shadow-raise);
}

/* Padding is fixed. Do not improvise it. */
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--rule);
  padding: 12px 16px;
}
/* The panel header title is the caps label, not a heading font — the serif is
   reserved for page and dialog level. */
.panel-title { font-size: var(--text-label); line-height: var(--text-label-lh);
  letter-spacing: var(--text-label-ls); text-transform: uppercase;
  font-weight: 600; color: var(--ink); }
.panel-desc  { margin-top: 4px; font-size: var(--text-xs); color: var(--ink-mute); }
.panel-body  { padding: 16px; }
.panel-body-flush { padding: 0; }
.panel-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--rule);
  background-color: var(--surface-alt);   /* a small recession closes the panel */
  padding: 10px 16px;
  font-size: var(--text-xs);
  color: var(--ink-mute);
}

/* ── 9.4 Stat / StatRow — the boxless KPI band ───────────────────────────── */

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 28px;
}
.stat { min-width: 0; }
.stat-label { color: var(--ink-mute); }
.stat-figure {
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.stat-value {
  font-family: var(--font-display);
  /* A geometric sans reads thinner than the serif did at this size, so the
     figure takes a little more weight to keep its presence. */
  font-weight: 500;
  font-size: var(--text-figure);
  line-height: var(--text-figure-lh);
  letter-spacing: var(--text-figure-ls);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.stat-sub   { font-size: var(--text-xs); color: var(--ink-mute); overflow: hidden;
              text-overflow: ellipsis; white-space: nowrap; }
.stat-delta { margin-top: 8px; display: flex; align-items: center; gap: 4px;
              font-size: var(--text-xs); }

/* No card, no background, no border around a stat. Only vertical hairlines
   between them, and only from md up — a hairline between stacked cells reads
   as a table, not as columns. */
@media (min-width: 768px) {
  .stat-row { display: flex; column-gap: 0; row-gap: 0; }
  .stat-row > .stat { flex: 1 1 0%; padding: 0 24px; }
  .stat-row > .stat:first-child { padding-left: 0; }
  .stat-row > .stat:last-child  { padding-right: 0; }
  .stat-row > .stat + .stat { border-left: 1px solid var(--rule); }
}

/* ── 9.5 Table ───────────────────────────────────────────────────────────── */

/* Wide tables scroll inside their own box. The page body never scrolls
   horizontally. */
.table-wrap { width: 100%; overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  /* the caps label; the double-weight rule separates header from body with
     no fill behind it */
  font-size: var(--text-label);
  line-height: var(--text-label-lh);
  letter-spacing: var(--text-label-ls);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-mute);
  border-bottom: 2px solid var(--rule);
  padding: 10px 12px;
  text-align: left;
  vertical-align: bottom;
}
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child,  .table td:last-child  { padding-right: 16px; }
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  color: var(--ink-soft);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.table tbody tr.row-interactive {
  cursor: pointer;
  transition: background-color 160ms var(--ease);
}
.table tbody tr.row-interactive:hover { background-color: var(--surface-alt); }
.table tbody tr[aria-selected="true"] { background-color: var(--royal-soft); }
/* Zebra striping is not used — the hairline is enough. */

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.th-sort:hover { color: var(--ink); }
.th-sort .icon { opacity: 0.4; }
.th-sort[data-state="asc"] .icon,
.th-sort[data-state="desc"] .icon { opacity: 1; color: var(--coral); }
/* On numeric columns the glyph sits left of a right-aligned label. */
.num .th-sort { flex-direction: row-reverse; }

/* ── 9.6 Tabs — the sliding underline ────────────────────────────────────── */

.tablist {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 24px;
  overflow-x: auto;
  border-bottom: 1px solid var(--rule);
}
.tab {
  position: relative;
  margin-bottom: -1px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  padding: 4px 0 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-mute);
  transition: color 160ms var(--ease);
}
.tab:hover { color: var(--ink-soft); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab-count {
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm);
  padding: 0 4px;
  font-size: var(--text-label);
  background-color: var(--surface-alt);
  color: var(--ink-mute);
}
.tab[aria-selected="true"] .tab-count {
  background-color: var(--coral-soft);
  color: var(--coral-strong);
}
/* One measured element, sliding — not a per-tab border. The travel reads as a
   single continuous movement. */
.tab-marker {
  pointer-events: none;
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background-color: var(--coral);
  transition: transform 240ms var(--ease), width 240ms var(--ease);
}

/* ── 9.7 Inputs — one shared control recipe ──────────────────────────────── */

.control {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--rule);
  background-color: var(--surface);
  color: var(--ink);
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}
.control::placeholder { color: var(--ink-faint); }
.control:hover { border-color: var(--rule-strong); }
.control:disabled {
  cursor: not-allowed;
  background-color: var(--surface-alt);
  color: var(--ink-mute);
}
.control[aria-invalid="true"] {
  border-color: var(--crimson);
  background-color: var(--crimson-soft);
}

.input    { height: 36px; padding: 0 10px; font-size: var(--text-body); }
.input-icon { padding-left: 32px; }
.textarea { resize: vertical; padding: 8px 10px; font-size: var(--text-body); min-height: 92px; }
.select {
  height: 36px;
  cursor: pointer;
  appearance: none;
  padding: 0 32px 0 10px;
  font-size: var(--text-body);
}
.select-wrap { position: relative; }
.select-wrap > .icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-mute);
  pointer-events: none;
}
.input-wrap { position: relative; }
.input-wrap > .input-leading {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

.checkbox {
  appearance: none;
  width: 16px; height: 16px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  background-color: var(--surface);
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.checkbox::after {
  content: "";
  width: 9px; height: 5px;
  border: 1.5px solid #fff;
  border-top: 0; border-right: 0;
  transform: rotate(-45deg) translateY(-1px);
  opacity: 0;
  transition: opacity 160ms var(--ease);
}
.checkbox:checked {
  border-color: var(--coral);
  background-color: var(--coral);
}
.checkbox:checked::after { opacity: 1; }

.switch {
  appearance: none;
  position: relative;
  width: 36px; height: 20px;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 1px solid var(--rule-strong);
  background-color: var(--surface-alt);
  cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 14px; height: 14px;
  margin-top: -7px;
  border-radius: 9999px;
  background-color: var(--surface);
  box-shadow: var(--shadow-raise);
  transition: transform 160ms var(--ease);
}
.switch:checked { border-color: var(--teal); background-color: var(--teal); }
.switch:checked::after { transform: translateX(16px); }

/* The Field wrapper is the accessibility contract in one place: id,
   aria-describedby and aria-invalid cannot be forgotten at a call site. */
.field { display: flex; flex-direction: column; gap: 6px; }
/* Form labels are THE CAPS LABEL, not sentence case. A form should read like a
   printed record card. */
.field-label {
  font-size: var(--text-label);
  line-height: var(--text-label-lh);
  letter-spacing: var(--text-label-ls);
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-mute);
}
.field-required { margin-left: 4px; color: var(--coral); }
.field-desc  { font-size: var(--text-xs); color: var(--ink-mute); }
.field-error { font-size: var(--text-xs); color: var(--crimson-strong); }

/* ── 9.8 Dialog ──────────────────────────────────────────────────────────── */

/* Navy at 35% with a 2px blur — not black at 50%. It keeps the overlay inside
   the brand family. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay-backdrop {
  position: absolute;
  inset: 0;
  background-color: color-mix(in srgb, var(--chrome) 35%, transparent);
  backdrop-filter: blur(2px);
  animation: fade 0.18s var(--ease) both;
}
.dialog {
  position: relative;
  display: flex;
  width: 100%;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  background-color: var(--surface);
  box-shadow: var(--shadow-float);
  animation: rise 0.24s var(--ease) both;
}
.dialog-sm { max-width: 400px; }
.dialog-md { max-width: 520px; }
.dialog-lg { max-width: 720px; }

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 12px;
}
.dialog-title {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  line-height: var(--text-h2-lh);
  letter-spacing: var(--text-h2-ls);
  color: var(--ink);
}
.dialog-desc { margin-top: 6px; font-size: var(--text-sm); color: var(--ink-soft); }
.dialog-body {
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px 20px;
  font-size: var(--text-body);
  color: var(--ink-soft);
}
.dialog-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--rule);
  background-color: var(--surface-alt);
  padding: 12px 20px;
}

/* ── 9.9 Drawer — detail without losing your place ───────────────────────── */

.drawer-overlay { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; }
.drawer {
  position: relative;
  display: flex;
  height: 100%;
  width: 100%;
  flex-direction: column;
  border-left: 1px solid var(--rule);
  background-color: var(--surface);
  box-shadow: var(--shadow-drawer);
  animation: slide-in 0.26s var(--ease) both;
}
@media (min-width: 640px) { .drawer { max-width: 520px; } }
.drawer-header {
  display: flex; align-items: flex-start; gap: 16px;
  border-bottom: 1px solid var(--rule);
  padding: 16px 20px;
}
.drawer-body   { min-height: 0; flex: 1 1 0%; overflow-y: auto; }
.drawer-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--rule);
  background-color: var(--surface-alt);
  padding: 12px 20px;
}

/* ── 9.10 Toast ──────────────────────────────────────────────────────────── */

.toast-region {
  pointer-events: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 60;
  display: flex;
  width: min(360px, calc(100vw - 2.5rem));
  flex-direction: column;
  gap: 10px;
}
.toast {
  pointer-events: auto;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  background-color: var(--surface);
  box-shadow: var(--shadow-float);
  animation: rise 0.24s var(--ease) both;
}
.toast-inner { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; }
.toast-title { font-size: var(--text-sm); font-weight: 500; color: var(--ink); }
.toast-desc  { margin-top: 4px; font-size: var(--text-xs); color: var(--ink-mute); }
/* the timer is a 1px hairline */
.toast-timer { height: 1px; transform-origin: left; }

/* ── 9.11 Tooltip — navy in BOTH themes: a read-out is chrome ────────────── */

.tooltip {
  pointer-events: none;
  position: fixed;
  z-index: 70;
  max-width: 240px;
  border-radius: var(--radius-md);
  background-color: var(--chrome);
  padding: 4px 8px;
  font-size: var(--text-xs);
  color: var(--chrome-text-strong);
  box-shadow: var(--shadow-float);
  animation: fade 0.18s var(--ease) both;
}

/* ── 9.12 Avatar ─────────────────────────────────────────────────────────── */

.avatar {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 9999px;
  border: 1px solid;
  font-weight: 600;
  user-select: none;
  line-height: 1;
}
.avatar-xs { width: 20px; height: 20px; font-size: var(--text-label); }
.avatar-sm { width: 24px; height: 24px; font-size: var(--text-label); }
.avatar-md { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 44px; height: 44px; font-size: var(--text-sm); }
/* The topbar avatar is the one solid-fill exception — it sits in chrome. */
.avatar-chrome {
  background-color: var(--coral-strong);
  border-color: transparent;
  color: #fff;
}

/* ── 9.13 Progress and score bars ────────────────────────────────────────── */

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 9999px;
  background-color: var(--surface-sunken);
}
.progress-fill {
  display: block;
  height: 100%;
  border-radius: 9999px;
  transition: width 500ms var(--ease);
}
@starting-style { .progress-fill { width: 0; } }
.progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--text-xs);
}
.progress-count { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--ink); }
.progress-slash { color: var(--ink-faint); }

/* ── 9.14 Empty state ────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 24px;
  text-align: center;
}
.empty-state-compact { padding: 40px 24px; }
/* The illustration is a hairline diagram in currentColor, so it inherits the
   surrounding text colour and can never fight the palette. */
.empty-illustration { color: var(--ink-faint); }
.empty-title {
  margin-top: 24px;
  font-family: var(--font-display);
  font-size: var(--text-h2);
  line-height: var(--text-h2-lh);
  letter-spacing: var(--text-h2-ls);
  color: var(--ink);
}
.empty-desc {
  margin-top: 8px;
  max-width: 46ch;
  font-size: var(--text-sm);
  color: var(--ink-mute);
}
.empty-action { margin-top: 20px; }

/* ── 9.15 Skeleton ───────────────────────────────────────────────────────── */

.skeleton {
  border-radius: var(--radius-sm);
  height: 12px;
  background-image: linear-gradient(90deg,
    var(--surface-alt) 0%, var(--rule) 45%, var(--surface-alt) 90%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}

/* ── 9.23 Status medallion and full-page states ──────────────────────────── */

.state-page {
  margin: 0 auto;
  display: flex;
  max-width: 28rem;
  flex-direction: column;
  align-items: center;
  padding: 96px 24px;
  text-align: center;
}
/* The confirm dialog clones the icon out of the button that opened it, at
   whatever size that button used; the medallion sets its own. */
[data-confirm-medallion] svg { width: 20px; height: 20px; }

.medallion {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  border-radius: 9999px;
  border: 1px solid;
}
.state-title {
  margin-top: 20px;
  font-family: var(--font-display);
  font-size: var(--text-h2);
  line-height: var(--text-h2-lh);
  letter-spacing: var(--text-h2-ls);
  font-weight: 500;
  color: var(--ink);
}
.state-desc { margin-top: 8px; font-size: var(--text-sm); line-height: 1.6; color: var(--ink-soft); }
/* Always surface the reference code in mono — it is what turns "it broke" into
   something a support conversation can act on. */
.state-code {
  margin-top: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background-color: var(--surface-alt);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}

/* ── 9.22 Filter bar — the ruled strip, like a masthead rule ─────────────── */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
}
.filter-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-search { width: 224px; }

/* ── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pagination-pages { display: flex; align-items: center; gap: 4px; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.page-link:hover { background-color: var(--surface-alt); color: var(--ink); }
.page-link[aria-current="page"] {
  border-color: var(--rule);
  background-color: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-raise);
}
.page-gap { padding: 0 4px; color: var(--ink-faint); }

/* ── Definition list used in detail rows and card metadata ───────────────── */

.meta-list { display: grid; gap: 10px; }
.meta-row  { display: flex; align-items: baseline; gap: 12px; }
.meta-term { flex-shrink: 0; width: 120px; color: var(--ink-mute); }
.meta-desc { min-width: 0; color: var(--ink); }

/* ── The keyboard hint chip ──────────────────────────────────────────────── */

.kbd {
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background-color: var(--surface);
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
}

/* ── Link tabs ───────────────────────────────────────────────────────────
   Where the tabs are links carrying a URL filter rather than scripted panels,
   the marker is the active tab's own border: there is nothing to slide
   between, because the page reloads. */

.tablist-static .tab[aria-selected="true"] { border-bottom-color: var(--coral); }

/* ── The expanding detail row ────────────────────────────────────────────
   The system would open a record in a drawer at its own route. That is a
   routing change, so the existing in-page expansion is kept and restyled. */

.detail-row > td { padding: 0; background-color: var(--surface-alt); }
.detail-panel { padding: 20px 16px; border-top: 1px solid var(--rule); }

/* ── Book covers ─────────────────────────────────────────────────────────── */

.book-cover {
  max-height: 120px;
  width: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
}
.book-cover-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 176px;
  padding: 16px;
  background-color: var(--surface-alt);
  border-bottom: 1px solid var(--rule);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.book-cover-frame img { max-height: 144px; width: auto; object-fit: contain; }
.book-cover-badge { position: absolute; top: 8px; right: 8px; }

/* A checkbox sits beside its label rather than under a caps label. */
.field-inline { gap: 4px; }

/* A field the ISBN lookup has just filled — tinted until someone edits it, so
   it is clear what came from Google Books. At rest these are ordinary fields:
   the old permanent grey recess made them look disabled. */
.control[data-filled="true"] {
  background-color: var(--teal-soft);
  border-color: var(--teal-line);
}

/* A cover thumbnail in a list row. */
.cover-thumb {
  height: 44px;
  width: 31px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
}
.cover-thumb-empty {
  display: grid;
  place-items: center;
  background-color: var(--surface-alt);
  color: var(--ink-faint);
}

/* ── Roster cards ────────────────────────────────────────────────────────
   Cards in a row share a height so their footers line up on one baseline —
   ragged footers read as an accident rather than a grid. */

.roster > .panel { display: flex; flex-direction: column; }
.roster > .panel > .panel-body { flex: 1 1 auto; }

/* The filter bar's top border duplicates the page header's rule when it sits
   directly beneath one. */
.filter-bar-flush { border-top: 0; padding-top: 0; }

/* ── Book picker (combobox) ──────────────────────────────────────────────
   Replaces bootstrap-select. A text box that shows the chosen book and drops
   a list below it on click or typing. The native <select> stays in the form
   for submission and server-side validation, out of sight and out of the tab
   order. */

.combo { position: relative; }
.combo-field { position: relative; }
.combo-input { padding-left: 32px; padding-right: 60px; text-overflow: ellipsis; }
.combo-has-value .combo-input { font-weight: 500; }

.combo-lead,
.combo-caret {
  position: absolute;
  top: 50%;
  display: flex;
  pointer-events: none;
  transform: translateY(-50%);
}
.combo-lead  { left: 10px;  color: var(--ink-faint); }
.combo-caret { right: 10px; color: var(--ink-mute); transition: transform 160ms var(--ease); }
.combo-open .combo-caret { transform: translateY(-50%) rotate(180deg); }

.combo-clear {
  position: absolute;
  right: 30px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  border-radius: var(--radius-sm);
  color: var(--ink-faint);
  transition: color 160ms var(--ease), background-color 160ms var(--ease);
}
.combo-clear:hover { color: var(--ink); background-color: var(--surface-alt); }

.combo-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  max-height: min(20rem, 50vh);
  overflow-y: auto;
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  background-color: var(--surface);
  box-shadow: var(--shadow-float);
  animation: rise 0.24s var(--ease) both;
}
.combo-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.combo-option[data-active="true"] { background-color: var(--surface-alt); }
.combo-check { display: flex; width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; color: var(--coral); }
.combo-text  { min-width: 0; flex: 1 1 auto; }
.combo-title { display: block; font-size: var(--text-sm); color: var(--ink); }
.combo-option[aria-selected="true"] .combo-title { font-weight: 500; }
.combo-meta  { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--ink-mute); }
.combo-stock { flex-shrink: 0; margin-top: 2px; font-size: var(--text-xs); white-space: nowrap; }
.combo-empty { padding: 16px 12px; font-size: var(--text-sm); color: var(--ink-mute); }

.combo-native {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  opacity: 0;
  pointer-events: none;
}
