/* Documentation-site chrome and components.
   Colours, shape, elevation, motion and spacing come from tokens.css
   (the app's single M3 token sheet, vendored). No raw colours here beyond
   the transparent/white text cases noted inline; functional data colours
   are not used on this site's chrome. */

/* ---------- derived vars (set by appearance.js, safe fallbacks here) ---------- */
:root {
  --site-font-family: inherit;
  --site-font-scale: 1;
  --site-font-weight: 400;
  --site-letter-spacing: 0em;
  --site-line-height: 1.5;
  --rainbow-duration: 15s;
  --site-maxw: 1180px;
}

* { box-sizing: border-box; }

html {
  font-size: calc(16px * var(--site-font-scale));
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  font-family: var(--site-font-family), "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: var(--site-font-weight);
  letter-spacing: var(--site-letter-spacing);
  line-height: var(--site-line-height);
  min-height: 100vh;
}

[data-theme='dark'] body { color-scheme: dark; }

/* accent override hooks (empty unless a seed colour is set) */
:root {
  --accent-live: var(--md-sys-color-primary);
}
[data-theme='dark'] { --accent-live: var(--md-sys-color-primary); }
html[style*="--site-accent-light"][data-theme='light'] { --accent-live: var(--site-accent-light); }
html[style*="--site-accent-dark"][data-theme='dark'] { --accent-live: var(--site-accent-dark); }

.rainbow-accent {
  animation: hue-cycle var(--rainbow-duration) linear infinite;
}
@keyframes hue-cycle {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}
/* Rainbow walks the wheel in CSS-land above; interactive controls keep their
   own readable colours so contrast never depends on the animation frame. */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 300;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  padding: var(--mr-space-2) var(--mr-space-4);
  border-radius: 0 0 var(--md-sys-shape-corner-md) 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: none;
  box-shadow: var(--mr-focus-ring);
  border-radius: var(--md-sys-shape-corner-sm);
}

a { color: var(--accent-live); }

/* ---------- header / footer ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mr-space-3);
  align-items: center;
  padding: var(--mr-space-3) var(--mr-space-5);
  background: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.site-brand {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  flex: 1;
}
.site-brand a {
  font-size: var(--md-sys-type-title-large-size);
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}
.site-tagline {
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-type-body-small-size);
}
#header-actions {
  display: flex;
  gap: var(--mr-space-2);
  align-items: center;
}
.bell-btn { position: relative; }

.documents-note {
  margin: 0;
  padding: var(--mr-space-2) var(--mr-space-5);
  font-size: var(--md-sys-type-label-medium-size);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.site-footer {
  margin-top: var(--mr-space-8);
  padding: var(--mr-space-6) var(--mr-space-5);
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-type-body-small-size);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mr-space-4);
  margin-bottom: var(--mr-space-3);
}

/* ---------- main content column ---------- */
main.page {
  max-width: var(--site-maxw);
  margin: 0 auto;
  padding: var(--mr-space-6) var(--mr-space-5) var(--mr-space-8);
}
main h1 {
  font-size: var(--md-sys-type-headline-large-size);
  line-height: 1.15;
  margin: 0 0 var(--mr-space-3);
}
main h2 {
  font-size: var(--md-sys-type-headline-small-size);
  margin: var(--mr-space-7) 0 var(--mr-space-3);
}
main h3 {
  font-size: var(--md-sys-type-title-large-size);
  margin: var(--mr-space-5) 0 var(--mr-space-2);
}
.page-lead { font-size: var(--md-sys-type-body-large-size); color: var(--md-sys-color-on-surface); max-width: 70ch; }
.setting-desc { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-body-medium-size); max-width: 72ch; }
.provenance { border-left: 3px solid var(--md-sys-color-outline-variant); padding-left: var(--mr-space-3); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.95em; }

.hero {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 2fr;
  gap: var(--mr-space-6);
  align-items: center;
  margin-bottom: var(--mr-space-6);
}
.hero img { width: 100%; max-width: 480px; border-radius: var(--md-sys-shape-corner-lg); box-shadow: var(--md-sys-elevation-2); }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: var(--mr-space-4);
  list-style: none;
  padding: 0;
}
.feature-card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--md-sys-shape-corner-md);
  padding: var(--mr-space-4);
  box-shadow: var(--md-sys-elevation-1);
}
.feature-card h3 { margin: 0 0 var(--mr-space-1); font-size: var(--md-sys-type-title-medium-size); }
.feature-card p { margin: 0; color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-body-medium-size); }

.quickstart ol { padding-left: var(--mr-space-5); }
.quickstart code { background: var(--md-sys-color-surface-container-high); border-radius: var(--md-sys-shape-corner-xs); padding: 0 4px; }
.unsigned-note strong { color: var(--md-sys-color-on-surface); background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); padding: 2px 6px; border-radius: var(--md-sys-shape-corner-xs); display: inline-block; }

.empty-state {
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container);
  border: 1px dashed var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-md);
  padding: var(--mr-space-4);
  max-width: 72ch;
}

/* ---------- buttons, inputs, switches ---------- */
.mr-btn {
  font: inherit;
  font-size: var(--md-sys-type-label-large-size);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-full);
  padding: 8px 16px;
  min-height: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--mr-space-2);
  text-decoration: none;
  transition: background var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short3) var(--md-sys-motion-easing-standard);
}
.mr-btn--filled { background: var(--accent-live); color: var(--md-sys-color-on-primary); }
.mr-btn--tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.mr-btn--text { background: transparent; color: var(--accent-live); }
.mr-btn--danger { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.mr-btn:hover { filter: brightness(1.04); }
.mr-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.mr-input, .mr-select, textarea.mr-input {
  font: inherit;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-xs);
  padding: 8px 10px;
  min-height: 40px;
}
.mr-input:focus-visible, .mr-select:focus-visible { border-color: var(--accent-live); }

.mr-switch { appearance: none; width: 44px; height: 24px; border-radius: 999px; background: var(--md-sys-color-surface-container-highest); border: 2px solid var(--md-sys-color-outline); position: relative; cursor: pointer; vertical-align: middle; }
.mr-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--md-sys-color-outline); transition: transform var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard); }
.mr-switch:checked { background: var(--accent-live); border-color: var(--accent-live); }
.mr-switch:checked::after { transform: translateX(20px); background: var(--md-sys-color-on-primary); }

input[type="range"] { accent-color: var(--accent-live); min-height: 40px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-live); }

.field-label { display: block; margin: var(--mr-space-3) 0 var(--mr-space-1); font-size: var(--md-sys-type-label-large-size); font-weight: 600; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--mr-space-4); padding: var(--mr-space-2) 0; flex-wrap: wrap; }
.setting-label { display: flex; align-items: center; gap: var(--mr-space-3); font-weight: 500; padding: var(--mr-space-1) 0; }
.checkline { justify-content: flex-start; }
.pair { display: inline-flex; gap: var(--mr-space-2); align-items: center; }
.sliderline { flex-wrap: nowrap; }
.checkrow { display: flex; gap: var(--mr-space-4); margin: var(--mr-space-2) 0; flex-wrap: wrap; }
.form-error { color: var(--md-sys-color-error); font-size: var(--md-sys-type-body-small-size); }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--md-sys-color-outline); display: inline-block; vertical-align: middle; background: var(--md-sys-color-surface-container-highest); cursor: pointer; padding: 0; }
/* functional data colour: the rainbow swatch IS the hue wheel, not chrome */
.swatch--rainbow { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }

/* ---------- search bar + anchored builder ---------- */
.sb-wrap { position: relative; display: flex; gap: var(--mr-space-2); align-items: flex-start; }
.sb-field { position: relative; flex: 1; display: flex; min-width: 220px; }
.sb-input { width: 100%; padding-right: 34px; }
.sb-clear { position: absolute; right: 2px; top: 2px; min-height: 36px; }
.sb-builder-btn {
  font-family: Consolas, monospace;
  font-size: 13px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  min-width: 44px; min-height: 40px;
  cursor: pointer;
}
.has-builder .builder-pop { top: calc(100% + 6px) !important; left: auto !important; right: 0 !important; position: absolute !important; }
.builder-pop {
  z-index: 120;
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-lg);
  box-shadow: var(--md-sys-elevation-3);
  padding: var(--mr-space-4);
  width: min(520px, calc(100vw - 32px));
  overflow: auto;
}
.builder-row { display: flex; gap: var(--mr-space-3); align-items: end; flex-wrap: wrap; }
.builder-flags { display: flex; gap: var(--mr-space-1); }
.flag-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--md-sys-color-surface-container-high); border-radius: var(--md-sys-shape-corner-full); padding: 4px 10px; cursor: pointer; }
.builder-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--mr-space-2); margin: var(--mr-space-2) 0; }
.builder-piece { display: grid; gap: 4px; }
.piece-name { font-size: var(--md-sys-type-label-medium-size); color: var(--md-sys-color-on-surface-variant); }
.builder-piece .mr-input { min-height: 34px; }
.builder-anchors { display: flex; gap: var(--mr-space-2); align-content: start; }
.builder-sample { width: 100%; resize: vertical; }
.builder-out { max-height: 160px; overflow: auto; background: var(--md-sys-color-surface); border-radius: var(--md-sys-shape-corner-sm); padding: var(--mr-space-2); }
.builder-matchlist { margin: 0; padding-left: var(--mr-space-4); }
.builder-error { color: var(--md-sys-color-error); }
.builder-warn { color: var(--md-sys-color-error); }
.builder-empty, .builder-note { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-label-medium-size); }
.builder-actions { display: flex; gap: var(--mr-space-2); margin-top: var(--mr-space-3); flex-wrap: wrap; }

/* ---------- colour picker popover ---------- */
.cp-pop { width: 280px; }
.cp-field { display: grid; gap: var(--mr-space-2); }
.cp-sv { position: relative; height: 150px; border-radius: var(--md-sys-shape-corner-sm); touch-action: none; }
/* functional data colour: cursor must stay visible over every hue the picker can show */
.cp-cursor { position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; transform: translate(-50%, 50%); pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,.55); }
/* functional data colour: the hue rail IS the spectrum it picks from */
.cp-hue { width: 100%; background: linear-gradient(to right, red, yellow, lime, cyan, blue, magenta, red); border-radius: 999px; appearance: none; height: 16px; }
.cp-inputs { display: grid; gap: 6px; margin-top: var(--mr-space-2); }
.cp-contrast { font-size: var(--md-sys-type-label-medium-size); color: var(--md-sys-color-on-surface-variant); }
.cp-actions { display: flex; gap: var(--mr-space-2); align-items: center; flex-wrap: wrap; margin-top: var(--mr-space-2); }
.cp-recents { display: flex; gap: 6px; }

/* ---------- modal / dialog ---------- */
.modal-scrim {
  position: fixed; inset: 0;
  background: var(--md-sys-color-scrim);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--mr-space-6) var(--mr-space-4);
  z-index: 200;
  overflow: auto;
}
.modal {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-radius: var(--md-sys-shape-corner-xl);
  box-shadow: var(--md-sys-elevation-3);
  padding: var(--mr-space-5);
  width: min(560px, 100%);
  margin-top: 6vh;
}
.modal-title { margin: 0 0 var(--mr-space-2); font-size: var(--md-sys-type-title-large-size); }
.modal-lead { margin-top: 0; }
.modal-target { color: var(--md-sys-color-on-surface-variant); }
.modal-count { font-weight: 700; }
.modal-hint { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-body-small-size); }
.modal-actions { display: flex; gap: var(--mr-space-2); margin-top: var(--mr-space-4); flex-wrap: wrap; justify-content: flex-end; }

.super-key { display: flex; gap: var(--mr-space-2); align-items: center; padding: var(--mr-space-2) 0; }
.super-slider-wrap { position: relative; margin: var(--mr-space-3) 0; }
.super-slider-wrap input[type="range"] { width: 100%; position: relative; z-index: 2; }
.super-fill {
  position: absolute; inset-block: 12px; left: 0; width: 0;
  background: var(--md-sys-color-primary-container);
  border-radius: 999px;
  transition: width 120ms linear;
  z-index: 1;
}
.super-fill.charging { animation: charge-pulse 900ms ease-in-out infinite alternate; }
@keyframes charge-pulse { from { opacity: 0.55; } to { opacity: 1; } }
.super-emergency { margin-right: auto; }

/* ---------- toasts ---------- */
.toast-host {
  position: fixed;
  right: var(--mr-space-4);
  bottom: var(--mr-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--mr-space-2);
  z-index: 250;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  gap: var(--mr-space-2);
  align-items: flex-start;
  border-radius: var(--md-sys-shape-corner-md);
  box-shadow: var(--md-sys-elevation-2);
  padding: var(--mr-space-3);
  color: var(--md-sys-color-on-surface);
  animation: toast-in var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-decelerate);
}
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-text { flex: 1; }
.toast-title { font-weight: 600; }
.toast-body { font-size: var(--md-sys-type-body-small-size); color: var(--md-sys-color-on-surface-variant); }
.toast-x { min-height: 28px; min-width: 28px; }

/* ---------- notification centre panel ---------- */
.centre-panel {
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-xl);
  box-shadow: var(--md-sys-elevation-3);
  padding: var(--mr-space-5);
  width: min(680px, 100%);
  margin-top: 6vh;
}
.centre-toolbar { display: flex; gap: var(--mr-space-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--mr-space-3); }
.centre-list { max-height: 45vh; overflow: auto; display: grid; gap: var(--mr-space-2); }
.centre-row { display: flex; gap: var(--mr-space-3); align-items: center; background: var(--md-sys-color-surface); border-radius: var(--md-sys-shape-corner-md); padding: var(--mr-space-3); }
.centre-row.is-selected { outline: 2px solid var(--accent-live); }
.centre-row-main { flex: 1; }
.centre-row-title { font-weight: 600; }
.centre-row-body { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-body-small-size); }
.centre-row-time { color: var(--md-sys-color-outline); font-size: var(--md-sys-type-label-small-size); }
.centre-bulk { display: flex; gap: var(--mr-space-2); align-items: center; flex-wrap: wrap; margin: var(--mr-space-3) 0; }
.centre-count { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-label-large-size); }

/* ---------- dim sum card ---------- */
.dimsum-card {
  position: fixed;
  left: var(--mr-space-4);
  bottom: var(--mr-space-4);
  z-index: 240;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-radius: var(--md-sys-shape-corner-lg);
  box-shadow: var(--md-sys-elevation-3);
  padding: var(--mr-space-4);
  width: 220px;
  display: grid;
  gap: var(--mr-space-2);
  animation: toast-in var(--md-sys-motion-duration-medium1) var(--md-sys-motion-easing-decelerate);
}
.dimsum-title { font-weight: 600; font-size: var(--md-sys-type-body-medium-size); }
.dimsum-card img { width: 100%; height: auto; border-radius: var(--md-sys-shape-corner-sm); }
.dimsum-name { font-size: var(--md-sys-type-title-medium-size); }
.dimsum-note { font-size: var(--md-sys-type-label-small-size); color: var(--md-sys-color-on-surface-variant); }
.dimsum-x { position: absolute; top: 4px; right: 4px; min-height: 28px; min-width: 28px; }

/* ---------- unlock ladder ---------- */
.ladder-stage { display: grid; gap: var(--mr-space-3); margin: var(--mr-space-3) 0; }
.ladder-dimsum-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--mr-space-2); }
.ladder-dish {
  display: grid; gap: 4px; justify-items: center;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-md);
  padding: var(--mr-space-2);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.ladder-dish img { border-radius: var(--md-sys-shape-corner-sm); width: 72px; height: 72px; object-fit: cover; }
.ladder-sum-row { display: flex; gap: var(--mr-space-2); align-items: center; }
.ladder-sum-in { max-width: 90px; }
.ladder-progress { color: var(--md-sys-color-on-surface-variant); }
.ladder-clock { font-size: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.ladder-won { color: var(--md-sys-color-success, #146c2e); font-weight: 600; }
.ladder-lost { color: var(--md-sys-color-on-surface-variant); }
.ladder-budget { font-size: var(--md-sys-type-label-large-size); color: var(--md-sys-color-on-surface-variant); }
.ladder-nonce-note { font-size: var(--md-sys-type-label-small-size); color: var(--md-sys-color-outline); }
.mole-grid { display: grid; grid-template-columns: repeat(3, 64px); gap: var(--mr-space-2); justify-content: center; }
.mole-cell {
  width: 64px; height: 64px;
  border-radius: var(--md-sys-shape-corner-md);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  font-size: 30px;
  cursor: pointer;
}
.mole-cell[data-state="up"] { background: var(--md-sys-color-tertiary-container); }
.ladder-mole-status { display: flex; gap: var(--mr-space-4); justify-content: space-between; }

/* ---------- tab strip (fixed rail; content padded to match the dock) ---------- */
#tabstrip-root { display: contents; }
.tabstrip {
  position: fixed;
  z-index: 90;
  top: 0;
  bottom: 0;
  left: 0;
  width: 216px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--md-sys-color-surface-container-low);
  padding: var(--mr-space-2);
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--md-sys-color-outline-variant);
}
/* content offset follows the chosen dock */
body { padding-left: 224px; }
body.dock-right { padding-left: 0; padding-right: 224px; }
.tabstrip.dock-right { left: auto; right: 0; border-right: none; border-left: 1px solid var(--md-sys-color-outline-variant); }

body.dock-top { padding-left: 0; padding-top: 64px; }
.tabstrip.dock-top { left: 0; right: 0; top: 0; bottom: auto; width: auto; height: auto; max-height: 44vh; flex-direction: row; flex-wrap: nowrap; align-items: center; border-right: none; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
body.dock-bottom { padding-left: 0; padding-bottom: 64px; }
.tabstrip.dock-bottom { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: auto; max-height: 44vh; flex-direction: row; flex-wrap: nowrap; align-items: center; border-right: none; border-top: 1px solid var(--md-sys-color-outline-variant); }

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font-size: var(--md-sys-type-label-large-size);
  border: 1px solid transparent;
  white-space: nowrap;
  flex: none;
}
.tab:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); }
.tab.is-active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}
.tab.is-locked { opacity: 0.85; }
.tab-pin, .tab-lockicon { font-size: 12px; }
.tabstrip-pinned { display: flex; flex-direction: column; gap: 2px; padding-bottom: var(--mr-space-2); border-bottom: 1px dashed var(--md-sys-color-outline-variant); margin-bottom: var(--mr-space-2); }
.tabstrip.dock-top .tabstrip-pinned, .tabstrip.dock-bottom .tabstrip-pinned { flex-direction: row; border-bottom: none; border-right: 1px dashed var(--md-sys-color-outline-variant); padding-bottom: 0; padding-right: var(--mr-space-2); margin-bottom: 0; }

.tab-group { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.tab-group-header {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none;
  color: var(--group-color, var(--md-sys-color-primary));
  font: inherit; font-size: var(--md-sys-type-label-medium-size); font-weight: 600;
  cursor: pointer; padding: 6px 10px; text-align: left;
  border-radius: var(--md-sys-shape-corner-sm);
}
.tab-group-zone { display: flex; flex-direction: column; gap: 2px; padding-left: var(--mr-space-3); border-left: 2px solid var(--group-color, var(--md-sys-color-primary)); }
.tabstrip.dock-top .tab-group, .tabstrip.dock-bottom .tab-group { flex-direction: row; align-items: center; }
.tabstrip.dock-top .tab-group-zone, .tabstrip.dock-bottom .tab-group-zone { flex-direction: row; border-left: none; border-top: 2px solid currentColor; padding-left: 0; padding-top: 2px; }

.tab-overflow-btn { position: fixed; z-index: 95; }
body:not(.dock-top):not(.dock-bottom):not(.dock-right) .tab-overflow-btn { left: 224px; top: 8px; }
body.dock-right .tab-overflow-btn { right: 232px; top: 8px; }
body.dock-top .tab-overflow-btn, body.dock-bottom .tab-overflow-btn { right: 8px; top: 68px; }
body.dock-bottom .tab-overflow-btn { top: auto; bottom: 72px; }
.tab[data-overflowed] { visibility: visible; }

.ctx-menu {
  position: fixed;
  z-index: 260;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-md);
  box-shadow: var(--md-sys-elevation-2);
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 6px;
  display: grid;
  gap: 2px;
  min-width: 220px;
}
.ctx-item {
  display: block; width: 100%;
  text-align: left;
  background: none; border: none;
  font: inherit; font-size: var(--md-sys-type-body-medium-size);
  color: var(--md-sys-color-on-surface);
  padding: 8px 12px;
  border-radius: var(--md-sys-shape-corner-sm);
  cursor: pointer;
  min-height: 36px;
}
.ctx-item:hover, .ctx-item:focus-visible { background: var(--md-sys-color-surface-container-highest); }
.ctx-item.is-danger { color: var(--md-sys-color-error); }
.ctx-colors { display: flex; gap: 6px; padding: 8px 12px; }

.picker-list { display: grid; gap: 6px; max-height: 40vh; overflow: auto; margin: var(--mr-space-2) 0; }
.picker-row {
  display: flex; gap: var(--mr-space-2); align-items: center; justify-content: space-between;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-sm);
  padding: 10px 12px; cursor: pointer; font: inherit; color: inherit;
  min-height: 44px;
}
.picker-row[aria-selected="true"] { border-color: var(--accent-live); }

.tab-appearance-pop { position: fixed; z-index: 260; display: grid; gap: 4px; max-height: 80vh; overflow: auto; }

/* ---------- command palette ---------- */
.palette-scrim { align-items: flex-start; }
.palette-panel {
  margin-top: 8vh;
  width: min(640px, 100%);
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-sys-shape-corner-xl);
  box-shadow: var(--md-sys-elevation-3);
  padding: var(--mr-space-4);
}
.palette-panel.is-full { width: min(1000px, 100%); margin-top: 4vh; }
.palette-search { margin-bottom: var(--mr-space-2); }
.palette-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; display: grid; gap: 4px; }
.palette-panel.is-full .palette-list { max-height: 62vh; }
.palette-row {
  display: flex; gap: var(--mr-space-2); align-items: center;
  padding: 8px 12px; border-radius: var(--md-sys-shape-corner-md); cursor: pointer;
  min-height: 44px;
}
.palette-row[aria-selected="true"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.palette-kind {
  font-size: var(--md-sys-type-label-small-size);
  padding: 2px 8px; border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
  flex: none;
}
.palette-kind.kind-setting { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.palette-label { flex: 1; }
.palette-sub { color: var(--md-sys-color-outline); font-size: var(--md-sys-type-label-medium-size); }
.pl-inline { max-width: 140px; min-height: 34px; }
.palette-foot { display: flex; justify-content: space-between; gap: var(--mr-space-3); align-items: center; margin-top: var(--mr-space-2); }
.palette-hint { color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-label-medium-size); margin: 0; }
.palette-empty { padding: var(--mr-space-4); color: var(--md-sys-color-on-surface-variant); }

/* ---------- settings page ---------- */
.settings-tabstrip { display: flex; gap: 4px; flex-wrap: wrap; margin: var(--mr-space-4) 0; }
.settings-tab {
  font: inherit; font-size: var(--md-sys-type-label-large-size); font-weight: 500;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid transparent;
  border-radius: var(--md-sys-shape-corner-full);
  padding: 8px 16px; cursor: pointer; min-height: 40px;
}
.settings-tab[aria-selected="true"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.settings-section { display: grid; gap: var(--mr-space-2); }
.weekday-wrap { display: flex; gap: var(--mr-space-1); flex-wrap: wrap; }
.schedule-form { display: grid; gap: var(--mr-space-2); max-width: 560px; margin-top: var(--mr-space-3); }

/* ---------- docs hub / changelog / downloads ---------- */
.docs-list { list-style: none; padding: 0; display: grid; gap: var(--mr-space-3); }
.docs-item { background: var(--md-sys-color-surface-container-low); border-radius: var(--md-sys-shape-corner-md); padding: var(--mr-space-4); box-shadow: var(--md-sys-elevation-1); }
.docs-link { font-size: var(--md-sys-type-title-medium-size); font-weight: 600; text-decoration: none; display: inline-flex; gap: var(--mr-space-2); align-items: baseline; }
.docs-sub { color: var(--md-sys-color-outline); font-weight: 400; font-size: var(--md-sys-type-body-medium-size); }
.docs-blurb { margin: var(--mr-space-1) 0 0; color: var(--md-sys-color-on-surface-variant); font-size: var(--md-sys-type-body-medium-size); }

.changelog-entry { background: var(--md-sys-color-surface-container-low); border-radius: var(--md-sys-shape-corner-md); padding: var(--mr-space-4); box-shadow: var(--md-sys-elevation-1); display: grid; gap: var(--mr-space-2); }
.changelog-head { display: flex; justify-content: space-between; gap: var(--mr-space-3); flex-wrap: wrap; align-items: baseline; }
.changelog-tag { color: var(--md-sys-color-outline); font-size: var(--md-sys-type-label-medium-size); }
.md-body h2, .md-body h3 { margin: var(--mr-space-3) 0 var(--mr-space-1); }
.md-body pre { background: var(--md-sys-color-surface); border-radius: var(--md-sys-shape-corner-sm); padding: var(--mr-space-3); overflow-x: auto; }
.asset-list { columns: 2; }
.dl-body { display: grid; gap: var(--mr-space-3); justify-items: start; margin: var(--mr-space-3) 0; }
.dl-btn { font-size: var(--md-sys-type-title-medium-size); padding: 12px 22px; }

/* article bodies rendered from static HTML share md styles */
.article-body table { border-collapse: collapse; width: 100%; margin: var(--mr-space-3) 0; }
.article-body th, .article-body td { border: 1px solid var(--md-sys-color-outline-variant); padding: 8px 10px; text-align: left; font-size: var(--md-sys-type-body-medium-size); }
.article-body th { background: var(--md-sys-color-surface-container); }
.article-body pre { background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface); padding: var(--mr-space-3); border-radius: var(--md-sys-shape-corner-sm); overflow-x: auto; }
.article-body blockquote { border-left: 3px solid var(--accent-live); margin: var(--mr-space-3) 0; padding: var(--mr-space-2) var(--mr-space-4); background: var(--md-sys-color-surface-container-low); }

.suggested { margin-top: var(--mr-space-7); padding-top: var(--mr-space-4); border-top: 1px solid var(--md-sys-color-outline-variant); }
.suggested ul { display: flex; gap: var(--mr-space-3); flex-wrap: wrap; list-style: none; padding: 0; }

/* bilingual secondary lines: zh duplicates hide in English mode; in Chinese
   and bilingual modes both tracks stay visible (stated in About). */
html[lang='en'] [data-lang-zh] { display: none; }
.bi-secondary { display: block; color: var(--md-sys-color-on-surface-variant); font-size: 0.85em; font-weight: 400; }
h1 .bi-secondary, h2 .bi-secondary, h3 .bi-secondary { display: inline-block; margin-left: 8px; }

/* session chip / next action */
.session-chip {
  position: fixed; left: 50%; transform: translateX(-50%); top: var(--mr-space-2);
  z-index: 230;
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 6px 14px;
  font-variant-numeric: tabular-nums;
}
.next-action {
  position: fixed; left: var(--mr-space-4); bottom: var(--mr-space-4);
  z-index: 235;
  display: flex; gap: var(--mr-space-2); align-items: center;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: var(--md-sys-shape-corner-md);
  padding: var(--mr-space-2) var(--mr-space-3);
  box-shadow: var(--md-sys-elevation-1);
  max-width: min(340px, 70vw);
}
.next-action label { font-weight: 500; }

.support-plain-line {
  background: var(--md-sys-color-surface-container-highest);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-sm);
  padding: var(--mr-space-2) var(--mr-space-3);
  font-weight: 600;
}

/* ---------- density + low stimulation + reduced motion ---------- */
html[data-density="-1"] { --site-line-height: 1.35; }
html[data-density="1"] { --site-line-height: 1.65; }
.low-stimulation .feature-card, .low-stimulation .docs-item, .low-stimulation .changelog-entry { box-shadow: none; }
.low-stimulation .toast, .low-stimulation .dimsum-card { animation: none; }
.low-stimulation .super-fill.charging { animation: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast, .dimsum-card { animation: none; }
  .super-fill.charging { animation: none; }
}
html.reduce-motion { scroll-behavior: auto; }
html.reduce-motion .toast, html.reduce-motion .dimsum-card { animation: none; }
html.reduce-motion .super-fill.charging { animation: none; }
html.reduce-motion .rainbow-accent { animation-duration: 3600s; } /* effectively one settled hue */

/* ---------- responsive: 320px up ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero img { max-width: 320px; }
}
@media (max-width: 720px) {
  :root { --site-maxw: 100%; }
  /* narrow screens: the strip becomes a fixed top bar whatever the dock choice,
     and content padding follows it */
  body, body.dock-top, body.dock-bottom, body.dock-right {
    padding-left: 0; padding-right: 0; padding-top: 60px; padding-bottom: 0;
  }
  .tabstrip, .tabstrip.dock-left, .tabstrip.dock-right, .tabstrip.dock-top, .tabstrip.dock-bottom {
    left: 0; right: 0; top: 0; bottom: auto;
    width: auto; height: auto; max-height: 40vh;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    min-width: 0; max-width: none;
    position: fixed;
    border-right: none; border-left: none;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    border-top: none;
  }
  .tabstrip-pinned { flex-direction: row; border-bottom: none; padding: 0 var(--mr-space-2) 0 0; margin: 0; }
  .tab-group { flex-direction: row; align-items: center; }
  .tab-group-zone { flex-direction: row; border-left: none; padding-left: 0; }
  main.page { padding: var(--mr-space-4) var(--mr-space-4) var(--mr-space-8); }
  .asset-list { columns: 1; }
  .toast-host { left: var(--mr-space-4); right: var(--mr-space-4); max-width: none; }
  .tab-overflow-btn, body.dock-top .tab-overflow-btn, body.dock-bottom .tab-overflow-btn { right: 8px; top: 64px; }
  .dimsum-card { width: min(200px, 60vw); }
  .next-action { bottom: var(--mr-space-4); top: auto; }
  .session-chip { display: none; }
}
@media (max-width: 380px) {
  .tab { padding: 8px 10px; }
  .sb-field { min-width: 150px; }
}
