/* USB4 version2 Gen4 by ryu-kazuho — styles */
:root {
  --topbar: 56px;
  --bg: #060a12;
  --panel: rgba(9, 14, 25, 0.74);
  --panel-solid: #0b1220;
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.32);
  --text: #e6edf6;
  --mute: #93a3b8;
  --faint: #5d6b80;
  --acc: #38bdf8;
  --pos: #ff8a3d;
  --zero: #dfe7f2;
  --neg: #3da5ff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { position: fixed; top: var(--topbar); left: 0; right: 0; bottom: 0; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar); z-index: 8;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 16px 0 18px;
  background: #04060b; border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; min-width: 0; }
.brand-icon { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.18)); }
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name .by { font-size: 12px; font-weight: 400; margin-left: 4px; }
#topbar .lang { flex: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; flex: none; cursor: pointer;
  border-radius: 9px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .03); color: #fff;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .35); }
.icon-btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.icon-btn svg { width: 19px; height: 19px; }
#topbar .lang button { font-size: 12px; padding: 7px 11px; }

/* ---------- view tabs (under the top bar) ---------- */
#views {
  position: fixed; top: calc(var(--topbar) + 12px); left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 12px;
  max-width: calc(100vw - 32px); overflow-x: auto; scrollbar-width: none;
}
#views::-webkit-scrollbar { display: none; }
.vtab {
  appearance: none; border: 1px solid transparent; background: transparent; color: var(--mute); cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1; white-space: nowrap;
  padding: 8px 13px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.vtab:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.vtab.active { color: #dff4ff; background: rgba(56, 189, 248, .16); border-color: rgba(56, 189, 248, .55); }
.vtab:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.vicon { font-size: 14px; }
.vsep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; flex: none; }
#app canvas { display: block; touch-action: none; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }

.panel {
  background: var(--panel);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
}

/* ---------- left column ---------- */
#left {
  position: fixed; top: calc(var(--topbar) + 66px); left: 16px; width: 344px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - var(--topbar) - 66px - 196px); z-index: 5;
}
#title { flex: none; display: flex; flex-direction: column; min-height: 0; }
#title summary {
  list-style: none; cursor: pointer; padding: 12px 14px 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
#title summary::-webkit-details-marker { display: none; }
#title summary::after { content: "▾"; font-size: 12px; color: var(--mute); transition: transform .2s; }
#title:not([open]) summary::after { transform: rotate(-90deg); }
#title h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.title-body { padding: 0 16px 12px; }
#title .sub { color: var(--mute); font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 2px; }
.chip {
  font: 500 11px/1 var(--mono); color: #cfe3f7;
  padding: 5px 7px; border-radius: 6px;
  background: rgba(56, 189, 248, 0.08); border: 1px solid rgba(56, 189, 248, 0.22);
}
.enc { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; }
.enc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0; }
.enc .k { color: var(--mute); white-space: nowrap; }
.enc .k b { color: var(--text); font-weight: 600; }
.bits { letter-spacing: .12em; color: #9fe6ff; }
.trits { display: flex; gap: 3px; }
.trits span {
  width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px;
  font-weight: 700; font-size: 12px; border: 1px solid transparent; transition: transform .12s, box-shadow .12s;
}
.t-p { background: rgba(255, 138, 61, .16); color: var(--pos); }
.t-z { background: rgba(223, 231, 242, .10); color: var(--zero); }
.t-n { background: rgba(61, 165, 255, .16); color: var(--neg); }
.trits span.cur { border-color: currentColor; transform: translateY(-2px) scale(1.08); box-shadow: 0 0 10px currentColor; }
.simline { color: var(--faint); font-size: 10.5px; margin-top: 6px; }
.hint { margin-top: 10px; color: var(--faint); font-size: 11px; line-height: 1.5; }
.hint kbd {
  font: 600 10px/1 var(--mono); color: var(--mute); padding: 2px 4px; border-radius: 4px;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,.03);
}

#left.compact #title .chips, #left.compact #title .hint { display: none; }
#info { padding: 14px 16px; position: relative; overflow: auto; min-height: 0; }
#info.hidden { display: none; }
#info .tag {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--c, var(--acc));
}
#info .tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--acc)); box-shadow: 0 0 8px var(--c, var(--acc)); }
#info h2 { margin: 6px 26px 6px 0; font-size: 15.5px; font-weight: 650; }
#info p { margin: 0 0 10px; color: #c3cfdd; font-size: 12.5px; }
#info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 12px; }
#info dt { color: var(--mute); }
#info dd { margin: 0; font-family: var(--mono); font-size: 11.5px; text-align: right; color: var(--text); }
#infoClose {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--mute); cursor: pointer; font-size: 15px; line-height: 1;
}
#infoClose:hover { color: var(--text); border-color: var(--line-strong); }

/* ---------- language ---------- */
html:lang(zh-CN) body { font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
html:lang(ja) body { font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", Meiryo, "Noto Sans CJK JP", sans-serif; }
html:lang(zh-CN) { --mono: ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", "Microsoft YaHei", monospace; }
html:lang(ja) { --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Hiragino Sans", "Yu Gothic", Meiryo, monospace; }
.lang {
  display: inline-flex; padding: 2px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .03);
}
.lang button {
  appearance: none; border: 0; background: transparent; color: var(--mute); cursor: pointer;
  font: 600 11px/1 system-ui, -apple-system, "PingFang SC", "Hiragino Sans", sans-serif;
  padding: 5px 8px; border-radius: 6px; transition: background .15s, color .15s;
}
.lang button:hover { color: var(--text); }
.lang button.active { background: rgba(56, 189, 248, .18); color: #dff4ff; }
.lang button:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }

/* ---------- controls ---------- */
#controls {
  position: fixed; top: calc(var(--topbar) + 66px); right: 16px; width: 290px; z-index: 5;
  max-height: calc(100vh - var(--topbar) - 66px - 186px); overflow-y: auto;
}
#controls summary {
  list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between;
  font: 600 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute);
}
#controls summary::-webkit-details-marker { display: none; }
#controls summary::after { content: "▾"; font-size: 12px; transition: transform .2s; }
#controls:not([open]) summary::after { transform: rotate(-90deg); }
.ctl-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.group-title { font: 600 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: -4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.slider label { display: flex; justify-content: space-between; font-size: 12px; color: #c3cfdd; margin-bottom: 5px; }
.slider label output { font-family: var(--mono); font-size: 11.5px; color: var(--text); }
input[type=range] { width: 100%; accent-color: var(--acc); height: 18px; margin: 0; }
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: rgba(255,255,255,.03); color: var(--text);
  padding: 7px 10px; border-radius: 8px; font: 500 12px/1 system-ui, sans-serif; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(56,189,248,.10); border-color: rgba(56,189,248,.45); }
.btn.active { background: rgba(56,189,248,.16); border-color: rgba(56,189,248,.6); color: #dff4ff; }
#playBtn { min-width: 86px; font-weight: 600; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; }
.tog { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #c3cfdd; cursor: pointer; user-select: none; }
.tog input { accent-color: var(--acc); margin: 0; width: 14px; height: 14px; }
.tog input:disabled, .tog input:disabled + span { opacity: .45; cursor: not-allowed; }

/* cable comparison table */
.cmp { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px 6px; align-items: center; }
.cmp-h { font: 600 10px/1.2 var(--mono); color: var(--faint); letter-spacing: .04em; }
.cmp-len { font: 500 11.5px/1 var(--mono); color: #c3cfdd; padding-right: 2px; white-space: nowrap; }
.cmp-cell {
  position: relative; overflow: hidden; height: 24px; padding: 0 8px; cursor: pointer; text-align: right;
  appearance: none; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, .03);
  color: var(--text); font: 600 11px/22px var(--mono); transition: border-color .15s;
}
.cmp-cell i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(74, 222, 128, .26); transition: width .35s; }
.cmp-cell b { position: relative; font-weight: 600; }
.cmp-cell:hover { border-color: var(--line-strong); }
.cmp-cell.closed { color: var(--bad); }
.cmp-cell.cur { border-color: rgba(56, 189, 248, .85); box-shadow: inset 0 0 0 1px rgba(56, 189, 248, .45); }
.cmp-cell:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.cmp-note { margin: -4px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--mute); }

/* quality selector */
.seg {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 2px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .03);
}
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--mute); cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 500; line-height: 1; padding: 7px 4px; border-radius: 6px;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: rgba(56, 189, 248, .18); color: #dff4ff; }
.seg button:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.perfline { font: 500 11px/1.4 var(--mono); color: var(--faint); margin-top: -4px; }

/* Medium / Low quality: a live blur over an animated canvas is re-computed every frame, which is
   costly on integrated GPUs — use a solid panel instead. */
html.perf-lite .panel { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(9, 14, 25, 0.92); }
.legend { display: flex; gap: 12px; font: 500 11px/1 var(--mono); color: var(--mute); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* ---------- scopes ---------- */
#scopes, #rtScopes {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 10px; padding: 10px; z-index: 4;
}
#scopes.hidden, #rtScopes.hidden { display: none; }
#scopes canvas.scope, #rtScopes canvas.scope { width: 236px; height: 144px; border-radius: 8px; border: 1px solid var(--line); display: block; cursor: pointer; }

#tooltip {
  position: fixed; pointer-events: none; z-index: 10; padding: 6px 9px; border-radius: 7px;
  background: rgba(6, 10, 18, .92); border: 1px solid var(--line-strong); font-size: 12px; white-space: nowrap;
  transform: translate(14px, 14px); opacity: 0; transition: opacity .12s;
}
#tooltip.show { opacity: 1; }
#tooltip small { display: block; color: var(--mute); font: 500 10.5px/1.4 var(--mono); }

/* ---------- 3D labels ---------- */
.lbl {
  font: 600 10.5px/1 var(--mono); color: #e6edf6; white-space: nowrap;
  padding: 4px 7px; border-radius: 5px;
  background: rgba(6, 10, 18, .72); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c) 25%, transparent);
  transition: opacity .25s;
}
.lbl.big { font-size: 12px; padding: 6px 10px; letter-spacing: .06em; color: var(--c); }
.lbl.blk { font-weight: 500; font-size: 10px; padding: 3px 6px; }
.lbl.zone { white-space: pre-line; text-align: center; line-height: 1.4; }
@media (max-aspect-ratio: 17/20) { .lbl.io { visibility: hidden; } }   /* portrait camera: the pins run off-screen */

/* ---------- levels: everyday scene ⇄ USB4 lane ---------- */
body:not([data-level="desk"]) .desk-only, body:not([data-level="board"]) .board-only,
body:not([data-level="lane"]) .lane-only, body:not([data-level="retimer"]) .retimer-only,
body:not([data-level="tunnel"]) .tunnel-only { display: none !important; }
.btn.second { width: 100%; margin-top: 8px; padding: 9px 12px; font-size: 13px; font-weight: 600; color: #e9d5ff; border-color: rgba(192, 132, 252, .55); background: rgba(192, 132, 252, .10); }
.btn.second:hover { background: rgba(192, 132, 252, .2); border-color: rgba(192, 132, 252, .8); }

/* ---------- tunnel level: bandwidth panel ---------- */
#bwPanel {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 5;
  width: min(860px, calc(100vw - 32px)); max-height: 46vh; overflow-y: auto;
}
#bwPanel summary {
  list-style: none; cursor: pointer; padding: 11px 14px; display: flex; align-items: center; justify-content: space-between;
  font: 600 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute);
}
#bwPanel summary::-webkit-details-marker { display: none; }
#bwPanel summary::after { content: "▾"; font-size: 12px; transition: transform .2s; }
#bwPanel:not([open]) summary::after { transform: rotate(-90deg); }
.bw-body { display: grid; grid-template-columns: minmax(250px, 300px) 1fr; gap: 10px 22px; padding: 0 16px 14px; }
.bw-ctl { display: flex; flex-direction: column; gap: 9px; }
.bw-lbl { display: flex; align-items: center; gap: 7px; font-size: 12px; color: #c3cfdd; }
.bw-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; flex: none; }
.bw-dot.dp, .b-dp { background: #c084fc; }
.bw-dot.pcie, .b-pcie { background: #4ade80; }
.bw-dot.usb, .b-usb { background: #fbbf24; }
.b-ctl { background: #94a3b8; }
.bw-bars { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bw-h { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; color: #c3cfdd; }
.bw-h output { font: 600 11.5px/1.2 var(--mono); color: var(--text); white-space: nowrap; }
.bw-bar { display: flex; height: 16px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); }
.bw-bar i { display: block; height: 100%; width: 0; transition: width .45s ease; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.bw-status { font-size: 12px; color: #c3cfdd; min-height: 1em; }
.bw-status.warn { color: #fbbf24; }
.bw-status.warn:empty { display: none; }
.bw-foot { font-size: 10.5px; color: var(--faint); }
.info-action { width: 100%; margin-top: 12px; }
#fade { position: fixed; inset: 0; z-index: 7; background: #04060b; opacity: 0; pointer-events: none; transition: opacity .35s ease; }
#fade.on { opacity: 1; }
.level-card { padding: 0; }
.level-card > summary {
  list-style: none; cursor: pointer; padding: 14px 16px 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.level-card > summary::-webkit-details-marker { display: none; }
.level-card > summary::after { content: "▾"; font-size: 12px; color: var(--mute); transition: transform .2s; }
.level-card:not([open]) > summary::after { transform: rotate(-90deg); }
.level-card .card-body { padding: 0 18px 14px; }
.level-card h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.level-card p { margin: 0 0 12px; color: #c3cfdd; font-size: 13px; }
.level-card .desk-hint { margin: 10px 0 0; font-size: 11.5px; color: var(--mute); }
.level-card kbd {
  font: 600 10px/1 var(--mono); color: var(--mute); padding: 2px 4px; border-radius: 4px;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,.03);
}
.btn.primary {
  width: 100%; padding: 10px 12px; font-size: 13.5px; font-weight: 600; color: #04121d;
  background: var(--acc); border-color: var(--acc); box-shadow: 0 0 18px rgba(56, 189, 248, .35);
}
.btn.primary:hover { background: #7dd3fc; border-color: #7dd3fc; }
.vtab.enter { color: var(--acc); }
.vtab.back { color: var(--text); }
/* the "click to go inside" label next to the laptop port (animate shadow only: CSS2D owns transform) */
.lbl.callout { pointer-events: auto; cursor: pointer; animation: callout 1.6s ease-in-out infinite; }
.lbl.link { pointer-events: auto; cursor: pointer; transition: opacity .25s, background-color .15s; }
.lbl.link:hover { background: color-mix(in srgb, var(--c) 26%, rgba(6, 10, 18, .85)); }
@keyframes callout {
  0%, 100% { box-shadow: 0 0 8px rgba(56, 189, 248, .25); }
  50% { box-shadow: 0 0 22px rgba(56, 189, 248, .7); }
}
@media (prefers-reduced-motion: reduce) { .lbl.callout { animation: none; } #fade { transition: none; } }

/* ---------- About dialog ---------- */
#about, #nrzDlg, #glossDlg {
  width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto;
  padding: 22px 24px 18px; border-radius: 14px; border: 1px solid var(--line-strong);
  background: #0b1220; color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
  font-size: 13px; line-height: 1.55;
}
#about::backdrop, #nrzDlg::backdrop, #glossDlg::backdrop { background: rgba(2, 4, 9, .62); }
.about-close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--mute); font-size: 17px; line-height: 1;
}
.about-close:hover { color: var(--text); border-color: var(--line-strong); }
.about-close:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.about-head { display: flex; align-items: center; gap: 12px; margin-right: 36px; }
.about-head .brand-icon { width: 40px; height: 40px; }
#glossDlg h2, #nrzDlg h2, #about h2 { margin: 0; font-size: 17px; font-weight: 650; color: #fff; }
#about h2 .by { font-size: 12px; font-weight: 400; margin-left: 4px; white-space: nowrap; display: inline-block; }
.about-ver { font: 500 11.5px/1.4 var(--mono); color: var(--mute); margin-top: 3px; }
.about-ver b { color: var(--acc); font-weight: 600; }
.about-desc { margin: 14px 0 4px; color: #c3cfdd; }
#glossDlg h3, #nrzDlg h3, #about h3 {
  margin: 18px 0 6px; font: 600 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--acc);
}
#nrzDlg ul, #about ul { margin: 0; padding-left: 18px; color: #c3cfdd; }
#nrzDlg li, #about li { margin: 4px 0; }
#nrzDlg li b, #about li b { color: var(--text); font-weight: 600; }
#nrzDlg kbd, #about kbd {
  font: 600 11px/1 var(--mono); color: var(--text); padding: 3px 6px; border-radius: 5px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .05);
}
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; align-items: center; color: #c3cfdd; }
.keys > span:nth-child(odd) { white-space: nowrap; }
.about-note { margin: 16px 0 0; font-size: 12px; color: var(--mute); }
#nrzDlg { width: min(900px, calc(100vw - 32px)); }
/* ---------- demo mode: a looping tour for screens at fairs or in meeting rooms ---------- */
body.demo #left, body.demo #controls, body.demo #views, body.demo #info { display: none !important; }
#demoCap {
  position: fixed; top: calc(var(--topbar) + 12px); left: 50%; transform: translateX(-50%); z-index: 6;
  width: max-content; max-width: min(920px, calc(100vw - 32px)); padding: 12px 20px 10px; text-align: center;
}
#demoCap[hidden] { display: none; }
#demoText { display: block; font-size: 17px; font-weight: 600; color: #fff; line-height: 1.5; }
#demoText.in { animation: capIn .6s ease; }
@keyframes capIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#demoCap small { display: inline-flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 11px; color: var(--mute); }
.demo-dot { width: 7px; height: 7px; border-radius: 50%; background: #f87171; animation: demoDot 1.6s ease-in-out infinite; }
@keyframes demoDot { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { #demoText.in, .demo-dot { animation: none; } }
.demo-btn { width: 100%; margin-top: 12px; padding: 9px 12px; font-size: 13px; font-weight: 600; color: #dff4ff; border-color: rgba(56, 189, 248, .5); }

/* ---------- guided tour for beginners ---------- */
.tour-hl {
  outline: 2px solid #7dd3fc !important; outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(56, 189, 248, .18), 0 0 28px rgba(56, 189, 248, .55) !important;
  animation: tourPulse 1.6s ease-in-out infinite;
}
@keyframes tourPulse { 50% { box-shadow: 0 0 0 10px rgba(56, 189, 248, .06), 0 0 36px rgba(56, 189, 248, .3); } }
#tour, #tourInvite { position: fixed; left: 50%; transform: translateX(-50%); z-index: 8; padding: 13px 16px 12px; }
#tour { top: calc(var(--topbar) + 66px); width: min(520px, calc(100vw - 32px)); }
#tourInvite { bottom: 18px; width: min(440px, calc(100vw - 32px)); }
#tour[hidden], #tourInvite[hidden] { display: none; }
.tour-head { display: flex; justify-content: space-between; align-items: center; }
.tour-step { font: 600 11px/1 var(--mono); color: var(--acc); letter-spacing: .08em; }
.tour-x { appearance: none; border: 1px solid var(--line); background: transparent; color: var(--mute); width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 15px; line-height: 1; }
.tour-x:hover { color: var(--text); border-color: var(--line-strong); }
#tour h2 { margin: 6px 0 4px; font-size: 16px; font-weight: 650; color: #fff; }
#tour p { margin: 0 0 12px; color: #c3cfdd; font-size: 13px; line-height: 1.6; }
#tourInvite p { margin: 0 0 10px; color: #dbe4ee; font-size: 13.5px; line-height: 1.55; }
.tour-nav { display: flex; justify-content: flex-end; gap: 8px; }
.tour-nav .btn { padding: 8px 12px; }
.tour-nav .btn.primary { width: auto; }
.tour-nav .btn:disabled { opacity: .4; cursor: default; }
.link-btn { appearance: none; background: none; border: 0; padding: 9px 0 0; color: var(--acc); font: inherit; font-size: 12.5px; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
@media (max-width: 860px) { #tour { top: auto; bottom: 12px; } }
@media (prefers-reduced-motion: reduce) { .tour-hl { animation: none; } }

/* ---------- shareable links ---------- */
.vsvg { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; }
#shareBtn.copied, .share-mini.copied, .gl-link.copied { color: #4ade80; }
.share-mini { float: right; margin-top: -42px; padding: 6px 10px; }
.gl-name { display: flex; align-items: baseline; gap: 8px; }
.gl-link {
  appearance: none; border: 1px solid transparent; background: none; color: var(--faint); cursor: pointer;
  font: 600 11px/1 var(--mono); padding: 2px 5px; border-radius: 5px; opacity: .6;
}
.gl-item:hover .gl-link, .gl-link:focus-visible { opacity: 1; border-color: var(--line); color: var(--mute); }
@media (max-width: 860px) { .share-mini { float: none; margin: 0 0 10px; } }

/* ---------- glossary ---------- */
#glossDlg { width: min(640px, calc(100vw - 32px)); }
#glossDlg h2 { margin-right: 40px; }
.gl-search {
  width: 100%; margin: 6px 0 4px; padding: 8px 11px; border-radius: 8px; font: inherit; font-size: 13px;
  color: var(--text); background: rgba(255, 255, 255, .04); border: 1px solid var(--line-strong);
}
.gl-search:focus { outline: 2px solid var(--acc); outline-offset: 0; border-color: transparent; }
.gl-list { display: flex; flex-direction: column; }
.gl-item { padding: 8px 10px; margin: 0 -10px; border-radius: 8px; transition: background-color .6s; }
.gl-item.flash { background: rgba(56, 189, 248, .16); transition: none; }
.gl-name { font-weight: 650; color: #fff; font-size: 13.5px; }
.gl-def { color: #c3cfdd; margin-top: 2px; }
.gl-empty { color: var(--mute); margin: 12px 0 0; }
.gl-term {
  appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: help;
  text-decoration: underline dotted rgba(125, 211, 252, .75); text-underline-offset: 3px; text-decoration-thickness: 1.5px;
}
.gl-term:hover, .gl-term:focus-visible { color: #e0f2fe; text-decoration-color: #7dd3fc; outline: none; }
#glossTip {
  position: fixed; z-index: 30; max-width: 300px; padding: 9px 11px; border-radius: 9px; pointer-events: none;
  background: rgba(8, 13, 24, .97); border: 1px solid var(--line-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  font-size: 12.5px; line-height: 1.5; color: #c3cfdd;
}
#glossTip[hidden] { display: none; }
#glossTip b { display: block; color: #fff; font-weight: 650; margin-bottom: 2px; }
#glossTip small { display: block; margin-top: 5px; color: var(--mute); font-size: 11px; }
#nrzDlg h2 { margin-right: 40px; }
.nrz-btn { width: 100%; padding: 8px 10px; color: #dff4ff; border-color: rgba(56, 189, 248, .45); }
.nrz-len { margin: 12px 0 10px; max-width: 360px; }
.nrz-scopes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nrz-scopes canvas { width: 100%; height: auto; aspect-ratio: 360 / 220; display: block; border-radius: 8px; border: 1px solid var(--line); }
.nrz-table { display: grid; grid-template-columns: minmax(110px, auto) repeat(3, 1fr); gap: 1px; margin-top: 12px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--line); font-size: 12px; }
.nrz-table > div { background: #0b1220; padding: 6px 9px; color: #c3cfdd; }
.nrz-table .nh { font: 600 11.5px/1.3 var(--mono); color: var(--c, var(--text)); }
.nrz-table .nl { color: var(--mute); }
.nrz-table .nv { font: 500 12px/1.3 var(--mono); color: var(--text); }
.nrz-table .nv.bad { color: #f87171; } .nrz-table .nv.mid { color: #fbbf24; } .nrz-table .nv.good { color: #4ade80; }
.nrz-c0 { --c: #f87171; } .nrz-c1 { --c: #4ade80; } .nrz-c2 { --c: #38bdf8; }
.about-note + .about-note { margin-top: 4px; }
.changelog { display: flex; flex-direction: column; gap: 10px; }
.log-head { display: flex; align-items: baseline; gap: 10px; font: 500 11.5px/1.3 var(--mono); color: var(--mute); }
.log-head b { color: var(--acc); font-weight: 600; font-size: 12.5px; }
.changelog ul { margin: 4px 0 0; }
.about-foot {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line);
  font: 500 11.5px/1.6 var(--mono); color: var(--mute);
}
.about-foot p { margin: 0; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; background: var(--bg);
  color: var(--mute); font: 500 13px/1.7 var(--mono); letter-spacing: .04em; transition: opacity .6s;
  padding: 24px; text-align: center;
}
#loading.gone { opacity: 0; pointer-events: none; }

@media (max-width: 1280px), (max-height: 820px) {
  #scopes canvas.scope, #rtScopes canvas.scope { width: 200px; height: 122px; }
  #left { max-height: calc(100vh - var(--topbar) - 66px - 170px); }
}
@media (max-width: 860px) {
  :root { --topbar: 50px; }
  #topbar { padding: 0 12px; gap: 10px; }
  .brand { gap: 9px; }
  .brand-icon { width: 28px; height: 28px; }
  .brand-name { font-size: 14px; }
  .brand-name .by { font-size: 11px; }
  #topbar .lang button { padding: 6px 8px; font-size: 11.5px; }
  .topbar-right { gap: 6px; }
  .icon-btn { width: 30px; height: 30px; }
  .icon-btn svg { width: 17px; height: 17px; }
  #about, #nrzDlg, #glossDlg { padding: 18px 16px 14px; }
  .nrz-scopes { grid-template-columns: 1fr; }
  #views {
    top: calc(var(--topbar) + 10px); left: 16px; right: 16px; transform: none;
    justify-content: flex-start; justify-content: safe center;   /* centred, but never clipped when it scrolls */
  }
  .vtab { padding: 7px 10px; font-size: 12.5px; }
  #left { top: calc(var(--topbar) + 60px); width: calc(100vw - 32px); max-height: 46vh; }
  .title-body { max-height: 32vh; overflow-y: auto; }
  .level-card .desk-hint { display: none; }
  .lbl.zone { font-size: 9.5px; padding: 3px 6px; letter-spacing: 0; }
  #controls { top: auto; bottom: calc((100vw - 56px) / 3 * 0.611 + 42px); right: 16px; width: min(290px, calc(100vw - 32px)); max-height: 50vh; overflow: auto; }
  #scopes, #rtScopes { gap: 6px; padding: 6px; width: calc(100vw - 32px); justify-content: space-between; }
  .bw-body { grid-template-columns: 1fr; }
  #scopes canvas.scope, #rtScopes canvas.scope { width: calc((100vw - 32px - 24px) / 3); height: auto; aspect-ratio: 360 / 220; }
}

/* legend dots (classes instead of inline style attributes, so CSP can stay strict) */
.legend i.d-pos { background: var(--pos); }
.legend i.d-zero { background: var(--zero); }
.legend i.d-neg { background: var(--neg); }
