* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0e16; color: #e0e0ee; overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100vh; }

/* ===== Topbar ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 48px; padding: 0 14px; background: #11151f; border-bottom: 1px solid #1f2636; z-index: 20; }
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
.brand-logo { height: 26px; width: 26px; object-fit: contain; }
.brand-mark { color: #44aaff; }
.brand-series { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #5f6b80;
  border: 1px solid #2a3550; border-radius: 999px; padding: 1px 7px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-sep { width: 1px; height: 22px; background: #2a3346; margin: 0 4px; }
.action-btn { background: #161c28; border: 1px solid #283142; color: #c7d0e0; font-size: 12.5px;
  padding: 6px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.action-btn:hover { background: #1d2536; color: #fff; }
.action-btn.toggle.on { background: #14304f; border-color: #44aaff; color: #aaddff; }
.action-btn.on { background: #14304f; border-color: #44aaff; color: #aaddff; }
.action-btn.danger:hover { background: #3a1a20; border-color: #a55; color: #ffb6b6; }

/* time-loop transport controls (Play / Pause / Reset) */
.sim-controls { display: inline-flex; align-items: center; gap: 3px;
  background: #0f1421; border: 1px solid #283142; border-radius: 8px; padding: 2px 3px; }
.sim-controls .sim-btn { padding: 4px 8px; font-size: 13px; border: 1px solid transparent;
  background: transparent; color: #aac4e6; border-radius: 5px; min-width: 28px; line-height: 1; }
.sim-controls .sim-btn:hover { background: #1d2536; color: #dcefff; }
.sim-controls .sim-btn.on { background: #14304f; border-color: #44aaff; color: #8be19a; }
.sim-controls #btn-pause.on { color: #ffd066; }
.sim-controls .sim-time { font-size: 10.5px; color: #6a7a92; font-variant-numeric: tabular-nums;
  padding: 0 8px 0 6px; min-width: 56px; text-align: right; letter-spacing: 0.3px; }

/* Tools palette — floating horizontal row under the topbar */
.tools-palette { position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 3px; z-index: 18;
  background: rgba(20,24,34,0.93); border: 1px solid #2c3c5c; border-radius: 10px; padding: 5px 6px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  user-select: none; }
.tools-palette[hidden] { display: none; }
.tools-palette.dragging { cursor: grabbing; box-shadow: 0 18px 50px rgba(0,0,0,0.7); }
.tools-palette-grip { display: flex; align-items: center; justify-content: center; width: 14px;
  margin-right: 3px; background: none; border: none; cursor: grab;
  color: #4a5870; padding: 0; border-radius: 5px; }
.tools-palette-grip:hover { color: #aaddff; background: #14304f; }
.tools-palette-grip svg { width: 8px; height: 16px; fill: currentColor; pointer-events: none; }
.tools-palette.dragging .tools-palette-grip { cursor: grabbing; }

.tool-icon { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; width: 50px; min-height: 48px; background: none; border: 1px solid transparent; color: #b8c5d8;
  padding: 5px 4px 4px; border-radius: 7px; cursor: pointer; font: 600 9.5px/1 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  letter-spacing: .15px; transition: background .12s, color .12s, border-color .12s; }
.tool-icon:hover { background: #1b2940; color: #fff; border-color: #2c3c5c; }
.tool-icon.on { background: #14304f; border-color: #44aaff; color: #cfe8ff; }
.tool-icon.on .tool-svg { color: #aaddff; }
.tool-svg { width: 22px; height: 22px; color: #93a3bb; stroke: currentColor; stroke-width: 1.6;
  fill: none; transition: color .12s; }
.tool-icon:hover .tool-svg { color: #dceaff; }
.tool-name { font-size: 9.5px; opacity: .92; white-space: nowrap; }
/* Status dot in the top-right corner — uses the existing .tool-state element. */
.tool-state { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 999px;
  background: transparent; text-indent: -9999px; overflow: hidden; pointer-events: none; }
.tool-state.on { background: #44ddaa; box-shadow: 0 0 6px rgba(68,221,170,.7); }

.tool-icon-sep { width: 1px; align-self: stretch; background: #28344a; margin: 4px 3px; }

.tool-msg { position: absolute; top: calc(100% + 6px); right: 6px;
  background: rgba(15,28,22,.95); border: 1px solid #2a5a3c; border-radius: 6px;
  font-size: 11.5px; color: #8fd0a0; padding: 6px 10px; line-height: 1.4;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.tool-msg[hidden] { display: none; }

@media (max-width: 760px) {
  .tool-icon { width: 44px; min-height: 44px; }
  .tool-name { font-size: 9px; }
  .tool-svg { width: 20px; height: 20px; }
}

/* ===== Stage / canvas ===== */
#stage { position: relative; flex: 1; min-height: 0; }
#lab-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hint-bar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(15,18,30,0.82); border: 1px solid #243049; color: #9fb0c8; font-size: 11.5px;
  padding: 5px 12px; border-radius: 999px; pointer-events: none; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.hint-bar b { color: #cfe0f5; }

/* live coordinate readout (shown while an item is selected / dragged) */
.coord-readout { position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; z-index: 13;
  background: rgba(15,18,30,0.9); border: 1px solid #2c3c5c; border-radius: 9px;
  padding: 6px 14px; font-size: 12.5px; color: #9fb0c8; pointer-events: none;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 8px 24px rgba(0,0,0,0.45); }
.coord-readout[hidden] { display: none; }
.coord-readout .co-name { color: #aaddff; font-weight: 600; text-transform: capitalize;
  border-right: 1px solid #2c3c5c; padding-right: 12px; }
.coord-readout .co-xy { font-variant-numeric: tabular-nums; letter-spacing: 0.2px; }
.coord-readout .co-xy b { color: #eaf2ff; font-weight: 600; }

/* measurement rows used inside the unified details-panel */
.measure-rows { display: flex; flex-direction: column; gap: 8px; }
.measure-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 3px 0; }
.measure-row .ml { color: #93a3bb; }
.measure-row .mv { color: #eaf2ff; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }

/* one card per measurement instrument (or selected non-instrument item) */
.measure-card { border: 1px solid #1f2636; border-radius: 6px; padding: 6px 9px 7px;
  background: rgba(11,16,26,0.55); display: flex; flex-direction: column; gap: 1px; }
.measure-card.is-selected { border-color: #2c5078; background: rgba(20,38,66,0.55);
  box-shadow: 0 0 0 1px rgba(68,170,255,0.18) inset; }
.measure-card-title { display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid #1a2333;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: #aaddff; font-weight: 700; }
.measure-card-title .mt-meta { color: #6a7a92; font-weight: 500; font-size: 10px;
  text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }

/* live signal graph subsection (probe history, voltmeter, etc.) */
.details-graph { margin-top: 10px; padding-top: 9px; border-top: 1px solid #1f2636; }
.details-graph[hidden] { display: none; }
.details-graph-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px;
  color: #707d92; margin-bottom: 6px; }
.details-graph canvas { display: block; width: 100%; height: 100px; background: #0b101a;
  border: 1px solid #1a2333; border-radius: 5px; }

/* camera-view button group, lives inside the camera floating panel */
.view-buttons { display: flex; gap: 0; border: 1px solid #283142; border-radius: 7px; overflow: hidden;
  background: #161c28; width: 100%; }
.view-buttons button { flex: 1; background: transparent; border: none; border-right: 1px solid #283142;
  color: #aac4e6; font-size: 11.5px; font-weight: 600; padding: 6px 0; cursor: pointer; line-height: 1.2; }
.view-buttons button:last-child { border-right: none; }
.view-buttons button:hover { background: #1d2536; color: #dcefff; }
.view-buttons button.on { background: #14304f; color: #aaddff; }

/* ===== Floating panels ===== */
.floating-panel { position: absolute; top: 14px; width: 270px; max-height: calc(100% - 28px);
  background: rgba(18,22,32,0.92); border: 1px solid rgba(255,255,255,0.10); border-radius: 10px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.55); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  display: flex; flex-direction: column; overflow: hidden; z-index: 12; }
.floating-panel[hidden] { display: none; }
.lib-panel { left: 14px; max-height: 58%; }   /* leave room below for viz-tools-panel + details-panel to stack on the left side */
.exp-panel { left: 296px; width: 300px; }   /* sits to the right of the 270px library panel */
.camera-panel { right: 14px; top: 14px; width: 220px; }
.camera-panel .camera-body { padding: 10px 12px 12px; display: flex; flex-direction: column;
  gap: 10px; align-items: center; }
.camera-panel #viewcube-canvas { width: 180px; height: 180px; display: block;
  background: #0b101a; border: 1px solid #1a2333; border-radius: 6px; cursor: pointer; }
.camera-panel .camera-reset { width: 100%; }
/* notes/formulas tiles under the camera panel on the right column */
.info-panel { right: 14px; top: 396px; width: 290px; max-height: calc(100% - 410px); }
.quiz-panel { left: 50%; transform: translateX(-50%); top: auto; bottom: 16px; width: 380px; max-height: calc(100% - 90px); }
.scope-panel { right: 14px; top: auto; bottom: 14px; width: 460px; z-index: 14; }
.details-panel { left: 14px; top: auto; bottom: 14px; width: 280px; max-height: calc(100% - 36px);
  z-index: 14; }
.details-panel .panel-header { padding: 8px 12px; }
.details-panel .panel-header-title { color: #aaddff; text-transform: capitalize; }
.details-panel .details-body { padding: 9px 12px 11px; }

/* drawing-mode banner — shown while the user is placing a Gauss sphere or Ampère loop */
.viz-draw-banner { position: absolute; left: 50%; top: 76px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; z-index: 19; pointer-events: none;
  background: linear-gradient(180deg, rgba(30,52,86,0.96), rgba(20,38,66,0.96));
  border: 1.5px solid #44aaff; border-radius: 10px; padding: 9px 16px; min-width: 320px; max-width: 540px;
  color: #eaf6ff; font: 500 13px/1.45 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  box-shadow: 0 12px 36px rgba(0,0,0,0.6), 0 0 0 1px rgba(68,170,255,0.15);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: viz-banner-pulse 1.6s ease-in-out infinite; }
.viz-draw-banner[hidden] { display: none; }
.viz-draw-banner .viz-banner-icon { flex: 0 0 auto; width: 28px; height: 28px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 999px;
  background: rgba(68,170,255,0.18); color: #cfe8ff; font-size: 16px; font-weight: 700; }
.viz-draw-banner .viz-banner-text { flex: 1; }
.viz-draw-banner .viz-banner-step { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px;
  color: #8fc4ff; margin-bottom: 1px; font-weight: 700; }
.viz-draw-banner .viz-banner-body { color: #eaf6ff; }
.viz-draw-banner .viz-banner-body b { color: #ffe28f; font-weight: 700; }
.viz-draw-banner .viz-banner-esc { flex: 0 0 auto; font-size: 10.5px; color: #9ec6f0;
  border: 1px solid #2c5078; border-radius: 5px; padding: 2px 7px; background: rgba(10,16,28,0.55);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
@keyframes viz-banner-pulse {
  0%, 100% { box-shadow: 0 12px 36px rgba(0,0,0,0.6), 0 0 0 1px rgba(68,170,255,0.15); }
  50%      { box-shadow: 0 12px 36px rgba(0,0,0,0.6), 0 0 0 4px rgba(68,170,255,0.28); }
}

/* Field-analysis floating panel — holds the Gauss + Ampère readouts in one
   draggable window that tiles under the apparatus library on the left side. */
.viz-tools-panel { left: 14px; top: 320px; width: 280px;
  max-height: calc(100% - 340px); z-index: 14; }
.panel-header-drag { cursor: grab; user-select: none; }
.floating-panel.dragging .panel-header-drag { cursor: grabbing; }
.floating-panel.dragging { box-shadow: 0 18px 50px rgba(0,0,0,0.7); }
.viz-tools-panel .viz-tools-body { padding: 4px 12px 10px; overflow-y: auto; }
.viz-tools-slot { padding: 9px 0; border-bottom: 1px solid #1f2636; }
.viz-tools-slot:last-child { border-bottom: none; }
.viz-tools-slot[hidden] { display: none; }
.viz-tools-slot .viz-readout-title { font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.7px; color: #8fc4ff; font-weight: 700; margin-bottom: 6px; }
.viz-tools-slot .viz-readout-body { font-size: 12px; line-height: 1.55; color: #cfe6ff;
  font-variant-numeric: tabular-nums; }
.viz-tools-slot .viz-readout-body b { color: #ffe28f; font-weight: 700; }
.viz-tools-slot .viz-readout-hint { font-size: 11.5px; color: #9aa9bf; line-height: 1.4; }
.scope-panel .scope-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.scope-panel #scope-canvas { width: 100%; height: 220px; background: #0a0d14; border-radius: 6px; display: block; }
.scope-panel .scope-channels { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #b6c1d4; }
.scope-panel .scope-channels .ch-row { display: flex; gap: 6px; align-items: center; }
.scope-panel .scope-channels .ch-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.scope-panel .scope-controls { display: flex; gap: 8px; align-items: center; font-size: 11px; color: #8893a6; }
.scope-panel .scope-controls button { background: #1a2330; border: 1px solid #2a3548; color: #dde3ef; border-radius: 4px; padding: 3px 8px; cursor: pointer; font-size: 11px; }
.scope-panel .scope-controls button:hover { background: #243043; border-color: #44aaff; }
.scope-panel .scope-controls input[type=range] { flex: 1; }
.panel-header { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid #1f2636; }
.panel-header-title { font-size: 13px; font-weight: 600; color: #fff; }
.panel-header-spacer { flex: 1; }
.panel-header-btn { background: none; border: none; color: #8893a6; font-size: 18px; line-height: 1; cursor: pointer; }
.panel-header-btn:hover { color: #fff; }
.panel-body { padding: 6px 10px; overflow-y: auto; min-height: 0; }   /* min-height:0 → scrolls only once the panel hits its max height */
.panel-sub-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px; color: #707d92; margin: 10px 0 5px; }
.panel-sub-title:first-child { margin-top: 0; }

/* accordion category sections (apparatus + experiments) */
.acc-section { border-bottom: 1px solid #1b2433; }
.acc-section:last-child { border-bottom: none; }
.acc-head { display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: none; cursor: pointer;
  padding: 9px 4px; color: #c4d0e2; font-size: 12.5px; font-weight: 600; text-align: left; }
.acc-head:hover { color: #fff; }
.acc-section.open > .acc-head { color: #eaf4ff; background: linear-gradient(90deg, rgba(68,170,255,0.12), rgba(68,170,255,0)); border-left: 2px solid #44aaff; padding-left: 6px; }
.acc-section.open > .acc-head .acc-ico { color: #cfe6ff; }
.acc-section.open > .acc-head .acc-count { color: #cfe6ff; background: #14304f; }
.acc-ico { width: 22px; height: 22px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: #7fb0e0; }
.acc-ico svg { width: 19px; height: 19px; display: block; }
.acc-title { flex: 1; }
.acc-count { font-size: 10.5px; font-weight: 600; color: #6b788f; background: #161f2e; border-radius: 999px; padding: 1px 7px; }
.acc-chev { width: 6px; height: 6px; flex: 0 0 auto; margin: 0 2px; border-right: 2px solid #6b788f; border-bottom: 2px solid #6b788f;
  transform: rotate(-45deg); transition: transform 0.16s ease; }
.acc-head:hover .acc-chev { border-color: #9fb2c8; }
.acc-section.open .acc-chev { transform: rotate(45deg); border-color: #cfe6ff; }
.acc-body { display: none; padding: 1px 0 9px 2px; }
.acc-section.open .acc-body { display: block; }
.muted { color: #8893a6; font-size: 12px; line-height: 1.5; }

/* ===== Apparatus library ===== */
.lib-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: #151b27; border: 1px solid #232c3d; color: #dbe3f0; border-radius: 7px;
  padding: 7px 9px; margin-bottom: 4px; cursor: pointer; font-size: 12.5px; }
.lib-item:hover { background: #1c2740; border-color: #44aaff; }
.lib-ico { width: 30px; height: 21px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  background: #0e141f; border: 1px solid #232c3d; border-radius: 4px; }
.lib-ico svg { width: 28px; height: 20px; display: block; }
.lib-item:hover .lib-ico { border-color: #355377; }

/* ===== Experiments ===== */
.exp-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; text-align: left;
  background: #151b27; border: 1px solid #232c3d; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.exp-item:hover { background: #1c2740; border-color: #44aaff; }
.exp-name { font-size: 13px; font-weight: 600; color: #eaf1fb; }
.exp-diff { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.5px; padding: 1px 7px; border-radius: 999px; align-self: center; }
.exp-diff.intro { background: #14331f; color: #9be8b0; }
.exp-diff.core { background: #14283f; color: #8fc4ff; }
.exp-diff.advanced { background: #2e1f3f; color: #c9a4ff; }
.exp-blurb { grid-column: 1 / -1; font-size: 11.5px; color: #93a0b5; line-height: 1.4; }

/* ===== Properties ===== */
.prop-title { font-size: 13px; font-weight: 600; color: #fff; text-transform: capitalize; margin-bottom: 8px; }
.prop-row { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #aab8cc; margin-bottom: 10px; }
.prop-row select, .prop-row input[type=number] { background: #0f1420; border: 1px solid #2a3445; color: #e6edf7;
  border-radius: 6px; padding: 6px 8px; font-size: 12.5px; }
.prop-row.prop-range { gap: 2px; }
.prop-row input[type=range] { width: 100%; accent-color: #44aaff; }
.prop-row.prop-check { flex-direction: row; align-items: center; gap: 8px; }
.prop-del { width: 100%; background: #2a1a20; border: 1px solid #5a3540; color: #ff9aa6;
  border-radius: 7px; padding: 7px; cursor: pointer; font-size: 12px; margin-top: 4px; }
.prop-del:hover { background: #3a232b; }

/* ===== Info ===== */
.info-exp h3 { font-size: 14px; color: #fff; margin-bottom: 4px; }
.info-exp p { font-size: 12.5px; line-height: 1.5; margin-bottom: 6px; color: #c4cdde; }
.formula-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.formula-list li { font-size: 12px; color: #b7c3d6; background: rgba(10,12,20,0.6);
  border-left: 3px solid #44aaff; border-radius: 4px; padding: 5px 9px; }

/* clickable law list */
.law-hint { font-size: 10px; text-transform: none; letter-spacing: 0; color: #5f6b80; margin-left: 6px; }
.law-list { display: flex; flex-direction: column; gap: 5px; }
.law-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; width: 100%; text-align: left;
  background: rgba(10,12,20,0.6); border: 1px solid #222c3d; border-left: 3px solid #44aaff; border-radius: 5px;
  padding: 6px 9px; cursor: pointer; }
.law-item:hover { background: #16243a; border-color: #44aaff; }
.law-name { font-size: 12px; font-weight: 600; color: #dbe6f5; grid-column: 1; }
.law-eq { font-size: 11px; color: #8fb4dd; grid-column: 1; grid-row: 2; }
.law-go { grid-column: 2; grid-row: 1 / span 2; color: #5f7aa0; font-size: 18px; }

/* law detail card */
.law-back { background: none; border: none; color: #66b6ff; cursor: pointer; font-size: 12px; padding: 0 0 8px; }
.law-back:hover { color: #9fd0ff; }
.law-card h3 { font-size: 15px; color: #fff; margin-bottom: 8px; line-height: 1.3; }
.law-formula { font-size: 14px; color: #aaddff; background: rgba(20,48,79,0.55); border: 1px solid #2c4a6e;
  border-radius: 6px; padding: 9px 11px; text-align: center; margin-bottom: 10px; letter-spacing: 0.3px; }
.law-summary { font-size: 12.5px; color: #e3ebf7; font-weight: 500; margin-bottom: 8px; line-height: 1.5; }
.law-card p { font-size: 12px; color: #bcc7d8; line-height: 1.55; margin-bottom: 8px; }
.law-sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #707d92; margin: 10px 0 5px; }
.law-vars { list-style: none; display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.law-vars li { display: flex; gap: 8px; font-size: 12px; color: #bcc7d8; line-height: 1.4; }
.law-vars li b { color: #8fd0ff; min-width: 42px; flex: 0 0 auto; font-weight: 600; }
.law-try { width: 100%; margin-top: 10px; background: #14304f; border: 1px solid #2c5a8c;
  color: #aaddff; border-radius: 6px; padding: 8px; cursor: pointer; font-size: 12px; font-weight: 600; }
.law-try:hover { background: #1a3f66; border-color: #44aaff; color: #dcefff; }

/* ===== Quiz ===== */
.quiz-body { display: flex; flex-direction: column; gap: 12px; }
.quiz-home { display: flex; flex-direction: column; gap: 12px; }
.quiz-title { font-size: 16px; font-weight: 600; color: #fff; }
.quiz-sub { font-size: 12.5px; color: #aabbcc; line-height: 1.45; }
.quiz-mode-list { display: flex; flex-direction: column; gap: 6px; }
.quiz-mode-btn { background: #14304f; border: 1px solid #44aaff; color: #aaddff; border-radius: 7px;
  padding: 9px 11px; font-size: 12.5px; cursor: pointer; text-align: left; }
.quiz-mode-btn:hover { background: #1a3a5e; }
.quiz-status { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #98a4b4; }
.quiz-q { background: rgba(10,12,20,0.6); border-left: 3px solid #44aaff; border-radius: 4px; padding: 10px 12px; font-size: 13.5px; color: #fff; line-height: 1.45; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quiz-choice { background: #1c1c2a; border: 1px solid #2a2a3a; color: #e6e6f2; border-radius: 6px; padding: 9px 10px; font-size: 12px; cursor: pointer; text-align: left; }
.quiz-choice:hover:not(:disabled) { background: #2a2a3a; border-color: #44aaff; }
.quiz-choice.correct { background: #14331f; border-color: #5a5; color: #b6f9b6; }
.quiz-choice.wrong { background: #311; border-color: #a55; color: #f9b6b6; }
.quiz-feedback { min-height: 18px; font-size: 12px; padding: 6px 8px; border-radius: 4px; color: #ccd; }
.quiz-feedback.ok { background: #14331f; color: #b6f9b6; border-left: 3px solid #5a5; }
.quiz-feedback.no { background: #311; color: #f9b6b6; border-left: 3px solid #a55; }
.quiz-controls { display: flex; gap: 8px; justify-content: flex-end; }
.quiz-btn { background: #1c2a3a; border: 1px solid #44aaff; color: #aaddff; border-radius: 5px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.quiz-btn:hover { background: #244466; }
.quiz-btn.primary { background: #2a5588; color: #fff; }
.quiz-results { display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.quiz-score { font-size: 28px; font-weight: 700; color: #fff; }
.quiz-pct { font-size: 16px; color: #aabbcc; font-weight: 400; }
.quiz-verdict { font-size: 13px; color: #cce6ff; font-style: italic; }
.chal-item { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  background: #151b27; border: 1px solid #232c3d; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.chal-item:hover { background: #1c2740; border-color: #44aaff; }
.chal-item b { font-size: 12.5px; color: #eaf1fb; }
.chal-item span { font-size: 11.5px; color: #93a0b5; }
.chal-req { font-size: 11.5px; color: #93a0b5; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { background: #14283f; color: #8fc4ff; border-radius: 999px; padding: 1px 8px; font-size: 11px; }

/* category-tile home + quiz framework v2 additions */
.quiz-tiles { display: flex; flex-direction: column; gap: 6px; }
.quiz-tile { position: relative; display: flex; flex-direction: column; gap: 2px;
  background: #14304f; border: 1px solid #2c5a8c; color: #cce6ff;
  border-radius: 7px; padding: 9px 11px; text-align: left; cursor: pointer; }
.quiz-tile:hover { background: #1a3a5e; border-color: #44aaff; }
.quiz-tile-label { font-size: 12.5px; font-weight: 600; color: #eaf1fb; }
.quiz-tile-blurb { font-size: 11.5px; color: #93a0b5; line-height: 1.4; }
.quiz-tile-count { position: absolute; top: 8px; right: 10px; font-size: 11px;
  color: #8fc4ff; background: #0d1828; border-radius: 999px; padding: 1px 7px; }
.quiz-btn-back { padding: 4px 8px; font-size: 11px; }
.chal-item { position: relative; }
.chal-diff { position: absolute; top: 8px; right: 10px; font-size: 10.5px; color: #ffce66; letter-spacing: 1px; }

/* status dot + hold ring */
.quiz-status-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  background: #555; box-shadow: 0 0 0 2px rgba(255,255,255,0.08) inset; }
.quiz-status-dot.pending { background: #666; }
.quiz-status-dot.fail    { background: #d05a5a; box-shadow: 0 0 6px rgba(208,90,90,0.6); }
.quiz-status-dot.pass    { background: #5acb6e; box-shadow: 0 0 8px rgba(90,203,110,0.7); }
.quiz-status-dot.held    { animation: chalPulse 1.1s ease-in-out infinite; }
@keyframes chalPulse { 0%,100% { box-shadow: 0 0 4px rgba(255,210,90,0.5); } 50% { box-shadow: 0 0 12px rgba(255,210,90,0.95); } }

/* readout panel */
.quiz-readout { background: rgba(10,12,20,0.55); border: 1px solid #232c3d; border-radius: 6px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.quiz-readout-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: #cdd7e6; }
.quiz-readout-row .qr-k { color: #93a0b5; min-width: 56px; }
.quiz-readout-row .qr-v { color: #eaf1fb; text-align: right; }
.quiz-readout-row.qr-msg .qr-v { font-style: italic; color: #ffce99; text-align: left; flex: 1; }
.quiz-readout-hint { font-size: 12px; color: #ffe0a8; background: rgba(255,206,153,0.08);
  border: 1px solid rgba(255,206,153,0.22); border-radius: 5px; padding: 6px 8px; margin-top: 4px; }
.quiz-readout-hint[hidden] { display: none; }
.quiz-btn.on { background: #3b3220; border-color: #ffce99; color: #ffce99; }

/* numeric input row */
.quiz-numeric-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.quiz-numeric-label { font-size: 12px; color: #cdd7e6; flex: 1 1 auto; }
.quiz-numeric-input { background: #0d1828; border: 1px solid #2c5a8c; color: #eaf1fb;
  border-radius: 5px; padding: 5px 8px; width: 80px; font-size: 13px; }
.quiz-numeric-unit { font-size: 11px; color: #8fc4ff; min-width: 18px; }

/* slider row (predict) */
.quiz-slider-row { display: flex; flex-direction: column; gap: 4px;
  background: rgba(10,12,20,0.4); border: 1px solid #232c3d; border-radius: 6px; padding: 8px; }
.quiz-slider-row label { font-size: 12px; color: #cdd7e6; }
.quiz-slider-val { color: #ffce66; font-weight: 600; }
.quiz-slider { width: 100%; }

/* hold-time bar (tune) */
.quiz-hold-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: #93a0b5; }
.quiz-hold-bar { flex: 1; height: 8px; background: #14283f; border: 1px solid #232c3d; border-radius: 999px; overflow: hidden; }
.quiz-hold-fill { height: 100%; width: 0%; background: linear-gradient(90deg,#5acb6e,#ffce66); transition: width 0.15s linear; }
.quiz-hold-needed { color: #8fc4ff; }

/* missing-item highlight pulse on the apparatus library */
.lib-item.lib-pulse { animation: libPulse 1.1s ease-in-out infinite;
  border-color: #ffce66 !important; }
@keyframes libPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,206,102,0.6); }
  50%     { box-shadow: 0 0 0 6px rgba(255,206,102,0.0); }
}

/* ===== In-place apparatus HUD (settings + delete; rotation is the floor gizmo) ===== */
.apparatus-hud { position: fixed; z-index: 16; pointer-events: none; }
.apparatus-hud[hidden] { display: none; }
.hud-actions { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); display: flex; gap: 6px; pointer-events: auto; }
.hud-actions button { height: 28px; padding: 0 11px; border-radius: 7px; cursor: pointer; font-size: 12.5px; line-height: 1;
  background: rgba(20,24,34,0.96); border: 1px solid #2c3a52; color: #cdd7e6; white-space: nowrap; }
.hud-actions .hud-del { width: 30px; padding: 0; font-size: 16px; }
.hud-actions .hud-toggle { font-weight: 600; }
.hud-actions .hud-toggle.on { background: rgba(80,160,90,0.95); border-color: #6cc878; color: #fff; }
.hud-actions .hud-toggle.off { background: rgba(160,80,80,0.95); border-color: #c87a78; color: #fff; }
.hud-actions .hud-toggle.on:hover { background: rgba(96,180,108,0.98); }
.hud-actions .hud-toggle.off:hover { background: rgba(180,96,96,0.98); }
.hud-actions button:hover { border-color: #44aaff; color: #fff; }
.hud-actions .hud-del:hover { border-color: #a55; color: #ffb6b6; }
/* Settings panel grows UPWARD from the anchor by default so it never covers the
 * apparatus mesh sitting below. JS adds .hud-settings-below when there isn't
 * room above (apparatus too close to the top of the canvas). */
.hud-settings { position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 18px)); width: 216px;
  background: rgba(18,22,32,0.97); border: 1px solid rgba(68,170,255,0.4); border-radius: 10px; padding: 10px 11px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); pointer-events: auto; }
.hud-settings.hud-settings-below { transform: translate(-50%, 18px); }

/* Hover tooltip — follows the cursor and shows the apparatus name. */
.apparatus-tip { position: fixed; z-index: 18; pointer-events: none;
  background: rgba(14,18,26,0.92); color: #eef2f7; font-size: 12px;
  border: 1px solid rgba(68,170,255,0.45); border-radius: 6px;
  padding: 4px 9px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45); transform: translate(12px, 18px); }
.apparatus-tip[hidden] { display: none; }
.hud-settings[hidden] { display: none; }
.hud-settings .prop-title { margin-bottom: 8px; }
.hud-settings .prop-row { margin-bottom: 9px; }
.hud-settings .prop-row:last-child { margin-bottom: 0; }

/* ===== Custom tooltips (replaces native title tooltips) ===== */
.ui-tip {
  position: fixed; z-index: 2147483600; pointer-events: none;
  max-width: 240px; white-space: normal; overflow-wrap: break-word; word-break: break-word;
  background: rgba(20,24,34,0.97); color: #dfe8f5;
  border: 1px solid #2c3c5c; border-radius: 7px; padding: 6px 10px;
  font: 500 11.5px/1.45 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
  letter-spacing: .1px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.ui-tip[hidden] { display: none; }
