/* ==========================================================================
   Shared "Tabletop Ledger" Design System (F8 Reusable Hub Foundation)
   Warm paper light default + ember accent + serif display + dark dice-tray
   namespace (--x-*) + complete [data-theme="dark"] variable parity.
   ========================================================================== */

:root,
[data-theme="light"] {
  /* Warm "tabletop ledger" paper palette */
  --page: #efe9de;
  --tile: #fffdf9;
  --head: #f7f2e8;
  --soft: #f5f0e6;
  --trk: #e7dfd0;
  --ctl: #fffdf9;
  --ctl-hover: #f6f0e4;
  --nav: #fbf7ef;

  --line: #ddd3c1;
  --div: #e9e1d2;
  --line-strong: #c6b9a1;

  --ink: #1c1814;
  --ink-2: #463e35;
  --ink-3: #6b6256;
  --ink-4: #8f8575;
  --ink-inv: #fffdf9;

  /* Ember accent (primary actions, active states) */
  --acc: #b8431f;
  --acc-hover: #9c3716;
  --acc-tint: #fcefe7;
  --acc-line: #f1c9b4;
  --acc-ink: #9c3716;

  /* Data & semantic accents */
  --data: #0f766e;
  --data-tint: #e6f4f1;
  --data-line: #b5ddd6;
  --green: #047857;
  --green-tint: #e5f4ec;
  --green-line: #b9dfca;
  --amber: #a16207;
  --amber-bg: #fefaeb;
  --amber-tint: #fdf0c4;
  --amber-line: #ecd28a;
  --red: #be123c;
  --red-tint: #fff1f2;
  --red-line: #fecdd3;

  /* Dedicated dark "dice tray" surface (--x-*, active even in light mode) */
  --x-bg: #17130f;
  --x-panel: #1e1914;
  --x-ctl: #28211a;
  --x-ctl-hover: #332a21;
  --x-trk: #382f25;
  --x-axis: #4d4234;
  --x-div: #2a231b;
  --x-grid: rgba(255, 235, 200, 0.07);
  --x-ink: #f6efe3;
  --x-ink-2: #cdbfa9;
  --x-ink-3: #9a8c77;
  --x-ok: #5fd38d;
  --x-warn: #f2b84b;
  --x-fail: #ff8070;
  --x-data: #e3b45a;

  /* Footer surface */
  --foot-bg: #1a1612;
  --foot-bar: #120f0c;
  --foot-line: rgba(255, 235, 200, 0.09);
  --foot-grid: rgba(255, 235, 200, 0.05);
  --foot-ink: #d6c9b4;
  --foot-muted: #978a76;

  --focus: 0 0 0 2px var(--tile), 0 0 0 4px var(--acc);
  --r-sm: 5px;
  --r-md: 9px;
  --r-lg: 14px;

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --num: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --disp: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.3, 1.45, 0.5, 1);

  --wrap-max: 1280px;
  --nav-h: 54px;
}

/* Reserved full dark theme layer (activated via document.documentElement.dataset.theme = "dark") */
[data-theme="dark"] {
  --page: #0f0d0b;
  --tile: #181410;
  --head: #1e1914;
  --soft: #231d17;
  --trk: #2d261e;
  --ctl: #221c16;
  --ctl-hover: #2b241c;
  --nav: #14110e;

  --line: #2e271e;
  --div: #251f18;
  --line-strong: #433a2d;

  --ink: #f4ede1;
  --ink-2: #d0c4b0;
  --ink-3: #a09480;
  --ink-4: #766b5a;
  --ink-inv: #fffdf9;

  --acc: #e0643a;
  --acc-hover: #ec7d57;
  --acc-tint: rgba(224, 100, 58, 0.15);
  --acc-line: rgba(236, 125, 87, 0.36);
  --acc-ink: #f2a583;

  --data: #4fc4b6;
  --data-tint: rgba(79, 196, 182, 0.14);
  --data-line: rgba(79, 196, 182, 0.34);
  --green: #4ade80;
  --green-tint: rgba(74, 222, 128, 0.14);
  --green-line: rgba(74, 222, 128, 0.32);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.1);
  --amber-tint: rgba(251, 191, 36, 0.16);
  --amber-line: rgba(251, 191, 36, 0.34);
  --red: #fb7185;
  --red-tint: rgba(251, 113, 133, 0.14);
  --red-line: rgba(251, 113, 133, 0.34);

  --x-bg: #120f0c;
  --x-panel: #19140f;
  --x-ctl: #241d16;
  --x-ctl-hover: #2f261d;
  --x-trk: #342b21;
  --x-axis: #4d4234;
  --x-div: #231c15;
  --x-grid: rgba(255, 235, 200, 0.06);
  --x-ink: #f6efe3;
  --x-ink-2: #cdbfa9;
  --x-ink-3: #9a8c77;
  --x-ok: #5fd38d;
  --x-warn: #f2b84b;
  --x-fail: #ff8070;
  --x-data: #e3b45a;

  --foot-bg: #120f0c;
  --foot-bar: #0b0907;
  --foot-line: rgba(255, 235, 200, 0.08);
  --foot-grid: rgba(255, 235, 200, 0.04);
  --foot-ink: #d6c9b4;
  --foot-muted: #8f826e;

  --focus: 0 0 0 2px var(--tile), 0 0 0 4px var(--acc);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background-color: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--page);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font-family: inherit;
  touch-action: manipulation;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.wrap {
  width: 100%;
  max-width: var(--wrap-max);
  margin: 0 auto;
  padding: 0 20px;
}

/* Top Navigation Bar */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: var(--nav);
  border-bottom: 1px solid var(--line);
  transition: border-color 0.15s var(--ease);
}

.top.scrolled {
  border-bottom-color: var(--line-strong);
}

.top-in {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background-color: var(--acc);
  color: var(--ink-inv);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-word {
  font-family: var(--disp);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  align-items: center;
  height: var(--nav-h);
  gap: 4px;
}

.nav a {
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.nav a:hover {
  color: var(--ink);
  background-color: var(--soft);
}

.nav a.is-on {
  color: var(--acc-ink);
  font-weight: 600;
  background-color: var(--acc-tint);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ib {
  height: 34px;
  min-width: 34px;
  padding: 0 9px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background-color: var(--ctl);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.ib:hover:not(.is-muted) {
  border-color: var(--ink-4);
  background-color: var(--ctl-hover);
  color: var(--ink);
}

.ib-icon {
  width: 34px;
  padding: 0;
}

.ib.is-muted {
  border-color: transparent;
  background-color: transparent;
  color: var(--ink-4);
  cursor: default;
}

/* Main Canvas */
.site-main {
  flex: 1;
  padding: 16px 0 36px;
}

/* Compact Workbench Title Strip (No bloated SaaS Hero) */
.title-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.title-main {
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.page-h1 {
  margin: 0;
  font-family: var(--disp);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.tag-chip {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
}

.page-desc {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.title-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Flat Hairline Tile (Core Reusable Card) */
.tile {
  background-color: var(--tile);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 2px 0 var(--line);
  overflow: hidden;
}

.th {
  min-height: 44px;
  padding: 7px 14px;
  background-color: var(--head);
  border-bottom: 1px solid var(--div);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.th-l {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.th-r {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ico {
  width: 26px;
  height: 26px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background-color: var(--tile);
  color: var(--acc);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.th h2 {
  margin: 0;
  font-family: var(--disp);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
}

.th-meta {
  color: var(--ink-4);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* Dark Instrument Tile Variant (.tile.xr) */
.tile.xr {
  background-color: var(--x-bg);
  border-color: var(--x-div);
  color: var(--x-ink);
  background-image: radial-gradient(circle, var(--x-grid) 1.2px, transparent 1.4px);
  background-size: 18px 18px;
  box-shadow: 0 2px 0 var(--x-axis);
}

.tile.xr .th {
  background-color: var(--x-panel);
  border-bottom-color: var(--x-div);
}

.tile.xr .ico {
  background-color: var(--x-ctl);
  border-color: var(--x-axis);
  color: var(--x-data);
}

.tile.xr .th h2 {
  color: var(--x-ink);
}

/* Compact Segmented Controls */
.seg {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  gap: 2px;
  border-radius: var(--r-md);
  background-color: var(--div);
  border: 1px solid var(--line);
}

.seg-btn {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.is-on {
  background-color: var(--ctl);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}

.seg.seg-dark {
  background-color: var(--x-bg);
  border-color: var(--x-axis);
}

.seg.seg-dark .seg-btn {
  height: 24px;
  padding: 0 9px;
  font-size: 11.5px;
  color: var(--x-ink-3);
}

.seg.seg-dark .seg-btn:hover {
  color: var(--x-ink);
}

.seg.seg-dark .seg-btn.is-on {
  background-color: var(--x-ctl-hover);
  color: var(--x-ink);
  box-shadow: inset 0 0 0 1px var(--x-axis);
}

/* Tactile Keycap */
kbd.keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom-width: 2px;
  background-color: rgba(0, 0, 0, 0.22);
  color: var(--ink-inv);
  transition: transform 0.12s var(--ease), border-bottom-width 0.12s var(--ease);
}

/* Primary & Utility Buttons */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn:active {
  transform: translateY(1px);
}

.btn-pri {
  background-color: var(--acc);
  color: var(--ink-inv);
}

.btn-pri:hover {
  background-color: var(--acc-hover);
}

.btn-dark {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--x-axis);
  background-color: var(--x-ctl);
  color: var(--x-ink-2);
  font-size: 12px;
  font-weight: 600;
}

.btn-dark:hover {
  background-color: var(--x-ctl-hover);
  color: var(--x-ink);
  border-color: var(--x-ink-3);
}

/* Secondary action: white, bordered (one set, reused everywhere) */
.btn-sec {
  background-color: var(--ctl);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-sec:hover {
  background-color: var(--ctl-hover);
  border-color: var(--ink-4);
}

.btn-sec.is-on {
  border-color: var(--acc);
  background-color: var(--acc-tint);
  color: var(--acc-ink);
}

.btn-sm {
  height: 32px;
  padding: 0 10px;
  gap: 6px;
  font-size: 12.5px;
}

/* Input field: white, clearly bordered. Same look for every editable value. */
.field {
  height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background-color: var(--ctl);
  overflow: hidden;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.field:hover {
  border-color: var(--ink-4);
}

.field:focus-within {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-tint);
}

.field.has-steps {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
}

.step-btn {
  height: 100%;
  border: 0;
  background-color: var(--soft);
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
}

.step-btn:first-child {
  border-right: 1px solid var(--div);
}

.step-btn:last-child {
  border-left: 1px solid var(--div);
}

.step-btn:hover {
  background-color: var(--div);
  color: var(--ink);
}

.step-btn:active {
  background-color: var(--trk);
}

.num-in {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  padding: 0 4px;
}

.num-in:focus {
  outline: none;
  box-shadow: none;
}

.num-in::-webkit-outer-spin-button,
.num-in::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.num-in[type="number"] {
  -moz-appearance: textfield;
}

.field.field-dark {
  background-color: var(--x-ctl);
  border-color: var(--x-axis);
}

.field.field-dark:hover {
  border-color: var(--x-ink-3);
}

.field.field-dark:focus-within {
  border-color: var(--x-data);
  box-shadow: 0 0 0 3px rgba(227, 180, 90, 0.2);
}

.field-dark .num-in {
  color: var(--x-ink);
  font-size: 13px;
}

/* Fixed one-line annotation (always visible, short). */
.field-note {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  font-weight: 400;
  color: var(--ink-4);
}

/* "?" help: tap / click / keyboard only, never hover. Panel floats beside the button. */
.help {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.help-btn {
  position: relative;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background-color: var(--ctl);
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.help-btn::after {
  content: "";
  position: absolute;
  inset: -12px;
}

.help-btn:hover {
  border-color: var(--ink-4);
  color: var(--ink);
}

.help-btn[aria-expanded="true"] {
  border-color: var(--acc);
  background-color: var(--acc-tint);
  color: var(--acc-ink);
}

.help-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: -4px;
  width: min(240px, 78vw);
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background-color: var(--tile);
  box-shadow: 0 8px 24px rgba(28, 24, 20, 0.16);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
}

.help-panel[hidden] {
  display: none;
}

/* Lower 7:5 Asymmetric Editorial Grid (.cb) */
.cb {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.cb-l {
  grid-column: 1 / 8;
  display: grid;
  gap: 12px;
}

.cb-r {
  grid-column: 8 / 13;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 8px 14px;
  text-align: left;
  border-bottom: 1px solid var(--div);
  vertical-align: top;
}

.data-table th {
  background-color: var(--soft);
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Spine-Connected Steps */
.spine-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.spine-item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 0 12px;
  padding: 13px 16px 13px 12px;
  border-bottom: 1px solid var(--div);
}

.spine-item:last-child {
  border-bottom: none;
}

.spine-item::before {
  content: "";
  position: absolute;
  left: 33px;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: var(--div);
}

.spine-item:first-child::before {
  top: 24px;
}

.spine-item:last-child::before {
  bottom: calc(100% - 24px);
}

.spine-num {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1px solid var(--acc-line);
  background-color: var(--acc-tint);
  color: var(--acc-ink);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spine-title {
  margin: 1px 0 3px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.spine-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-3);
}

/* Scannable Q/A Badge FAQ */
.qa-a + .qa-a {
  margin-top: 8px;
}

.qa-list {
  margin: 0;
  padding: 0;
}

.qa-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--div);
}

.qa-item:last-child {
  border-bottom: none;
}

.qa-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.qa-row + .qa-row {
  margin-top: 8px;
}

.qa-badge {
  width: 22px;
  height: 22px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qa-badge.is-q {
  color: var(--ink);
}

.qa-badge.is-a {
  color: var(--ink-4);
}

.qa-q {
  margin: 1px 0 0;
  font-size: 13.5px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--ink);
}

.qa-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.qa-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: currentColor;
}

.qa-pill.tone-acc {
  color: var(--data);
}

.qa-pill.tone-ok {
  color: var(--green);
}

.qa-pill.tone-warn {
  color: var(--amber);
}

.qa-pill.tone-data {
  background-color: var(--data-tint);
  border: 1px solid var(--data-line);
  color: var(--data);
}

.qa-a {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-3);
}

/* Dark Dotted-Tray Footer (.sf) */
.sf {
  margin-top: auto;
  background-color: var(--foot-bg);
  border-top: 1px solid var(--foot-line);
  color: var(--foot-ink);
  background-image: radial-gradient(circle, var(--foot-grid) 1.2px, transparent 1.4px);
  background-size: 18px 18px;
}

.sf-top {
  padding: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.sf-note {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sf-note p {
  margin: 0;
  font-size: 12.5px;
  color: var(--foot-muted);
}

.sf-bar {
  background-color: var(--foot-bar);
  border-top: 1px solid var(--foot-line);
}

.sf-bar-in {
  min-height: 44px;
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--foot-muted);
}

.sf-gh {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  border: 1px solid var(--foot-line);
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--foot-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.sf-gh:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--foot-ink);
}

@media (max-width: 959px) {
  .cb-l,
  .cb-r {
    grid-column: 1 / -1;
  }

}

@media (max-width: 767px) {
  .wrap {
    padding: 0 14px;
  }

  .nav {
    display: none;
  }

  .top-in {
    height: 50px;
  }

  .btn,
  .seg-btn {
    min-height: 38px;
  }
}

/* Touch devices (mobile-first): bigger targets, no keyboard-only hints */
@media (pointer: coarse) {
  .btn,
  .btn-sm,
  .btn-dark {
    min-height: 44px;
  }

  .seg-btn,
  .seg.seg-dark .seg-btn {
    height: 40px;
  }

  .field,
  .xr-misc .field {
    height: 44px;
  }

  .field.has-steps {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
  }

  .nav a {
    height: 40px;
  }

  kbd.keycap {
    display: none;
  }
}

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

/* ==========================================================================
   Multi-page chrome (2026-11-28): Tools menu, page anchors, footer tool list
   Link = accent text; current page = flat readout; no hover-only behaviour.
   ========================================================================== */
.tools {
  position: relative;
}

/* Top-bar nav items (site-structure.md section 8): one menu per category, then "All tools".
   Plain entries, no button chrome; lists open on tap/click (no hover) and show names only. */
.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.nav-item {
  height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: var(--r-md);
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.nav-item:hover {
  color: var(--ink);
  background-color: var(--soft);
}

.nav-item:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.tools-btn[aria-expanded="true"] {
  color: var(--ink);
  background-color: var(--soft);
}

.tools-caret {
  color: var(--ink-4);
  transition: transform 0.15s var(--ease);
}

.tools-btn[aria-expanded="true"] .tools-caret {
  transform: rotate(180deg);
}

.tools-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 10px);
  left: 0;
  width: min(300px, calc(100vw - 28px));
  padding: 8px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  background-color: var(--tile);
  box-shadow: 0 12px 32px rgba(28, 24, 20, 0.18);
}

.tools-panel[hidden] {
  display: none;
}

.tools-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.tools-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--ink);
}

a.tools-item:hover {
  background-color: var(--acc-tint);
}

a.tools-item .tools-name {
  color: var(--acc-ink);
}

.tools-name {
  font-size: 14px;
  font-weight: 600;
}

.tools-here {
  align-self: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
}

.tools-item.is-current {
  background-color: var(--soft);
}

.tools-item.is-current .tools-name {
  color: var(--ink);
}

/* "All tools" panel: every tool, one compact column per category, like the footer list */
.tools-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.tools-col {
  flex: 1 0 240px;
}

.tools-cat {
  display: block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.tools-panel-all .tools-list {
  gap: 0;
}

.tools-panel-all .tools-item {
  padding: 5px 10px;
}

.tools-panel-all .tools-name {
  font-size: 13px;
}

.tools-foot {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--div);
}

.tools-panel-all {
  max-height: calc(100vh - 76px);
  overflow-y: auto;
}

/* Wide screens: the panel starts at the left of the nav and grows with the number of categories */
@media (min-width: 768px) {
  .topnav {
    position: relative;
  }

  .tools.tools-all {
    position: static;
  }

  .tools-panel-all {
    width: max-content;
    min-width: 280px;
    max-width: min(800px, calc(100vw - 210px));
  }
}

/* Footer tool list (fallback directory) */
.sf-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sf-tools .sf-tools-h,
.sf-cat {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--foot-muted);
}

.sf-tools ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
}

.sf-tools a {
  display: inline-block;
  padding: 4px 0;
  font-size: 13px;
  color: var(--foot-ink);
  text-decoration: none;
}

.sf-tools a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 767px) {
  .tools {
    position: static;
  }

  .tools-panel {
    top: calc(100% + 6px);
    left: 14px;
    right: 14px;
    width: auto;
  }
}

@media (pointer: coarse) {
  .nav-item {
    height: 40px;
  }

  .tools-item {
    min-height: 48px;
    align-content: center;
  }

  .tools-panel-all .tools-item {
    min-height: 44px;
  }

  .sf-tools a {
    padding: 10px 0;
  }
}

/* ==========================================================================
   Tool cards (shared by the home directory and the "More tools" block on tool pages)
   Cards are links: bordered + accent on hover/focus (operable grammar).
   ========================================================================== */
.home-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.home-card {
  height: 100%;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background-color: var(--tile);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.home-card:hover {
  border-color: var(--acc);
  background-color: var(--acc-tint);
}

.home-card:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.home-card-name {
  font-family: var(--disp);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.home-card-desc {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

.home-card-cta {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--acc-ink);
}

/* "More tools" block at the bottom of tool pages (site-structure.md v03 section 3) */
.more-tools {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.more-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 12px;
}

.more-h {
  margin: 0;
  font-family: var(--disp);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.more-all {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--acc-ink);
  text-decoration: none;
}

.more-all:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (pointer: coarse) {
  .more-all {
    min-height: 44px;
  }
}

@media (max-width: 479px) {
  .top-left {
    gap: 8px;
  }

  /* Two menus need the room: the inactive language mark steps aside */
  .top-right {
    display: none;
  }

  .topnav {
    gap: 0;
  }

  .topnav .nav-item {
    padding: 0 6px;
    font-size: 13px;
  }
}
