* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --navy: #002147;
  --navy-light: #1e5a8a;
  --accent: #002147;
  --accent-soft: #e8f1f8;
  --accent-text: #002147;
  --bg: #f3f0e8;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2ddd3;
}
button,
a,
.opt,
.card,
.chip,
.zh-toggle,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}
button,
.opt,
.zh-toggle {
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
body {
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #ebe6dc 0%, var(--bg) 40%, #f5f2ec 100%);
  color: var(--text);
  min-height: 100vh;
}
.page-hero {
  background: linear-gradient(135deg, #002147 0%, #163d66 48%, #1e5a8a 100%);
  color: #fff;
  padding: 24px 20px 32px;
  border-radius: 0 0 28px 28px;
  box-shadow: 0 14px 40px rgba(0,33,71,0.18);
  text-align: center;
}
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.top-bar .login-btn {
  padding: 5px 12px; border: 1px solid rgba(255,255,255,0.35); border-radius: 999px;
  background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.92); font: inherit;
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.top-bar .login-btn:hover { background: rgba(255,255,255,0.22); }
.lang-btn {
  padding: 5px 12px; border: 1px solid rgba(255,255,255,0.35); border-radius: 999px;
  background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.92); font: inherit;
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.lang-btn:hover { background: rgba(255,255,255,0.22); }
.nav-links {
  display: flex;
  gap: 10px;
  margin-right: auto;
  flex-wrap: wrap;
}
.nav-links a {
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  white-space: nowrap;
}
.nav-links a:hover { background: rgba(255,255,255,0.15); }
.nav-links a.active { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.45); }
@media (min-width: 768px) {
  .nav-links { flex-wrap: nowrap; }
}
.page-hero h1 { font-size: 24px; letter-spacing: 0.1em; margin-bottom: 6px; }
.page-hero p { font-size: 13px; color: rgba(255,255,255,0.8); }
.wrap { max-width: 640px; margin: 0 auto; padding: 28px 16px 48px; display: flex; flex-direction: column; gap: 20px; }
.card {
  background: #fff; border-radius: 20px; border: 1px solid rgba(0,33,71,0.08);
  padding: 22px 24px; box-shadow: 0 12px 32px rgba(0,33,71,0.08);
}
.card h2 { font-size: 16px; margin-bottom: 16px; color: var(--navy); }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.vis-segment { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2px; }
.vis-segment-opt { position: relative; cursor: pointer; min-width: 0; }
.vis-segment-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.vis-segment-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  height: 100%;
  padding: 14px 14px 12px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #fafbfc;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.vis-segment-opt:hover .vis-segment-inner { border-color: #b8cdd9; background: #fff; }
.vis-segment-opt input:focus-visible + .vis-segment-inner { outline: 2px solid var(--navy-light); outline-offset: 2px; }
.vis-segment-opt input:checked + .vis-segment-inner {
  border-color: var(--navy-light);
  background: linear-gradient(145deg, #e8f1f8 0%, #fff 55%);
  box-shadow: 0 4px 16px rgba(0, 33, 71, 0.1);
}
.vis-segment-inner .vis-icon { font-size: 18px; line-height: 1; margin-bottom: 2px; }
.vis-segment-inner .vis-title { font-size: 14px; font-weight: 800; color: var(--navy); }
.vis-segment-inner .vis-desc { font-size: 11px; color: var(--muted); line-height: 1.45; font-weight: 500; }
@media (max-width: 400px) {
  .vis-segment { grid-template-columns: 1fr; }
}
.studio-kw-field { margin-bottom: 16px; }
.studio-kw-opt { display: block; position: relative; cursor: pointer; }
.studio-kw-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.studio-kw-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 14px 12px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #fafbfc;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.studio-kw-head { display: flex; align-items: center; gap: 8px; }
.studio-kw-opt:hover .studio-kw-inner { border-color: #b8cdd9; background: #fff; }
.studio-kw-opt input:focus-visible + .studio-kw-inner {
  outline: 2px solid var(--navy-light);
  outline-offset: 2px;
}
.studio-kw-opt input:checked + .studio-kw-inner {
  border-color: var(--navy-light);
  background: linear-gradient(145deg, #f3eef8 0%, #fff 58%);
  box-shadow: 0 4px 16px rgba(0, 33, 71, 0.08);
}
.studio-kw-panel {
  margin-top: 10px;
  padding: 14px 14px 12px;
  border: 2px dashed #c9d4e0;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  border-width: 0;
  transition: max-height 0.28s ease, opacity 0.22s ease, margin 0.22s ease, padding 0.22s ease, border-width 0.1s;
}
.studio-kw-panel.is-open {
  max-height: 160px;
  opacity: 1;
  margin-top: 10px;
  padding: 14px 14px 12px;
  border-width: 2px;
}
.studio-kw-panel:not(.is-open) { pointer-events: none; }
.studio-kw-input-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.studio-kw-panel input {
  width: 100%;
  padding: 11px 13px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  box-sizing: border-box;
}
.studio-kw-panel input:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(30, 90, 138, 0.12);
}
.studio-kw-hint { margin: 8px 0 0; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 2px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 14px; background: #fafbfc;
}
@media (max-width: 767px) {
  .field input, .field select, .field textarea {
    font-size: 16px;
  }
  .field label {
    font-size: 13px;
  }
  .field-hint {
    font-size: 13px;
  }
}
.field-hint { font-size: 12px; margin: 6px 0 0; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(30,90,138,0.12);
}
.btn-primary, .btn-ghost {
  padding: 11px 18px; border-radius: 12px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-primary {
  width: 100%; border: none; color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  box-shadow: 0 6px 18px rgba(0,33,71,0.25);
}
.btn-ghost {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn-primary { width: auto; flex: 1; min-width: 140px; }
.hidden { display: none !important; }
.quiz-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.session-quiz.card { padding: 16px 18px 20px; }
.session-head { margin-bottom: 10px; }
.session-title { font-size: 17px; font-weight: 800; color: var(--navy); margin: 0 0 8px; }
.session-progress { height: 6px; background: #e8e4dc; border-radius: 999px; overflow: hidden; }
.session-progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--navy), var(--navy-light)); border-radius: 999px; transition: width 0.25s ease; }
.session-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; font-weight: 600; }
.session-queue { display: flex; gap: 8px; justify-content: flex-start; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.session-queue::-webkit-scrollbar { display: none; }
.session-queue-dot {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--border);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--muted); background: #fff;
}
.session-queue-dot.cur { border-color: var(--navy); color: var(--navy); background: #e8f1f8; }
.session-queue-dot.done { border-color: #059669; color: #059669; background: #ecfdf5; }
.session-card {
  background: #fff; border-radius: 18px; border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0, 33, 71, 0.07); overflow: hidden;
}
.session-card-art {
  max-height: min(38vw, 168px); min-height: 88px;
  background: linear-gradient(135deg, #faf3e3, #f0e5d2);
  display: flex; align-items: center; justify-content: center; padding: 8px 10px;
}
.session-card-body { padding: 12px 14px 14px; text-align: center; }
.prompt-area { min-height: 0; margin-bottom: 14px; width: 100%; }
.prompt-area .prompt-scene { display: contents; }
.prompt-scene-img {
  max-height: 152px; max-width: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 12px; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}
.prompt-scene-empty {
  width: 100%; min-height: 72px; max-height: 120px; border-radius: 12px; background: rgba(255,255,255,0.5);
  display: grid; place-items: center; font-size: 12px; color: var(--muted); padding: 8px;
}
.prompt-blank { color: var(--muted); font-weight: 800; letter-spacing: 0.08em; }
.prompt-context { width: 100%; max-width: 420px; }
.prompt-tag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--navy); background: #e8f1f8; padding: 2px 8px; border-radius: 999px;
}
.prompt-tag-ai { background: linear-gradient(135deg, #ede9fe, #dbeafe); color: #3730a3; }
.ai-prep-card { padding: 24px 16px; text-align: center; }
.ai-prep { margin: 0; font-size: 13px; }
.prompt-sentence { font-size: 16px; line-height: 1.55; color: var(--navy); margin: 8px 0 0; }
.prompt-def { font-size: 15px; line-height: 1.55; color: var(--navy); margin: 8px 0 0; }
.prompt-dialogue-line { font-size: 14px; line-height: 1.5; color: var(--navy); margin: 6px 0 0; padding-left: 10px; border-left: 3px solid rgba(0,33,71,0.12); }
.prompt-dialogue-focus { font-weight: 600; }
.prompt-focus { color: var(--navy); font-weight: 800; }
.prompt-meaning { font-size: 20px; font-weight: 700; color: var(--navy); margin: 8px 0 0; }
.prompt-hint { font-size: 12px; margin: 6px 0 0; }
.btn-listen {
  margin-top: 10px; padding: 10px 16px; border-radius: 999px; border: none; cursor: pointer;
  font: inherit; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--navy), var(--navy-light));
}
.prompt-word { font-size: 28px; font-weight: 800; color: var(--navy); text-align: center; }
.quiz-feedback-wrap { margin-top: 14px; }
.quiz-feedback {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); text-align: left;
}
.quiz-feedback.ok { background: #ecfdf5; border-color: #a7f3d0; }
.quiz-feedback.review { background: #fffbeb; border-color: #fde68a; }
.quiz-feedback-title { font-weight: 700; font-size: 14px; margin: 0 0 8px; color: var(--navy); }
.quiz-feedback-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 8px;
}
.quiz-feedback-word { font-size: 17px; margin: 0; color: var(--navy); line-height: 1.2; }
.quiz-feedback-ipa {
  font-family: "Iowan Old Style", Georgia, serif; font-size: 12px; font-style: italic;
  color: var(--accent-text); display: inline-flex; align-items: center; gap: 4px;
}
.quiz-feedback-ipa .ipa-accent { font-size: 9px; font-weight: 700; font-style: normal; opacity: 0.75; }
.quiz-feedback .zh-toggle-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.quiz-feedback .zh-toggle {
  width: 22px; height: 20px; border: 1px solid #b8cdd9; border-radius: 4px;
  background: #e8f1f8; color: var(--navy); font-size: 10px; font-weight: 700;
  cursor: pointer; display: grid; place-items: center; line-height: 1; padding: 0; font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.quiz-feedback .zh-toggle:hover { background: var(--navy-light); color: #fff; border-color: var(--navy-light); }
.quiz-feedback .zh-toggle:active { background: #dbeafe; color: var(--navy); border-color: #93c5fd; }
.quiz-feedback .zh-toggle-wrap.open .zh-toggle,
.quiz-feedback .zh-toggle-wrap.open .zh-toggle:active,
.quiz-feedback .zh-toggle-wrap.open .zh-toggle:hover {
  background: var(--navy); color: #fff; border-color: var(--navy);
}
.quiz-feedback .zh-toggle:focus { outline: none; }
.quiz-feedback .zh-toggle:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--navy-light);
}
.quiz-feedback .card-zh-pop {
  display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 12;
  min-width: 100px; max-width: 240px; padding: 6px 9px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 16px rgba(15,23,42,0.14);
  font-size: 12px; color: var(--text); line-height: 1.45; white-space: normal;
}
.quiz-feedback .zh-toggle-wrap.open .card-zh-pop { display: block; }
.quiz-feedback-def { font-size: 13px; color: var(--navy); line-height: 1.5; margin: 0 0 6px; }
.quiz-feedback-why { font-size: 13px; color: #334155; line-height: 1.5; margin: 0 0 8px; }
.quiz-feedback-why-label { font-weight: 700; color: var(--navy); }
.quiz-feedback-context { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 8px; }
.btn-replay { width: auto; padding: 6px 12px; font-size: 12px; }
#nextBtn { margin-top: 12px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  padding: 12px 14px; border: 2px solid var(--border); border-radius: 12px; background: #fff;
  text-align: left; font: inherit; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.opt:active:not(:disabled) { background: #f8fafc; }
.opt:disabled { opacity: 1; color: var(--text); -webkit-text-fill-color: var(--text); }
.opt.correct:disabled { color: var(--navy); -webkit-text-fill-color: var(--navy); }
.opt.wrong:disabled { color: var(--navy); -webkit-text-fill-color: var(--navy); }
.opt:hover { border-color: var(--navy-light); background: #f8fafc; }
.opt.correct { border-color: #059669; background: #ecfdf5; }
.opt.wrong { border-color: #dc2626; background: #fef2f2; }
.score { font-size: 32px; font-weight: 800; color: var(--navy); margin: 12px 0 18px; }
.history { list-style: none; font-size: 13px; color: var(--muted); }
.history li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.studio-main { max-width: 720px; }
.studio-records h2 { font-size: 16px; color: var(--navy); margin-bottom: 14px; }
.creation-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 24px 12px; }
.studio-records .creation-section-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: -4px 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1f5f9;
}
.preview-meta { margin-top: 12px; padding: 12px 14px; background: #f8fafc; border-radius: 12px; border: 1px solid var(--border); font-size: 12.5px; line-height: 1.5; }
.preview-meta.hidden { display: none; }
.preview-meta-row { margin-bottom: 8px; }
.preview-meta-row:last-child { margin-bottom: 0; }
.preview-meta-row p { margin: 4px 0 0; color: var(--text); }
.preview-meta-row .preview-label { display: block; margin-bottom: 2px; }
.studio-card .field { margin-bottom: 14px; }
.studio-word-input {
  width: 100%;
  min-height: 96px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}
.studio-word-input:focus { border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(30, 90, 138, 0.15); }
.btn-generate-all { width: 100%; margin-top: 4px; padding: 12px 18px; font-size: 15px; }
.btn-generate-all:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-generate-all.is-busy { cursor: wait; }
.studio-card #msg { margin-top: 14px; }
.studio-card #msg:not(.hidden) { display: block; }
.studio-preview {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.studio-preview-img { width: 100%; max-width: 240px; margin: 0 auto; text-align: center; }
.preview-img-frame {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #faf3e3, #f0e5d2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.preview-img-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-img-frame img.preview-img-hidden { display: none !important; }
.preview-img-empty { font-size: 12px; color: var(--muted); padding: 12px; text-align: center; }
.preview-img-empty[hidden] { display: none !important; }
.preview-label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 6px; letter-spacing: 0.04em; }
.studio-preview-audio { display: flex; flex-direction: column; gap: 12px; width: 100%; min-width: 0; }
.audio-block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.audio-block .preview-label { margin-top: 0; margin-bottom: 2px; }
.audio-block audio { width: 100%; max-width: 100%; height: 36px; }
.audio-block audio.hidden { display: none; }
.status-pill { display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 12px; }
.status-pill.ok { background: #ecfdf5; color: #047857; }
.status-pill.bad { background: #fef2f2; color: #dc2626; }
.msg { padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.msg.error { background: #fef2f2; color: #dc2626; }
.msg.ok { background: #ecfdf5; color: #047857; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.hint code { background: #fff; padding: 1px 4px; border-radius: 4px; }

#appDialogRoot { position: relative; z-index: 200; }
body.app-dialog-open { overflow: hidden; }
.app-dialog-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px;
  animation: app-dialog-fade 0.18s ease both;
}
@keyframes app-dialog-fade { from { opacity: 0; } to { opacity: 1; } }
.app-dialog {
  width: min(420px, 100%);
  background: linear-gradient(180deg, #fff 0%, #f8f6f0 100%);
  border-radius: 22px; overflow: hidden;
  box-shadow: 0 28px 70px rgba(0, 33, 71, 0.28);
  border: 1px solid rgba(0, 33, 71, 0.08);
  animation: app-dialog-in 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes app-dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.app-dialog-header {
  background: linear-gradient(135deg, #002147 0%, #163d66 48%, #1e5a8a 100%);
  color: #fff; padding: 18px 22px 16px;
}
.app-dialog-header h3 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.35; }
.app-dialog-body { padding: 18px 22px 6px; font-size: 14px; line-height: 1.55; color: var(--text); }
.app-dialog-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 18px 18px; border-top: 1px solid var(--border); background: #f5f2ec;
}
.app-dialog-btn {
  padding: 9px 18px; border-radius: 10px; border: 1.5px solid var(--border);
  background: #fff; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
}
.app-dialog-btn.primary {
  background: linear-gradient(135deg, #002147, #1e5a8a); color: #fff;
  border-color: transparent; box-shadow: 0 4px 12px rgba(0, 33, 71, 0.25);
}
.app-dialog-btn.primary:hover { transform: translateY(-1px); }
