* { 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; }

/* Tools dropdown */
.tools-wrap { position: relative; }
.tools-menu { position: absolute; right: 0; top: calc(100% + 6px); width: 208px; z-index: 30;
  background: rgba(20,24,34,0.97); border: 1px solid #2c3c5c; border-radius: 9px; padding: 5px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.tools-menu[hidden] { display: none; }
.tool-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  background: none; border: none; color: #cdd7e6; font-size: 12.5px; text-align: left;
  padding: 8px 9px; border-radius: 6px; cursor: pointer; }
.tool-row:hover { background: #1b2940; color: #fff; }
.tool-state { font-size: 11px; font-weight: 600; color: #6b788f; border: 1px solid #38465c;
  border-radius: 999px; padding: 1px 9px; }
.tool-state.on { color: #aaddff; border-color: #44aaff; background: #14304f; }
.tool-sep { height: 1px; background: #28344a; margin: 4px 6px; }
.tool-msg { font-size: 11.5px; color: #8fd0a0; padding: 4px 9px 6px; line-height: 1.4; }
.tool-msg[hidden] { display: none; }

/* ===== 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%; bottom: 44px; 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; }

/* measurements panel (live readouts for the selected item) */
.measure-panel { position: absolute; right: 14px; bottom: 168px; top: auto; z-index: 14; width: 216px;
  background: rgba(18,22,32,0.95); border: 1px solid #2c3c5c; border-radius: 10px; padding: 10px 12px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 12px 36px rgba(0,0,0,0.55); }
.measure-panel[hidden] { display: none; }
.measure-title { font-size: 12.5px; font-weight: 600; color: #aaddff; text-transform: capitalize;
  margin-bottom: 8px; padding-bottom: 7px; border-bottom: 1px solid #243049; }
.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; }

/* wave intensity graph (appears when a slit/aperture forms a pattern) */
.wave-graph { position: absolute; left: 296px; bottom: 16px; z-index: 13;
  background: rgba(15,18,30,0.92); border: 1px solid #2c3c5c; border-radius: 9px; padding: 8px 10px 6px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 8px 24px rgba(0,0,0,0.45); }
.wave-graph[hidden] { display: none; }
.wave-graph-title { font-size: 11px; color: #9fb0c8; margin-bottom: 5px; letter-spacing: 0.3px; }
.wave-graph canvas { display: block; border-radius: 4px; }

/* quick camera-view buttons (sit just above the orientation cube, bottom-right) */
.view-buttons { position: absolute; right: 14px; bottom: 130px; z-index: 13; display: flex; gap: 4px; }
.view-buttons button { background: rgba(18,22,32,0.9); border: 1px solid #2c3c5c; color: #aac4e6;
  font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 6px; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.view-buttons button:hover { background: #14304f; border-color: #44aaff; color: #dcefff; }
.view-buttons button.on { background: #14304f; border-color: #44aaff; color: #dcefff; }

/* ===== 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; }
.exp-panel { left: 296px; width: 300px; }   /* sits to the right of the 270px library panel */
.info-panel { right: 14px; width: 290px; }
.quiz-panel { left: 50%; transform: translateX(-50%); top: auto; bottom: 16px; width: 380px; max-height: calc(100% - 90px); }
.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-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); }
.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; }

/* ===== 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 button:hover { border-color: #44aaff; color: #fff; }
.hud-actions .hud-del:hover { border-color: #a55; color: #ffb6b6; }
.hud-settings { position: absolute; left: 0; top: 24px; transform: translateX(-50%); 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[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; }
