/* ==========================================================================
   Lattice Weaver. Interactive static replica of the egui companion GUI.
   Design tokens, type scale, radii, and spacing are ported 1:1 from
   companion/src/gui/theme.rs. Colors are applied as CSS custom properties set
   per-theme by js/themes.js; switching a theme recolors everything live.
   ========================================================================== */

/* ---- OpenDyslexic (accessibility font toggle), via @fontsource on jsdelivr.
   Falls back gracefully if the CDN is unavailable. ------------------------- */
@font-face {
  font-family: "OpenDyslexic";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5.1.0/files/opendyslexic-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "OpenDyslexic";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5.1.0/files/opendyslexic-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "OpenDyslexic";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic@5.1.0/files/opendyslexic-latin-700-normal.woff2") format("woff2");
}

/* ==========================================================================
   Tokens. The color variables are overwritten by applyTheme(); these are the
   Lattice Dark defaults so the page renders before JS runs. Radii/type/spacing
   are constants (theme.rs: R_TAG 4, R_BTN 8, R_CARD 10, R_MODAL 12, R_PILL 999;
   SZ_DISPLAY 21, SZ_TITLE 16, SZ_BODY 13.5, SZ_LABEL 12.5, SZ_CAPTION 11).
   ========================================================================== */
:root {
  --bg: #101118; --titlebar: #16171F; --panel: #14151C; --window-border: #3E4254;
  --card: #1E202A; --elevated: #262A38; --row-bg: #181A22; --stroke: #303342;
  --stroke-hover: #3E4254; --scrim: #08090E; --text: #E2E5F0; --muted: #949BAF;
  --faint: #6C7288; --text-disabled: #50556A; --accent: #818CF8;
  --accent-hover: #97A0FA; --accent-active: #6B77E8; --ok: #34D399;
  --warn: #FBBF24; --bad: #F87171;

  /* Per-slot accents (theme.rs slot_color): P0 = accent, then teal/fuchsia/sky. */
  --p0: var(--accent); --p1: #2DD4BF; --p2: #E879F9; --p3: #38BDF8;

  --r-tag: 4px; --r-btn: 8px; --r-card: 10px; --r-modal: 12px; --r-pill: 999px;
  --sz-display: 21px; --sz-title: 16px; --sz-body: 13.5px; --sz-label: 12.5px;
  --sz-caption: 11px; --sz-mono: 12px;

  --ui-font: "Sora", system-ui, sans-serif;
  --mono-font: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #1b1d2a 0%, #0b0c12 55%, #07080c 100%);
  min-height: 100vh;
  font-family: var(--ui-font);
  color: var(--text);
  overflow-x: hidden;
}

/* Embedded on the landing page: drop the opaque backdrop so the page's lattice
   shows through, and tighten the window shadow so it does not read as a block. */
html.embedded body { background: transparent; }
html.embedded .weaver-window { box-shadow: 0 16px 44px -22px rgba(0, 0, 0, 0.1); }

/* ---- persistent "visual only" disclosure banner (page chrome, not the app) -- */
.demo-notice {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 14px;
  font-family: var(--ui-font); font-size: 15px; font-weight: 600;
  letter-spacing: 0.01em;
  color: #cdd3f0;
  background: rgba(12, 13, 20, 0.92);
  border-bottom: 1px solid rgba(129, 140, 248, 0.25);
  backdrop-filter: blur(6px);
}
.demo-notice .dot { color: var(--accent); }
.demo-notice .open-newtab { color: var(--accent); text-decoration: none; font-weight: 600; margin-left: 4px; }
.demo-notice .open-newtab:hover { text-decoration: underline; }
/* only offer the new-tab link when the demo is embedded on the landing page */
html:not(.embedded) .demo-notice .open-newtab { display: none; }

.demo-stage {
  display: flex; flex-direction: column; align-items: center;
  padding: 26px 16px 48px;
  gap: 18px;
}
.demo-sub {
  max-width: 880px; text-align: center; color: var(--muted);
  font-size: 16px; line-height: 1.55;
}
.demo-sub a { color: var(--accent); text-decoration: none; }
.demo-sub a:hover { text-decoration: underline; }

/* The scaler keeps the fixed 760px window from overflowing narrow viewports:
   weaver.js sets transform: scale() so the desktop-shaped app is centered in a
   device frame with no horizontal page scroll. */
.weaver-scaler { transform-origin: top center; }

/* ==========================================================================
   The window shell (frameless, 1px border, mod.rs). Fixed 760px wide.
   ========================================================================== */
.weaver-window {
  width: 760px;
  background: var(--bg);
  border: 1px solid var(--window-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  font-size: var(--sz-body);
  position: relative;
  user-select: none;
  display: flex; flex-direction: column;
}

/* ---- titlebar (28px, TITLEBAR) ---- */
.wv-titlebar {
  height: 28px; flex: 0 0 28px;
  background: var(--titlebar);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
}
.wv-titlebar .title { font-size: 11px; color: var(--faint); }
.wv-caption { display: flex; align-items: center; gap: 6px; }
.wv-capbtn {
  width: 22px; height: 22px; display: grid; place-items: center;
  color: var(--faint); cursor: pointer; border-radius: var(--r-btn);
}
.wv-capbtn:hover { color: var(--text); }
.wv-capbtn.disabled { color: var(--text-disabled); cursor: default; }
.wv-capbtn svg { width: 12px; height: 12px; }

/* ---- header (56px, PANEL) ---- */
.wv-header {
  height: 56px; flex: 0 0 56px;
  background: var(--panel);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.wv-brand { display: flex; align-items: center; gap: 4px; }
.wv-jewel { width: 22px; height: 22px; }
.wv-wordmark {
  font-weight: 700; font-size: 17.8px; letter-spacing: 0.22em;
  color: var(--text); padding-left: 4px;
}
.wv-header-right { display: flex; align-items: center; gap: 8px; }

/* chips */
.wv-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 11px; border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--sz-label); white-space: nowrap;
  cursor: pointer;
}
.wv-chip.access { border: 1px solid var(--stroke); background: transparent; }
.wv-chip.access .k { color: var(--muted); }
.wv-chip.access .v { color: var(--ok); display: inline-flex; align-items: center; gap: 3px; }
.wv-chip.access .v svg { width: 13px; height: 13px; }
.wv-chip.license { color: var(--ok); }
.wv-chip.license.lic { background: color-mix(in srgb, var(--ok) 16%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); }
.wv-chip.license.free { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---- banner strip (routing state) ---- */
.wv-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.wv-banner .bdot { width: 16px; display: grid; place-items: center; }
.wv-banner .bdot .diamond { width: 11px; height: 11px; background: var(--warn); transform: rotate(45deg); }
.wv-banner .prefix { font-weight: 600; font-size: var(--sz-body); color: var(--warn); }
.wv-banner .sep { color: var(--warn); font-size: 11.5px; }
.wv-banner .rest { font-size: 11.5px; color: var(--text); }
.wv-banner .spacer { flex: 1; }
.wv-banner.waiting { background: color-mix(in srgb, var(--accent) 12%, transparent); border-bottom-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.wv-banner.waiting .prefix, .wv-banner.waiting .sep { color: var(--accent); }
.wv-banner.waiting .bdot .diamond { background: var(--accent); }

/* ---- toolbar (46px, PANEL) ---- */
.wv-toolbar {
  height: 46px; flex: 0 0 46px;
  background: var(--panel);
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
}
.wv-toolbar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ==========================================================================
   Buttons (widgets.rs)
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--ui-font); font-weight: 600; font-size: var(--sz-label);
  border-radius: var(--r-btn); cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; line-height: 1;
  transition: background .09s ease, border-color .09s ease, transform .05s ease;
}
.btn:active { transform: translateY(0.5px); }
.btn.primary { background: var(--accent); color: var(--bg); padding: 7px 14px; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { background: var(--accent-active); }
.btn.secondary { background: var(--card); color: var(--text); border-color: var(--stroke); padding: 6px 13px; }
.btn.secondary:hover { background: var(--elevated); border-color: var(--stroke-hover); }
.btn.danger {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  padding: 6px 13px;
}
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 22%, transparent); }
.btn.compact { padding: 4px 12px; font-size: 12px; }
.btn.full { width: 100%; }
.btn svg { width: 15px; height: 15px; }

/* nav buttons */
.navbtn {
  font-family: var(--ui-font); font-weight: 600; font-size: var(--sz-label);
  padding: 6px 13px; border-radius: var(--r-btn); cursor: pointer;
  background: var(--card); color: var(--muted); border: 1px solid var(--stroke);
  transition: background .09s ease, border-color .09s ease, color .09s ease;
}
.navbtn:hover { border-color: var(--stroke-hover); color: var(--text); }
.navbtn.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent); color: var(--text);
}

/* capture button (toolbar) */
.capbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-btn);
  font-family: var(--ui-font); font-weight: 600; font-size: var(--sz-label);
  cursor: pointer;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent);
}
.capbtn .cdot { width: 8px; height: 8px; background: var(--warn); transform: rotate(45deg); }
.capbtn.active { color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.capbtn.active .cdot { background: var(--ok); border-radius: 50%; transform: none; }

/* small square icon button */
.iconbtn {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: var(--r-btn); background: var(--card);
  border: 1px solid var(--stroke); color: var(--muted); cursor: pointer;
}
.iconbtn:hover { background: var(--elevated); border-color: var(--stroke-hover); color: var(--text); }
.iconbtn svg { width: 15px; height: 15px; }

/* ==========================================================================
   Body + screens
   ========================================================================== */
.wv-body {
  background: var(--bg);
  padding: 12px 16px;
  flex: 1 1 auto;
  min-height: 300px;
}
.screen { display: none; }
.screen.active { display: block; }

.page-head { display: flex; align-items: center; position: relative; margin-bottom: 8px; }
.page-head .title {
  position: absolute; left: 0; right: 0; text-align: center;
  font-weight: 600; font-size: var(--sz-title); color: var(--text);
  pointer-events: none;
}
.page-rule { height: 1px; background: var(--stroke); margin: 8px 0; }

.section-title { font-weight: 600; font-size: var(--sz-title); color: var(--text); }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--stroke);
  border-radius: var(--r-card); padding: 14px;
}

/* ---- Dashboard ---- */
.slots-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 16px; margin-top: 10px; }
.slot-card {
  background: var(--card); border: 1px solid var(--stroke);
  border-radius: var(--r-card); padding: 10px;
  min-height: 180px; display: flex; flex-direction: column; position: relative;
}
.slot-card.degraded { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.slot-card.flash { box-shadow: 0 0 0 2px var(--slotc, var(--accent)) inset; }
.slot-head { display: flex; align-items: center; gap: 6px; }
.slot-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill); font-weight: 600; font-size: var(--sz-label);
}
.slot-role { font-size: var(--sz-label); color: var(--muted); }
.slot-head .right { margin-left: auto; display: flex; gap: 6px; }
.chip-degraded {
  display: inline-flex; align-items: center; gap: 5px; height: 18px; padding: 0 8px;
  border-radius: var(--r-pill); font-weight: 600; font-size: var(--sz-label);
  color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
}
.chip-degraded .ring { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--bad); }

.dev-row {
  display: flex; align-items: center; gap: 4px;
  background: var(--row-bg); border-radius: var(--r-btn);
  padding: 4px 5px; margin-top: 6px;
}
.dev-row.bad {
  background: color-mix(in srgb, var(--bad) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
}
.dev-row .kind { font-weight: 600; font-size: 11px; color: var(--faint); }
.dev-row .name { font-family: var(--mono-font); font-size: 12px; color: var(--text); }
.dev-row .status { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: var(--sz-caption); color: var(--ok); }
.dev-row .status .sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dev-row.bad .kind { color: var(--text); }

.slot-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; }
.slot-foot .profile { font-size: 11px; color: var(--faint); }
.slot-foot .profile b { color: var(--muted); font-weight: 600; margin-left: 3px; }
.slot-foot .chips { margin-left: auto; display: flex; gap: 4px; }
.inst-chip {
  font-size: 10.5px; padding: 1.5px 5px; border-radius: var(--r-tag);
  color: var(--slotc, var(--accent));
  background: color-mix(in srgb, var(--slotc, var(--accent)) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--slotc, var(--accent)) 45%, transparent);
}

/* empty slot */
.slot-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 2px;
  border: 1px solid color-mix(in srgb, var(--p1) 50%, transparent);
  background: transparent;
}
.slot-empty .t1 { font-weight: 600; font-size: var(--sz-body); color: var(--text); margin-top: 8px; }
.slot-empty .t2 { font-size: 11.5px; color: var(--muted); max-width: 240px; }
.slot-empty .t3 { font-size: 11px; color: var(--faint); margin-top: 6px; }

/* tips + log */
.wv-tips {
  background: var(--bg); border-top: 1px solid var(--stroke);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 5px 16px; color: var(--muted); font-size: 11.5px;
}
.wv-tips .tdiamond { width: 7px; height: 7px; background: var(--accent); transform: rotate(45deg); }
.wv-log { background: var(--panel); padding: 8px 16px; }
.wv-log .loghead { display: flex; align-items: center; gap: 2px; cursor: pointer; }
.wv-log .caret { width: 14px; height: 14px; display: grid; place-items: center; color: var(--muted); }
.wv-log .caret svg { width: 11px; height: 11px; }
.wv-log .loghead .lt { font-weight: 600; font-size: var(--sz-label); color: var(--text); margin-left: 2px; }
.wv-log .loghead .copy { margin-left: auto; }
.wv-log .logbox {
  margin-top: 6px; background: var(--bg); border: 1px solid var(--stroke);
  border-radius: var(--r-btn); padding: 6px 10px; height: 120px; overflow-y: auto;
}
.wv-log .logbox.collapsed { display: none; }
.wv-log .empty { text-align: center; color: var(--faint); font-size: 11.5px; padding: 8px 0; }
.wv-log .line { font-family: var(--mono-font); font-size: 12px; color: var(--text); padding: 1px 2px; border-radius: 4px; }
.wv-log .line:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* grip */
.wv-grip { background: var(--panel); padding: 4px 0 6px; display: grid; place-items: center; }
.wv-grip .bar { width: 44px; height: 3px; border-radius: var(--r-pill); background: var(--stroke); }

/* ---- Settings ---- */
.tab-strip { display: flex; gap: 6px; margin-bottom: 12px; }
.setting {
  background: var(--card); border: 1px solid var(--stroke);
  border-radius: var(--r-card); padding: 14px; margin-bottom: 10px;
  display: flex; align-items: flex-start; gap: 12px;
}
.setting .meta { flex: 1; }
.setting .meta .st { font-size: var(--sz-body); color: var(--text); }
.setting .meta .sb { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.setting .control { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* toggle */
.toggle { width: 38px; height: 20px; border-radius: var(--r-pill); background: var(--stroke); position: relative; cursor: pointer; transition: background .09s ease; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: left .09s ease, background .09s ease; }
.toggle.on { background: var(--accent); }
.toggle.on .knob { left: 21px; background: var(--text); }

/* select (dropdown) */
.wv-select {
  position: relative; min-width: 200px;
}
.wv-select .cur {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; border-radius: var(--r-btn);
  background: var(--card); border: 1px solid var(--stroke); color: var(--text);
  font-size: var(--sz-label); cursor: pointer;
}
.wv-select .cur:hover { border-color: var(--stroke-hover); background: var(--elevated); }
.wv-select .cur svg { width: 12px; height: 12px; color: var(--muted); }
.wv-select .menu {
  position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; left: 0;
  max-height: 260px; overflow-y: auto;
  background: var(--elevated); border: 1px solid var(--stroke);
  border-radius: var(--r-btn); padding: 4px; display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.wv-select.open .menu { display: block; }
.wv-select .opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-size: var(--sz-label); color: var(--text);
}
.wv-select .opt:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.wv-select .opt.sel { background: color-mix(in srgb, var(--accent) 18%, transparent); outline: 1px solid var(--accent); }
.wv-select .opt .sw { display: inline-flex; gap: 3px; margin-left: auto; }
.wv-select .opt .sw i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---- Help ---- */
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-about { display: flex; align-items: center; gap: 16px; }
.help-about .jewel { width: 26px; height: 26px; flex: 0 0 26px; }
.help-about .v1 { font-weight: 600; font-size: 15px; color: var(--text); }
.help-about .v2 { font-size: 10.5px; color: var(--faint); margin-top: 2px; }
.help-about .v3 { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.help-card .ht { font-weight: 600; font-size: 15px; color: var(--text); }
.help-links { text-align: center; }
.chip-row { display: flex; justify-content: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.link-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5.5px 11px; border-radius: var(--r-pill);
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  font-weight: 600; font-size: 11px; text-decoration: none; cursor: pointer;
}
.link-chip:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.link-chip svg { width: 13px; height: 13px; }
.help-routing .hbody { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.faq { margin-top: 9px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.faq:first-of-type { margin-top: 8px; }
.faq .lead { font-weight: 600; font-size: 12.5px; color: var(--text); }
.faq .word { font-weight: 600; font-size: 12.5px; }
.faq .word.warn { color: var(--warn); }
.faq .word.bad { color: var(--bad); }

/* ---- Doctor ---- */
.doctor-top { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.doctor-top .lastrun { font-family: var(--mono-font); font-size: 11px; color: var(--faint); }
.check {
  background: var(--card); border: 1px solid var(--stroke);
  border-radius: var(--r-card); padding: 9px 12px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.check.blocked { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.glyph-chip { width: 18px; height: 18px; flex: 0 0 18px; display: grid; place-items: center; position: relative; }
.glyph-chip .bgshape { position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; }
.glyph-chip.pass .circle { width: 18px; height: 18px; border-radius: 50%; background: color-mix(in srgb, var(--ok) 16%, transparent); border: 1px solid var(--ok); position: absolute; inset: 0; }
.glyph-chip.warn .diamond { width: 16px; height: 16px; background: color-mix(in srgb, var(--warn) 16%, transparent); border: 1px solid var(--warn); transform: rotate(45deg); position: absolute; inset: 1px; }
.glyph-chip svg { position: relative; width: 12px; height: 12px; }
.check .meta { flex: 1; }
.check .cn { font-weight: 600; font-size: var(--sz-label); color: var(--text); }
.check .cd { font-size: 11px; color: var(--muted); line-height: 1.4; }
.check .ca { font-size: 11px; color: var(--warn); margin-top: 2px; }
.check .tag { margin-left: auto; font-weight: 600; font-size: 11px; }
.check .tag.pass { color: var(--ok); }
.check .tag.warn { color: var(--warn); }
.doctor-reward { text-align: center; }
.doctor-reward .t1 { font-weight: 600; font-size: var(--sz-title); color: var(--ok); margin-top: 8px; }
.doctor-reward .t2 { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tools-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ---- Games ---- */
.games-top { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.game-card {
  background: var(--card); border: 1px solid var(--stroke);
  border-radius: var(--r-card); padding: 12px 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}
.game-ic { width: 34px; height: 34px; border-radius: var(--r-btn); display: grid; place-items: center; font-weight: 700; font-size: 11px; flex: 0 0 34px; }
.game-card .meta { flex: 1; }
.game-card .gn { font-weight: 600; font-size: 14px; color: var(--text); }
.game-card .gd { font-family: var(--mono-font); font-size: 12px; color: var(--muted); margin-top: 3px; }
.game-card .gnote { font-size: 11px; color: var(--ok); margin-top: 3px; }
.game-card .acts { margin-left: auto; display: flex; gap: 8px; }

/* ==========================================================================
   Modals (scrim + floating card). Guided setup, calibration, etc.
   ========================================================================== */
.wv-scrim {
  position: absolute; inset: 0; z-index: 30;
  background: color-mix(in srgb, var(--scrim) 62%, transparent);
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 118px;
}
.wv-scrim.show { display: flex; }
.modal {
  width: 520px; max-width: calc(100% - 48px);
  background: var(--elevated); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: var(--r-modal); padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal .mhead { display: flex; align-items: center; gap: 8px; }
.modal .mhead .jewel { width: 22px; height: 22px; }
.modal .mhead .mt { font-weight: 600; font-size: var(--sz-display); color: var(--text); }
.modal .mhead .ms { font-size: 12.5px; color: var(--muted); }
.modal .mhead .x { margin-left: auto; }

/* guided stepper */
.stepper { display: flex; align-items: center; justify-content: center; gap: 0; margin: 12px 0 14px; }
.step { display: flex; align-items: center; gap: 6px; }
.step .node { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.step .node.done { background: color-mix(in srgb, var(--ok) 16%, transparent); border: 1px solid var(--ok); color: var(--ok); }
.step .node.active { background: var(--accent); color: var(--bg); }
.step .node.pending { border: 1px solid var(--stroke); color: var(--faint); }
.step .lbl { font-size: 11.5px; }
.step .lbl.done { color: var(--muted); }
.step .lbl.active { color: var(--text); }
.step .lbl.pending { color: var(--faint); }
.connector { width: 28px; height: 1.5px; margin: 0 6px; }
.connector.done { background: var(--ok); }
.connector.pending { background: var(--faint); }

.guided-center { text-align: center; }
.pulse-ring { width: 120px; height: 120px; margin: 0 auto; position: relative; display: grid; place-items: center; }
.pulse-ring .r { position: absolute; border: 2px solid var(--slotc, var(--accent)); border-radius: 50%; inset: 0; margin: auto; animation: pulse 2.2s ease-out infinite; }
.pulse-ring .r:nth-child(2) { animation-delay: .73s; }
.pulse-ring .r:nth-child(3) { animation-delay: 1.46s; }
.pulse-ring .icon { position: relative; width: 42px; height: 42px; color: var(--slotc, var(--accent)); }
@keyframes pulse { 0% { width: 56%; height: 56%; opacity: 1; } 100% { width: 100%; height: 100%; opacity: 0; } }
.guided-center .gtitle { font-weight: 600; font-size: var(--sz-title); color: var(--text); margin-top: 10px; }
.guided-center .glisten { font-family: var(--mono-font); font-size: 11px; color: var(--faint); margin-top: 4px; }
.guided-center .gask { font-size: 11px; color: var(--accent); margin-top: 2px; }
.guided-center .gskip-note { font-size: 10.5px; color: var(--faint); margin-top: 2px; }
.modal-actions { display: flex; align-items: center; margin-top: 16px; }
.modal-actions .right { margin-left: auto; }

/* count cards */
.count-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 10px 0 20px; }
.count-card {
  background: var(--bg); border: 1px solid var(--stroke); border-radius: var(--r-card);
  padding: 14px; text-align: center; cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.count-card.sel { border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.count-card .n { font-weight: 600; font-size: var(--sz-display); color: var(--text); }
.count-card .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.count-card.sel .sub { color: #B9C0FB; }

/* success card */
.guided-success { display: flex; align-items: center; gap: 10px; }
.guided-success .ring { width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--ok) 16%, transparent); border: 1.5px solid var(--ok); display: grid; place-items: center; color: var(--ok); flex: 0 0 36px; }
.guided-success .ring svg { width: 22px; height: 22px; }
.guided-success .st { font-weight: 600; font-size: var(--sz-display); color: var(--text); }
.guided-success .sb { font-size: 12.5px; color: var(--muted); }

/* ---- calibration card ---- */
.calib { text-align: center; }
.calib .ctitle { font-weight: 600; font-size: var(--sz-title); color: var(--text); }
.calib .cstep { font-weight: 600; font-size: var(--sz-caption); color: var(--accent); margin-top: 2px; }
.calib .mouse-canvas { height: 172px; display: grid; place-items: center; margin: 10px 0; }
.calib-mouse { width: 118px; height: 168px; }
.calib .dots { display: flex; justify-content: center; gap: 10px; margin: 12px 0; }
.calib .dots i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--stroke); display: inline-block; }
.calib .dots i.on { background: var(--accent); border-color: var(--accent); }
.calib .cheading { font-weight: 600; font-size: 14.5px; color: var(--text); }
.calib .cinstr { font-size: var(--sz-body); color: var(--muted); margin-top: 6px; line-height: 1.5; max-width: 420px; margin-inline: auto; }
.calib .crule { height: 1px; background: var(--stroke); margin: 14px 0 8px; }
.calib .cfoot { font-size: var(--sz-caption); color: var(--faint); line-height: 1.5; max-width: 440px; margin-inline: auto; }
.calib-nav { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }

/* confirmation/generic small modal */
.modal.sm { width: 440px; }
.modal .mbody { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 8px; }

/* transient toast */
.wv-toast {
  position: absolute; left: 50%; bottom: 56px; transform: translateX(-50%);
  z-index: 40; padding: 8px 16px; border-radius: var(--r-pill);
  background: var(--elevated); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--text); font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.wv-toast.show { opacity: 1; }

/* ---- icon-pack drawing language (theme.rs IconPack) ---- */
.weaver-window.pack-precision svg[viewBox="0 0 24 24"] { stroke-linecap: butt; stroke-linejoin: miter; stroke-width: 1.8; }
.weaver-window.pack-rounded svg[viewBox="0 0 24 24"] { stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.5; }
.weaver-window.pack-pixel svg[viewBox="0 0 24 24"] { stroke-linecap: square; stroke-linejoin: miter; stroke-width: 2.6; }

/* glyph-chip color by state (Setup Doctor) */
.glyph-chip.pass { color: var(--ok); }
.glyph-chip.warn { color: var(--warn); }

/* ---- demo navigator (page chrome, clearly outside the app window) ---- */
.demo-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  max-width: 760px; justify-content: center;
}
.demo-nav .lbl { width: 100%; text-align: center; color: var(--faint); font-size: 11.5px; margin-bottom: 2px; }
.demo-nav button {
  font-family: var(--ui-font); font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: var(--r-pill); cursor: pointer;
  color: #cdd3f0; background: rgba(129,140,248,0.10);
  border: 1px solid rgba(129,140,248,0.35);
}
.demo-nav button:hover { background: rgba(129,140,248,0.22); }

/* responsive: the scaler is sized by JS; nothing here should allow x-scroll */
@media (max-width: 820px) {
  .demo-stage { padding: 20px 8px 40px; }
}
