/* ==========================================================================
   CastleCRM design system. 4 of 5: LAYOUTS. The app shell (the strap), page header, the ticket
   header on detail pages, list/form/detail page frames, the dashboard, login and the style guide.
   ========================================================================== */

/* ---------- The strap: an ink lanyard with gold stitching ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.strap {
  position: relative; display: grid; align-items: stretch; background: var(--strap-bg); color: var(--strap-text);
  grid-template-columns: auto minmax(0, 1fr) minmax(12rem, 19rem) auto;
  grid-template-areas: "brand nav search user";
  min-height: var(--strap-h);
}
.strap::before, .strap::after {
  content: ""; position: absolute; left: 0; right: 0; height: 0; z-index: 2; pointer-events: none;
  border-top: var(--rule-mid) dashed var(--stitch); opacity: .9;
}
.strap::before { top: 5px; }
.strap::after { bottom: 5px; }
.strap :focus-visible { outline-color: var(--focus-on-dark); outline-offset: -3px; }
.strap__brand { grid-area: brand; display: flex; align-items: center; padding: 0 var(--sp-6) 0 var(--sp-6); }
.strap__brand img { display: block; height: 26px; width: auto; }
.strap__mark { display: none !important; }
.strap__nav { grid-area: nav; display: flex; min-width: 0; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; align-items: stretch; min-width: 0; }
.nav > li { display: flex; position: relative; }
.nav__link {
  display: flex; align-items: center; gap: 6px; padding: 0 11px; white-space: nowrap; text-decoration: none;
  color: var(--strap-text); font-size: var(--fs-1); font-weight: var(--fw-medium); font-stretch: var(--wd-semi);
}
a.nav__link:hover { color: var(--text-inverse); background: var(--strap-field); text-decoration: none; }
.nav__link[aria-current="page"], a.nav__link[aria-current="page"]:hover { background: var(--strap-current); color: var(--strap-on-current); font-weight: var(--fw-heavy); }
.nav__link--inert { color: var(--strap-text-off); cursor: default; }
.nav__count { padding: 1px 4px; background: var(--strap-text); color: var(--strap-bg); font: var(--fw-bold) 11px / 1.2 var(--font); font-variant-numeric: tabular-nums; }
.nav__link[aria-current="page"] .nav__count { background: var(--strap-on-current); color: var(--strap-current); }
.strap__search { grid-area: search; position: relative; display: flex; align-items: center; padding: 0 var(--sp-3); margin: 0; }
.strap__search-input {
  width: 100%; height: 32px; padding: 0 var(--sp-3) 0 32px; border: var(--rule-hair) solid var(--strap-field-border); border-radius: var(--radius);
  background: var(--strap-field); color: var(--text-inverse); font-size: var(--fs-1);
}
.strap__search-input::placeholder { color: var(--strap-text-dim); opacity: 1; }
.strap__search-input:focus { outline: var(--focus-ring) solid var(--focus-on-dark); outline-offset: 0; }
.strap__search-icon { position: absolute; left: 22px; color: var(--strap-text-dim); pointer-events: none; }
.strap__user { grid-area: user; display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-5) 0 var(--sp-2); }
.strap__user form { margin: 0; display: flex; }
.strap__account, .strap__logout {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 32px; padding: 0 6px; border: 0; background: none;
  color: var(--strap-text); text-decoration: none; cursor: pointer; font-size: var(--fs-1); font-weight: var(--fw-semibold); font-stretch: var(--wd-semi); white-space: nowrap;
}
.strap__account:hover, .strap__logout:hover { color: var(--text-inverse); background: var(--strap-field); text-decoration: none; }
.strap__account .avatar { background: var(--strap-text); border: 0; color: var(--strap-bg); }
.strap__account-label, .strap__logout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 1680px) {
  .strap__account-label, .strap__logout-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}
/* Laptop and tablet: two strap rows, sections across the second */
@media (max-width: 1379px) {
  .strap { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand search user" "nav nav nav"; grid-template-rows: 54px 42px; }
  .strap__search { justify-content: flex-end; }
  .strap__search-input { max-width: 24rem; }
  .strap__search-icon { left: auto; right: calc(var(--sp-3) + 24rem - 32px); }
  .strap__search { width: 100%; }
  .strap__nav { border-top: var(--rule-hair) solid var(--strap-field); padding: 0 var(--sp-3) 6px; overflow-x: auto; scrollbar-width: none; }
  .strap__nav::-webkit-scrollbar { display: none; }
}
/* Phone: brand + account, then the sections (scroll sideways), then search on stock */
@media (max-width: 760px) {
  .strap { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand user" "nav nav" "search search"; grid-template-rows: 52px 44px auto; }
  .strap::after { bottom: auto; top: 90px; }
  .strap__brand { padding: 0 var(--sp-4); }
  .strap__brand img { height: 22px; }
  .strap__user { padding: 0 var(--sp-3) 0 0; }
  .strap__account, .strap__logout { min-height: var(--tap); min-width: var(--tap); justify-content: center; }
  .strap__nav { padding: 0 0 6px; }
  .nav__link { padding: 0 var(--sp-3); }
  .nav > li:has([aria-current]) { order: -1; } /* keep the current section in view without scrolling */
  .strap__search { padding: var(--sp-2) var(--sp-4); background: var(--surface-sunk); border-bottom: var(--rule-hair) solid var(--rule); }
  .strap__search-input { max-width: none; height: 38px; background: var(--surface); color: var(--text); border-color: var(--border-field); }
  .strap__search-input::placeholder { color: var(--text-faint); }
  .strap__search-input:focus { outline-color: var(--focus); }
  .strap__search-icon { left: 26px; right: auto; color: var(--text-muted); }
}

/* ---------- Page frame ---------- */
.content { flex: 1; width: 100%; max-width: var(--page-max); margin: 0 auto; padding: var(--sp-5) var(--gutter) var(--sp-8); min-width: 0; }
.app-foot {
  display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-5); width: 100%; max-width: var(--page-max); margin: 0 auto;
  padding: var(--sp-3) var(--gutter) var(--sp-5); color: var(--text-muted); font-size: var(--fs-0); font-weight: var(--fw-semibold);
}
.app-foot > span { color: var(--text); font-weight: var(--fw-heavy); margin-right: auto; }
.app-foot a { color: var(--text-muted); }

/* Page header: the big wide title on a 3 px rule */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-5); padding-bottom: 14px; margin-bottom: var(--sp-1); border-bottom: var(--rule-title) solid var(--rule-strong); }
.page-header h1 { margin: 0; }
.page-header p { margin: var(--sp-2) 0 0; color: var(--text-muted); max-width: 72ch; }
.page-header .page-actions { padding-bottom: 2px; }
.page-header__kicker { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 6px; font-weight: var(--fw-heavy); font-stretch: 80%; font-size: var(--fs-2); }

/* ---------- The ticket: header of every record page ---------- */
.ticket {
  position: relative; display: grid; margin: 0 0 var(--sp-1);
  grid-template-columns: minmax(220px, max-content) minmax(0, 1fr) auto;
  grid-template-areas: "stub main side" "stub actions actions" "facts facts facts";
  border: var(--rule-heavy) solid var(--rule-strong);
  clip-path: polygon(0 var(--notch), var(--notch) 0, calc(100% - var(--notch)) 0, 100% var(--notch), 100% 100%, 0 100%);
}
.ticket:not(:has(> .ticket__stub)) { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main side" "actions actions" "facts facts"; }
.ticket__reg { position: absolute; top: 14px; right: 14px; width: 15px; height: 15px; border-radius: 50%; box-shadow: inset 0 0 0 var(--rule-mid) var(--rule-strong); pointer-events: none; }
.ticket__reg::before, .ticket__reg::after { content: ""; position: absolute; background: var(--rule-strong); }
.ticket__reg::before { left: 6.75px; top: -3px; width: 1.5px; height: 21px; }
.ticket__reg::after { top: 6.75px; left: -3px; height: 1.5px; width: 21px; }
.ticket__stub {
  grid-area: stub; display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-3); padding: 18px var(--sp-5);
  background: var(--strap-bg); color: var(--text-inverse); border-right: var(--rule-heavy) dashed var(--surface); min-width: 0;
}
.ticket__stub::after { content: ""; width: 40px; height: 6px; background: var(--accent); }
.ticket__kind { font: var(--fw-bold) var(--fs-0) / 1 var(--font); font-stretch: var(--wd-narrow); color: var(--strap-text); }
.ticket__no { margin: 0; font: var(--fw-max) var(--fs-6) / 0.9 var(--font); font-stretch: var(--wd-condensed); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
.ticket__no--sm { font-size: 34px; white-space: normal; overflow-wrap: anywhere; max-width: 16rem; }
.ticket__main { grid-area: main; padding: var(--sp-5) var(--sp-6) var(--sp-2); min-width: 0; }
.ticket__title { margin: 0; font: var(--fw-black) 30px / 1.02 var(--font); font-stretch: var(--wd-wide); letter-spacing: -0.015em; max-width: 30ch; overflow-wrap: anywhere; }
.ticket__sub { margin: var(--sp-2) 0 0; color: var(--text-muted); }
.ticket__sub a { color: var(--text); font-weight: var(--fw-heavy); }
.ticket__flags { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); margin-top: var(--sp-2); }
.ticket__flags:empty { display: none; }
.ticket__side { grid-area: side; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: var(--sp-5) 56px var(--sp-2) var(--sp-6); border-left: var(--rule-hair) solid var(--rule); min-width: 0; }
.ticket__side:empty { display: none; }
.ticket__label { font: var(--fw-bold) var(--fs-0) / 1 var(--font); font-stretch: var(--wd-narrow); color: var(--text-muted); }
.ticket__state { font-size: var(--fs-2); font-weight: var(--fw-heavy); }
.ticket__actions { grid-area: actions; padding: var(--sp-2) var(--sp-6) 18px; }
.ticket__actions:empty { display: none; }
.ticket > .facts { grid-area: facts; border-top: var(--rule-heavy) solid var(--rule-strong); }

/* Detail body: main column + activity/files column */
.detail-body { margin-top: var(--sp-1); }
.detail-grid { display: grid; gap: var(--sp-7) var(--sp-8); grid-template-columns: minmax(0, 2fr) minmax(17rem, 1fr); align-items: start; margin-top: var(--sp-5); }
.detail-grid > .stack > * + * { margin-top: var(--sp-7); }
.detail-section-nav { position: sticky; top: 0; z-index: var(--z-sticky); background: var(--surface); }

@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  :root { --gutter: var(--sp-4); --fs-5: 30px; --fs-6: 40px; }
  .content { padding-top: var(--sp-4); }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .page-actions .btn { flex: 1 1 auto; }
  .ticket { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stub" "main" "side" "actions" "facts"; clip-path: polygon(0 var(--notch), var(--notch) 0, calc(100% - var(--notch)) 0, 100% var(--notch), 100% 100%, 0 100%); }
  .ticket:not(:has(> .ticket__stub)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "side" "actions" "facts"; }
  .ticket__stub { flex-direction: row; align-items: flex-end; justify-content: space-between; padding: var(--sp-4) var(--sp-4) var(--sp-3); border-right: 0; border-bottom: var(--rule-heavy) dashed var(--surface); }
  .ticket__stub::after { display: none; }
  .ticket__main { padding: var(--sp-4) var(--sp-4) var(--sp-2); }
  .ticket__title { font-size: var(--fs-4); }
  .ticket__side { padding: var(--sp-2) var(--sp-4); border-left: 0; }
  .ticket__actions { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  .ticket__actions .btn { flex: 1 1 auto; }
  .ticket__reg { display: none; }
  .ticket > .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ticket > .facts > div:nth-child(2n+1) { border-left: 0; }
  .ticket > .facts > div:nth-child(n+3) { border-top: var(--rule-hair) solid var(--rule); }
}

/* ---------- Form page ---------- */
.form-card { max-width: 62rem; margin-top: var(--sp-5); }
.form-card > .alert { margin-bottom: var(--sp-5); }
.form-actions--sticky { position: sticky; bottom: 0; z-index: var(--z-sticky); background: var(--surface); padding-bottom: var(--sp-3); }
.form-actions__note { margin: 0 0 0 auto; color: var(--text-muted); font-size: var(--fs-0); font-weight: var(--fw-semibold); }

/* ---------- List page: phone reflow (rows become ruled blocks) ---------- */
@media (max-width: 40rem) {
  .table--reflow thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--reflow, .table--reflow tbody { display: block; }
  .table--reflow tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--sp-3); padding: 9px 0; border-bottom: var(--rule-hair) solid var(--rule); }
  .table--reflow tbody tr:last-child { border-bottom: var(--rule-heavy) solid var(--rule-strong); }
  .table--reflow td { display: block; height: auto; padding: 0 !important; border: 0 !important; background: none !important; }
  .table--reflow td:first-child { flex: 1 1 100%; font-size: var(--fs-2); }
  .table--reflow td.num { text-align: left; }
  .table--reflow td[data-label]:not(:first-child):not(:empty)::before { content: attr(data-label) " "; color: var(--text-muted); font-size: var(--fs-0); font-weight: var(--fw-bold); font-stretch: var(--wd-narrow); }
  .table--reflow tr:hover td { background: none; }
}

/* ---------- Dashboard: "Today", what needs attention ---------- */
.today-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-5); padding-bottom: 14px; border-bottom: var(--rule-title) solid var(--rule-strong); }
.today-head h1 { margin: 0; }
.today-head__date { display: block; margin-bottom: 6px; font-weight: var(--fw-heavy); font-stretch: 80%; font-size: var(--fs-2); color: var(--text-muted); }
.today-head__summary { margin: var(--sp-2) 0 0; max-width: 80ch; font-size: var(--fs-2); }
.today-head__summary strong { font-variant-numeric: tabular-nums; }
.today-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(18rem, 1fr); gap: var(--sp-7) var(--sp-8); align-items: start; margin-top: var(--sp-5); }
.today-grid > .stack > * + * { margin-top: var(--sp-7); }
.queue__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); padding-bottom: var(--sp-2); }
.queue__head h2 { margin: 0; flex: 1 1 auto; }
.queue__n { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 5px; margin-left: var(--sp-2); vertical-align: 0.15em; background: var(--text); color: var(--text-inverse); font: var(--fw-heavy) var(--fs-0) / 1 var(--font); font-stretch: var(--wd-narrow); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.queue__why { flex: 1 1 100%; margin: 0; color: var(--text-muted); font-size: var(--fs-0); order: 3; }
.queue .table th { border-top-width: var(--rule-heavy); }
.queue .table td:first-child { width: 96px; }
.week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: var(--rule-mid) solid var(--rule-strong); }
.week__day { min-width: 0; border-left: var(--rule-hair) solid var(--rule); }
.week__day:first-child { border-left: 0; }
.week__name { display: flex; justify-content: space-between; align-items: baseline; padding: 6px var(--sp-2); background: var(--surface-sunk); border-bottom: var(--rule-hair) solid var(--rule-strong); font-weight: var(--fw-heavy); font-stretch: var(--wd-narrow); }
.week__name b { font-weight: var(--fw-max); font-size: var(--fs-3); font-stretch: var(--wd-condensed); font-variant-numeric: tabular-nums; }
.week__day--today .week__name { background: var(--accent); color: var(--on-accent); }
.week__list { list-style: none; margin: 0; padding: 0; }
.week__item { padding: 6px var(--sp-2); border-bottom: var(--rule-hair) solid var(--rule-soft); font-size: var(--fs-0); line-height: 1.25; }
.week__item .record-no { font-size: var(--fs-1); display: block; }
.week__item--out { box-shadow: inset 0 3px 0 var(--ink-c); }
.week__empty { padding: 6px var(--sp-2); color: var(--text-faint); font-size: var(--fs-0); }
.week-key { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin: var(--sp-2) 0 0; font-size: var(--fs-0); color: var(--text-muted); }
.week-key span::before { content: ""; display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; background: var(--rule-strong); }
.week-key .week-key__out::before { background: var(--ink-c); }
.note-placeholder { display: flex; gap: var(--sp-3); align-items: flex-start; margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4); border: var(--rule-hair) dashed var(--rule-strong); color: var(--text-muted); font-size: var(--fs-0); }
.note-placeholder strong { color: var(--text); }
.note-placeholder .icon { color: var(--text); margin-top: 1px; }
@media (max-width: 1100px) { .today-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .week { grid-template-columns: minmax(0, 1fr); }
  .week__day { border-left: 0; }
  .week__day + .week__day { border-top: var(--rule-hair) solid var(--rule-strong); }
  .queue .table td:first-child { width: auto; }
}

/* ---------- Login: the front door keeps the storybook castle ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth__art {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: var(--sp-6);
  padding: var(--sp-8) var(--sp-8) var(--sp-7); background: var(--surface-inverse); color: var(--text-inverse); overflow: hidden;
}
.auth__art::before, .auth__art::after { content: ""; position: absolute; top: 0; bottom: 0; width: 0; border-left: var(--rule-mid) dashed var(--stitch); opacity: .9; }
.auth__art::before { left: 10px; }
.auth__art::after { right: 10px; }
.auth__castle { display: block; width: min(30rem, 92%); height: auto; margin: auto; }
.auth__line { margin: 0; max-width: 16ch; font: var(--fw-black) 44px / 0.98 var(--font); font-stretch: var(--wd-xwide); letter-spacing: -0.02em; color: var(--text-inverse); text-wrap: balance; }
.auth__line em { font-style: normal; color: var(--accent); }
.auth__sub { margin: 0; max-width: 40ch; color: var(--strap-text); font-size: var(--fs-2); }
.auth__panel { display: flex; align-items: center; justify-content: center; padding: var(--sp-8) var(--sp-7); }
.auth__card { width: 100%; max-width: 25rem; }
.auth__logo { display: block; height: 34px; width: auto; margin-bottom: var(--sp-8); }
.auth__card h1 { padding-bottom: var(--sp-3); margin-bottom: var(--sp-2); border-bottom: var(--rule-title) solid var(--rule-strong); }
.auth__card > p { color: var(--text-muted); margin-bottom: var(--sp-6); }
.auth__card .btn--block { height: 42px; font-size: var(--fs-2); margin-top: var(--sp-2); }
.auth__card .field { margin-bottom: var(--sp-4); }
.auth__card .input { height: 40px; font-size: var(--fs-2); }
.auth__card .alert { margin-bottom: var(--sp-4); }
.auth__foot { margin-top: var(--sp-6); padding-top: var(--sp-3); border-top: var(--rule-hair) solid var(--rule); color: var(--text-muted); font-size: var(--fs-0); }
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth__art { flex-direction: row; align-items: flex-end; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6) var(--sp-4); }
  .auth__castle { width: 7.5rem; margin: 0; flex: none; }
  .auth__line { font-size: 24px; }
  .auth__sub { display: none; }
  .auth__panel { align-items: flex-start; padding: var(--sp-6) var(--sp-4) var(--sp-7); }
  .auth__logo { margin-bottom: var(--sp-6); height: 28px; }
}

/* ---------- Style guide ---------- */
.sg { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: var(--sp-7); margin-top: var(--sp-5); align-items: start; }
.sg__toc { position: sticky; top: var(--sp-4); font-size: var(--fs-1); }
.sg__toc ol { list-style: none; margin: 0; padding: 0; border-top: var(--rule-heavy) solid var(--rule-strong); }
.sg__toc a { display: flex; gap: var(--sp-2); padding: 5px 0; border-bottom: var(--rule-hair) solid var(--rule-soft); color: var(--text); text-decoration: none; font-weight: var(--fw-semibold); }
.sg__toc a:hover { color: var(--link); }
.sg__toc span { width: 1.5em; color: var(--text-faint); font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); }
.sg__body > section { margin-bottom: var(--sp-8); scroll-margin-top: var(--sp-4); }
.sg__body > section > h2 { font-size: var(--fs-4); padding-bottom: var(--sp-2); border-bottom: var(--rule-title) solid var(--rule-strong); margin-bottom: var(--sp-3); }
.sg__body > section > p, .sg__lead { max-width: 75ch; color: var(--text-muted); }
.sg-example { margin: var(--sp-4) 0 var(--sp-6); }
.sg-example__title { margin: 0 0 var(--sp-2); font: var(--fw-heavy) var(--fs-1) / 1.2 var(--font); }
.sg-example__note { margin: 0 0 var(--sp-2); color: var(--text-muted); font-size: var(--fs-0); max-width: 75ch; }
.sg-example__demo { padding: var(--sp-5); border: var(--rule-hair) solid var(--rule); background: var(--surface); min-width: 0; }
.sg-example__demo--sunk { background: var(--surface-sunk); }
.sg-example__code { border: var(--rule-hair) solid var(--rule); border-top: 0; }
.sg-example__code summary { padding: 6px var(--sp-3); cursor: pointer; font-size: var(--fs-0); font-weight: var(--fw-bold); color: var(--text-muted); background: var(--surface-sunk); }
.sg-example__code summary:hover { color: var(--text); }
.sg-example__code pre { max-height: 22rem; padding: var(--sp-3); font-size: 12px; line-height: 1.5; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; }
.sg-example__code code { background: none; padding: 0; }
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: 0; border-top: var(--rule-heavy) solid var(--rule-strong); }
.sg-swatch { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--sp-3); padding: var(--sp-2) var(--sp-3) var(--sp-2) 0; border-bottom: var(--rule-hair) solid var(--rule-soft); font-size: var(--fs-0); }
.sg-swatch i { display: block; height: 44px; border: var(--rule-hair) solid var(--rule); }
.sg-swatch b { display: block; font-size: var(--fs-1); }
.sg-swatch code { background: none; padding: 0; font-size: 11.5px; color: var(--text-muted); }
.sg-ratio { display: inline-block; margin-top: 2px; font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); }
.sg-ratio--fail { color: var(--text-muted); font-weight: var(--fw-medium); }
.sg-type-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: var(--sp-4); align-items: baseline; padding: var(--sp-2) 0; border-bottom: var(--rule-hair) solid var(--rule-soft); }
.sg-type-row > code { font-size: 11.5px; background: none; color: var(--text-muted); }
.sg-space { display: flex; align-items: center; gap: var(--sp-3); padding: 3px 0; font-size: var(--fs-0); }
.sg-space i { display: block; height: 12px; background: var(--primary); }
.sg-rule { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-2) 0; font-size: var(--fs-0); }
.sg-rule i { display: block; width: 10rem; }
.sg-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0; border-top: var(--rule-heavy) solid var(--rule-strong); }
.sg-icons li { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-1); border-bottom: var(--rule-hair) solid var(--rule-soft); font-size: var(--fs-0); font-family: var(--font-mono); }
.sg-icons .icon { width: var(--icon-lg); height: var(--icon-lg); }
.sg-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--sp-2) var(--sp-6); }
.sg-chips > div { display: flex; flex-direction: column; gap: 3px; padding: var(--sp-2) 0; border-bottom: var(--rule-hair) solid var(--rule-soft); }
.sg-chips code { background: none; padding: 0; font-size: 11px; color: var(--text-muted); }
@media (max-width: 1000px) {
  .sg { grid-template-columns: minmax(0, 1fr); }
  .sg__toc { position: static; }
  .sg__toc ol { display: flex; flex-wrap: wrap; gap: 0 var(--sp-4); }
}
.card__header + .week { margin-top: var(--sp-3); }
