:root {
  --bg: #02040b;
  --panel: rgba(12, 15, 25, 0.9);
  --card: #0f1729;
  --border: rgba(255, 255, 255, 0.18);
  --accent: #5dd69b;
  --accent-2: #f6d365;
  --text: #f5f5ff;
  --muted: #9ba1c5;
  font-family: "Inter", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, rgba(93, 214, 155, 0.2), transparent 40%),
              radial-gradient(circle at 70% 0%, rgba(246, 211, 101, 0.2), transparent 45%),
              linear-gradient(180deg, #01030d, #04040f 60%, #010104);
  color: var(--text);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

header.site-header {
  background: var(--panel);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.site-title {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3rem);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-links a {
  border-radius: 999px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  color: var(--text);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.nav-links a.active,
.nav-links a:hover {
  border-color: var(--accent);
  background: rgba(93, 214, 155, 0.16);
}

.section-title {
  margin: 36px 0 16px;
  font-size: 1.35rem;
}

.card,
.question-card,
.practice-card {
  background: var(--card);
  border-radius: 24px;
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.module-panel {
  margin-top: 36px;
  display: none;
}
.module-panel[data-active] {
  display: block;
}

.hidden {
  display: none !important;
}

.module-shell {
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 20px;
  background: rgba(15, 23, 42, 0.85);
  box-shadow: 0 20px 50px rgba(1, 1, 1, 0.4);
}

.module-launch {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 12px;
}

.launch-summary h2 {
  margin: 0;
  font-size: 1.4rem;
}

.launch-summary .feedback {
  margin: 0;
}

.launch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
}

.mode-field {
  flex: 1;
  min-width: 220px;
}

.module-buttons {
  display: flex;
  gap: 10px;
}

.question-prompt {
  margin: 12px 0;
  font-size: 1rem;
  color: var(--muted);
  min-height: 42px;
}

.highlighted-word {
  color: var(--accent);
  font-weight: 700;
}

.highlighted-prompt {
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.explanation {
  margin-top: 18px;
  border-radius: 18px;
  border: 1px solid rgba(93, 214, 155, 0.25);
  background: rgba(93, 214, 155, 0.06);
  padding: 16px;
}

.explanation.hidden {
  display: none;
}

.explanation-list {
  margin: 8px 0;
  padding-left: 20px;
  color: var(--text);
}
.translation-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.translation-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.translation-card textarea {
  min-height: 120px;
}

.translation-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.translation-result {
  border-radius: 18px;
  border: 1px solid rgba(93, 214, 155, 0.4);
  padding: 18px;
  background: rgba(93, 214, 155, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.translation-result.hidden {
  display: none;
}

.translation-heading {
  margin: 0;
  font-size: 1.5rem;
}

.translation-meaning {
  margin: 0;
  font-size: 1.2rem;
}

.translation-result .explanation-list {
  margin: 0;
  padding-left: 20px;
}

.stroke-plan-shell {
  margin-top: 12px;
}

.stroke-plan-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: grid;
  gap: 6px;
}

.stroke-plan-list li {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.02);
}

.stroke-plan-list li .stroke-label {
  font-weight: 600;
  color: var(--accent);
}

.stroke-plan-shell h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.word-preview {
  font-size: 1.4rem;
  margin: 0;
}

.translation-highlight {
  font-weight: 600;
  color: var(--accent);
}

.listening-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.listening-word {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  min-width: 140px;
  text-align: center;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.stroke-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

#stroke-canvas {
  width: 100%;
  max-width: 360px;
  height: 220px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
  cursor: crosshair;
  touch-action: none;
}

.stroke-display {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stroke-stage {
  position: relative;
  display: inline-block;
  touch-action: none;
}

.stroke-ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(4.5rem, 8vw, 7rem);
  color: rgba(255, 255, 255, 0.15);
  font-weight: 700;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ghost-hidden {
  opacity: 0;
}

.question-card.active-question {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(93, 214, 155, 0.4), inset 0 0 0 1px rgba(93, 214, 155, 0.3);
  background: rgba(93, 214, 155, 0.04);
}

.radical-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.radical-card {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  min-height: 120px;
}

.radical-card h3 {
  margin: 0;
  font-size: 1.4rem;
}

.radical-card p {
  margin: 4px 0;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.control-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.control-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 14px;
  color: var(--text);
}

.chip-row,
.level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip,
.level-button {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 10px 18px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.chip.active,
.level-button.active {
  border-color: var(--accent);
  background: rgba(93, 214, 155, 0.15);
}

.options-grid {
  display: grid;
  gap: 12px;
}

.options-grid button {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.options-grid button.correct {
  border-color: rgba(93, 214, 155, 0.8);
  background: rgba(93, 214, 155, 0.2);
}

.options-grid button.wrong {
  border-color: rgba(246, 101, 101, 0.8);
  background: rgba(246, 101, 101, 0.2);
}

.gradient-text {
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.listening-display {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.listening-timeline {
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
  --listening-progress: 0;
}

.listening-timeline::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, #e05353, #5dd69b);
  transform-origin: left;
  transform: scaleX(var(--listening-progress));
  transition: transform 0.2s ease;
}

.listening-history-card {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  margin-top: 10px;
}

.listening-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.listening-history-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.listening-history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

.listening-history-list li.correct-entry {
  border-color: rgba(93, 214, 155, 0.5);
  background: rgba(93, 214, 155, 0.1);
}

.listening-history-list li .history-word {
  font-weight: 600;
}

.listening-history-list li .history-accuracy {
  min-width: 60px;
  text-align: right;
}

.listening-history-list li .history-transcript {
  display: inline-block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 8px;
}

.module-panel[data-active] .module-shell {
  border-color: var(--accent);
  box-shadow: 0 25px 60px rgba(93, 214, 155, 0.35);
}

.feedback {
  font-size: 0.85rem;
  color: var(--muted);
}

textarea {
  min-height: 90px;
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 14px;
  font-size: 1rem;
}

button.primary,
button.secondary {
  border-radius: 14px;
  border: none;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #050506;
}

button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.vocab-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vocab-card .word {
  font-size: 1.5rem;
  font-weight: 600;
}

.vocab-card .level-badge {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.source-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 640px) {
  header.site-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
