/* ===== 讲题精灵 · 设计系统 ===== */
/* 方向：温暖纸感（schoolhouse warmth）+ 安静专业。中性色偏暖，品牌靛蓝 + 琥珀点缀，避开 AI 紫蓝霓虹与纯黑纯白 */
:root {
  --bg: #f7f5f0;            /* 暖米白 */
  --surface: #fffdfa;        /* 近白暖纸 */
  --surface-2: #f1ede4;     /* 柔和暖灰 */
  --ink: #26231d;           /* 暖墨（非纯黑）*/
  --ink-soft: #6c665b;
  --line: #e7e1d5;
  --brand: #4f46e5;         /* 靛蓝 */
  --brand-d: #4338ca;
  --brand-soft: #eef0ff;
  --accent: #f59e0b;        /* 琥珀点缀 */
  --accent-soft: #fef3e2;
  --teal: #0d9488;
  --warn: #e2433b;
  --video-bg: #0f172a;        /* 视频播放器专用深色区 */
  --work-bg: #fffdf5;         /* 演算过程编辑框底色 */
  --work-line: #ecdfb8;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(40, 33, 20, .04), 0 4px 12px rgba(40, 33, 20, .05);
  --shadow: 0 1px 2px rgba(40, 33, 20, .05), 0 10px 30px rgba(40, 33, 20, .07);
  --shadow-lg: 0 16px 48px rgba(40, 33, 20, .14);
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Noto Sans SC", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(.22, .8, .28, 1);  /* ease-out-quart，状态变化更顺 */
}

/* ===== 主题预设（data-theme 切换；paper 为默认，复用 :root 值）===== */
[data-theme="night"] {
  --bg: #14161c; --surface: #1c1f27; --surface-2: #232733; --ink: #e8e6e0; --ink-soft: #9aa0ad;
  --line: #2e3340; --brand: #818cf8; --brand-d: #6366f1; --brand-soft: #2a2f4a;
  --accent: #fbbf24; --accent-soft: #2e2a1f; --teal: #2dd4bf; --warn: #f87171;
  --video-bg: #0b0d12; --work-bg: #20242e; --work-line: #3a4150;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.3);
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
}
[data-theme="forest"] {
  --bg: #f3f6f1; --surface: #ffffff; --surface-2: #eef3ec; --ink: #1f2a22; --ink-soft: #5f6f63;
  --line: #dde6da; --brand: #059669; --brand-d: #047857; --brand-soft: #d1fae5;
  --accent: #d97706; --accent-soft: #fef3e2; --teal: #0d9488; --warn: #dc2626;
  --video-bg: #10231a; --work-bg: #f6fbf3; --work-line: #cfe3c8;
}
[data-theme="sakura"] {
  --bg: #fdf6f8; --surface: #ffffff; --surface-2: #fbeef2; --ink: #3a2f33; --ink-soft: #8a7680;
  --line: #f3dde4; --brand: #db2777; --brand-d: #be185d; --brand-soft: #fce7f0;
  --accent: #f59e0b; --accent-soft: #fef3e2; --teal: #0d9488; --warn: #e11d48;
  --video-bg: #2a1620; --work-bg: #fef4f7; --work-line: #f3cedd;
}
[data-theme="ocean"] {
  --bg: #f0f4f8; --surface: #ffffff; --surface-2: #e8eef5; --ink: #16263a; --ink-soft: #5a6b80;
  --line: #d6e0ec; --brand: #2563eb; --brand-d: #1d4ed8; --brand-soft: #dbeafe;
  --accent: #0891b2; --accent-soft: #e0f7fb; --teal: #0d9488; --warn: #dc2626;
  --video-bg: #0a1626; --work-bg: #f4f9fd; --work-line: #cfe0f0;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 460px at 88% -8%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 60%),
    radial-gradient(900px 420px at -4% 4%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ===== Top bar ===== */
.topbar-wrap {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line), 0 6px 20px rgba(40, 33, 20, .04);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
}
.global-status {
  padding: 8px 16px; text-align: center; font-size: 13px; line-height: 1.45;
  background: var(--brand-soft); color: var(--brand-d);
  border-top: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
}
.global-status[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px; object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}
.brand strong { display: block; font-size: 17px; letter-spacing: .3px; font-family: var(--font-display); }
.brand small { color: var(--ink-soft); font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.theme-switch { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.theme-dot {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.theme-dot:hover { transform: scale(1.14); }
.theme-dot:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.theme-dot.is-active { box-shadow: 0 0 0 2px var(--brand); }
.theme-dot.t-paper { background: linear-gradient(135deg, #4f46e5, #f59e0b); }
.theme-dot.t-night { background: linear-gradient(135deg, #818cf8, #fbbf24); }
.theme-dot.t-forest { background: linear-gradient(135deg, #059669, #d97706); }
.theme-dot.t-sakura { background: linear-gradient(135deg, #db2777, #f59e0b); }
.theme-dot.t-ocean { background: linear-gradient(135deg, #2563eb, #0891b2); }

/* ===== Buttons ===== */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; transition: transform .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid #c7d2fe; outline-offset: 2px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-d)); color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 28%, transparent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px color-mix(in srgb, var(--brand) 38%, transparent); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: var(--line); color: var(--ink-soft); cursor: not-allowed; box-shadow: none; transform: none; border-color: transparent; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand-d); }

/* ===== Hero ===== */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(820px 360px at 82% -20%, color-mix(in srgb, var(--brand) 11%, transparent), transparent 62%),
    radial-gradient(720px 340px at 4% 6%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, var(--brand-soft)) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--line);
  padding: clamp(44px, 6vw, 72px) 24px clamp(38px, 5vw, 60px);
}
.hero::after {
  /* 极淡网格纸纹理，强化“备课纸”气质 */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(rgba(79, 70, 229, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 70, 229, .045) 1px, transparent 1px);
  background-size: 28px 28px; -webkit-mask-image: radial-gradient(120% 80% at 50% 0%, #000 30%, transparent 75%); mask-image: radial-gradient(120% 80% at 50% 0%, #000 30%, transparent 75%);
}
.hero-inner { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: color-mix(in srgb, var(--brand-soft) 70%, var(--surface));
  color: var(--brand-d);
  font-size: 13px; font-weight: 700; padding: 7px 14px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  letter-spacing: .2px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.6vw, 50px); line-height: 1.12; margin: 18px 0 14px;
  letter-spacing: -.8px; font-weight: 800;
  color: var(--ink);
}
.hero-sub { font-size: clamp(15px, 2vw, 18px); color: var(--ink-soft); max-width: 680px; margin: 0 0 24px; }

/* ===== Layout ===== */
.layout {
  max-width: 640px; margin: clamp(16px, 3vw, 28px) auto; padding: 0 16px;
  display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start;
}
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.player-section { grid-column: 1 / -1; margin-top: 6px; }
.solution-section { grid-column: 1 / -1; margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.solution-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.solution-head .panel-title { margin: 0; }
.solution-canvas-wrap { overflow: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); padding: 16px; text-align: center; }
#solution-canvas { max-width: 100%; height: auto; display: block; margin: 0 auto; box-shadow: var(--shadow-lg); border-radius: 6px; }
.step-card textarea.work { min-height: 58px; background: var(--work-bg); border-color: var(--work-line); }
.panel-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; margin: 0 0 16px; padding-left: 14px; position: relative;
}
.panel-title::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 5px; height: 18px; border-radius: 999px;
  background: linear-gradient(180deg, var(--brand), var(--brand-d));
}
.panel-subtitle {
  font-size: 15px; font-weight: 600; margin: 24px 0 10px; color: var(--ink);
  padding-left: 14px; position: relative;
}
.panel-subtitle::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 5px; height: 15px; border-radius: 999px; background: var(--accent);
}
.panel-desc { color: var(--ink-soft); font-size: 13px; margin: -8px 0 14px; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: var(--radius-sm); padding: 11px; transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.tab:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); color: var(--brand-d); }
.tab.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-d)); color: #fff;
  border-color: transparent; box-shadow: 0 6px 16px rgba(79, 70, 229, .28); transform: translateY(-1px);
}
.tab:focus-visible { outline: 3px solid #c7d2fe; outline-offset: 2px; }
.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

/* ===== Fields ===== */
.field { border: 0; padding: 0; margin: 0 0 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
textarea, input[type="url"], input[type="text"], input[type="password"], select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }

/* ===== Dropzone ===== */
.dropzone {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: var(--radius-sm);
  padding: 28px; text-align: center; cursor: pointer; color: var(--ink-soft);
  background: var(--surface-2); transition: border-color .18s var(--ease), background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
/* 覆盖在 dropzone 上的真实 file input：视觉隐藏但原生可点/可聚焦，移动端 100% 可靠 */
#image-input.dropzone-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; z-index: 3; margin: 0;
  font-size: 0; line-height: 0;
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--brand); background: color-mix(in srgb, var(--brand-soft) 70%, var(--surface)); color: var(--brand-d);
  transform: translateY(-1px);
}
.dropzone-icon { font-size: 30px; }
.dropzone small { font-size: 12px; opacity: .8; }
.image-preview { margin-top: 12px; }
.image-preview img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.image-preview-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 10px; flex-wrap: wrap; }

/* ===== Config grid ===== */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 4px; }
.config-grid .field:nth-child(3), .config-grid .field:nth-child(4) { grid-column: span 1; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }

/* Segmented control */
.segmented { display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); padding: 3px; gap: 3px; }
.seg { flex: 1; position: relative; text-align: center; border-radius: 8px; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 8px 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); transition: color .15s var(--ease); }
.seg input:checked + span { background: var(--surface); color: var(--brand-d); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 3px solid #c7d2fe; outline-offset: -3px; }

/* ===== Action row ===== */
.action-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.action-row.is-centered { justify-content: center; }
.action-row .btn { padding: 9px 14px; white-space: nowrap; }
.hint { font-size: 13px; color: var(--ink-soft); margin: 10px 0 0; }
.hint.is-error { color: var(--warn); }
.tts-reminder {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  margin: 14px 0 0; padding: 11px 14px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  color: var(--ink); font-size: 13px; line-height: 1.5;
}
.link-btn {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: none; border: 0; padding: 0; color: var(--brand-d);
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--brand); }
.link-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.field-hint { font-size: 12px; line-height: 1.5; color: var(--ink-soft); margin: 8px 0 0; }
.field-hint a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.field-hint a:hover { color: var(--brand-strong); }
.field-hint a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.field.is-disabled { opacity: .45; pointer-events: none; filter: grayscale(0.6); }
.field.is-disabled .field-label::after { content: '（动画模式已隐藏）'; font-size: 11px; font-weight: 400; color: var(--ink-soft); margin-left: 6px; }

/* ===== Steps editor ===== */
.steps-editor { display: flex; flex-direction: column; gap: 14px; min-height: 60px; }
.empty-state {
  border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 28px;
  text-align: center; color: var(--ink-soft); background: var(--surface-2);
}
.empty-state span { font-size: 30px; display: block; margin-bottom: 6px; }
.step-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px 14px 18px; background: var(--surface); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.step-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--accent)));
}
.step-card .step-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.step-card .step-no {
  background: linear-gradient(135deg, var(--brand), var(--brand-d)); color: #fff;
  font-size: 12px; font-weight: 700; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; flex: none; box-shadow: 0 3px 8px rgba(79, 70, 229, .3);
}
.step-card .step-title-input { font-weight: 600; border: 1px dashed transparent; background: transparent; padding: 4px 6px; border-radius: 6px; font-size: 14px; }
.step-card .step-title-input:hover, .step-card .step-title-input:focus { border-color: var(--line); background: var(--surface-2); }
.step-card label { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .3px; color: var(--ink-soft); margin: 8px 0 3px; text-transform: none; }
.step-card input.board, .step-card textarea.narr { font-size: 13px; }
.step-card textarea.narr { min-height: 52px; }
.step-card textarea.ex { min-height: 46px; background: var(--surface-2); }

/* ===== Player ===== */
.player-wrap {
  margin-top: 18px; padding: 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
#lesson-canvas {
  width: 100%; height: auto; display: block; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--video-bg); box-shadow: var(--shadow-lg);
}
/* 最大化（全屏）时让画布铺满、控制条留在底部 */
.player-wrap:fullscreen, .player-wrap:-webkit-full-screen {
  display: flex; flex-direction: column; width: 100vw; height: 100vh;
  margin: 0; padding: 16px; background: var(--video-bg); align-items: center; justify-content: center;
}
.player-wrap:fullscreen #lesson-canvas, .player-wrap:-webkit-full-screen #lesson-canvas {
  width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 70px);
  object-fit: contain; flex: 0 1 auto;
}
.player-wrap:fullscreen .player-bar, .player-wrap:-webkit-full-screen .player-bar {
  margin-top: 12px; width: min(960px, 100%);
}
.player-bar { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.progress { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-d)); transition: width .12s linear; }
.step-label { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.subtitle {
  margin: 12px 0 0; min-height: 22px; font-size: 15px; color: var(--ink);
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 11px 14px;
  border: 1px solid var(--line);
}

/* ===== Queue ===== */
.queue-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.queue-list li {
  display: flex; align-items: center; gap: 10px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.queue-list li:hover { border-color: color-mix(in srgb, var(--brand) 25%, var(--line)); }
.queue-list .q-no { background: linear-gradient(135deg, var(--teal), #0b7d73); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; flex: none; box-shadow: 0 2px 6px rgba(13, 148, 136, .3); }
.queue-list .q-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-list .q-del { border: 0; background: transparent; cursor: pointer; color: var(--ink-soft); font-size: 16px; transition: color .15s var(--ease); }
.queue-list .q-del:hover { color: var(--warn); }
.queue-empty { color: var(--ink-soft); font-size: 13px; background: transparent; border-style: dashed; }

/* ===== Footer ===== */
.footer { text-align: center; color: var(--ink-soft); font-size: 13px; padding: 30px 20px 50px; }
.footer::before { content: ''; display: block; width: 56px; height: 3px; border-radius: 999px; margin: 0 auto 18px; background: linear-gradient(90deg, var(--brand), var(--accent)); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(38, 35, 29, .42); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; background: var(--surface); border-radius: var(--radius);
  width: min(520px, 92vw); max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); animation: modal-in .22s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; font-family: var(--font-display); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-sep { border: 0; border-top: 1px dashed var(--line); margin: 6px 0; }
.modal-sub { font-size: 14px; font-weight: 700; color: var(--brand-d); margin: 4px 0 0; }

/* ===== Entrance ===== */
.layout > .panel, .player-section, .solution-section { animation: rise .5s var(--ease) both; }
.solution-section { animation-delay: .06s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ===== Responsive ===== */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .hero { padding: 40px 18px 34px; }
  .panel { padding: 18px; }
}

@media (max-width: 680px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .brand { gap: 10px; }
  .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
  .brand strong { font-size: 15px; }
  .brand small { font-size: 11px; }
  .theme-dot { width: 18px; height: 18px; }

  .hero { padding: 30px 16px 26px; }
  .hero h1 { font-size: 26px; letter-spacing: -.4px; margin: 14px 0 12px; }
  .hero-sub { font-size: 14px; margin-bottom: 18px; }
  .badge { font-size: 12px; padding: 6px 12px; }

  .layout { padding: 0 12px; margin: 14px auto; gap: 14px; }
  .panel { padding: 14px; border-radius: 14px; }
  .panel-title { font-size: 16px; }

  .tabs { flex-direction: column; gap: 6px; }
  .tab { width: 100%; padding: 10px; }

  .action-row { flex-direction: column; gap: 8px; margin-top: 14px; }
  .action-row .btn { width: 100%; padding: 11px 14px; }
  .action-row.is-centered { align-items: stretch; }

  textarea, input[type="url"], input[type="text"], input[type="password"], select { font-size: 16px; padding: 11px 12px; }

  .player-bar { flex-wrap: wrap; gap: 8px; }
  .step-label { font-size: 12px; }
  .subtitle { font-size: 14px; padding: 10px 12px; }

  .solution-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .solution-canvas-wrap { padding: 10px; }

  .queue-list li { padding: 9px 10px; font-size: 13px; }
  .queue-list .q-text { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-card { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .modal-head { padding: 16px 18px; }
  .modal-body { padding: 16px 18px; }

  .footer { padding: 24px 16px 40px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
