/* === BASE MODAL OVERLAY === */
.sov { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9000; display: none; align-items: center; justify-content: center; }
    .sov.op { display: flex; }
    .spanel { background: var(--surf); border-radius: 14px; padding: 18px; width: 215px; max-height: 90vh; overflow-y: auto; border: 1px solid var(--brd); box-shadow: 0 10px 30px rgba(0,0,0,.15); }
    .spanel.lg { width: min(96vw, 360px); max-height: 94vh; }
    .spanel.full { width: min(96vw, 500px); }
    .spttl { font-size: 12px; font-weight: 800; color: var(--txt); margin-bottom: 14px; display: block; }
    .srow2 { margin-bottom: 12px; }
    .slbl { font-size: 8px; font-weight: 700; color: var(--sub); text-transform: uppercase; margin-bottom: 6px; }
    .sopts { display: flex; gap: 5px; }
    .sopts.vertical { flex-direction: column; }
    .sopt { flex: 1; padding: 7px 4px; border-radius: 7px; border: 1px solid var(--brd); font-size: 8px; font-weight: 700; text-align: center; cursor: pointer; color: var(--sub); background: var(--surf); transition: .2s; }
    .sopt.on { background: var(--acc); color: #fff; border-color: var(--acc); }
    .sclose { width: 100%; margin-top: 10px; padding: 8px; background: var(--acc); color: #fff; border: none; border-radius: 8px; font-size: 9px; font-weight: 700; cursor: pointer; }

/* === SEARCH OVERLAY === */


/* === DEMO LAUNCHER PANEL === */
.demo-launcher {
      position: fixed; bottom: 16px; left: 16px; z-index: 4000;
      background: var(--surf); border: 1px solid var(--brd);
      border-radius: 12px; padding: 10px;
      display: flex; flex-direction: column; gap: 6px;
      box-shadow: 0 4px 20px rgba(0,0,0,.2);
      max-width: 210px;
    }
    .demo-launcher-toprow { display: flex; align-items: center; justify-content: space-between; }
    .demo-launcher-title { font-size: 7px; font-weight: 900; color: var(--sub); text-transform: uppercase; letter-spacing: .08em; }
    .demo-toggle { width: 22px; height: 22px; border-radius: 50%; background: var(--acc); color: #fff; border: none; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; transition: .2s; }
    .demo-toggle:hover { opacity: .8; }
    .demo-launcher-inner { display: flex; flex-direction: column; gap: 6px; }
    .demo-launcher.collapsed .demo-launcher-inner { display: none; }
    .demo-section-lbl { font-size: 7px; font-weight: 900; color: var(--sub); text-transform: uppercase; letter-spacing: .06em; }
    .demo-group { display: flex; flex-wrap: wrap; gap: 4px; }
    .demo-btn {
      padding: 4px 8px; background: var(--bar); border: 1px solid var(--brd);
      border-radius: 6px; font-size: 8px; font-weight: 700; color: var(--txt);
      cursor: pointer; font-family: var(--font); white-space: nowrap; transition: .15s;
    }
    .demo-btn:hover, .demo-btn.active { background: var(--acc); color: #fff; border-color: var(--acc); }

/* === SHARED MODAL COMPONENTS === */
.mod-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
    .mod-close { background: none; border: none; font-size: 16px; color: var(--sub); cursor: pointer; line-height: 1; padding: 2px; }
    .modal-vthumb { width: 100%; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--thumb); position: relative; margin-bottom: 10px; flex-shrink: 0; }
    .modal-vthumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
    .modal-vthumb-badge { position: absolute; bottom: 5px; right: 5px; background: rgba(0,0,0,.8); color: #fff; font-size: 8px; padding: 2px 5px; border-radius: 3px; }
    .modal-vinfo { background: var(--bar); border-radius: 7px; padding: 8px 10px; margin-bottom: 10px; font-size: 10px; font-weight: 700; color: var(--txt); border-left: 3px solid var(--acc); line-height: 1.4; }
    .modal-desc { font-size: 10px; color: var(--sub); line-height: 1.6; margin-bottom: 12px; }
    .mbtn { width: 100%; padding: 9px; border: none; border-radius: 8px; font-size: 10px; font-weight: 800; cursor: pointer; font-family: var(--font); letter-spacing: .3px; transition: .15s; }
    .mbtn.primary { background: var(--acc); color: #fff; }
    .mbtn.secondary { background: var(--bar); color: var(--txt); border: 1px solid var(--brd); }
    .mbtn.danger { background: #ef4444; color: #fff; }
    .mbtn:hover { opacity: .85; }
    .mbtn:disabled { opacity: .4; cursor: not-allowed; }
    .mbtn-row { display: flex; gap: 6px; margin-top: 6px; }
    .modal-footer-btns { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

/* === SUBTITLE CHOICE GRID === */
.sub-choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 10px; }
    .sub-choice-card { border: 1.5px solid var(--brd); border-radius: 8px; padding: 8px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: .15s; background: var(--surf); }
    .sub-choice-card.on { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 8%, var(--surf)); }
    .sub-choice-card .radio-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--brd); flex-shrink: 0; transition: .15s; }
    .sub-choice-card.on .radio-dot { border-color: var(--acc); background: var(--acc); }
    .sub-choice-label { font-size: 10px; font-weight: 700; color: var(--txt); flex: 1; }
    .sub-choice-badge { font-size: 7px; background: var(--acc); color: #fff; border-radius: 3px; padding: 1px 4px; white-space: nowrap; }

/* === HERO CREATE MODAL === */
.portrait-upload { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 12px; }
    .portrait-circle { width: 72px; height: 72px; border-radius: 50%; border: 2px dashed var(--brd); background: var(--bar); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 28px; transition: .2s; overflow: hidden; }
    .portrait-circle:hover { border-color: var(--acc); }
    .portrait-hint { font-size: 8px; color: var(--sub); }
    .form-row { margin-bottom: 10px; }
    .form-row label { display: block; font-size: 8px; font-weight: 700; color: var(--sub); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
    .form-input-line { width: 100%; padding: 8px 10px; background: var(--bar); border: 1px solid var(--brd); border-radius: 7px; font-size: 11px; color: var(--txt); font-family: var(--font); outline: none; transition: .15s; }
    .form-input-line:focus { border-color: var(--acc); background: var(--surf); }
    .voice-box { background: var(--bar); border-radius: 8px; padding: 10px; border: 1px solid var(--brd); }
    .voice-status-text { font-size: 9px; color: var(--sub); margin-bottom: 8px; }
    .voice-actions-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
    .rec-btn { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--brd); background: var(--surf); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .2s; font-size: 15px; flex-shrink: 0; }
    .rec-btn.recording { background: #ef4444; border-color: #ef4444; animation: pulseRec .8s ease-in-out infinite; }
    @keyframes pulseRec { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }
    .voice-file-btn { font-size: 9px; color: var(--acc); background: none; border: none; cursor: pointer; font-family: var(--font); }

/* Hero Forge specific adjustments */
.portrait-circle { background: #f3f4f6; color: #4b5563; }
.voice-box { background: #f3f4f6; border-radius: 12px; border: 1px solid var(--brd); padding: 15px; }
.rec-btn { background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.voice-file-btn { font-weight: 700; color: #3b82f6; }

/* Waveform Canvas */
.waveform-canvas {
  width: 100%;
  height: 52px;
  border-radius: 6px;
  background: var(--surf);
  border: 1px solid var(--brd);
  margin-bottom: 8px;
  display: block;
  cursor: pointer;
  touch-action: none;
}

/* Recording Prompt Card */
.recording-prompt {
  background: color-mix(in srgb, var(--acc) 6%, var(--surf));
  border: 1px solid color-mix(in srgb, var(--acc) 20%, var(--brd));
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.recording-prompt__label {
  font-size: 8px;
  font-weight: 800;
  color: var(--acc);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.recording-prompt__text {
  font-size: 11px;
  font-weight: 600;
  color: var(--txt);
  line-height: 1.65;
  margin: 0 0 6px;
  word-break: keep-all;
}
.recording-prompt__ipa {
  font-size: 9px;
  font-family: 'Segoe UI', 'Noto Sans', sans-serif;
  color: var(--sub);
  line-height: 1.7;
  margin: 0;
  padding-top: 6px;
  border-top: 1px dashed var(--brd);
  word-break: break-word;
}
.recording-prompt__re-record-warn {
  font-size: 8px;
  color: #ef4444;
  font-weight: 700;
  margin-top: 6px;
  display: none;
}

/* Recording Countdown */
.rec-countdown-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}
.rec-countdown-num {
  font-size: 56px;
  font-weight: 900;
  color: var(--acc);
  line-height: 1;
  animation: countdownPulse 1s ease-in-out infinite;
}
.rec-countdown-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--sub);
  margin-top: 8px;
  letter-spacing: .03em;
}
@keyframes countdownPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: .7; }
}
.rec-active-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  display: inline-block;
  animation: recDotBlink 1s ease-in-out infinite;
}
@keyframes recDotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

@media (max-height: 500px) {
    .spanel.lg { width: min(96vw, 360px); padding: 14px; }
    .portrait-circle { width: 60px; height: 60px; font-size: 24px; }
    .mod-header { margin-bottom: 8px; }
    .form-row { margin-bottom: 6px; }
}

/* === NOTICE MODAL (Learning Start Guide) === */
.notice-box { background: color-mix(in srgb, var(--acc) 8%, var(--surf)); border: 1px solid color-mix(in srgb, var(--acc) 25%, transparent); border-radius: 8px; padding: 9px 12px; font-size: 10px; color: var(--txt); margin-bottom: 12px; line-height: 1.5; }
    .kb-guide { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
    .kb-section-lbl { font-size: 7px; font-weight: 900; color: var(--sub); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
    .kb-item { display: flex; align-items: center; gap: 6px; }
    .kb-key { background: var(--bar); border: 1px solid var(--brd); border-bottom-width: 2px; border-radius: 4px; padding: 2px 6px; font-size: 8px; font-weight: 800; color: var(--txt); font-family: monospace; white-space: nowrap; flex-shrink: 0; }
    .kb-desc { font-size: 9px; color: var(--sub); }
    .countdown-btn { width: 100%; padding: 11px; background: var(--acc); color: #fff; border: none; border-radius: 8px; font-size: 11px; font-weight: 800; cursor: pointer; font-family: var(--font); transition: .15s; }
    .countdown-btn:hover { opacity: .9; }

/* === COMPLETION MODAL === */
.completion-header { text-align: center; margin-bottom: 14px; }
    .completion-icon { font-size: 40px; display: block; margin-bottom: 6px; }
    .completion-title { font-size: 14px; font-weight: 900; color: var(--txt); }
    .completion-summary { font-size: 10px; color: var(--sub); margin-top: 4px; }
    .xp-bar-wrap { background: var(--bar); border-radius: 6px; height: 8px; overflow: hidden; margin-bottom: 4px; }
    .xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--acc), var(--acc2)); border-radius: 6px; width: 78%; transition: width 1s ease; }
    .xp-label-row { display: flex; justify-content: space-between; font-size: 9px; font-weight: 700; color: var(--sub); margin-bottom: 10px; }
    .stat-mini-row { display: flex; gap: 6px; margin-bottom: 12px; }
    .stat-mini { flex: 1; background: var(--bar); border-radius: 8px; padding: 7px; text-align: center; border: 1px solid var(--brd); }
    .stat-mini-val { font-size: 16px; font-weight: 900; color: var(--acc); }
    .stat-mini-lbl { font-size: 7px; color: var(--sub); margin-top: 2px; }
    .completion-timer { font-size: 9px; color: var(--sub); text-align: center; margin-top: 8px; }

/* === LOADING MODAL === */
.loading-center { text-align: center; padding: 10px 0; }
    .loading-ring { width: 48px; height: 48px; border: 4px solid var(--brd); border-top-color: var(--acc); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
    @keyframes spin { to { transform: rotate(360deg); } }
    .loading-title { font-size: 11px; font-weight: 800; color: var(--txt); margin-bottom: 4px; letter-spacing: .5px; }
    .loading-sub { font-size: 9px; color: var(--sub); margin-bottom: 12px; }
    .loading-prog-track { background: var(--bar); border-radius: 4px; height: 4px; overflow: hidden; }
    .loading-prog-fill { height: 100%; background: var(--acc); border-radius: 4px; transition: width .5s ease; }
    .loading-pct { font-size: 8px; color: var(--sub); margin-top: 5px; }

/* === MIC ERROR MODAL === */
.mic-icon { font-size: 36px; text-align: center; display: block; margin-bottom: 8px; }
    .mic-title { font-size: 13px; font-weight: 900; color: #ef4444; text-align: center; margin-bottom: 4px; }
    .mic-desc { font-size: 10px; color: var(--sub); text-align: center; line-height: 1.6; margin-bottom: 14px; }

/* === TOAST NOTIFICATION === */
.lt-toast {
      position: fixed; top: 24px; right: 16px; z-index: 5000;
      background: var(--surf); border: 1px solid var(--brd);
      border-left: 3px solid var(--acc);
      border-radius: 8px; padding: 10px 14px;
      font-size: 10px; font-weight: 700; color: var(--txt);
      box-shadow: 0 4px 16px rgba(0,0,0,.15);
      max-width: 230px; pointer-events: none;
      transform: translateX(120%); transition: transform .3s cubic-bezier(.175,.885,.32,1.275);
    }
    .lt-toast.show { transform: translateX(0); }
    .lt-toast.success { border-left-color: #10b981; }
    .lt-toast.warning { border-left-color: #f59e0b; }
    .lt-toast.error { border-left-color: #ef4444; }
    .lt-toast-icon { margin-right: 6px; }

/* === MY PAGE (Drawer extension) === */
.my-page-panel {
      position: fixed; bottom: 0; left: 0; right: 0; z-index: 2500;
      background: var(--surf); border-top: 1px solid var(--brd);
      border-radius: 16px 16px 0 0;
      padding: 16px 16px 24px;
      transform: translateY(100%); transition: transform .3s cubic-bezier(.25,.46,.45,.94);
      max-height: 70vh; overflow-y: auto;
    }
    .my-page-panel.open { transform: translateY(0); }
    .my-page-handle { width: 36px; height: 4px; background: var(--brd); border-radius: 2px; margin: 0 auto 14px; }
    .my-page-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
    .my-avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--acc), var(--acc2)); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
    .my-name { font-size: 13px; font-weight: 800; color: var(--txt); }
    .my-level { font-size: 9px; color: var(--sub); margin-top: 2px; }
    .my-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
    .my-stat { background: var(--bar); border-radius: 8px; padding: 8px; text-align: center; border: 1px solid var(--brd); }
    .my-stat-val { font-size: 18px; font-weight: 900; color: var(--acc); }
    .my-stat-lbl { font-size: 7px; color: var(--sub); margin-top: 2px; }
    .my-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; transition: .15s; border: 1px solid transparent; }
    .my-menu-item:hover { background: var(--bar); border-color: var(--brd); }
    .my-menu-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }
    .my-menu-text { font-size: 11px; font-weight: 700; color: var(--txt); }
    .my-page-ov { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 2499; display: none; }
    .my-page-ov.open { display: block; }

/* ═══════════════════════════════════════
   UNIFIED PREP MODAL (3-Phase)
═══════════════════════════════════════ */
.prep-panel { max-width:420px; width:94%; padding:16px; }

.prep-embed-wrap {
  width:100%; aspect-ratio:16/9; position:relative;
  background:#000; border-radius:var(--cr); overflow:hidden;
  margin:10px 0;
}
.prep-embed-frame { position:absolute; inset:0; width:100%; height:100%; border:0; }

.prep-video-title {
  font-size:12px; font-weight:700; color:var(--txt);
  line-height:1.4; margin:0 0 10px;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}

/* Subtitle selection cards */
.prep-sub-row { display:flex; flex-direction:column; gap:6px; margin-bottom:12px; }
.prep-sub-card {
  display:flex; align-items:center; gap:10px; padding:9px 12px;
  background:var(--bar); border:1px solid var(--brd); border-radius:var(--cr);
  cursor:pointer; transition:border-color .15s; font-size:11px; font-weight:600; color:var(--txt);
}
.prep-sub-card.on {
  border-color:var(--acc);
  background:color-mix(in srgb, var(--acc) 8%, var(--bar));
}
.prep-sub-card .radio-dot {
  width:14px; height:14px; border-radius:50%; border:2px solid var(--brd); flex-shrink:0; transition:all .15s;
}
.prep-sub-card.on .radio-dot { border-color:var(--acc); background:var(--acc); }

.prep-cached-notice {
  font-size:10px; color:#10b981; padding:8px 12px;
  background:color-mix(in srgb,#10b981 10%,var(--bar));
  border-radius:var(--cr); margin-bottom:10px; line-height:1.4;
}

.prep-start-btn { width:100%; }

/* Phase 3 — ad slot + progress */
.prep-ad-label {
  font-size:9px; font-weight:800; letter-spacing:.1em;
  color:var(--sub); text-align:center; margin:4px 0 0;
}
.prep-prog-area { padding:12px 0 4px; }
.prep-stage-lbl {
  font-size:11px; font-weight:600; color:var(--txt); margin-bottom:8px; min-height:16px;
}
.prep-prog-track { height:5px; background:var(--bar); border-radius:3px; overflow:hidden; margin-bottom:6px; }
.prep-prog-fill {
  height:100%; background:var(--acc); border-radius:3px; width:0%;
  transition:width .4s ease;
}
.prep-prog-row { display:flex; justify-content:space-between; align-items:center; }
.prep-prog-pct { font-size:11px; font-weight:800; color:var(--acc); }
.prep-prog-eta { font-size:9px; color:var(--sub); }

/* Unified Progress Action Button styles */
.prep-progress-btn {
  font-family: var(--font);
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
}
.prep-progress-btn.ready-pulse {
  background: #10b981 !important;
  color: #fff !important;
  animation: readyPulse 1.5s infinite ease-in-out;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}
@keyframes readyPulse {
  0%, 100% {
    transform: scale(1);
    background: #10b981 !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  }
  50% {
    transform: scale(1.03);
    background: #34d399 !important; /* Brighter green for glow/blink effect */
    box-shadow: 0 4px 25px rgba(16, 185, 129, 0.8);
  }
}