/* Product variables alias the shared tokens (platform/shared-web/shared-tokens.css,
   loaded before this file). VEQ's palette is the shared baseline, so every
   token resolves through var(); VEQ-only variables stay in the dark block. */
:root {
  --ink: var(--velo-ink);
  --muted: var(--velo-muted);
  --line: var(--velo-line);
  --soft: var(--velo-soft);
  --blue: var(--velo-blue);
  --cyan: var(--velo-cyan);
  --red: var(--velo-red);
  --shadow: var(--velo-shadow);
  /* Inter is not loaded on this page (the Google Fonts link only exists on
     manual.html); override the shared sans token so Inter stays an
     opportunistic fallback after the CJK system fonts. */
  --velo-font-sans: "PingFang SC", "Microsoft YaHei", Inter, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef3f7;
  font-family: var(--velo-font-sans);
}
a { color: inherit; text-decoration: none; }
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}
.topbar > div { display: flex; align-items: center; gap: 18px; font-size: 13px; }
.brand { display: inline-flex; align-items: center; min-width: 0; color: var(--blue); font-size: 18px; }
.brand .logo { flex: 0 0 auto; font-weight: 700; letter-spacing: .14em; line-height: 1; }
.brand .logo b { color: var(--cyan); }
.brand .sub { min-width: 0; display: inline-flex; flex-direction: column; gap: 1px; margin-left: 9px; color: var(--muted); font-size: 10.5px; font-weight: 500; letter-spacing: .04em; line-height: 1.1; }
.brand .brand-full, .brand .brand-purpose { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .brand-full { color: var(--ink); }
.brand .brand-purpose { color: var(--muted); }
.node-status { color: var(--muted); }
.node-status.primary { color: #247356; }
.node-status.fallback { color: #96651e; }
.studio {
  width: min(1800px, 100%);
  min-height: calc(100vh - 58px);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(285px, 350px) minmax(520px, 1fr) minmax(260px, 320px);
  gap: 16px;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}
.input-panel, .result-panel { padding: 22px; overflow: auto; }
.panel-heading { margin-bottom: 20px; }
.panel-heading p, .visual-head p { margin: 0 0 5px; color: var(--blue); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.panel-heading h1, .visual-head h2 { margin: 0; font-size: 25px; letter-spacing: -.025em; }
html[lang="zh-CN"] .panel-heading h1, html[lang="zh-CN"] .visual-head h2 { font-size: 22px; }
.panel-heading > span { display: block; margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.55; }
fieldset { margin: 18px 0 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; }
legend { padding: 0 7px; color: var(--muted); font-size: 12px; }
.input-pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 18px; padding: 4px; border-radius: 11px; background: var(--soft); }
.input-pagination button { min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.input-pagination button.active { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(34, 57, 84, .08); }
.input-pagination button:hover, .input-pagination button:focus-visible { color: var(--blue); outline: none; }
.input-page { margin: 12px 0 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; }
.input-page[hidden] { display: none; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.input-panel > .field { margin-top: 14px; }
.field span, .compact-field span { color: var(--muted); font-size: 11px; line-height: 1.3; }
.boundary-field-grid, .topology-order-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compact-field { min-width: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; column-gap: .25em; }
.compact-field span { white-space: nowrap; }
.mapping-linked-field span { color: var(--cyan); font-weight: 700; }
.mapping-linked-field input { border-color: #96d8d3; }
.compact-field input { min-width: 0; height: 34px; }
.compact-field select { min-width: 0; height: 34px; }
.compact-field.span-all { grid-column: 1 / -1; }
/* 数学符号排版：变量用斜体衬线，下标/上标保持直立（ISO 80000-2 惯例）。 */
.math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", "Times New Roman", serif; font-size: 1.2em; }
.math sub, .math sup { font-style: normal; }
.topology-panel { margin-top: 18px; border-top: 1px solid var(--line); }
.topology-panel summary { padding: 12px 0 4px; color: var(--muted); font-size: 12px; cursor: pointer; }
.topology-content { padding: 4px 0 0; }
.topology-pagination { display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 8px; padding: 4px; border-radius: 11px; background: var(--soft); }
.topology-pagination button { min-height: 32px; padding: 7px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; line-height: 1.35; text-align: left; cursor: pointer; }
.topology-pagination button.active { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(34, 57, 84, .08); }
.topology-pagination button:hover, .topology-pagination button:focus-visible { color: var(--blue); outline: none; }
.topology-pagination button:focus-visible { box-shadow: 0 0 0 3px rgba(31, 101, 214, .14); }
.topology-page { min-width: 0; }
.topology-page[hidden] { display: none; }
.topology-order-grid { margin-top: 8px; }
.topology-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.topology-count-layout { min-width: 0; display: grid; gap: 12px; margin-top: 12px; }
.topology-primary-grid { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.topology-count-families { margin-top: 0; }
.topology-extra-grid { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topology-family-column { min-width: 0; display: grid; gap: 8px; align-content: start; }
.topology-field { min-width: 0; display: grid; grid-template-columns: minmax(22px, auto) minmax(0, 1fr); align-items: center; gap: 6px; }
.topology-field[hidden] { display: none; }
.topology-field input { min-width: 0; height: 34px; }
.topology-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 10px 12px; border-radius: 9px; background: var(--soft); color: var(--muted); font-size: 11px; }
.topology-summary strong { color: var(--ink); }
.topology-summary strong.invalid { color: var(--red); font-size: 10px; text-align: right; }
.boundary-upload { margin-top: 14px; }
.boundary-fit-status { margin-top: 8px; color: var(--cyan); font-size: 11px; line-height: 1.45; }
/* The status line is empty until a COO fit completes; hide it so it does
   not reserve blank space at the bottom of the boundary panel. */
.boundary-fit-status:empty { display: none; }
.boundary-preview { min-height: 0; display: grid; grid-template-rows: auto 400px; gap: 9px; }
.boundary-preview[hidden] { display: none; }
.boundary-preview-shell { height: 400px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(#fff, #fbfcfd); overflow: hidden; }
.boundary-preview-shell svg { display: block; width: 100%; height: 100%; }
.boundary-line { fill: none; stroke: var(--blue); stroke-width: 1.8; }
.boundary-point { fill: var(--red); }
input, select {
  width: 100%;
  height: 39px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
input:focus, select:focus { border-color: var(--blue); outline: 3px solid rgba(31, 101, 214, .1); }
.run-button {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
  border: 0;
  border-radius: 11px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.run-button:disabled { opacity: .55; cursor: wait; }
/* "Clear equilibrium solve" — deliberately quiet (grey outline, muted text);
   only the hover state turns red to signal the discard. */
.clear-solve-button {
  width: 100%;
  margin-top: 10px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.clear-solve-button:hover:not(:disabled) { border-color: var(--red); color: var(--red); background: #fdf6f6; }
.clear-solve-button:disabled { opacity: .5; cursor: not-allowed; }
.error { min-height: 18px; margin: 10px 0 0; color: var(--red); font-size: 12px; line-height: 1.4; }
.visual-panel { padding: 22px; display: grid; grid-template-rows: auto auto auto; align-content: start; gap: 16px; }
.visual-pagination { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 11px; background: var(--soft); }
.visual-pagination button { min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; }
.visual-pagination button.active { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(34, 57, 84, .08); }
.visual-pagination button:disabled { opacity: .45; cursor: not-allowed; }
.visual-page { min-width: 0; display: grid; align-content: start; gap: 16px; }
.visual-page[hidden] { display: none; }
.surface-shell { height: 400px; }
.surface-shell[hidden] { display: none; }
.visual-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.visual-head > span { padding: 6px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; }
.visual-head > span.ok { background: #e8f7ef; color: #247356; }
.visual-head > span.bad { background: #fbeaec; color: var(--red); }
.plot-shell { position: relative; min-height: 0; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(#fff, #fbfcfd); overflow: hidden; }
.plot-shell svg, .profile-grid svg { display: block; width: 100%; height: 100%; }
.plot-placeholder { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #96a1ae; font-size: 13px; pointer-events: none; }
.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.profile-grid article { min-width: 0; height: 150px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.profile-grid h3 { margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.profile-grid svg { height: 112px; }
.shape-diagnostics { display: grid; gap: 10px; }
.shape-diagnostics[hidden] { display: none; }
.equilibrium-quality { min-width: 0; display: grid; gap: 10px; }
.equilibrium-quality[hidden] { display: none; }
.quality-note { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.quality-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quality-summary article, .quality-profile-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--soft); }
.quality-summary span { display: block; color: var(--muted); font-size: 10px; line-height: 1.35; }
.quality-summary strong { display: block; margin-top: 6px; font-size: 15px; overflow-wrap: anywhere; }
.quality-profile-card { height: 180px; background: #fff; }
.quality-profile-card h4 { margin: 0 0 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
.quality-profile-card svg { display: block; width: 100%; height: 140px; }
.quality-spatial { min-width: 0; display: grid; gap: 9px; margin-top: 4px; }
.quality-spatial[hidden] { display: none; }
.quality-map-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quality-map-heading h4 { margin: 0; font-size: 13px; }
.quality-component-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.quality-component-tabs button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted); font: inherit; font-size: 10px; cursor: pointer; }
.quality-component-tabs button.active { border-color: var(--blue); background: #edf3ff; color: var(--blue); font-weight: 700; }
.quality-map-shell { height: 360px; border: 1px solid var(--line); border-radius: 13px; background: #fff; overflow: hidden; }
.quality-map-shell svg { display: block; width: 100%; height: 100%; }
.boundary-preview-shell,
.surface-shell,
.quality-map-shell {
  display: flex;
  align-items: center;
  justify-content: center;
}
.boundary-preview-shell svg,
.surface-shell svg,
.quality-map-shell svg {
  flex: 0 0 auto;
  width: auto;
  height: 100%;
}
.residual-cell { stroke: none; }
.quality-scale { display: grid; grid-template-columns: auto minmax(30px, 1fr) auto minmax(30px, 1fr) auto; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.quality-scale i { height: 6px; border-radius: 999px; background: linear-gradient(90deg, #2166ac, #fff); }
.quality-scale i:nth-of-type(2) { background: linear-gradient(90deg, #fff, #b2182b); }
.quality-decomposition-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quality-decomposition-summary article { min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.quality-decomposition-summary span { display: block; color: var(--muted); font-size: 9px; }
.quality-decomposition-summary strong { display: block; margin-top: 5px; font-size: 13px; overflow-wrap: anywhere; }
.quality-comparison { display: grid; gap: 7px; margin-top: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.quality-comparison[hidden] { display: none; }
.quality-comparison-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quality-comparison-grid article { min-width: 0; padding: 9px; border-radius: 9px; background: var(--soft); }
.quality-comparison-grid span, .quality-comparison-grid small { display: block; color: var(--muted); font-size: 9px; }
.quality-comparison-grid strong { display: block; margin: 5px 0 3px; font-size: 13px; }
.quality-comparison-grid strong.lower { color: #247356; }
.quality-comparison-grid strong.higher { color: var(--red); }
.diagnostic-heading p { margin: 0 0 4px; color: var(--blue); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.diagnostic-heading h3 { margin: 0; font-size: 15px; }
.result-panel { display: flex; flex-direction: column; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.metrics article { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.metrics span { display: block; color: var(--muted); font-size: 10px; }
.metrics strong { display: block; margin-top: 7px; overflow: hidden; font-size: 16px; text-overflow: ellipsis; }
.diagnostics { margin-top: 24px; }
.diagnostics h3 { margin: 0 0 12px; font-size: 13px; }
.diagnostics dl { margin: 0; }
.diagnostics dl div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.diagnostics dt { color: var(--muted); }
.diagnostics dd { margin: 0; overflow-wrap: anywhere; }
.diagnostics ul { padding-left: 18px; color: #96651e; font-size: 11px; line-height: 1.5; }
.axis { stroke: #8794a3; stroke-width: 1; }
.grid-line { stroke: #e6ebf0; stroke-width: 1; }
.surface-line { fill: none; stroke-width: 1.4; }
.profile-line { fill: none; stroke: var(--cyan); stroke-width: 2; }
.tick-label { fill: #7a8796; font-size: 10px; }
@media (max-width: 1180px) {
  .studio { grid-template-columns: 320px minmax(0, 1fr); }
  .result-panel { grid-column: 1 / -1; }
  .metrics { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; }
  .brand { max-width: 100%; }
  .node-status { display: none; }
  .topbar-right { width: 100%; min-width: 0; justify-content: flex-start; gap: 8px; }
  .topbar-right > a { display: none; }
  .topbar-tools { min-width: 0; flex-wrap: wrap; }
  .hbtn { padding: 5px 8px; font-size: 11px; }
  .studio { display: block; padding: 10px; }
  .panel { margin-bottom: 10px; border-radius: 14px; }
  .visual-panel { min-height: 720px; }
  .field-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .quality-summary { grid-template-columns: 1fr 1fr; }
  .quality-map-heading { align-items: flex-start; flex-direction: column; }
  .quality-component-tabs { width: 100%; }
  .quality-component-tabs button { flex: 1; }
  .quality-map-shell { height: 300px; }
  .quality-comparison-grid { grid-template-columns: 1fr 1fr; }
  .profile-grid article { height: 155px; }
  .boundary-preview { grid-template-rows: auto 320px; }
  .boundary-preview-shell, .surface-shell { height: 320px; min-height: 320px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  #tour-card { left: 12px !important; right: 12px; width: auto; }
}

/* ---- toolbar buttons + language toggle ---- */
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.topbar-tools { display: flex; align-items: center; gap: 6px; }
.help-menu-wrap { position: relative; flex: 0 0 auto; }
.help-menu-trigger[aria-expanded="true"] { border-color: var(--blue); color: var(--blue); }
.help-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 80; display: none; min-width: 132px; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 14px 34px -20px rgba(34, 57, 84, .35); }
.help-menu.on { display: grid; gap: 2px; }
.help-menu .hbtn { width: 100%; border: 0; border-radius: 6px; text-align: left; }
.help-menu .hbtn:hover { background: var(--soft); }
/* .hbtn lives in shared-controls.css (identical canonical rules). */
#fileIn { display: none; }

/* ---- input import/export row ---- */
.io-row { display: flex; gap: 10px; margin: 28px 0 10px; }
.io-row button {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.io-row button:hover { border-color: var(--blue); color: var(--blue); }

/* ---- report button ---- */
.report-button {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border: 0;
  border-radius: 11px;
  background: var(--cyan);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.report-button:hover { filter: brightness(1.05); }

/* ---- user manual slide-in panel ---- */
#manualPanel { position: fixed; inset: 0; z-index: 60; display: none; }
#manualPanel.on { display: block; }
#manualPanel .mp-dim { position: absolute; inset: 0; background: rgba(20, 35, 58, 0.35); }
#manualPanel .mp-card {
  position: absolute; top: 0; right: 0;
  width: min(440px, 92vw); height: 100vh;
  background: #fff; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
#manualPanel .mp-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
#manualPanel .mp-head h3 { margin: 0; font-size: 15px; color: var(--blue); flex: 1; }
#manualPanel .mp-x { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: 0; padding: 0; }
#manualPanel .mp-x:hover { color: var(--ink); }
#manualPanel .mp-body { flex: 1; overflow-y: auto; padding: 14px 18px; }
#manualPanel .mp-sec { margin-bottom: 18px; }
#manualPanel .mp-sec h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--cyan); }
#manualPanel .mp-sec p { margin: 0 0 6px; font-size: 12.5px; line-height: 1.6; }
#manualPanel .mp-sec ol { margin: 4px 0 0 18px; padding: 0; font-size: 12.5px; line-height: 1.7; }
#manualPanel .mp-sec li { margin-bottom: 3px; }
#manualPanel .mp-sec table { width: 100%; border-collapse: collapse; font-size: 12px; }
#manualPanel .mp-sec td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
#manualPanel .mp-sec td.k { color: var(--muted); white-space: nowrap; width: 30%; }
#manualPanel .mp-sec .manual-metrics td.k { white-space: normal; width: 28%; }
#manualPanel .mp-sec td.u { color: #96a1ae; width: 14%; }
#manualPanel .mp-foot { padding: 10px 18px; border-top: 1px solid var(--line); }
#manualPanel .mp-foot button { padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; }
#manualPanel .mp-foot button:hover { border-color: var(--blue); color: var(--blue); }

/* ---- guided tour overlay ---- */
#tour { position: fixed; inset: 0; z-index: 90; display: none; pointer-events: none; }
#tour.on { display: block; }
.tour-dim { position: absolute; inset: 0; background: rgba(4, 7, 12, 0.32); pointer-events: auto; }
.tour-highlight {
  position: absolute; border: 2px solid var(--blue); border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(4, 7, 12, 0.12), 0 0 24px rgba(31, 101, 214, 0.3);
  pointer-events: none; transition: 0.16s;
}
.tour-card {
  position: absolute; width: min(360px, calc(100vw - 24px));
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 15px 16px; box-shadow: 0 22px 60px -22px rgba(0, 0, 0, 0.3); pointer-events: auto;
}
.tour-card h3 { margin: 0 0 6px; color: var(--blue); font-size: 15px; }
.tour-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.tour-step { margin-top: 9px; color: #96a1ae; font-size: 11px; }
.tour-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.tour-actions button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.tour-actions button.primary { border-color: var(--blue); background: var(--blue); color: #fff; font-weight: 700; }

/* ---- dark/light theme (toggle lives in the Help menu; default light, opt-in dark) ----
   Light mode is untouched above. Dark mode only re-defines the palette + a few
   surface/text vars and overrides the hardcoded #fff surfaces / status tints. */
[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8eef7;
  --muted: #94a3b8;
  --line: #2a3a55;
  --soft: #172031;
  --blue: #5b9bff;
  --cyan: #34d4cc;
  --red: #ef7b85;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --app-bg: #121a29;
  --surface: #1e2940;
  --surface-2: #243250;
  --topbar-bg: rgba(27, 37, 56, 0.92);
  --tick: #8a98ad;
  --grid: #2a3a55;
  --axis: #5b6b82;
  --placeholder: #6b7a91;
  --ok: #4ec39a;
  --warn: #d9a44e;
  --ok-bg: #1d3a30;
  --bad-bg: #3a2228;
  --accent-bg: #1e2f4d;
  --surface-danger: #2a1a1d;
}
[data-theme="dark"] body { background: var(--app-bg); }
[data-theme="dark"] .topbar { background: var(--topbar-bg); }
[data-theme="dark"] .panel,
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] .clear-solve-button,
[data-theme="dark"] .help-menu,
[data-theme="dark"] .hbtn,
[data-theme="dark"] .tour-card,
[data-theme="dark"] #manualPanel .mp-card,
[data-theme="dark"] .quality-component-tabs button,
[data-theme="dark"] .quality-map-shell,
[data-theme="dark"] .quality-comparison,
[data-theme="dark"] .quality-profile-card,
[data-theme="dark"] .visual-pagination button.active { background: var(--surface); }
[data-theme="dark"] .input-pagination button.active { background: var(--surface); }
[data-theme="dark"] .boundary-preview-shell,
[data-theme="dark"] .plot-shell { background: linear-gradient(var(--surface), var(--surface-2)); }
[data-theme="dark"] .plot-placeholder { color: var(--placeholder); }
[data-theme="dark"] .node-status.primary { color: var(--ok); }
[data-theme="dark"] .node-status.fallback { color: var(--warn); }
[data-theme="dark"] .visual-head > span.ok { background: var(--ok-bg); color: var(--ok); }
[data-theme="dark"] .visual-head > span.bad { background: var(--bad-bg); }
[data-theme="dark"] .quality-comparison-grid strong.lower { color: var(--ok); }
[data-theme="dark"] .diagnostics ul { color: var(--warn); }
[data-theme="dark"] .clear-solve-button:hover:not(:disabled) { background: var(--surface-danger); }
[data-theme="dark"] .quality-component-tabs button.active { background: var(--accent-bg); }
[data-theme="dark"] .axis { stroke: var(--axis); }
[data-theme="dark"] .grid-line { stroke: var(--grid); }
[data-theme="dark"] .tick-label { fill: var(--tick); }
[data-theme="dark"] .tour-step,
[data-theme="dark"] #manualPanel .mp-sec td.u { color: var(--placeholder); }

/* ── Account dropdown menu ── */
.toolbar-menu-wrap { position: relative; flex: 0 0 auto; }
.toolbar-menu-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 12px; letter-spacing: inherit;
  color: var(--ink); background: #fff;
  box-sizing: border-box;
  height: 28px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; cursor: pointer;
}
.toolbar-menu-trigger:hover { color: var(--ink); border-color: var(--line); }
.toolbar-menu-trigger[aria-expanded="true"] { color: var(--ink); background: #eef2f8; border-color: var(--line); }
.toolbar-menu-trigger .menu-caret { font-size: 9px; color: var(--muted); }
.toolbar-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 80;
  display: none; min-width: 156px; padding: 5px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 34px -20px rgba(34,57,84,.35);
}
.toolbar-menu.on { display: grid; gap: 2px; }
.toolbar-menu button {
  width: 100%; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
  text-align: left; font: 11px/1.35 inherit; padding: 7px 8px;
}
.toolbar-menu button:hover { background: var(--soft); color: var(--ink); }
.toolbar-menu button.danger:hover { color: var(--red); }
.toolbar-menu .menu-aff {
  padding: 5px 8px 7px; border-bottom: 1px solid var(--line);
  font-size: 10px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere;
}
.toolbar-menu .unverified { color: #c24b55; font-weight: 700; }
.toolbar-menu .unverified:hover { color: #c24b55; }
.userbox {
  display: inline-flex; position: relative; margin-left: 6px;
  font-size: 13px; color: var(--muted);
}
.userbox .uname { color: var(--ink); font-weight: 600; }
.userbox.guest .uname { color: var(--blue); }
.userbox.guest .menu-caret { display: none; }
.userbox.guest #userMenu { display: none !important; }
[data-theme="dark"] .toolbar-menu {
  background: #1a2540; border-color: var(--line);
  box-shadow: 0 12px 36px rgba(0,0,0,.3);
}
[data-theme="dark"] .toolbar-menu-trigger { color: #94a3b8; background: rgba(255,255,255,.04); }
[data-theme="dark"] .toolbar-menu-trigger:hover { color: #e8eef7; border-color: var(--line); }
[data-theme="dark"] .toolbar-menu-trigger[aria-expanded="true"] { color: #e8eef7; background: rgba(255,255,255,.08); border-color: var(--line); }
[data-theme="dark"] .toolbar-menu button:hover { background: rgba(91,155,255,.1); }
[data-theme="dark"] .toolbar-menu .unverified { color: #ff7b7b; }

