/* SolarSystemExplorer — Cribbed from geo/body explorer for consistency. */

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

/* Flyout widths as CSS vars — layout.js's resize handles rewrite these.
   Rail width feeds narrow-screen floating rules further down. */
:root {
  --rail-w: 76px;
  --flyout-left-w: 268px;
  --flyout-right-w: 340px;
  --flyout-left-info-w: 360px;
}

/* Workspace: a flex row of [ rail | flyout | canvas | flyout ].
   The main canvas comes first in the document so it paints first and is the
   first landmark for assistive tech; CSS `order` places the rails and
   flyouts visually either side. */
#workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  position: relative;
}
#workspace > #canvas-area { order: 3; flex: 1 1 auto; min-width: 0; }

/* ===== Topbar ===== */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: #0b0f1f;
  border-bottom: 1px solid #1c2236;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.app-brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.app-logo { width: 28px; height: 28px; object-fit: contain; }
.app-title { font-size: 15px; font-weight: 600; letter-spacing: 0.2px; }
.hint { font-size: 12px; color: #8e92a8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-sep { width: 1px; height: 22px; background: #2a3148; margin: 0 4px; }
.action-btn {
  background: #161b2e; color: #cfd3e5;
  border: 1px solid #2a3148; border-radius: 5px;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.action-btn:hover { background: #1d2440; }
.action-btn.toggle { color: #8a90a8; }
.action-btn.toggle.on { background: #1d3a5a; color: #e6f0ff; border-color: #3a78b4; }

/* ===== Canvas ===== */
#canvas-area { position: relative; flex: 1 1 auto; min-height: 0; background: #050616; }
#scene-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 14px; color: #8e92a8;
}

.hover-tip {
  position: absolute; pointer-events: none;
  background: rgba(20, 24, 40, 0.92); border: 1px solid #2a3148; color: #e6e8f0;
  padding: 4px 7px; border-radius: 4px; font-size: 12px;
  transform: translate(10px, 10px);
  z-index: 5;
}
.hover-tip .tip-name { font-weight: 600; }
.hover-tip .tip-sub  { color: #8e92a8; font-size: 11px; margin-top: 1px; }

/* ===== Floating panels ===== */
.floating-panel {
  position: absolute; z-index: 4;
  background: rgba(12, 16, 30, 0.94);
  border: 1px solid #2a3148; border-radius: 7px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 80px);
}
/* HTML [hidden] would normally apply display:none, but the class rule above
   wins on specificity — restore the hide behaviour explicitly. */
.floating-panel[hidden] { display: none !important; }
.panel-header {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; background: #131a30;
  border-bottom: 1px solid #2a3148;
  border-radius: 7px 7px 0 0; cursor: grab;
  user-select: none;
}
.panel-header-title { font-size: 12px; font-weight: 600; color: #cfd3e5; }
.panel-header-spacer { flex: 1 1 auto; }
.panel-header-btn {
  background: transparent; border: 0; color: #8e92a8;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 2px 5px;
}
.panel-header-btn:hover { color: #fff; }
.panel-header-search {
  background: #0b0f1f; border: 1px solid #2a3148; color: #cfd3e5;
  border-radius: 4px; padding: 3px 7px; font-size: 11px; width: 110px;
}
.panel-body { padding: 9px 11px; overflow-y: auto; }

/* Default positions */
.overlays-panel { top: 56px; right: 12px; width: 248px; }
.info-panel { top: 56px; left: 12px; width: 440px; max-height: calc(100vh - 160px); }
.library-panel { top: 56px; left: 12px; width: 268px; max-height: calc(100vh - 80px); }
.quiz-panel {
  width: 480px; min-width: 320px; min-height: 240px;
  max-height: calc(100vh - 200px);
  top: auto; bottom: 88px;
  left: calc(50% - 240px); right: auto;
}

/* When the bodies (library) panel is visible, info pops in next to it. */
.info-panel { left: 296px; }

/* When the bodies panel is closed, info expands into the freed space. */
#canvas-area:has(#library-panel[hidden]) .info-panel {
  left: 12px;
  width: 880px;
}

/* ===== Overlay checkboxes ===== */
.panel-sub-title {
  font-size: 10px; color: #6b7090; text-transform: uppercase; letter-spacing: 0.7px;
  margin: 10px 0 4px;
}
.panel-sub-title:first-child { margin-top: 0; }
.ov-check {
  display: flex; align-items: center; gap: 7px; padding: 3px 0;
  font-size: 12px; color: #cfd3e5; cursor: pointer;
}
.ov-check input { margin: 0; }

/* ===== Shared accordion (overlays panel) ===== */
.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(102,187,255,0.12), rgba(102,187,255,0));
  border-left: 2px solid #66bbff; padding-left: 6px;
}
.acc-section.open > .acc-head .acc-ico { color: #cfe6ff; }
.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-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-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; }

/* ===== Library accordion ===== */
.country-library { display: flex; flex-direction: column; gap: 1px; }
.solar-accordion { display: flex; flex-direction: column; gap: 2px; }
.lib-cat-section { display: flex; flex-direction: column; border-bottom: 1px solid #1b2433; }
.lib-cat-section:last-child { border-bottom: none; }
.lib-cat-head {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  background: transparent; border: none;
  color: #c4d0e2;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  text-align: left;
}
.lib-cat-head:hover { color: #fff; }
.lib-cat-section.open > .lib-cat-head {
  color: #eaf4ff;
  background: linear-gradient(90deg, rgba(102,187,255,0.12), rgba(102,187,255,0));
  border-left: 2px solid #66bbff; padding-left: 6px;
}
.lib-cat-section.open > .lib-cat-head .lib-cat-ico { color: #cfe6ff; }
.lib-cat-ico {
  width: 22px; height: 22px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; color: #7fb0e0;
}
.lib-cat-ico svg { width: 19px; height: 19px; display: block; }
.lib-cat-caret {
  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;
}
.lib-cat-section.open .lib-cat-caret { transform: rotate(45deg); border-color: #cfe6ff; }
.lib-cat-name { flex: 1 1 auto; }
.lib-cat-count {
  color: #9fb4d0; font-size: 10px;
  background: #161b2e; border: 1px solid #2a3148;
  padding: 1px 7px; border-radius: 8px;
}
.lib-cat-body { display: flex; flex-direction: column; gap: 1px; padding-left: 4px; }
.lib-cat-body[hidden] { display: none; }
.library-row {
  padding: 5px 8px; border-radius: 5px; border: 1px solid transparent;
  cursor: pointer; transition: background 120ms, border-color 120ms;
}
.library-row:hover { background: rgba(68,170,255,0.07); border-color: rgba(68,170,255,0.25); }
.library-row.selected {
  background: #1f3a5a; border-color: #3a78b4;
  border-left: 3px solid #66bbff;
}
.library-row.selected .library-name { color: #fff; font-weight: 700; }
.library-name { font-size: 12.5px; color: #e6e8f0; }
.library-sub  { font-size: 10.5px; color: #8e92a8; margin-top: 1px; }
.library-moon { padding-left: 18px; }
.lib-moon-wrap { margin-top: 2px; margin-bottom: 4px; }

/* ===== Info card ===== */
.info-empty { color: #8e92a8; font-size: 12px; font-style: italic; }
.info-hero { margin-bottom: 8px; }
.info-hero-title { font-size: 18px; font-weight: 700; color: #fff; }
.info-hero-sub { font-size: 12px; color: #8e92a8; font-style: italic; }
.info-hero-kind {
  display: inline-block; margin-top: 3px;
  font-size: 10px; color: #66bbff; background: rgba(102,187,255,0.10);
  border: 1px solid rgba(102,187,255,0.30);
  padding: 2px 7px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.6px;
}
.info-summary { font-size: 12.5px; color: #cfd3e5; line-height: 1.45; margin: 6px 0 10px; }
.info-grid { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
.info-stat {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 11.5px; padding: 3px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
}
.info-stat-label { color: #8e92a8; }
.info-stat-value { color: #e6e8f0; text-align: right; }
.info-section-title {
  font-size: 11px; color: #6b7090; text-transform: uppercase; letter-spacing: 0.7px;
  margin: 12px 0 5px;
}
.info-facts, .info-missions { margin: 0 0 4px 16px; padding: 0; }
.info-facts li, .info-missions li { font-size: 12px; color: #cfd3e5; margin: 3px 0; line-height: 1.4; }
.info-moons { display: flex; flex-wrap: wrap; gap: 4px; }
.info-moon-chip {
  background: #1a2238; color: #cfe; border: 1px solid #3a4868;
  border-radius: 4px; font-size: 11px; padding: 3px 7px; cursor: pointer;
}
.info-moon-chip:hover { background: #233055; border-color: #4a6088; }

/* Info mini 3D preview */
.info-3d-mount {
  width: 100%; height: 180px;
  background: radial-gradient(ellipse at center, #0a1024 0%, #050616 100%);
  border-radius: 6px; margin-bottom: 10px; overflow: hidden;
  border: 1px solid #1c2236;
}

/* Feature chips list */
.info-features { display: flex; flex-direction: column; gap: 3px; }
.info-feature-chip {
  background: #1a2238; color: #e6e8f0; border: 1px solid #3a4868;
  border-radius: 4px; font-size: 11.5px; padding: 5px 8px; cursor: pointer;
  text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.info-feature-chip:hover { background: #233055; border-color: #4a6088; }
.info-feature-chip-type {
  font-size: 10px; color: #8a90a8;
  background: rgba(120,160,220,0.08); border: 1px solid rgba(120,160,220,0.2);
  padding: 1px 6px; border-radius: 3px; text-transform: lowercase; letter-spacing: 0.3px;
}

/* Selected feature card inside info panel */
.info-feature-card {
  background: rgba(50, 40, 16, 0.18);
  border: 1px solid rgba(255, 200, 100, 0.20);
  border-radius: 6px; padding: 8px 10px; margin: 8px 0 10px;
}
.info-feature-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.info-feature-name { font-size: 14px; font-weight: 600; color: #ffe5a0; }
.info-feature-type {
  font-size: 10px; color: #ffce6a; text-transform: uppercase; letter-spacing: 0.6px;
  background: rgba(255, 200, 100, 0.1); border: 1px solid rgba(255, 200, 100, 0.3);
  padding: 2px 6px; border-radius: 3px;
}
.info-feature-summary { font-size: 12px; color: #cfd3e5; line-height: 1.45; margin: 6px 0 4px; }
.info-feature-image {
  margin: 8px 0 4px;
  border: 1px solid rgba(255, 200, 100, 0.20);
  border-radius: 5px; overflow: hidden;
  background: #050616;
}
.info-feature-image img {
  display: block; width: 100%; height: auto; max-height: 260px; object-fit: cover;
}
.info-feature-caption {
  font-size: 11px; color: #8e92a8; font-style: italic;
  padding: 5px 8px;
  border-top: 1px solid rgba(255, 200, 100, 0.10);
}
.info-feature-details { font-size: 12px; color: #cfd3e5; line-height: 1.45; margin: 6px 0 4px; }
.info-feature-wiki {
  display: inline-block; margin-top: 6px;
  font-size: 11px; color: #66bbff; text-decoration: none;
}
.info-feature-wiki:hover { text-decoration: underline; }
.info-back-btn {
  background: #1a2238; color: #cfd3e5; border: 1px solid #3a4868;
  border-radius: 4px; font-size: 11px; padding: 4px 9px; cursor: pointer;
  margin-top: 6px;
}
.info-back-btn:hover { background: #233055; border-color: #4a6088; }

/* ===== Timebar ===== */
.timebar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: rgba(12, 16, 30, 0.94);
  border: 1px solid #2a3148; border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  padding: 8px 12px;
  z-index: 4;
  max-width: calc(100vw - 32px);
}
.tb-btn {
  background: #161b2e; color: #cfd3e5;
  border: 1px solid #2a3148; border-radius: 5px;
  padding: 4px 10px; font-size: 13px; line-height: 1; cursor: pointer;
  transition: background 120ms, border-color 120ms;
  min-width: 34px;
}
.tb-btn:hover { background: #1d2440; border-color: #3a4868; }
.tb-btn-sm { padding: 3px 8px; font-size: 11px; min-width: 0; }
.tb-group { display: flex; align-items: center; gap: 8px; }
.tb-group-wide { flex: 1 1 auto; min-width: 240px; }
.tb-label { font-size: 11px; color: #8e92a8; text-transform: uppercase; letter-spacing: 0.6px; }
.tb-range { -webkit-appearance: none; appearance: none; height: 4px; background: #2a3148; border-radius: 2px; outline: none; width: 160px; }
.tb-group-wide .tb-range { width: 100%; min-width: 180px; }
.tb-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #66bbff; border: 1px solid #1d3a5a; cursor: pointer;
}
.tb-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #66bbff; border: 1px solid #1d3a5a; cursor: pointer;
}
.tb-readout {
  font-size: 12px; color: #e6e8f0; font-variant-numeric: tabular-nums;
  min-width: 70px; text-align: right;
}

/* Label checkboxes locked while the quiz is open (they'd reveal answers). */
.ov-check.quiz-disabled { opacity: 0.45; cursor: not-allowed; }
.ov-check.quiz-disabled input { cursor: not-allowed; }

/* ===== Quiz ===== */
.quiz-body { display: flex; flex-direction: column; gap: 11px; }

.quiz-home { display: flex; flex-direction: column; gap: 10px; }
.quiz-title { font-size: 16px; font-weight: 600; color: #fff; }
.quiz-sub   { font-size: 12.5px; color: #8e92a8; line-height: 1.45; }

.quiz-mode-list { display: flex; flex-direction: column; gap: 6px; }
.quiz-mode-btn {
  background: #161b2e; border: 1px solid #2a3148; color: #cfd3e5;
  border-radius: 6px; padding: 8px 11px; cursor: pointer;
  text-align: left; display: flex; flex-direction: column; gap: 2px;
}
.quiz-mode-btn:hover { background: #1d2440; border-color: #3a78b4; }
.quiz-mode-name { font-size: 13px; font-weight: 600; color: #e6f0ff; }
.quiz-mode-desc { font-size: 11px; color: #8e92a8; font-weight: 400; }

.quiz-status {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: #8e92a8;
}
.quiz-status strong { color: #cfd3e5; }

.quiz-q {
  background: rgba(10, 14, 30, 0.6);
  border-left: 3px solid #66bbff;
  border-radius: 4px;
  padding: 9px 11px;
  font-size: 13px; color: #fff; line-height: 1.45;
}
.quiz-q em { font-style: italic; color: #aaddff; font-weight: 400; }

.quiz-clues { margin: 0 0 0 18px; padding: 0; font-size: 12px; color: #cfd3e5; }
.quiz-clues li { margin: 2px 0; }

.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quiz-choice {
  background: #1a2238; border: 1px solid #3a4868;
  color: #e6e8f0; border-radius: 6px;
  padding: 8px 10px; font-size: 12.5px;
  cursor: pointer; text-align: left;
}
.quiz-choice:hover  { background: #233055; border-color: #4a6088; }
.quiz-choice.correct { background: #1a3a1c; border-color: #4a8c52; color: #b6f9b6; }
.quiz-choice.wrong   { background: #3a1a1c; border-color: #8c4a52; color: #f9b6b6; }
.quiz-choice:disabled { cursor: default; }

.quiz-find-hint { font-size: 12px; color: #8eb7e0; font-style: italic; }

.quiz-feedback {
  min-height: 18px; font-size: 12px;
  padding: 6px 8px; border-radius: 4px;
  background: transparent; color: #cfd3e5;
}
.quiz-feedback.ok { background: rgba(20, 51, 31, 0.7); color: #b6f9b6; border-left: 3px solid #5aaa5a; }
.quiz-feedback.no { background: rgba(51, 17, 17, 0.7); color: #f9b6b6; border-left: 3px solid #aa5a5a; }

.quiz-controls { display: flex; gap: 8px; justify-content: flex-end; }
.quiz-btn {
  background: #161b2e; border: 1px solid #2a3148;
  color: #cfd3e5; border-radius: 5px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.quiz-btn:hover { background: #1d2440; border-color: #3a78b4; }
.quiz-btn.primary { background: #1d3a5a; border-color: #3a78b4; color: #e6f0ff; }
.quiz-btn.primary:hover { background: #244a72; }

.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: #8e92a8; font-weight: 400; }
.quiz-verdict { font-size: 13px; color: #cfd3e5; font-style: italic; }

/* ===== 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; }

/* ---- read-aloud (TTS) topbar control ---- */
.tts-btn { display: inline-flex; align-items: center; justify-content: center; }
.tts-btn svg { width: 16px; height: 16px; display: block; }
.tts-btn.playing { color: #5ac8d4 !important; border-color: #3a8cb4 !important; }
.tts-btn.playing svg { animation: tts-pulse 1.1s ease-in-out infinite; }
@keyframes tts-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.tts-btn svg { pointer-events: none; }
#btn-autospeak { padding: 5px 9px; line-height: 0; }
#btn-autospeak svg { width: 16px; height: 16px; }
#btn-autospeak.on { background: #1d3a5a; border-color: #3a78b4; color: #bfe3ff; }

/* ===== Share button flash feedback ===== */
.action-btn.flash { border-color: #2aa890; color: #7fe8d3; background: #15463f; }

/* ===== Intro tour (spotlight walkthrough) ===== */
.tour-overlay { position: fixed; inset: 0; z-index: 100000; pointer-events: auto; background: transparent; }
.tour-ring { position: fixed; z-index: 100001; pointer-events: none; border: 2px solid #44aaff; border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(8,10,18,0.62), 0 0 18px rgba(68,170,255,0.55) inset, 0 0 22px rgba(68,170,255,0.45);
  transition: left .2s ease, top .2s ease, width .2s ease, height .2s ease; }
.tour-pop { position: fixed; z-index: 100002; width: 320px; max-width: calc(100vw - 24px);
  background: rgba(20,24,34,0.98); border: 1px solid #2c3c5c; border-radius: 11px; padding: 15px 16px 13px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: #e7eef8; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif; }
.tour-step { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: #6fb0e8; font-weight: 700; margin-bottom: 5px; }
.tour-pop h4 { margin: 0 0 6px; font-size: 15.5px; font-weight: 700; color: #fff; }
.tour-pop p { margin: 0 0 13px; font-size: 12.8px; line-height: 1.5; color: #c4d2e4; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-spacer { flex: 1; }
.tour-btn { background: #1c2a3a; border: 1px solid #2c4a6e; color: #cfe6ff; border-radius: 7px;
  padding: 7px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.tour-btn:hover { background: #244466; border-color: #44aaff; }
.tour-btn.primary { background: #2a5588; border-color: #44aaff; color: #fff; }
.tour-btn.primary:hover { background: #336aa8; }
.tour-skip { background: none; border: none; color: #8593a8; font-size: 12px; cursor: pointer; padding: 7px 4px; }
.tour-skip:hover { color: #cfe6ff; text-decoration: underline; }
#btn-tour { font-weight: 700; padding: 5px 11px; }

/* ===== Tutor Mode (right-docked guided course) ===== */
#btn-tutor.tutor-cta { background: #15463f; border-color: #1f7a6b; color: #7fe8d3; font-weight: 600; }
#btn-tutor.tutor-cta:hover { background: #1b594f; border-color: #2aa890; color: #b8f5e8; }
#btn-tutor.tutor-cta.on { background: #1f7a6b; border-color: #2aa890; color: #eafff9; }

#tutor-panel { position: fixed; top: 44px; right: 0; bottom: 0; width: 384px; max-width: 92vw; z-index: 40;
  display: flex; flex-direction: column; background: rgba(13,17,26,0.97); border-left: 1px solid #243049;
  box-shadow: -14px 0 40px rgba(0,0,0,0.45); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: #e7eef8; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif; }
#tutor-panel[hidden] { display: none !important; }
.tutor-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px; border-bottom: 1px solid #1c2536; }
.tutor-titles { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.tutor-kicker { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #2aa890; font-weight: 700; }
.tutor-h { font-size: 15.5px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tutor-x { background: none; border: 1px solid #2a3a52; color: #aebdd2; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; font-size: 17px; line-height: 1; }
.tutor-x:hover { background: #1a2536; color: #fff; }
.tutor-progress { height: 4px; background: #16202f; }
.tutor-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg,#2aa890,#44aaff); transition: width .3s ease; }
.tutor-scroll { flex: 1; overflow-y: auto; padding: 14px; }

.tutor-intro { font-size: 12.8px; line-height: 1.55; color: #b9c6d8; margin-bottom: 12px; }
.tutor-stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.tutor-stage { display: flex; gap: 10px; align-items: flex-start; background: #141c2a; border: 1px solid #233148; border-radius: 10px; padding: 11px 12px; cursor: pointer; transition: border-color .15s, background .15s, transform .12s; }
.tutor-stage:hover { border-color: #2aa890; background: #16202f; transform: translateY(-1px); }
.tutor-stage.locked { opacity: .5; cursor: not-allowed; }
.tutor-stage.locked:hover { border-color: #233148; background: #141c2a; transform: none; }
.tutor-stage.done { border-color: #1f5a4f; }
.ts-badge { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 3px 7px; border-radius: 999px; white-space: nowrap; align-self: center; }
.ts-badge.beginner { background: #14331f; color: #9be8b0; }
.ts-badge.intermediate { background: #14283f; color: #8fc4ff; }
.ts-badge.advanced { background: #2e1f3f; color: #c9a4ff; }
.ts-main { flex: 1; min-width: 0; }
.ts-title { font-size: 13.5px; font-weight: 700; color: #eef4fb; }
.ts-check { color: #58d6a8; }
.ts-sum { font-size: 11.5px; color: #93a3b8; line-height: 1.4; margin-top: 2px; }
.ts-go { font-size: 11.5px; color: #2aa890; font-weight: 600; align-self: center; white-space: nowrap; }

.tutor-bc { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tutor-link { background: none; border: none; color: #6fb0e8; font-size: 12px; cursor: pointer; padding: 0; }
.tutor-link:hover { color: #9fd0ff; }
.tutor-stepcount { font-size: 11px; color: #7d8ba0; }
.tutor-objs { background: #10212c; border: 1px solid #1d3a44; border-radius: 9px; padding: 10px 12px; margin-bottom: 12px; }
.tutor-objs-t { font-size: 10px; text-transform: uppercase; letter-spacing: .7px; color: #6fb0a0; font-weight: 700; margin-bottom: 5px; }
.tutor-objs ul { margin: 0; padding-left: 18px; }
.tutor-objs li { font-size: 12px; color: #c2d2e2; line-height: 1.5; }

.tutor-card { background: #131b28; border: 1px solid #243149; border-radius: 11px; padding: 14px 15px; }
.tutor-card.task { border-color: #2a4a44; }
.tutor-card.quiz { border-color: #2c4a6e; }
.tutor-tag { display: inline-block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-bottom: 8px; }
.tutor-card.task .tutor-tag { background: #14332c; color: #8fe6cf; }
.tutor-card.quiz .tutor-tag { background: #14283f; color: #8fc4ff; }
.tutor-card h3 { margin: 0 0 8px; font-size: 15px; color: #fff; }
.tutor-prose { font-size: 13px; line-height: 1.6; color: #c8d5e6; }
.tutor-prose p { margin: 0 0 9px; }
.tutor-prose ul, .tutor-prose ol { margin: 0 0 9px; padding-left: 20px; }
.tutor-prose li { margin: 3px 0; }
.tutor-prose strong { color: #eaf2fb; }
.tutor-prose code { background: #0e1420; border: 1px solid #25324a; border-radius: 4px; padding: 1px 5px; font-size: 12px; color: #9fd0ff; }
.tutor-hint { margin-top: 10px; font-size: 12px; color: #c9b98f; background: rgba(60,48,20,.35); border: 1px solid #4a3f22; border-radius: 7px; padding: 7px 10px; }
.tutor-q { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.45; margin-bottom: 11px; }
.tutor-choices { display: flex; flex-direction: column; gap: 7px; }
.tutor-choice { text-align: left; background: #1a1f2e; border: 1px solid #2a3142; color: #e6ecf6; border-radius: 8px; padding: 10px 12px; font-size: 12.8px; cursor: pointer; }
.tutor-choice:hover:not(:disabled) { background: #232a3c; border-color: #44aaff; }
.tutor-choice.correct { background: #14331f; border-color: #4caf6a; color: #b6f9b6; }
.tutor-choice.wrong { background: #311; border-color: #a55; color: #f9b6b6; }
.tutor-checkmsg { min-height: 16px; font-size: 12px; line-height: 1.45; margin-top: 10px; }
.tutor-checkmsg.ok { color: #8fe6b0; }
.tutor-checkmsg.no { color: #f3a6a6; }

.tutor-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.tutor-foot.center { flex-direction: column; }
.tutor-btn { background: #1c2a3a; border: 1px solid #2c4a6e; color: #cfe6ff; border-radius: 8px; padding: 9px 16px; font-size: 12.8px; font-weight: 600; cursor: pointer; }
.tutor-btn:hover { background: #244466; border-color: #44aaff; }
.tutor-btn.primary { background: #1f7a6b; border-color: #2aa890; color: #eafff9; }
.tutor-btn.primary:hover { background: #258a78; }
.tutor-btn.disabled, .tutor-btn:disabled { opacity: .4; cursor: not-allowed; }

.tutor-done { text-align: center; padding: 18px 6px; }
.tutor-done-badge { width: 56px; height: 56px; border-radius: 50%; background: #15463f; border: 2px solid #2aa890; color: #7fe8d3; font-size: 28px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.tutor-done h3 { margin: 0 0 6px; color: #fff; font-size: 18px; }
.tutor-done p { font-size: 13px; color: #c2d2e2; margin: 0 0 16px; }
.tutor-alldone { font-size: 12.5px; color: #9be8c8; background: #122a24; border: 1px solid #1f5a4f; border-radius: 8px; padding: 10px 12px; }

@media (max-width: 720px) { #tutor-panel { width: 100vw; max-width: 100vw; } }

/* ===== Icon rail + flyout (panel-kit) ============================== *
 * Adapted from body-explorer. The rail is always visible; clicking an icon
 * opens ONE full-height flyout on that side, so panels can never tile each
 * other into slivers, and the canvas takes what is left. */

.icon-rail {
  flex: 0 0 auto;
  width: var(--rail-w, 76px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  background: rgba(8, 10, 20, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 6;
}
#rail-left  { order: 1; border-right: 1px solid rgba(255,255,255,0.07); }

.rail-sep {
  width: 44px; height: 1px;
  margin: 6px 0;
  background: rgba(255,255,255,0.10);
  flex: 0 0 auto;
}

/* Rail buttons — the same elements that used to sit in the topbar, restacked
   as icon-over-label so `title` still carries the longer tooltip. */
.rail-btn {
  width: 64px;
  height: auto;
  flex-direction: column;
  gap: 4px;
  padding: 7px 2px 6px;
  justify-content: center;
  position: relative;
  white-space: normal;
  display: flex;
  align-items: center;
}
.rail-btn .btn-label {
  display: block;
  font-size: 10.5px;
  line-height: 1.1;
  letter-spacing: 0.1px;
}
.rail-btn .btn-ico { width: 20px; height: 20px; }
.rail-btn.on::after {
  content: '';
  position: absolute;
  top: 5px; bottom: 5px;
  right: -7px;
  width: 2px;
  border-radius: 2px;
  background: #66bbff;
}

/* ---- flyouts ---- */
.flyout {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: rgba(8, 10, 20, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
#flyout-left  { order: 2; width: var(--flyout-left-w, 268px);  padding: 10px 10px 10px 8px; }
#flyout-right { order: 4; width: var(--flyout-right-w, 340px); padding: 10px 8px 10px 10px; }

/* Info card is prose + a mini 3D preview where the other left-hand panels
   are short lists, so it earns a wider column. layout.js sets data-open. */
#flyout-left[data-open="info-panel"] { width: var(--flyout-left-info-w, 360px); }

/* A flyout with nothing open takes no space — closing a panel hands its
   width straight back to the canvas. */
#flyout-left[data-empty="true"],
#flyout-right[data-empty="true"] {
  width: 0;
  padding: 0;
  overflow: hidden;
}

/* Drag the inner edge to resize. */
.rail-resize {
  position: absolute;
  top: 0; bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 5;
  background: transparent;
  transition: background 120ms;
}
.rail-resize:hover, .rail-resize.dragging { background: rgba(102,187,255,0.35); }
[data-rail-resize="left"]  { right: 0; }
[data-rail-resize="right"] { left: 0; }
.flyout[data-empty="true"] .rail-resize { display: none; }

/* Panels, docked. Overrides .floating-panel absolute positioning inside a
   flyout — only one panel per flyout so each simply fills it. The
   .floating-panel block above stays intact for anything genuinely floating
   (nothing currently is, but the mixin is left in place). */
.flyout > .floating-panel {
  position: static;
  width: 100%;
  max-width: none;
  height: auto;
  max-height: none;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  resize: none;
  box-shadow: none;
  background: rgba(18, 18, 28, 0.72);
  top: auto; left: auto; right: auto; bottom: auto;
}
.flyout > .floating-panel .panel-header { cursor: default; }

/* The old .info-panel :has() rule (widening when Bodies is closed) is
   irrelevant inside a flyout — data-open drives width now — so it becomes a
   no-op here. */
.flyout > .info-panel { left: auto !important; width: 100% !important; }

/* Tutor mode docks into the right flyout. It used to be a fixed drawer
   attached to <body>; now it sits inside the flyout like everything else. */
#flyout-right > #tutor-panel {
  position: static;
  top: auto; right: auto; bottom: auto;
  width: 100%; max-width: none; height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: none;
  background: rgba(13,17,26,0.92);
}

/* ---- first-run hint over the canvas ---- */
.canvas-hint {
  position: absolute;
  right: 16px; bottom: 74px;             /* clear the timebar */
  z-index: 7;
  display: flex; align-items: center; gap: 10px;
  max-width: min(340px, calc(100% - 32px));
  padding: 8px 10px 8px 14px;
  font-size: 12.5px; line-height: 1.45; color: #cdd6e6;
  background: rgba(12, 16, 28, 0.82);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 26px rgba(0,0,0,0.45);
  animation: hint-in 320ms ease both;
}
.canvas-hint[hidden] { display: none; }
.canvas-hint-text { min-width: 0; }
.canvas-hint-x {
  flex: 0 0 auto;
  background: transparent; border: none; color: #8e9bb0;
  font-size: 17px; line-height: 1; width: 22px; height: 22px;
  border-radius: 50%; cursor: pointer;
}
.canvas-hint-x:hover { background: rgba(255,255,255,0.10); color: #fff; }
@keyframes hint-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .canvas-hint { animation: none; } }

/* Narrow-screen fallback: flyouts stop being layout and float over the
   canvas. Only one may be open anywhere (layout.js enforces that when
   workspace[data-floating="true"]). Rails stay put so everything is one tap
   away. */
@media (max-width: 1200px) {
  #flyout-left  { width: var(--flyout-left-w, 244px); }
  #flyout-right { width: var(--flyout-right-w, 300px); }
  #flyout-left[data-open="info-panel"] { width: var(--flyout-left-info-w, 320px); }
}
@media (max-width: 900px) {
  #flyout-left  { width: var(--flyout-left-w, 228px); }
  #flyout-right { width: var(--flyout-right-w, 280px); }
  #flyout-left[data-open="info-panel"] { width: var(--flyout-left-info-w, 296px); }

  #workspace[data-floating="true"] .flyout {
    position: absolute;
    top: 0; bottom: 0;
    z-index: 12;
    width: min(320px, 84vw);
    box-shadow: 0 18px 50px rgba(0,0,0,0.6);
  }
  #workspace[data-floating="true"] #flyout-left  { left: var(--rail-w, 76px); }
  #workspace[data-floating="true"] #flyout-right { right: 0; }
  /* Empty flyouts still collapse so the canvas isn't sitting under a strip. */
  #workspace[data-floating="true"] .flyout[data-empty="true"] { display: none; }
}
