:root {
  --blue: #0284c7;
  --blue-dark: #0369a1;
  --blue-deep: #0c4a6e;
  --blue-tint: #e0f2fe;
  --green: #16a34a;
  --green-bg: #e8f7ee;
  --red: #e0555f;
  --red-bg: #fdeaec;
  --amber: #b45309;
  --amber-bg: #fff6da;
  --amber-border: #e8c96b;
  --coral: #f0653f;
  --ink: #1c2a3a;
  --ink-soft: #55677c;
  --ink-faint: #8394a7;
  --bg: #f0f9ff;
  --card-bg: #ffffff;
  --border: #e4eaf1;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 45, 75, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(15, 66, 105, 0.18);
  --shadow-lg: 0 16px 40px -12px rgba(15, 66, 105, 0.24);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Lexend", "Noto Sans KR", "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background:
    radial-gradient(720px 420px at 12% -8%, rgba(2, 132, 199, 0.10), transparent 60%),
    radial-gradient(640px 380px at 92% 6%, rgba(240, 101, 63, 0.08), transparent 55%),
    linear-gradient(180deg, #f0f9ff 0%, #fdf9ee 42%, #f6f8fb 100%);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { text-wrap: balance; }

a { color: var(--blue-dark); }

:focus-visible {
  outline: 3px solid rgba(2, 132, 199, 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid rgba(228, 234, 241, 0.9);
}
.site-nav .logo-box {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(155deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px -3px rgba(2, 132, 199, 0.55);
}
.site-nav .nav-title {
  font-family: "Baloo 2", "Noto Sans KR", sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--blue-deep);
  letter-spacing: 0.2px;
}
.site-nav .nav-sub { font-size: 12px; color: var(--ink-faint); font-weight: 500; font-family: "Lexend", "Noto Sans KR", sans-serif; }

.video-embed-section {
  position: sticky;
  top: 61px;
  z-index: 9;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 0;
  background: linear-gradient(180deg, #f0f9ff 0%, #fdf9ee 100%);
}
.video-embed-frame-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #000;
}
.video-embed-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
#video-embed-close {
  display: block;
  margin: 10px auto 0;
  background: #fff;
}

.site-header {
  text-align: center;
  padding: 40px 16px 6px;
}
.site-header h1 {
  margin: 0;
  font-family: "Baloo 2", "Noto Sans KR", sans-serif;
  font-size: 32px;
  letter-spacing: -0.2px;
  color: var(--blue-deep);
}
.site-header h1 span { color: var(--blue); }
.subtitle { color: var(--ink-soft); margin: 8px 0 0; font-size: 15px; }

.banner {
  max-width: 760px;
  margin: 20px auto;
  padding: 16px 20px;
  background: linear-gradient(155deg, var(--amber-bg) 0%, #fffdf5 100%);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  color: #6b5218;
  box-shadow: var(--shadow-sm);
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px 26px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 240ms var(--ease);
}
.card h2 {
  margin-top: 0;
  font-size: 19px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--blue-deep);
}
.h2-note { font-size: 13px; font-weight: 500; color: var(--ink-faint); }
.hint { color: var(--ink-soft); font-size: 13.5px; margin: 4px 0 12px; }

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  font-family: "Lexend", sans-serif;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 3px 8px -2px rgba(2, 132, 199, 0.5);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.row input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fbfcfe;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.row input[type="text"]:focus {
  border-color: var(--blue);
  background: #fff;
  outline: none;
}

.btn {
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease), background 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}
.btn.primary {
  background: linear-gradient(155deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(2, 132, 199, 0.55);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 20px -6px rgba(2, 132, 199, 0.6); }
.btn.primary:active { transform: translateY(0) scale(0.97); }
.btn.secondary { background: #fff; color: var(--ink-soft); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--blue); color: var(--blue-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn.secondary:active { transform: translateY(0) scale(0.97); }
.btn.accent {
  background: linear-gradient(155deg, var(--green) 0%, #0f8a3f 100%);
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(22, 163, 74, 0.5);
}
.btn.accent:hover { transform: translateY(-1px); box-shadow: 0 10px 20px -6px rgba(22, 163, 74, 0.55); }
.btn.accent:active { transform: translateY(0) scale(0.97); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--border); }
.btn.ghost:hover { border-color: var(--ink-faint); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.points-display {
  font-weight: 600;
  color: var(--blue-dark);
  background: var(--blue-tint);
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
}

.level-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}
.level-btn {
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  min-width: 44px;
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease), background 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}
.level-btn:hover { border-color: var(--blue); color: var(--blue-dark); transform: translateY(-1px); }
.level-btn.active {
  background: linear-gradient(155deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 14px -4px rgba(2, 132, 199, 0.5);
}

.link-list { list-style: none; padding: 0; margin: 0 0 10px; }
.link-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  background: #fbfcfe;
  border-radius: var(--radius-pill);
  margin-bottom: 7px;
  font-size: 14px;
}
.link-list li a { color: var(--blue-dark); text-decoration: none; font-weight: 500; }
.link-list li a:hover { text-decoration: underline; }
.link-list .link-actions { display: flex; gap: 6px; flex-shrink: 0; }
.link-list button { font-size: 12px; padding: 6px 12px; }

.book-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}
.ready-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #157a3e;
  background: var(--green-bg);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.teacher-panel textarea {
  width: 100%;
  margin: 10px 0;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #fbfcfe;
}
.teacher-panel textarea:focus { border-color: var(--blue); background: #fff; outline: none; }
.teacher-panel code {
  background: #eef2f8;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 12.5px;
}

.status { font-size: 13.5px; color: var(--ink-soft); min-height: 18px; }
.status.error { color: var(--red); }
.status.ok { color: var(--green); }

.steps {
  margin: 0 0 16px;
  padding-left: 22px;
  font-size: 14px;
  color: var(--ink);
}
.steps li { margin-bottom: 6px; }
.steps a { font-weight: 600; }

#paste-transcript {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
  background: #fbfcfe;
  transition: border-color 160ms var(--ease);
}
#paste-transcript:focus { border-color: var(--blue); background: #fff; outline: none; }

.fallback { margin-top: 20px; font-size: 14px; }
.fallback summary {
  cursor: pointer;
  color: var(--blue-dark);
  font-weight: 600;
  padding: 4px 0;
}
.fallback summary:hover { color: var(--blue); }
.fallback .row { margin-top: 12px; }

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 8px;
}
.points-badge {
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-bg);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
}
.progress-bar {
  height: 9px;
  background: #eef2f8;
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 22px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue) 0%, #22c55e 100%);
  border-radius: var(--radius-pill);
  width: 0%;
  transition: width 0.4s var(--ease);
}

.sentence-display {
  font-size: 25px;
  font-weight: 600;
  line-height: 1.65;
  margin: 0 0 10px;
  padding: 22px 24px;
  background: linear-gradient(155deg, var(--blue-tint) 0%, #f3faff 100%);
  border: 1px solid #d3ecfb;
  border-radius: var(--radius);
  color: var(--blue-deep);
}
.sentence-display .stress {
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
}
.linking-hint {
  font-size: 13.5px;
  color: var(--ink-soft);
  min-height: 18px;
  margin: 0 0 16px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.speed-group {
  display: inline-flex;
  gap: 4px;
  background: #eef2f8;
  padding: 4px;
  border-radius: var(--radius-pill);
}
.speed-btn {
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 140ms var(--ease);
}
.speed-btn:hover:not(.active) { color: var(--ink); }
.speed-btn.active {
  background: #fff;
  color: var(--amber);
  border-color: var(--amber-border);
  box-shadow: var(--shadow-sm);
}

.device-note { margin: -4px 0 14px; font-size: 12px; }

.mic-help summary { color: var(--ink-soft); font-weight: 600; }

.feedback-area {
  background: linear-gradient(155deg, #f9fbff 0%, #f4f8fc 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 16px;
  animation: feedback-in 280ms var(--ease);
}
@keyframes feedback-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.feedback-label { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.word-feedback { font-size: 18px; line-height: 1.9; margin: 0 0 8px; }
.word-feedback .word {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  margin: 2px 3px 2px 0;
  font-weight: 600;
}
.word-feedback .word.good { background: var(--green-bg); color: #157a3e; }
.word-feedback .word.needs { background: var(--red-bg); color: #a13139; }
.word-feedback .word.substituted { background: var(--amber-bg); color: #8a5a12; }
.word-feedback .word.substituted small { font-size: 11px; font-weight: 500; opacity: 0.85; }
.score-display { margin: 0; font-weight: 700; color: var(--blue-deep); }
#confidence-hint { margin: 8px 0 0; }
.compare-row { margin-top: 12px; margin-bottom: 0; }

.nav-row { margin-top: 6px; }

#finished h2 { font-size: 22px; }
#finished-summary { font-size: 15px; color: var(--ink-soft); }

.site-footer {
  text-align: center;
  color: var(--ink-faint);
  font-size: 12px;
  padding: 24px 16px 44px;
}

@media (max-width: 480px) {
  .site-header h1 { font-size: 26px; }
  .sentence-display { font-size: 20px; padding: 18px 18px; }
  .card { padding: 20px 18px 22px; }
}
