/* =========================================================
   지능형 과학실 ON 공통 배치 (크롬북 가로 1366×768 / 세로 768×1366)
   - 상단바: 제목 + 되돌리기·처음부터·저장하고 나가기·설정
   - 메뉴: 학습목표 → 진단하기 → 탐구하기(01·02·03) → 확인하기 → 정리하기
           → 창의적으로 생각하기 → 보고서 양식 다운로드 → 실험 다시하기
   - 가로: 작업영역(약 70%) + 오른쪽 조절 패널 320px, 말풍선은 작업영역 하단
   - 세로: 작업영역 → 말풍선 한 줄 → 아이콘 줄 → 조절 패널(한 번에 하나)
   ========================================================= */
:root {
  --cb-top: 52px;
  --cb-menu: 52px;
  --cb-panel: 320px;
  --cb-touch: 44px;
  --cb-menu-bg: #4f8ef7;
  --cb-menu-bg2: #3f7fe8;
  --cb-accent: #ffe76a;
  --cb-panel-bg: #f6f8fc;
}
html.cb-large { font-size: 112.5%; }
html.cb-large body { font-size: 1.06em; }

/* ---------- 원본 상단·단계 탭·바닥글은 기능만 유지하고 숨김 ---------- */
.hero, .mission-nav, footer { display: none !important; }
.stage-head { display: none; }

/* ---------- 앱 모드(학생 화면) 전체 틀 ---------- */
body.cb-app-on {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--cb-top) var(--cb-menu) minmax(0, 1fr);
  transition: grid-template-rows .22s ease;
}
body:not(.cb-app-on) .cb-topbar,
body:not(.cb-app-on) .cb-menu { display: none; }

/* ---------- 상단바 ---------- */
.cb-topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.cb-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; white-space: nowrap; }
.cb-title b { font-weight: 850; color: var(--ink); }
.cb-title i { font-style: normal; color: #b6c2d3; }
.cb-title #cbStageTitle { overflow: hidden; text-overflow: ellipsis; color: #34465f; font-weight: 650; }
.cb-logo { color: var(--blue); display: grid; place-items: center; }
.cb-mode { margin-left: 6px; padding: 3px 9px; border-radius: 999px; background: #eef4ff; color: var(--blue2); font-size: 12px; font-weight: 800; }
.cb-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.cb-tool {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--cb-touch); min-width: var(--cb-touch);
  padding: 0 10px; border: 0; border-radius: 10px;
  background: transparent; color: #34465f; font-size: 13px; font-weight: 750;
}
.cb-tool:hover:not(:disabled) { background: #eef3fa; }
.cb-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.cb-tool:disabled { opacity: .38; }

/* 설정 팝오버 */
.cb-pop {
  position: absolute; right: 12px; top: calc(var(--cb-top) - 4px); z-index: 40;
  width: 240px; padding: 8px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; box-shadow: 0 14px 34px rgba(18, 46, 86, .16);
}
.cb-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--cb-touch); padding: 0 8px; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; }
.cb-switch:hover { background: #f3f6fb; }
.cb-switch input { position: absolute; opacity: 0; pointer-events: none; }
.cb-switch i { position: relative; width: 40px; height: 22px; border-radius: 999px; background: #cbd5e1; transition: background .2s; flex: none; }
.cb-switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.cb-switch input:checked + i { background: var(--blue); }
.cb-switch input:checked + i::after { transform: translateX(18px); }
.cb-switch input:focus-visible + i { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- 학습 흐름 메뉴 ---------- */
.cb-menu {
  position: relative; z-index: 25;
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px;
  background: var(--cb-menu-bg);
  overflow-x: auto; overflow-y: visible;
  scrollbar-width: none;
  max-height: var(--cb-menu);
  opacity: 1;
  transition: max-height .22s ease, opacity .18s ease, padding .22s ease;
}
.cb-menu-auto-hidden { grid-template-rows: var(--cb-top) 0 minmax(0, 1fr) !important; }
.cb-menu-auto-hidden .cb-menu {
  min-height: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.cb-menu::-webkit-scrollbar { display: none; }
.cb-menu > button, .cb-explore > button {
  position: relative; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1.5px solid rgba(255,255,255,.9); border-radius: 8px;
  background: transparent; color: #fff;
  font-size: 15px; font-weight: 750; white-space: nowrap;
}
.cb-menu > button:hover, .cb-explore > button:hover { background: rgba(255,255,255,.14); }
.cb-explore > button.active { border-color: transparent; color: var(--cb-accent); }
.cb-explore > button svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.cb-step-chip { padding: 1px 7px; border-radius: 6px; background: rgba(255,255,255,.2); font-size: 12px; }
.cb-done { display: none; font-style: normal; width: 18px; height: 18px; border-radius: 50%; background: var(--cb-accent); color: #1e3a8a; font-size: 11px; font-weight: 900; place-items: center; }
.cb-menu button.is-done .cb-done { display: inline-grid; }
.cb-explore { position: static; flex: none; }
.cb-dropdown {
  position: fixed; z-index: 45; min-width: 280px; padding: 6px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
  box-shadow: 0 16px 40px rgba(18,46,86,.18);
}
.cb-dropdown button {
  display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto; column-gap: 10px;
  width: 100%; min-height: 56px; padding: 8px 10px; border: 0; border-radius: 10px;
  background: transparent; text-align: left; color: var(--ink);
}
.cb-dropdown button:hover:not(:disabled), .cb-dropdown button[aria-current="step"] { background: #eef4ff; }
.cb-dropdown button span { grid-row: span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #e8eef7; color: #64748b; font-size: 12px; font-weight: 900; }
.cb-dropdown button[aria-current="step"] span, .cb-dropdown button.complete span { background: var(--blue); color: #fff; }
.cb-dropdown button b { font-size: 14px; }
.cb-dropdown button small { color: var(--muted); font-size: 12px; }
.cb-dropdown button:disabled small::after { content: " · 잠김"; }

/* ---------- 앱 그리드 ---------- */
main.cb-app {
  max-width: none; margin: 0; padding: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--cb-panel);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "work panel" "bubble panel";
}
.cb-work { grid-area: work; min-height: 0; overflow: auto; padding: 16px 20px 20px; scroll-behavior: smooth; }
.cb-bubble { grid-area: bubble; }
.cb-tabs { grid-area: tabs; display: none; }
.cb-panel { grid-area: panel; min-height: 0; overflow: auto; background: var(--cb-panel-bg); border-left: 1px solid var(--line); padding: 12px; }

/* 작업영역 안의 원본 요소 다듬기 */
.cb-work .stage.active { animation: none; }
.cb-work .stage-action { position: static; margin-top: 14px; box-shadow: none; }
.cb-work .principle-lab.observation-only .signal-workbench { display: block; }
.cb-work .graph-card { padding-bottom: 12px; }
.cb-work .experiment-lab { margin-top: 12px; }
.cb-visual-only.experiment-body, .cb-visual-only.mystery-builder { display: block !important; grid-template-columns: none !important; }
.cb-visual-only .mystery-preview { border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: var(--shadow); padding: 14px 16px; }
.cb-work .mission-brief.mystery { margin-bottom: 12px; }
.cb-work .stage-one-analysis-head {
  padding: 8px 2px 12px;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}
.cb-work .stage-one-analysis-head > div > span,
.cb-work .embedded-head > span {
  width: auto;
  min-width: 50px;
  padding: 0 10px;
  background: var(--blue);
  color: #fff;
}
.cb-work .stage-one-analysis-head small { color: var(--blue); font-size: 11px; }
.cb-work .stage-one-analysis-head h2 { color: var(--ink); font-size: 22px; }
.cb-work .stage-one-flow { padding: 0; border: 0; background: transparent; }
.cb-work .stage-one-panel { box-shadow: var(--shadow); }
.cb-work #stageOneOrbitInput { display: none; }
.cb-work .stage-one-hypothesis label { color: #263b58; font-size: 15px; line-height: 1.5; }
.cb-work .stage-one-hypothesis > strong { font-size: 15px; }
.cb-work .conclusion-question > strong { color: #1b3556; font-size: 18px; line-height: 1.55; }
.cb-work .candidate-name-field { color: #1b3556; font-size: 16px !important; }
.cb-work .stage-one-visual.graph-only { padding: 0; background: transparent; }
.cb-work .hypothesis-notebook { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.cb-work .hypothesis-notebook .notebook-title { grid-column: 1 / -1; }
.cb-work .hypothesis-sentences {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cb-work .hypothesis-sentences label {
  padding: 14px 16px;
  border-radius: 12px;
  background: #f3f6fb;
  color: #203754;
  font-size: 17px;
  line-height: 1.65;
}
.cb-work .hypothesis-sentences select, .cb-work .conclusion-sentences select { font-size: 16px; }
.cb-work .hypothesis-sentences .hypothesis-feedback { grid-column: 1 / -1; margin: 0; }
.cb-work #saveHypothesisBtn { grid-column: 1 / -1; justify-self: end; }
.cb-work .conclusion-notebook { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.cb-work .conclusion-notebook > div:first-child { grid-column: 1 / -1; }
.cb-work .conclusion-sentences {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cb-work .conclusion-sentences label {
  padding: 14px 16px;
  border-radius: 12px;
  background: #f3f6fb;
  color: #203754;
  font-size: 16px;
  line-height: 1.6;
}
.cb-work .conclusion-notebook > button { grid-column: 1 / -1; justify-self: end; }
.cb-work .conclusion-notebook > p { grid-column: 1 / -1; }
.mystery-preview-head h3 { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.mystery-preview-head h3 span { color: var(--muted); font-size: 12px; font-weight: 650; }
.mystery-preview canvas, .success-reveal canvas { cursor: grab; touch-action: none; }
.mystery-preview canvas:active, .success-reveal canvas:active { cursor: grabbing; }
.experiment-records-main {
  margin-top: 14px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #f8fbff;
}
.experiment-records-main h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
}
.experiment-records-main h3 small { color: var(--muted); font-size: 11px; }
.mystery-next-action { margin-top: 16px !important; }
.mystery-next-action .submission-feedback { margin: 0; color: var(--muted); text-align: left; }
.success-reveal .mystery-next-action button { margin: 0; }

/* ---------- 디로 말풍선 ---------- */
.cb-bubble {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: 8px 20px 10px;
  background: linear-gradient(transparent, var(--bg) 30%);
}
.cb-bubble > p {
  flex: 1; min-width: 0; margin: 0; padding: 9px 14px;
  border: 1px solid #c9d6ea; border-radius: 14px; background: #fff;
  color: #2d3e57; font-size: 14px; font-weight: 600; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cb-bubble.is-open > p { white-space: normal; }
.cb-avatar { position: relative; flex: none; width: 60px; height: 40px; }
.cb-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cb-avatar img + svg { display: none; }
.cb-avatar svg { width: 40px; height: 40px; fill: #dbeafe; stroke: #2869ff; stroke-width: 1.6; }
.cb-avatar svg circle:not(:first-child) { fill: #1e3a8a; stroke: none; }
.cb-bubble-fold { flex: none; min-height: 36px; padding: 0 12px; border: 1px solid #c9d6ea; border-radius: 10px; background: #fff; color: #34465f; font-size: 13px; font-weight: 750; }
.cb-bubble.cb-flash > p { animation: cbFlash .9s ease; }
@keyframes cbFlash { from { background: #fff7cc; } to { background: #fff; } }
body.cb-bubble-off .cb-bubble { display: none; }

/* ---------- 조절 패널 ---------- */
.cb-pblock { display: flex; flex-direction: column; gap: 10px; }
.cb-sec { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.cb-sec-title { margin: 0 0 10px; font-size: 15px; font-weight: 850; color: var(--ink); }
.cb-help summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 28px; margin: 0; }
.cb-help summary::-webkit-details-marker { display: none; }
.cb-help summary::after { content: "▸"; color: var(--muted); }
.cb-help[open] summary::after { content: "▾"; }
.cb-help ul { margin: 8px 0 0; padding-left: 18px; color: #3b4d66; font-size: 13.5px; line-height: 1.55; }
.cb-help li + li { margin-top: 4px; }

.cb-observe { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cb-observe small { display: block; color: var(--muted); font-size: 12px; }
.cb-observe b { font-size: 15px; }
.cb-observe #toggleObservationBtn { min-height: var(--cb-touch); padding: 0 16px; font-size: 14px; }
.cb-panel .principle-readouts { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 0; }
.cb-panel .principle-readouts div { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 11px; border-radius: 10px; background: #f3f7fd; }
.cb-panel .principle-readouts small { font-size: 12.5px; }
.cb-panel .principle-readouts b { font-size: 15px; }
.cb-panel .spectrum-card { box-shadow: none; border: 0; padding: 0; background: transparent; }
.cb-panel .spectrum-card .panel-head { margin-bottom: 8px; }
.cb-graph-jump button { min-height: var(--cb-touch); }

/* ---------- v41: 도플러 이동과 시선속도 관측점을 같은 관찰 프레임에 배치 ---------- */
.linked-signal-card { display: grid; gap: 9px; }
.linked-signal-card > .panel-head { margin-top: 1px; }
.embedded-spectrum {
  padding: 11px 12px 12px;
  border-radius: 14px;
  background: #f6f9fe;
  border: 1px solid #dfe8f5;
}
.embedded-spectrum .panel-head { margin-bottom: 7px; }
.embedded-spectrum canvas,
.linked-signal-card .embedded-spectrum canvas {
  display: block;
  width: 100%;
  height: 112px;
  border: 0;
  border-radius: 10px;
  background: #071b38;
  cursor: default;
  touch-action: auto;
}
.embedded-spectrum strong {
  padding: 5px 9px;
  border-radius: 999px;
  background: #e9f1ff;
  color: var(--blue);
  font-size: 11px;
}
.signal-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 24px;
  color: #61738b;
  font-size: 11.5px;
  font-weight: 800;
}
.signal-link i { color: #2869ff; font-size: 16px; font-style: normal; }
.linked-signal-card .signal-shape-canvas {
  min-height: 160px;
  cursor: default;
  touch-action: auto;
}
.support-text-hidden { display: none !important; }
.conclusion-question { gap: 5px !important; }
.conclusion-question > span { color: #1b3556; font-weight: 850; }
.conclusion-question > small { color: #5d6f86; font-size: 12px; line-height: 1.5; }
@media (max-width: 680px) {
  .embedded-spectrum canvas,
  .linked-signal-card .embedded-spectrum canvas { height: 96px; }
  .signal-link { min-height: 20px; }
  .linked-signal-card .signal-shape-canvas { min-height: 150px; }
}

.cb-panel .experiment-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border: 0; margin-bottom: 10px; }
.cb-panel .experiment-tabs button { min-height: var(--cb-touch); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.cb-panel .experiment-controls, .cb-panel .mystery-controls { display: block; padding: 0; border: 0; background: transparent; box-shadow: none; }
.cb-panel .experiment-controls > label, .cb-panel .mystery-controls > label { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin: 10px 0; font-size: 14px; font-weight: 700; }
.cb-panel .experiment-controls input[type="range"], .cb-panel .mystery-controls input[type="range"] { grid-column: 1 / -1; width: 100%; height: 28px; }
.cb-panel .experiment-metaphor { margin-bottom: 4px; }
.cb-panel .dependent-readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cb-panel .builder-title { margin-bottom: 2px; }
.cb-panel .builder-title small { color: var(--muted); font-size: 12px; }
.cb-panel .builder-title h3 { margin: 0; font-size: 15px; }
.cb-panel .builder-actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
.cb-panel .builder-actions button { min-height: var(--cb-touch); }
.cb-panel .builder-feedback { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.cb-panel .external-data-bar { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 12px; padding: 12px 0 0; border: 0; border-top: 1px dashed var(--line); border-radius: 0; background: transparent; box-shadow: none; }
.cb-panel .external-data-bar > p { margin: 0; font-size: 12.5px; }
.cb-panel .external-data-bar select, .cb-panel .external-data-bar .file-upload { min-height: var(--cb-touch); }
.cb-panel .cb-external-panel {
  margin-top: 10px;
  border: 2px solid #8fb4ff;
  background: linear-gradient(145deg, #f7faff, #eef4ff);
  box-shadow: 0 8px 20px rgba(40, 105, 255, .10);
}
.cb-panel .cb-external-panel .external-data-bar { margin: 0; padding: 0; border: 0; background: transparent; }
.cb-panel .cb-external-panel .external-data-bar b { color: #1e4ba6; font-size: 14px; }
.cb-panel .mystery-readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 10px; }
.cb-panel .data-table-wrap { margin: 0 0 10px; overflow-x: auto; }
.cb-panel .data-table { font-size: 12.5px; }
.cb-panel .data-table th, .cb-panel .data-table td { padding: 6px 5px; }

.cb-lockable { position: relative; }
.cb-lock-note { display: none; margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: #fff7e0; color: #7a5300; font-size: 13px; font-weight: 700; }
.cb-lockable.is-locked > :not(.cb-lock-note) { opacity: .45; pointer-events: none; }
.cb-lockable.is-locked .cb-lock-note { display: block; }

.cb-mini canvas { border: 1px solid var(--line); border-radius: 10px; background: #fbfdff; }
.cb-mini-cap { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.cb-records { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cb-records li { display: grid; grid-template-columns: 22px 1fr; gap: 2px 8px; padding: 8px 10px; border-radius: 10px; background: #f3f7fd; font-size: 13px; }
.cb-records li > i { grid-row: span 2; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #dfe7f2; color: #8191a8; font-style: normal; font-size: 11px; font-weight: 900; }
.cb-records li.done > i { background: var(--green); color: #fff; }
.cb-records li b { font-size: 13px; }
.cb-records li span { color: #4b5d76; font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 공통 레이어(대화상자) ---------- */
.cb-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(7, 27, 56, .48); }
.cb-dialog { display: flex; flex-direction: column; width: min(760px, 100%); max-height: min(88vh, 860px); border-radius: 18px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.3); overflow: hidden; }
.cb-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--cb-menu-bg); color: #fff; }
.cb-dialog-head h2 { margin: 0; font-size: 18px; }
.cb-x { width: var(--cb-touch); height: var(--cb-touch); border: 0; border-radius: 10px; background: transparent; color: #fff; font-size: 26px; line-height: 1; }
.cb-x:hover { background: rgba(255,255,255,.16); }
.cb-dialog-body { padding: 18px 20px; overflow: auto; font-size: 15px; line-height: 1.6; }
.cb-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.cb-dialog-foot:empty { display: none; }
.cb-dialog-foot button { min-height: var(--cb-touch); }
.cb-dialog-body h3 { margin: 4px 0 8px; font-size: 16px; }
.cb-dialog-body ol, .cb-dialog-body ul { margin: 0; padding-left: 20px; }
.cb-goal-list li + li { margin-top: 6px; }
.cb-flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.cb-flow div { padding: 10px 12px; border-radius: 12px; background: #f3f7fd; font-size: 13.5px; }
.cb-flow b { display: block; color: var(--blue2); }

.cb-q { padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.cb-q + .cb-q { margin-top: 10px; }
.cb-q > p { margin: 0 0 10px; font-weight: 750; }
.cb-q-num { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; border-radius: 7px; background: var(--blue); color: #fff; font-size: 12px; }
.cb-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.cb-opts button { min-height: var(--cb-touch); min-width: 64px; padding: 0 14px; border: 1.5px solid #c8d4e6; border-radius: 10px; background: #fff; font-weight: 750; color: #2d3e57; }
.cb-opts button:hover { border-color: var(--blue); }
.cb-opts button.picked { border-color: var(--blue); background: #eef4ff; color: var(--blue2); }
.cb-opts.ox button { min-width: 84px; font-size: 20px; }
.cb-fb { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.cb-fb.ok { background: #e7f7f0; color: #0b6b4c; }
.cb-fb.retry { background: #fff4e5; color: #8a4b00; }
.cb-fb .cb-link { margin-top: 8px; min-height: 40px; }
.cb-write textarea { width: 100%; min-height: 120px; padding: 10px 12px; border: 1px solid #c8d4e6; border-radius: 12px; resize: vertical; }
.cb-write-tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.cb-keys { display: flex; gap: 6px; flex-wrap: wrap; }
.cb-keys span { padding: 4px 10px; border-radius: 999px; background: #eef2f7; color: #64748b; font-size: 13px; font-weight: 700; }
.cb-keys span.hit { background: #e7f7f0; color: #0b6b4c; }
.cb-keys span.hit::before { content: "✓ "; }
.cb-progress { display: grid; gap: 8px; margin-top: 10px; }
.cb-progress div { display: grid; grid-template-columns: 120px 1fr 54px; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.cb-progress meter { width: 100%; height: 12px; }
.cb-progress span { text-align: right; color: var(--muted); }
.cb-sum { margin: 0; padding-left: 20px; }
.cb-sum li + li { margin-top: 6px; }
.cb-mic { display: inline-flex; align-items: center; gap: 6px; min-height: var(--cb-touch); }
.cb-mic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.cb-mic[aria-pressed="true"] { background: #fde8ec; border-color: #e95b70; color: #b4233b; }
.cb-mic[aria-pressed="true"] svg { animation: cbPulse 1.2s ease-in-out infinite; }
@keyframes cbPulse { 50% { opacity: .35; } }
.cb-voice { margin-top: 8px; }
.cb-voice-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cb-voice-status { color: var(--muted); font-size: 13px; }
.cb-voice-live { margin: 8px 0 0; padding: 8px 12px; border: 1px dashed #9db6e3; border-radius: 10px; background: #f5f8ff; color: #3b5b99; font-size: 14px; }
.cb-write-how { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }

/* ================= 세로 모드 (태블릿 모드 768×1366 등) ================= */
@media (max-aspect-ratio: 1/1) {
  :root { --cb-top: 52px; --cb-menu: 52px; }
  .cb-tool span { display: none; }
  .cb-tool { padding: 0; justify-content: center; }
  .cb-title #cbStageTitle { max-width: 34vw; }
  .cb-mode { display: none; }
  main.cb-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto auto;
    grid-template-areas: "work" "bubble" "tabs" "panel";
  }
  .cb-work { padding: 12px 14px 16px; }
  .cb-bubble { padding: 6px 14px; background: #fff; border-top: 1px solid var(--line); }
  .cb-tabs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    padding: 6px 14px; background: #fff; border-top: 1px solid var(--line);
  }
  .cb-tabs button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--cb-touch); border: 1px solid var(--line); border-radius: 10px;
    background: #fff; color: #34465f; font-size: 14px; font-weight: 800;
  }
  .cb-tabs button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .cb-tabs button[aria-selected="true"] { background: #eef4ff; border-color: var(--blue); color: var(--blue2); }
  .cb-panel { max-height: 40vh; border-left: 0; border-top: 1px solid var(--line); padding: 10px 14px 14px; }
  .cb-pblock .cb-sec { display: none; }
  .cb-pblock .cb-sec.cb-on { display: block; }
  .cb-sec-title { display: none; }
  .cb-help summary { display: none; }
  .cb-help { display: block; }
  .cb-help ul { margin-top: 0; }
  /* 세로 패널은 폭이 넓으므로 2열 배치 */
  .cb-panel .principle-readouts { grid-template-columns: repeat(3, 1fr); }
  .cb-panel .principle-readouts div { display: block; }
  .cb-panel .experiment-controls > label, .cb-panel .mystery-controls > label { margin: 8px 0; }
  .cb-panel .cb-sec[data-sec="control"] .mystery-controls { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .cb-panel .mystery-controls .builder-title, .cb-panel .mystery-controls .builder-actions, .cb-panel .mystery-controls .builder-feedback { grid-column: 1 / -1; }
  .cb-panel .mystery-controls .builder-actions { grid-template-columns: 1fr 1fr; }
  .cb-panel .experiment-controls { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .cb-panel .experiment-metaphor, .cb-panel .dependent-readouts, .cb-panel #collectDataBtn { grid-column: 1 / -1; }
  .cb-flow { grid-template-columns: 1fr; }
  .cb-progress div { grid-template-columns: 100px 1fr 48px; }
}

/* 아주 좁은 화면 보조 */
@media (max-width: 560px) {
  .cb-title > b, .cb-title > i { display: none; }
}

/* ---------- v39 디로 말풍선: 첫 줄 = 지금 할 일, 둘째 줄 = 방금 피드백 ---------- */
.cb-bubble-tag { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; background: #e8f0ff; color: #1f4fd1; font-size: 12.5px; font-weight: 850; vertical-align: 1px; }
.cb-bubble-note { display: block; margin-top: 3px; padding-top: 3px; border-top: 1px dashed #d8e1ee; color: #5b6b82; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-bubble-note::before { content: '방금 · '; color: #8a98ad; font-weight: 750; }
.cb-bubble-note[hidden] { display: none; }
.cb-bubble.is-open .cb-bubble-note { white-space: normal; }

/* ---------- v39 기록 = 탐구 경로 ---------- */
.cb-sec-title small { margin-left: 4px; color: #7a8aa1; font-size: 12px; font-weight: 700; }
.cb-sub-title { margin: 14px 0 6px; font-size: 13px; color: #34465f; }
.cb-records li.cb-step { grid-template-columns: 24px 1fr; gap: 3px 8px; align-items: start; }
.cb-records li.cb-step > i { grid-row: span 4; width: 22px; height: 22px; font-size: 11.5px; }
.cb-records li.is-done > i { background: var(--green); color: #fff; }
.cb-records li.is-now { background: #fff; box-shadow: inset 0 0 0 2px #2869ff; }
.cb-records li.is-now > i { background: #2869ff; color: #fff; }
.cb-records li.is-wait { opacity: .62; }
.cb-step-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cb-step-head b { flex: 1; min-width: 0; }
.cb-chip { flex: none; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-style: normal; font-weight: 800; }
.cb-chip-done { background: #e4f6ec; color: #11834a; }
.cb-chip-now { background: #2869ff; color: #fff; }
.cb-chip-wait { background: #e7ecf3; color: #6b7a90; }
.cb-records li .cb-step-text { grid-column: 2; }
.cb-records li.is-now .cb-step-text { -webkit-line-clamp: 5; color: #24364f; }
.cb-step-note { grid-column: 2; color: #6b7a90; font-size: 12px; }
.cb-redo { grid-column: 2; justify-self: start; min-height: 34px !important; margin-top: 2px; font-size: 12.5px !important; }
.cb-hist { grid-column: 2; font-size: 12.5px; }
.cb-hist summary { cursor: pointer; color: #1f4fd1; font-weight: 750; min-height: 28px; display: flex; align-items: center; }
.cb-hist ol { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.cb-hist ol li { display: block; padding: 6px 8px; border-left: 3px solid #c9d6ea; background: #fff; border-radius: 6px; font-size: 12px; }
.cb-hist ol li small { color: #7a8aa1; font-weight: 700; }
.cb-hist ol li p { margin: 2px 0 0; color: #4b5d76; }
.cb-hist-rows { width: 100%; margin-top: 4px; border-collapse: collapse; font-size: 11.5px; }
.cb-hist-rows th, .cb-hist-rows td { padding: 2px 4px; border-bottom: 1px solid #e6ecf4; text-align: left; }
.cb-undo-body ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; color: #4b5d76; font-size: 14px; }
.cb-topbar .cb-dim { opacity: .5; }

/* ---------- v40 1차 개선: 최초 문제 상황과 보고서 연결 ---------- */
.inquiry-intro-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 25, 52, .66);
  backdrop-filter: blur(5px);
}
.inquiry-intro-modal[hidden] { display: none; }
.inquiry-intro-dialog {
  position: relative;
  width: min(760px, 100%);
  padding: 34px;
  border: 1px solid #d7e3f5;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(8, 30, 66, .28);
}
.inquiry-intro-live {
  margin: 12px 0 4px;
  padding: 12px;
  border: 1px solid #dbe5f2;
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7), 0 8px 24px rgba(24,59,108,.08);
}
.inquiry-intro-live > div { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.inquiry-intro-live small { color: #738399; font-size: 11px; font-weight: 750; }
.inquiry-intro-live strong { color: #1c3150; font-size: 16px; }
.inquiry-intro-live span { margin-left: auto; padding: 3px 8px; border-radius: 7px; background: #e9f0ff; color: #2869ff; font-size: 10px; font-weight: 900; }
.inquiry-intro-live canvas { display: block; width: 100%; height: 190px; border: 1px solid #e0e8f2; border-radius: 12px; background: #fff; }
.periodicity-activity canvas.answer-fixed { cursor: default; }
.inquiry-intro-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #eff4fb;
  color: #50627a;
  font-size: 24px;
}
.inquiry-intro-badge {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eaf1ff;
  color: #1556d6;
  font-size: 13px;
  font-weight: 850;
}
.inquiry-intro-dialog h2 { margin: 18px 0 12px; color: #152943; font-size: clamp(21px, 2.4vw, 28px); line-height: 1.48; }
.inquiry-intro-dialog p { margin: 0 0 24px; color: #53657c; font-size: 16px; line-height: 1.7; }
.report-question {
  display: grid;
  gap: 5px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-left: 4px solid #2869ff;
  border-radius: 12px;
  background: #f1f6ff;
  color: #1c3557;
}
.report-question small { color: #5b75a0; font-size: 12px; font-weight: 800; }
.report-question strong { font-size: 15px; line-height: 1.55; }
.preview-question { margin-top: 16px; }
@media (max-width: 680px) {
  .inquiry-intro-modal { padding: 14px; }
  .inquiry-intro-dialog { padding: 28px 20px 22px; border-radius: 18px; }
  .inquiry-intro-live canvas { height: 160px; }
  .cb-work .hypothesis-sentences, .cb-work .conclusion-sentences { grid-template-columns: 1fr; }
}

/* v51: 좁은 창에서 상단 메뉴 드래그 스크롤 */
.cb-menu.cb-menu-scrollable { cursor: grab; user-select: none; -webkit-user-select: none; }
.cb-menu.cb-menu-scrollable > button, .cb-menu.cb-menu-scrollable .cb-explore > button { cursor: pointer; }
.cb-menu.cb-menu-dragging, .cb-menu.cb-menu-dragging * { cursor: grabbing !important; }
