:root {
  --bg: #0f1115;
  --panel-bg: #171921;
  --input-bg: #1e212b;
  --border: #2a2d36;
  --text: #e8e8ec;
  --text-muted: #a8abb8;
  --text-dim: #6b7280;
  --text-dimmer: #565a68;
  --pacer-text: #c4c6d0;
  --accent: #4f6df5;
  --accent-contrast: #ffffff;
  --danger: #ff5c5c;
  --success: #6bcf8f;
  --success-bg: #14201a;
  --success-bg-strong: #1c3a2a;
  --success-border: #2f6b46;
  --error-text: #ff8f8f;
  --error-bg: #2a1414;
  --error-bg-strong: #3a1c1c;
  --error-border: #6b2f2f;
  --banner-bg: #1a2440;
  --banner-text: #c8d0f5;
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --paper-bg: #26211b;
  --paper-text: #ddd2b8;
}

:root[data-theme="light"] {
  --bg: #f4f5f8;
  --panel-bg: #ffffff;
  --input-bg: #eef0f4;
  --border: #dde1e8;
  --text: #1a1d24;
  --text-muted: #5b6270;
  --text-dim: #7a8194;
  --text-dimmer: #b0b5bf;
  --pacer-text: #3a3f4a;
  --accent: #4f6df5;
  --accent-contrast: #ffffff;
  --danger: #d8433d;
  --success: #1f8a4c;
  --success-bg: #e6f7ec;
  --success-bg-strong: #d3f0dd;
  --success-border: #34a35e;
  --error-text: #c23b3b;
  --error-bg: #fbe9e9;
  --error-bg-strong: #f6d4d4;
  --error-border: #d97a7a;
  --banner-bg: #e8ecfc;
  --banner-text: #33408a;
  --overlay-bg: rgba(20, 22, 30, 0.5);
  --paper-bg: #f8f1e0;
  --paper-text: #2b2416;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard", "Malgun Gothic", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.15s ease, color 0.15s ease;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  transition: max-width 0.2s ease;
}

.app.wide-mode {
  max-width: 1100px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.header-top h1 {
  font-size: 22px;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.account-label {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.auth-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
}

.auth-brand {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.auth-card h3 {
  margin: 0 0 16px;
  text-align: center;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: -4px 0 8px;
}

.auth-field {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  box-sizing: border-box;
}

.auth-error {
  color: var(--error-text);
  font-size: 13px;
  margin: 4px 0 10px;
  min-height: 16px;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
}

.auth-toggle a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.auth-recover {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
}
.auth-recover a {
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}
.auth-hint-sm { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.auth-ok { color: var(--success); font-size: 13px; margin: 6px 0; }
.reset-done { font-size: 15px; text-align: center; margin: 10px 0 18px; line-height: 1.6; }
.reset-home { text-align: center; text-decoration: none; padding: 10px; border-radius: 8px; display: block; }

.auth-guest {
  text-align: center;
  margin-top: 10px;
}

.auth-guest a {
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}

.main-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.main-tab {
  flex: 1;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
}

.main-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px 14px;
  margin: 4px 0 20px;
}

/* 라벨과 그 그룹의 탭들이 한 덩어리로 줄바꿈되도록 묶는다 */
.mode-group-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  flex: 0 1 auto;
}

/* 모드 앞에 붙는 목적 라벨 — 측정 → 읽기 훈련 → 시각 보조 순서를 드러낸다 */
.mode-group {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-left: 8px;
  border-left: 2px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  white-space: nowrap;
}

.mode-group-wrap:first-child .mode-group {
  border-left: none;
  padding-left: 0;
}

/* flex:1(=basis 0)이면 8개 탭이 내용 너비를 무시하고 균등 분할돼
   글자가 세로로 쪼개진다. 내용 너비를 지키고 모자라면 다음 줄로 넘긴다. */
.mode-tabs .tab {
  flex: 0 1 auto;
  white-space: nowrap;
}

.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.input-panel textarea {
  width: 100%;
  height: 110px;
  resize: vertical;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.file-btn {
  background: var(--input-bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.library-select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.settings-row {
  margin-bottom: 16px;
}

.settings-row > label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.settings-choices {
  display: flex;
  gap: 8px;
}

.settings-choice {
  flex: 1;
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.settings-choice.active {
  border-color: var(--accent);
  background: var(--banner-bg);
  color: var(--banner-text);
}

.settings-preview {
  font-size: 20px;
  line-height: 2;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  text-align: center;
}

.settings-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.controls {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.control-row label {
  width: 110px;
  font-size: 13px;
  color: var(--text-muted);
}

.control-row input[type="range"] {
  flex: 1;
}

.control-row span {
  width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.checkbox-row input[type="checkbox"] {
  margin-right: 4px;
}

.program-stage-label {
  margin-left: auto;
  color: var(--accent);
  font-weight: 600;
}

.fs-controls {
  display: none;
  gap: 8px;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
}

:fullscreen .fs-controls {
  display: flex;
}

#exitFullscreenBtn {
  display: none;
}

:fullscreen .fs-controls #exitFullscreenBtn {
  display: inline-block;
}

button {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  flex: 1;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  text-decoration: underline;
  font-size: 12px;
  padding: 4px 0;
}

.display-area {
  margin-bottom: 20px;
}

.progress-bar {
  height: 4px;
  background: var(--input-bg);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s linear;
}

.rsvp-box {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ---- 시폭 확대 훈련 ---- */
.widen-box {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
}
.widen-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 120px;
  width: 100%;
}
.widen-word {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  min-width: 1px;
}
.widen-fix { color: var(--accent); font-size: 28px; font-weight: 700; }
.widen-hint { font-size: 13px; color: var(--text-dim); text-align: center; padding: 0 16px; }

/* ---- 순간 노출(태키스토스코프) 훈련 ---- */
.flash-box {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
}
.flash-stage {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text);
  min-height: 60px;
  display: flex;
  align-items: center;
  text-align: center;
}
.flash-stage.msg { font-size: 15px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; padding: 0 20px; }
.flash-answer { display: flex; gap: 8px; }
.flash-input {
  padding: 10px 14px;
  font-size: 20px;
  letter-spacing: 0.1em;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  width: 200px;
}
.flash-score { font-size: 14px; color: var(--text-muted); min-height: 20px; }
.flash-score .ok { color: var(--success); }
.flash-score .no { color: var(--error-text); }

/* ---- 세션 결과 토스트 (훈련 전/후 비교) ---- */
.sr-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 3000;
  max-width: 90vw;
  text-align: center;
}
.sr-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sr-toast.neg { background: #b4794a; }

.orp-guide {
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.rsvp-word {
  font-size: 42px;
  font-weight: 600;
  margin: 8px 0;
  white-space: pre;
  letter-spacing: 0.5px;
}

.rsvp-word .pivot {
  color: var(--danger);
}

.guide-box {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 300px;
  overflow-y: auto;
  padding: 20px;
}

.guide-text {
  font-size: 22px;
  line-height: 2;
}

.guide-text .word {
  padding: 2px 1px;
  border-radius: 3px;
}

.guide-text .word.read {
  color: var(--text-dimmer);
}

/* ---- 문단 훈련 ---- */
.para-box {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 340px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.para-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.para-body {
  flex: 1;
  overflow-y: auto;
  font-size: 21px;
  line-height: 1.9;
  color: var(--text);
}

.para-hint {
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.para-bars {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.para-bar-row {
  display: grid;
  grid-template-columns: 24px 1fr 74px;
  grid-template-areas: 'label track val' '. sub sub';
  align-items: center;
  gap: 4px 10px;
  font-size: 13px;
}

.para-bar-label { grid-area: label; color: var(--text-dim); text-align: right; }
.para-bar-track {
  grid-area: track;
  height: 12px;
  background: var(--input-bg);
  border-radius: 6px;
  overflow: hidden;
}
.para-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.para-bar-val { grid-area: val; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.para-bar-sub { grid-area: sub; font-size: 11px; color: var(--text-dim); }

.para-bar-row.slow .para-bar-fill { background: var(--danger); }
.para-bar-row.slow .para-bar-val { color: var(--danger); font-weight: 700; }
.para-bar-row.fast .para-bar-fill { background: var(--success); }
.para-bar-row.fast .para-bar-val { color: var(--success); font-weight: 700; }

.para-verdict {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
}

.pacer-box {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 340px;
  overflow-y: auto;
  padding: 20px;
}

.pacer-inner {
  position: relative;
}

.pacer-text {
  font-size: 20px;
  line-height: 2.2;
  color: var(--pacer-text);
}

.pacer-text .word {
  padding: 1px 1px;
}

.pacer-text .word.current {
  font-weight: 700;
}

.pacer-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px 2px rgba(255, 92, 92, 0.5);
  transform: translate(-50%, 0);
  transition: left 0.15s linear, top 0.15s linear;
  opacity: 0;
  pointer-events: none;
}

.book-box {
  position: relative;
  background: #3a2c1e;
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 440px;
  overflow: hidden;
  padding: 14px;
  box-sizing: border-box;
  box-shadow: inset 0 0 44px rgba(0, 0, 0, 0.4);
}

.book3d {
  position: relative;
  width: 100%;
  height: calc(100% - 30px);
  perspective: 2400px;
}

.book-text {
  font-size: 19px;
  line-height: 1.95;
  font-family: "Noto Serif KR", "Nanum Myeongjo", Georgia, serif;
  color: var(--paper-text);
  text-align: justify;
}

.book-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  box-sizing: border-box;
  padding: 26px 30px;
  overflow: hidden;
  background: var(--paper-bg);
  transition: box-shadow 0.18s ease;
}

.book-leaf-left {
  left: 0;
  border-radius: 4px 0 0 4px;
  box-shadow: inset -18px 0 24px -18px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.book-leaf-right {
  right: 0;
  border-radius: 0 4px 4px 0;
  box-shadow: inset 18px 0 24px -18px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.book-leaf-left:hover {
  box-shadow: inset -18px 0 24px -18px rgba(0, 0, 0, 0.4), inset 34px -34px 34px -34px rgba(0, 0, 0, 0.22);
}

.book-leaf-right:hover {
  box-shadow: inset 18px 0 24px -18px rgba(0, 0, 0, 0.4), inset -34px -34px 34px -34px rgba(0, 0, 0, 0.22);
}

.book-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-1.5px);
  background: linear-gradient(to right, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.3));
  z-index: 15;
  pointer-events: none;
}

/* ---- 넘어가는 장 (turn.js식 3D 페이지 넘김) ---- */
.turn-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  z-index: 20;
  display: none;
  will-change: transform;
}

.turn-sheet.turning {
  display: block;
}

.turn-face {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 26px 30px;
  overflow: hidden;
  backface-visibility: hidden;
  background: var(--paper-bg);
}

.turn-back {
  transform: rotateY(180deg);
}

.turn-gloss {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}

.turn-sheet.turn-forward {
  animation: turnFwd var(--flip-ms, 700ms) cubic-bezier(0.5, 0.02, 0.4, 1) forwards;
}

.turn-sheet.turn-backward {
  animation: turnBwd var(--flip-ms, 700ms) cubic-bezier(0.5, 0.02, 0.4, 1) forwards;
}

@keyframes turnFwd {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(-180deg); }
}

@keyframes turnBwd {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(180deg); }
}

.turn-sheet.turn-forward .turn-gloss {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 48%);
  animation: glossPulse var(--flip-ms, 700ms) ease-in-out;
}

.turn-sheet.turn-backward .turn-gloss {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 48%);
  animation: glossPulse var(--flip-ms, 700ms) ease-in-out;
}

@keyframes glossPulse {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

.book-text .word {
  padding: 1px 2px;
  border-radius: 3px;
  transition: background 0.1s ease, color 0.1s ease;
}

.book-text .word.read {
  opacity: 0.45;
}

/* ---- 읽기 강조 스타일 (배경/테두리/밑줄) ---- */
:root {
  --hl-color: #4f6df5;
}

:root[data-hl="background"] .word.active,
:root[data-hl="background"] .word.current {
  background: var(--hl-color);
  color: #fff;
  border-radius: 3px;
}

:root[data-hl="outline"] .word.active,
:root[data-hl="outline"] .word.current {
  box-shadow: inset 0 0 0 2px var(--hl-color);
  border-radius: 3px;
}

:root[data-hl="underline"] .word.active,
:root[data-hl="underline"] .word.current {
  box-shadow: inset 0 -3px 0 0 var(--hl-color);
}

.book-nav {
  position: absolute;
  bottom: 10px;
  left: 24px;
  right: 24px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #e8dcc8;
}

.book-nav button {
  padding: 6px 12px;
  font-size: 13px;
}

.pattern-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pattern-btn {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-muted);
}

.pattern-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.eye-box {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  height: 440px;
  overflow: hidden;
}

.rsvp-box:fullscreen,
.guide-box:fullscreen,
.pacer-box:fullscreen,
.eye-box:fullscreen,
.schulte-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 40px;
}

/* ---- 책 전체화면: 실제 책처럼 중앙 배치 + 넉넉한 여백 ---- */
/* flex 중앙정렬은 일부 환경에서 불안정하므로 절대위치+transform으로 확실히 중앙에 둔다 */
.book-box:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 0;
  background: #241a10;
}

.book-box:fullscreen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 0;
  background: #241a10;
}

.book-box:-webkit-full-screen .book3d,
.book-box:fullscreen .book3d {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1120px, 92vw);
  height: min(82vh, 800px);
  perspective: 3200px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}

.book-box:-webkit-full-screen .book-leaf,
.book-box:-webkit-full-screen .turn-face,
.book-box:fullscreen .book-leaf,
.book-box:fullscreen .turn-face {
  padding: 56px 62px;
}

.book-box:-webkit-full-screen .book-text,
.book-box:fullscreen .book-text {
  font-size: 22px;
  line-height: 2.15;
}

.book-box:-webkit-full-screen .book-nav,
.book-box:fullscreen .book-nav {
  top: 18px;
  bottom: auto;
  left: 50%;
  right: auto;
  width: auto;
  transform: translateX(-50%);
  justify-content: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 16px;
  border-radius: 20px;
  z-index: 40;
}

.eye-box:fullscreen .eye-dot {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
}

.eye-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--accent);
  border-radius: 50%;
  width: 0;
  height: 0;
  display: none;
  pointer-events: none;
}

/* 시선을 고정하는 표적이라 경계가 선명해야 한다 — 글로우(box-shadow)를 쓰면 번져 보여 눈이 피로해진다 */
.eye-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--accent);
  left: 30px;
  top: 140px;
}

.eye-time {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.schulte-box {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.schulte-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 400px;
  margin: 0 auto 14px;
}

.schulte-cell {
  aspect-ratio: 1;
  font-size: 18px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}

.schulte-cell.done {
  background: var(--success-bg-strong);
  border-color: var(--success-border);
  color: var(--success);
}

.schulte-cell.wrong {
  background: var(--error-bg-strong);
  border-color: var(--error-border);
}

.schulte-result {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.age-group-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.diagnostic-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--banner-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--banner-text);
}

.diagnostic-bar button {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  flex-shrink: 0;
}

.diag-passage {
  font-size: 18px;
  line-height: 1.9;
  margin: 12px 0 18px;
  max-height: 40vh;
  overflow-y: auto;
}

.diag-timer {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.diag-guide {
  margin: 8px 0 18px;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
}

.diag-guide b {
  color: var(--text);
}

.diag-countdown {
  text-align: center;
  font-size: 72px;
  font-weight: 700;
  color: var(--accent);
  margin: 20px 0 8px;
  font-variant-numeric: tabular-nums;
}

.age-group-btn {
  flex: 1;
  padding: 8px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text-muted);
  cursor: pointer;
}

.age-group-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.level-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 30px 10px;
  grid-column: 1 / -1;
}

.level-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
}

.level-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-card.unlocked {
  border-color: var(--accent);
}

.level-card.completed {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.level-card.pro-locked {
  border-color: #c79a3a;
  background: linear-gradient(160deg, var(--panel-bg), rgba(199, 154, 58, 0.12));
  cursor: pointer;
  opacity: 1;
}

.level-pro {
  font-size: 10px;
  color: #d4a94a;
  font-weight: 700;
  margin-top: 2px;
}

.plan-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}

.plan-badge.free {
  background: var(--input-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.plan-badge.pro {
  background: linear-gradient(120deg, #c79a3a, #e0c060);
  color: #2b2416;
}

.upgrade-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #c79a3a;
  background: linear-gradient(120deg, #c79a3a, #e0c060);
  color: #2b2416;
  font-weight: 700;
  cursor: pointer;
}

.upgrade-benefits {
  list-style: none;
  padding: 0;
  margin: 12px 0 18px;
  font-size: 14px;
  line-height: 2;
}

.upgrade-benefits li::before {
  content: '✓ ';
  color: var(--success);
  font-weight: 700;
}

.upgrade-price {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0 4px;
}

.upgrade-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.checkout-card { max-width: 380px; }

.checkout-summary {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 4px 0 16px;
}

.checkout-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  padding: 3px 0;
}

.checkout-row.checkout-total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.checkout-fields { margin-bottom: 4px; }

.checkout-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkout-note {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin: 8px 0 14px;
}

.site-footer {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.footer-about h2 {
  font-size: 16px;
  margin: 0 0 10px;
  color: var(--text);
}

.footer-about p {
  font-size: 13px;
  line-height: 1.7;
  margin: 0 0 10px;
}

.footer-about h3 {
  font-size: 14px;
  margin: 20px 0 8px;
  color: var(--text);
}

.seo-list {
  margin: 0 0 6px;
  padding-left: 18px;
}
.seo-list li {
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 6px;
}

.seo-faq .faq-q {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 2px;
}
.seo-faq .faq-a {
  font-size: 13px;
  line-height: 1.7;
  margin: 0;
}

.footer-links {
  font-size: 12px;
  margin-top: 14px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: underline;
}

.footer-links span { margin: 0 6px; color: var(--text-dim); }

.footer-copy {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}

.policy-page {
  max-width: 720px;
  padding: 32px 20px 60px;
}

.policy-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 24px;
}

.policy-back {
  display: inline-block;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: underline;
  margin-bottom: 14px;
}

.policy-header h1 {
  font-size: 24px;
  margin: 0 0 6px;
}

.policy-updated {
  font-size: 12px;
  color: var(--text-dim);
}

.policy-body h2 {
  font-size: 16px;
  margin: 28px 0 10px;
}

.policy-body p, .policy-body li {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
}

.policy-body ul {
  margin: 6px 0 14px;
  padding-left: 20px;
}

.policy-body a { color: var(--accent); }

.policy-footnote {
  margin-top: 32px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---- 가이드 문서 (/guide/) ---- */
.guide-page { max-width: 760px; padding: 32px 20px 72px; }

.guide-lead {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  margin: 0 0 8px;
}

.guide-body h2 {
  font-size: 19px;
  margin: 36px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.guide-body h3 { font-size: 15px; margin: 22px 0 8px; }

.guide-body p, .guide-body li {
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-muted);
}

.guide-body ul, .guide-body ol { margin: 8px 0 16px; padding-left: 22px; }
.guide-body li { margin-bottom: 6px; }
.guide-body a { color: var(--accent); }
.guide-body strong { color: var(--text); }

.guide-table-wrap { overflow-x: auto; margin: 14px 0 20px; }
.guide-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 420px; }
.guide-table th, .guide-table td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  color: var(--text-muted);
}
.guide-table th { background: var(--input-bg); color: var(--text); font-weight: 700; }

.guide-note {
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--input-bg);
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
}

/* 선택자 앞의 a는 빼면 안 된다. 위의 `.guide-body a` 가 더 구체적이라
   클래스만으로 쓰면 글자색이 --accent로 덮여 파란 배경에 파란 글씨가 된다. */
a.guide-cta {
  display: inline-block;
  margin: 8px 0 4px;
  padding: 11px 18px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.guide-related { margin-top: 44px; border-top: 1px solid var(--border); padding-top: 20px; }
.guide-related h2 { border: none; font-size: 15px; margin: 0 0 10px; padding: 0; }
.guide-related ul { list-style: none; padding: 0; margin: 0; }
.guide-related li { margin-bottom: 8px; }

.guide-index-list { list-style: none; padding: 0; margin: 20px 0 0; }
.guide-index-list li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--panel-bg);
}
.guide-index-list a { font-size: 16px; font-weight: 700; color: var(--text); text-decoration: none; }
.guide-index-list p { margin: 6px 0 0; font-size: 14px; line-height: 1.75; color: var(--text-muted); }

.ad-rail {
  display: none;
  position: fixed;
  top: 0;
  width: 160px;
  height: 100vh;
  /* 비어 있는 장식용 자리다. 이게 없으면 넓은 화면에서 좌우 160px의 클릭을 전부 삼킨다 */
  pointer-events: none;
}

.ad-rail-left { left: 0; }
.ad-rail-right { right: 0; }

@media (min-width: 1400px) {
  .ad-rail { display: block; }
}

.announce-banner {
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  text-align: center;
}

.maintenance-card {
  max-width: 420px;
  margin: 80px auto;
  text-align: center;
  padding: 32px 24px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.maintenance-card h2 { margin: 0 0 12px; }
.maintenance-card p { color: var(--text-muted); line-height: 1.7; }

.guide-card h2 { margin: 0 0 14px; font-size: 18px; }
.guide-card h3 { margin: 22px 0 8px; font-size: 15px; }
.guide-card p, .guide-card li { font-size: 13px; line-height: 1.75; color: var(--text-muted); }
.guide-card ul { margin: 4px 0 10px; padding-left: 20px; }
.guide-card code {
  background: var(--input-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---- 관리자 통계 대시보드 ---- */
.stats-h {
  font-size: 15px;
  margin: 22px 0 10px;
  color: var(--text-muted);
}
.stats-h:first-child { margin-top: 4px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.stat-tile {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile-val { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-tile-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-tile-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.daychart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 150px;
  padding: 10px 4px 0;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.daybar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}
.daybar-fill {
  width: 60%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
}
.daybar-cnt { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; height: 12px; }
.daybar-lbl { font-size: 9px; color: var(--text-dim); margin-top: 4px; transform: rotate(-45deg); white-space: nowrap; }

.mode-chart {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.mode-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.mode-name { width: 90px; font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.mode-track { flex: 1; height: 14px; background: var(--input-bg); border-radius: 7px; overflow: hidden; }
.mode-fill { height: 100%; background: var(--accent); border-radius: 7px; }
.mode-cnt { width: 40px; text-align: right; font-size: 13px; color: var(--text); flex-shrink: 0; }
.stat-empty { color: var(--text-dim); font-size: 13px; padding: 8px 0; }

.level-icon { font-size: 22px; }
.level-num { font-weight: 700; font-size: 15px; }
.level-stage { font-size: 11px; color: var(--text-muted); }
.level-target { font-size: 12px; color: var(--text-dim); }
.level-score { font-size: 11px; color: var(--success); }

.level-banner {
  align-items: center;
  justify-content: space-between;
  background: var(--banner-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--banner-text);
}

.level-banner button {
  background: none;
  border: 1px solid var(--accent);
  color: var(--banner-text);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
}

/* ---- 코스 무대(큰 화면) ----
   단계마다 브라우저 전체화면을 다시 요청하면 막히므로, 표시 영역(#displayArea)에 .stage를
   걸어 화면 전체를 덮는 CSS 무대를 만들고 그 안에서 단계별 화면만 교체한다. 브라우저
   전체화면은 그 위에 얹는 보너스라서, 전체화면이 거부되는 환경(임베드 브라우저 등)에서도
   큰 화면이 보장된다. 진행바·조작 버튼·안내 카드도 무대 안으로 옮겨 붙인다
   (script.js의 courseEnterStage). */
body.stage-open { overflow: hidden; }

#displayArea.stage {
  position: fixed;
  inset: 0;
  margin: 0; /* fixed 요소에도 margin이 inset 계산에 반영되므로 초기화 */
  z-index: 900;
  background: var(--bg);
  box-sizing: border-box;
  padding: 14px 18px 74px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

#displayArea.stage .fs-controls { display: flex; }
#displayArea.stage .fs-controls #exitFullscreenBtn { display: inline-block; }

/* 무대에서는 훈련 화면에 자리를 최대한 내주고 진행바는 얇게 */
#displayArea.stage .course-bar { padding: 8px 12px; gap: 7px; }
#displayArea.stage .course-step { padding: 5px 4px; font-size: 10px; }
#displayArea.stage .course-step-icon { font-size: 15px; }
#displayArea.stage .course-bar-hint { font-size: 11px; }
#displayArea.stage .course-bar-title { font-size: 12px; }

#displayArea.stage .course-bar {
  order: -1;
  margin: 0;
  flex: 0 0 auto;
}

#displayArea.stage > .progress-bar,
#displayArea.stage > .stats {
  flex: 0 0 auto;
  margin: 0;
}

#displayArea.stage > .rsvp-box,
#displayArea.stage > .guide-box,
#displayArea.stage > .pacer-box,
#displayArea.stage > .eye-box,
#displayArea.stage > .schulte-box,
#displayArea.stage > .widen-box,
#displayArea.stage > .book-box {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  border-radius: 12px;
}

#displayArea.stage .rsvp-word { font-size: clamp(44px, 7vw, 96px); }
#displayArea.stage .orp-guide { font-size: clamp(20px, 2.4vw, 34px); }
#displayArea.stage .widen-word { font-size: clamp(28px, 3.4vw, 52px); }
#displayArea.stage .guide-text,
#displayArea.stage .pacer-text { font-size: clamp(20px, 2.2vw, 32px); }
#displayArea.stage .eye-dot { width: 26px; height: 26px; margin: -13px 0 0 -13px; }

#displayArea.stage > .book-box { background: #241a10; padding: 0; }

/* 무대 안에서는 책이 컨테이너를 넘지 않게 비율로 잡고, 위쪽 페이지 내비와 겹치지 않도록 내린다 */
#displayArea.stage .book3d {
  position: absolute;
  top: calc(50% + 20px);
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1120px, 94%);
  height: calc(100% - 66px);
  perspective: 3200px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}

#displayArea.stage .book-leaf,
#displayArea.stage .turn-face { padding: 50px 56px; }
#displayArea.stage .book-text { font-size: 22px; line-height: 2.15; }

#displayArea.stage .book-nav {
  top: 6px;
  bottom: auto;
  left: 50%;
  right: auto;
  width: auto;
  transform: translateX(-50%);
  justify-content: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 16px;
  border-radius: 999px;
}

/* 모바일 무대 — 위 규칙들은 id 우선순위가 높아서 파일 끝의 모바일 규칙을 덮어버린다.
   특히 책 여백(50/56px)이 그대로 적용되면 페이지 내용 폭이 46px밖에 안 남아 글자가
   한 줄에 두 글자씩 세로로 떨어진다. 여기서 무대 안쪽 값을 다시 좁혀준다. */
@media (max-width: 560px) {
  #displayArea.stage { padding: 10px 10px 62px; gap: 8px; }

  #displayArea.stage .course-bar { padding: 7px 10px; gap: 5px; }
  #displayArea.stage .course-bar-title { font-size: 11px; }
  /* 무대에서는 단계 칩을 한 줄로 — 두 줄로 접히면 훈련 화면을 그만큼 잡아먹는다 */
  #displayArea.stage .course-steps { flex-wrap: nowrap; }
  #displayArea.stage .course-step { flex: 1 1 0; min-width: 0; }
  #displayArea.stage .course-step { padding: 4px 2px; font-size: 9px; gap: 1px; }
  #displayArea.stage .course-step-icon { font-size: 13px; }
  #displayArea.stage .course-step-result { font-size: 9px; }
  #displayArea.stage .course-bar-hint { font-size: 10px; }
  #displayArea.stage .course-bar-top button { padding: 3px 8px; font-size: 11px; }

  #displayArea.stage .rsvp-word { font-size: clamp(28px, 11vw, 46px); }
  #displayArea.stage .orp-guide { font-size: 18px; }
  #displayArea.stage .widen-word { font-size: clamp(17px, 5.6vw, 24px); }
  #displayArea.stage .guide-text,
  #displayArea.stage .pacer-text { font-size: 17px; }

  #displayArea.stage .book3d {
    width: 97%;
    height: calc(100% - 48px);
    top: calc(50% + 14px);
  }
  #displayArea.stage .book-leaf,
  #displayArea.stage .turn-face { padding: 16px 13px; }
  #displayArea.stage .book-text { font-size: 15px; line-height: 1.95; }
  #displayArea.stage .book-nav { top: 2px; gap: 10px; padding: 4px 10px; }

  #displayArea.stage .fs-controls { bottom: 12px; gap: 6px; }
  #displayArea.stage .fs-controls button { padding: 8px 10px; font-size: 12px; }

  #displayArea.stage > .stats { grid-template-columns: repeat(4, 1fr); }
  #displayArea.stage > .stats .stat-label { font-size: 10px; }
  #displayArea.stage > .stats .stat-value { font-size: 15px; }
}

/* ---- 게스트 안내 (기록 미저장) ---- */
.guest-notice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.guest-notice b { font-size: 14px; }

.guest-notice p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
}

.guest-notice button {
  padding: 8px 14px;
  font-size: 13px;
}

.guest-inline {
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* 실패 직후 "여기까지 왔다"를 보여주는 자리라 안내문(.guest-inline)보다 눈에 띄어야 한다 */
.guest-pitch {
  margin: 10px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--banner-bg);
  font-size: 13px;
  line-height: 1.65;
  color: var(--banner-text);
}

.guest-pitch b {
  color: var(--text);
  font-weight: 700;
}

.history-empty {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 14px 8px;
}

/* ---- 훈련 코스 ---- */
.course-intro {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.course-intro h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.course-intro p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

.course-flow {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  counter-reset: cflow;
}

.course-flow li {
  counter-increment: cflow;
  flex: 1 1 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--input-bg, var(--panel-bg));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px;
  position: relative;
}

.course-flow li::before {
  content: counter(cflow);
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
}

.course-flow-icon { font-size: 20px; }
.course-flow b { font-size: 13px; }
.course-flow span:last-child { font-size: 11px; color: var(--text-muted); text-align: center; }

.course-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--banner-bg);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.course-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.course-bar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--banner-text);
}

.course-bar-top button {
  background: none;
  border: 1px solid var(--accent);
  color: var(--banner-text);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  flex-shrink: 0;
}

.course-steps {
  display: flex;
  gap: 6px;
}

.course-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.55;
}

.course-step-icon { font-size: 17px; }

.course-step.active {
  opacity: 1;
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(79, 109, 245, 0.25);
}

.course-step.done {
  opacity: 1;
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.course-step-result { font-size: 10px; }

.course-bar-hint {
  font-size: 12px;
  color: var(--banner-text);
  line-height: 1.5;
}

.course-bar-hint b { color: var(--accent); }

.course-step-badge {
  font-size: 34px;
  text-align: center;
  margin-bottom: 4px;
}

.course-step-of {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dim);
}

.course-step-meta {
  font-size: 13px;
  color: var(--text-dim);
  background: var(--input-bg, var(--panel-bg));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0 4px;
  line-height: 1.6;
}

.course-summary {
  list-style: none;
  margin: 12px 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.course-summary li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  background: var(--input-bg, var(--panel-bg));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.course-summary li b { font-weight: 600; }
.course-summary li span { color: var(--text-dim); font-size: 12px; }

.level-card.course-card .level-stage { color: var(--accent); }

@media (max-width: 560px) {
  .course-steps { flex-wrap: wrap; }
  .course-step { flex: 1 1 45%; }
}

.quiz-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.quiz-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.quiz-card h3 {
  margin: 0 0 4px;
}

.quiz-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.quiz-q {
  margin-bottom: 16px;
}

.quiz-q-text {
  font-size: 14px;
  margin-bottom: 8px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.quiz-option.correct {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.quiz-option.wrong {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
}

.quiz-result {
  margin: 12px 0;
  font-size: 14px;
}

.quiz-verdict.pass {
  color: var(--success);
  font-weight: 700;
}

.quiz-verdict.fail {
  color: var(--error-text);
  font-weight: 700;
}

.quiz-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.stat {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.history h2 {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stats-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 24px;
}

.stats-numbers {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stats-numbers .stat-num {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-numbers .stat-num b {
  font-size: 20px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stats-numbers .stat-num span {
  font-size: 11px;
  color: var(--text-muted);
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.badge.earned {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.badge.locked {
  opacity: 0.4;
}

.progress-chart {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.progress-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.progress-chart .chart-empty {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 30px 0;
}

.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-dot { fill: var(--accent); }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-label { fill: var(--text-dim); font-size: 10px; }
.chart-area { fill: var(--accent); opacity: 0.12; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--pacer-text);
}

th {
  color: var(--text-dim);
  font-weight: 500;
}

.admin-new-btn {
  width: 100%;
  margin-bottom: 16px;
}

.admin-level-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.admin-level-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

.admin-passage-preview {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 4px;
}

.admin-quiz-count {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0;
}

.admin-level-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.admin-editor {
  max-width: 640px;
}

.admin-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.admin-field input,
.admin-field select {
  flex: 1;
  max-width: 260px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}

.admin-field-block {
  flex-direction: column;
  align-items: stretch;
}

.admin-field-block textarea {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

.admin-quiz-q {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.admin-quiz-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.admin-quiz-q-header .remove-q-btn {
  padding: 2px 8px;
  font-size: 11px;
}

.admin-quiz-q .q-text {
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}

.admin-quiz-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.admin-quiz-opt .q-opt {
  flex: 1;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}

/* ---- 모바일 반응형 ---- */
@media (max-width: 560px) {
  .app { padding: 16px 12px 48px; }

  .header-top {
    flex-direction: column;
    gap: 10px;
  }
  .header-actions {
    position: static;
    flex-wrap: wrap;
    justify-content: center;
  }

  .main-tab { padding: 12px 8px; font-size: 14px; }
  .mode-tabs { gap: 8px 10px; }
  /* 좁은 화면에서도 내용 너비를 지킨다. 균등 분할하면 글자가 세로로 쪼개진다. */
  .mode-tabs .tab { flex: 0 1 auto; font-size: 13px; padding: 8px 10px; }
  .mode-group { font-size: 10px; padding-left: 6px; }

  .age-group-row { flex-wrap: wrap; }
  .age-group-btn { flex: 1 1 40%; }

  .diagnostic-bar { flex-direction: column; align-items: stretch; text-align: center; }

  .control-row label { width: 88px; font-size: 12px; }

  .button-row { flex-wrap: wrap; }
  .button-row button { flex: 1 1 45%; }

  .pattern-row .pattern-btn { flex: 1 1 28%; }

  .stats { grid-template-columns: repeat(2, 1fr); }

  .rsvp-word { font-size: 32px; }
  .guide-text, .pacer-text { font-size: 18px; }
  .book-text { font-size: 16px; }
  .book-leaf, .turn-face { padding: 18px 20px; }

  .stats-numbers { gap: 12px; }

  .quiz-card, .auth-card { padding: 18px; }

  table { font-size: 12px; }
  th, td { padding: 6px 4px; }
}
