/* Reusable components. */

/* ---------- Page scaffolding ---------- */
/* Pages sit centred in the main area (right of the sidebar) at a readable width. */
.page { padding: 26px var(--gutter) 40px; max-width: var(--page-max); margin-inline: auto; }
.page.narrow { max-width: var(--page-narrow); }
.page-head { margin-bottom: 26px; }
.page-head h1 { max-width: 16ch; }
.page-head .lede { margin-top: 14px; max-width: 34ch; }
@media (min-width: 1024px) { .page { padding-top: 38px; } }

.cols { display: grid; gap: 34px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .cols { grid-template-columns: minmax(0, 1fr) 340px; gap: 56px; align-items: start; }
  .cols.even { grid-template-columns: 1fr 1fr; }
  .cols > .aside { position: sticky; top: 88px; }
}

.section { margin-top: 38px; }
.section:first-child { margin-top: 0; }
.section-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; justify-content: space-between;
  padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: 25px; }
.section-head .meta { font-size: 14px; color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-m);
  font-weight: 700; font-size: 15.5px; text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s;
}
.btn svg { width: 19px; height: 19px; flex: none; }
.btn-primary { background: var(--coral); color: var(--coral-ink); }
.btn-primary:hover { background: var(--coral-hover); }
.btn-secondary { border-color: var(--line-2); color: var(--text); }
.btn-secondary:hover { border-color: var(--text-2); background: var(--surface); }
.btn-ghost { color: var(--text); padding: 0 12px; }
.btn-ghost:hover { background: var(--surface); }
.btn-light { background: var(--text); color: var(--bg); }
.btn-light:hover { background: #fff; }
.btn-danger { border-color: rgba(255,130,120,.45); color: #FFB3AC; }
.btn-danger:hover { background: rgba(255,130,120,.08); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Website-style text link: short rule, then label */
.line-link {
  display: inline-flex; align-items: center; gap: 12px; min-height: var(--tap);
  color: var(--coral); text-decoration: none; font-size: 15.5px;
}
.line-link::before { content: ""; width: 28px; height: 1px; background: currentColor; flex: none; }
.line-link:hover { color: var(--coral-hover); }
.line-link svg { width: 15px; height: 15px; }
.line-link .ext-note { color: var(--text-3); font-size: 12.5px; }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 3px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid var(--line-2); color: var(--text-2);
}
.tag svg { width: 12px; height: 12px; }
.tag-new { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag-concept { border-style: dashed; border-color: rgba(157,185,245,.6); color: var(--info); }
.tag-demo { border-style: dashed; color: var(--amber); border-color: rgba(242,190,92,.5); }
.tag-ext { color: var(--text-2); }
.tag-removed { color: var(--text-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.tag-warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag-coral { background: var(--coral-soft); color: var(--coral); border-color: transparent; }
.tag-solid { background: var(--surface-3); color: var(--text); border-color: transparent; }

/* ---------- Grade & hold identity ---------- */
.grade {
  display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.grade i {
  width: 12px; height: 12px; border-radius: 50%; background: var(--gc, #888); flex: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
}
.grade.lg { font-family: var(--font-display); font-size: 30px; gap: 10px; }
.grade.lg i { width: 18px; height: 18px; }
.hold-sw { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); white-space: nowrap; }
.hold-sw i {
  width: 14px; height: 10px; border-radius: 6px 8px 5px 7px; background: var(--hc, #888); transform: rotate(-12deg);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.12);
}
.ptag { font-family: var(--font-display); font-weight: 700; letter-spacing: .02em; }

/* ---------- Segmented control & tabs ---------- */
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--r-m); gap: 2px; background: var(--bg); max-width: 100%; overflow-x: auto; }
.seg button, .seg a {
  min-height: 38px; padding: 0 13px; border-radius: 4px; font-weight: 700; font-size: 14.5px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; white-space: nowrap;
}
.seg svg { width: 17px; height: 17px; }
.seg [aria-pressed="true"], .seg [aria-current="page"], .seg [aria-selected="true"] { background: var(--text); color: var(--bg); }
.seg button:hover:not([aria-pressed="true"]) { color: var(--text); }

.subnav {
  display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 26px; overflow-x: auto;
  scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  display: inline-flex; align-items: center; min-height: 46px; text-decoration: none; color: var(--text-2);
  font-weight: 700; font-size: 16px; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav a:hover { color: var(--text); }
.subnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--coral); }

/* ---------- Chips (filters) ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--line-2); font-size: 14.5px; color: var(--text-2); white-space: nowrap; flex: none;
  background: rgba(22,23,28,.85);
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--gc); box-shadow: 0 0 0 1px rgba(0,0,0,.45); }
.chip svg { width: 15px; height: 15px; }
/* chips keep 44px hit area */
.chip { position: relative; }
.chip::after { content: ""; position: absolute; inset: -3px 0; }

/* ---------- Rows & lists ---------- */
.rows > li, .rows > .row-item { border-bottom: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 0; text-decoration: none; color: inherit; width: 100%; min-height: 56px;
}
a.row:hover .row-title, button.row:hover .row-title { color: var(--coral); }
.row-title { font-weight: 700; font-size: 16.5px; line-height: 1.25; }
.row-sub { color: var(--text-2); font-size: 14px; margin-top: 2px; line-height: 1.4; }
.row-meta { text-align: right; font-size: 14px; color: var(--text-2); white-space: nowrap; }
.row-lead { width: 44px; display: grid; place-items: center; }
.row .chev { width: 18px; height: 18px; color: var(--text-3); }
.row.no-lead { grid-template-columns: minmax(0, 1fr) auto; }

.date-block {
  width: 48px; text-align: center; line-height: 1; padding: 6px 0; border: 1px solid var(--line-2); border-radius: var(--r-s);
}
.date-block b { display: block; font-family: var(--font-display); font-size: 22px; }
.date-block span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 22px; font-size: 15px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border-top: 1px solid var(--line); }
.stat { padding: 16px 16px 16px 0; border-bottom: 1px solid var(--line); }
.stat b { display: block; font-family: var(--font-display); font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 14px; color: var(--text-2); margin-top: 6px; }
.stat small { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* ---------- Notices ---------- */
.notice {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 14px 16px; border-radius: var(--r-m); border: 1px solid var(--line-2); background: var(--bg-raise);
}
.notice > svg { width: 20px; height: 20px; margin-top: 1px; color: var(--text-2); }
.notice b { display: block; }
.notice p { margin: 2px 0 0; color: var(--text-2); font-size: 14.5px; }
.notice.warn { border-color: rgba(242,190,92,.35); background: var(--amber-soft); }
.notice.warn > svg { color: var(--amber); }
.notice.concept { border-style: dashed; border-color: rgba(157,185,245,.45); background: rgba(157,185,245,.05); }
.notice.concept > svg { color: var(--info); }
.notice.ok { border-color: rgba(143,211,166,.35); background: var(--ok-soft); }
.notice.ok > svg { color: var(--ok); }
.notice.sim { border-style: dashed; border-color: rgba(242,190,92,.45); background: rgba(242,190,92,.05); }
.notice.sim > svg { color: var(--amber); }

.source-note { font-size: 12.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.source-note svg { width: 13px; height: 13px; }

/* ---------- Avatars ---------- */
.av {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; color: #16171C; background: var(--avc, #888);
}
.av.lg { width: 44px; height: 44px; font-size: 15px; }
.av.xl { width: 64px; height: 64px; font-size: 21px; }
.av.private { background: var(--surface-3); color: var(--text-2); }
.av-stack { display: inline-flex; }
.av-stack .av { box-shadow: 0 0 0 2px var(--bg); }
.av-stack .av + .av { margin-left: -8px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 7px; margin-bottom: 18px; }
.field > label, .field > .label, legend.label { font-weight: 700; font-size: 14.5px; }
.field .hint { font-size: 13px; color: var(--text-3); }
.field .err { font-size: 13.5px; color: #FFB3AC; display: none; }
.field.invalid .err { display: block; }
.field.invalid .input { border-color: #FF8A80; }
.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: var(--r-m);
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 16px;
}
.input:focus { border-color: var(--coral); outline: none; box-shadow: 0 0 0 3px var(--coral-soft); }
textarea.input { min-height: 88px; resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

.choice-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.choice {
  position: relative; display: grid; gap: 2px; padding: 12px 14px; min-height: var(--tap);
  border: 1px solid var(--line-2); border-radius: var(--r-m); cursor: pointer;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice b { font-size: 15.5px; }
.choice span { font-size: 13px; color: var(--text-2); }
.choice:hover { border-color: var(--text-3); }
.choice:has(input:checked) { border-color: var(--coral); background: var(--coral-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--coral); outline-offset: 2px; }
.choice:has(input:disabled) { opacity: .45; cursor: not-allowed; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle-row b { display: block; font-size: 15.5px; }
.toggle-row span { font-size: 13.5px; color: var(--text-2); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: var(--surface-3); transition: background .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text); transition: transform .18s var(--ease); }
.switch input:checked + i { background: var(--coral); }
.switch input:checked + i::after { transform: translateX(20px); background: var(--coral-ink); }
.switch input:focus-visible + i { outline: 2px solid var(--coral); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--r-m); }
.stepper button { width: var(--tap); height: var(--tap); display: grid; place-items: center; }
.stepper button svg { width: 18px; height: 18px; }
.stepper output { min-width: 44px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Meter ---------- */
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--text); border-radius: 3px; }
.meter.coral i { background: var(--coral); }

/* ---------- Empty ---------- */
.empty { padding: 34px 0; text-align: left; max-width: 46ch; }
.empty h3 { margin-bottom: 8px; }
.empty p { color: var(--text-2); }

/* ---------- Misc ---------- */
.divider-v { width: 1px; align-self: stretch; background: var(--line); }
.inline-icon { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; }
.kbd { font-size: 12px; border: 1px solid var(--line-2); border-radius: 3px; padding: 1px 5px; color: var(--text-2); }
.pill-count { font-size: 12px; color: var(--text-3); font-weight: 400; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-s { margin-top: 10px; } .mt-m { margin-top: 18px; } .mt-l { margin-top: 30px; }
.mb-s { margin-bottom: 10px; } .mb-m { margin-bottom: 18px; }
.hide-phone { display: none; }
@media (min-width: 720px) { .hide-phone { display: initial; } .hide-wide { display: none !important; } }

/* Row text stacks as blocks; .flex variants keep their own layout */
.row-title, .row-sub { display: block; }
.row-title.flex, .row-sub.flex { display: flex; }
.row-sub + .row-sub { margin-top: 2px; }

/* Grid children never grow past the viewport; carousels scroll inside (R11) */
.cols > *, .hero-grid > *, .guide-cols > *, .hist-body > * { min-width: 0; }
.table-wrap { overflow-x: auto; max-width: 100%; }
