:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #eef4f7;
  --text: #1d2433;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #176b87;
  --accent-2: #2f7d32;
  --warning: #a15c00;
  --shadow: 0 14px 40px rgba(29, 36, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: 0;
}

.source-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.file-loader {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  white-space: nowrap;
}

.file-loader input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  justify-content: flex-end;
}

.language-picker {
  min-width: 150px;
}

.language-picker select {
  min-height: 42px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  min-height: 88px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.toolbar {
  display: grid;
  grid-template-columns: 230px 150px 130px 210px minmax(240px, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="search"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.question-list,
.question-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.question-list {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.list-head button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.list-body {
  max-height: calc(100vh - 290px);
  overflow: auto;
}

.question-row {
  display: block;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.question-row:hover,
.question-row.active {
  background: var(--panel-2);
}

.question-row strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.question-row span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-detail {
  min-height: 640px;
  padding: 22px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.pill.answer {
  background: #e8f5e9;
  color: var(--accent-2);
}

.prompt {
  margin: 0 0 16px;
  font-size: 22px;
  line-height: 1.35;
}

.stimulus,
.image-panel,
.audio-panel {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.image-panel {
  display: block;
  padding: 0;
  overflow: hidden;
}

.audio-panel {
  display: flex;
  align-items: center;
  gap: 14px;
}

.image-panel img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.stimulus h3,
.audio-panel h3,
.options h3,
.explanation h3,
.json-block h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.speaker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease;
}

.speaker-button:hover {
  background: #0f5269;
  transform: translateY(-1px);
}

.speaker-button svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.audio-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.audio-panel audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.stimulus pre,
.json-block pre {
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.options {
  margin: 18px 0;
}

.option {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 44px;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.option.correct {
  border-color: #99d59d;
  background: #f0faf1;
}

.option .letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--panel-2);
  font-weight: 800;
}

.option.correct .letter {
  background: #c8e6c9;
  color: #1b5e20;
}

.explanation {
  margin-top: 16px;
  padding: 16px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #eff8fb;
}

.translation {
  color: var(--muted);
}

.json-block {
  margin-top: 16px;
}

.learning-shell h2 {
  margin: 0;
  font-size: 28px;
}

.learning-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.day-list,
.learning-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.day-list {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.learning-detail {
  min-height: 700px;
  padding: 22px;
}

.learning-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.tabbar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  padding: 0 12px;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.goal-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.goal-strip span {
  display: block;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: #344054;
  line-height: 1.45;
}

.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.flashcard {
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition:
    border-color 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.flashcard:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(23, 107, 135, 0.12);
  transform: translateY(-1px);
}

.flashcard-front,
.flashcard-back {
  display: flex;
  flex-direction: column;
  min-height: 228px;
  padding: 18px;
}

.flashcard-front span {
  align-self: flex-start;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.flashcard-front strong {
  margin-top: 22px;
  font-size: 30px;
  line-height: 1.1;
}

.flashcard-front small,
.flashcard-back small {
  margin-top: auto;
  color: var(--muted);
  line-height: 1.45;
}

.flashcard-back {
  display: none;
  background: #eff8fb;
}

.flashcard-back strong {
  color: var(--accent);
  font-size: 22px;
}

.flashcard-back p {
  margin: 12px 0;
  color: #344054;
  line-height: 1.55;
}

.flashcard-back em {
  display: block;
  margin-bottom: 12px;
  color: var(--text);
  font-style: normal;
  font-weight: 650;
  line-height: 1.5;
}

.flashcard.revealed .flashcard-front {
  display: none;
}

.flashcard.revealed .flashcard-back {
  display: flex;
}

.practice-list h3,
.lesson-panel h3 {
  margin: 0 0 14px;
  font-size: 22px;
}

.practice-card,
.lesson-panel {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.practice-prompt {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.practice-prompt span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.practice-prompt strong {
  line-height: 1.5;
}

.practice-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.practice-option {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}

.practice-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 800;
}

.practice-option.selected {
  border-color: var(--accent);
}

.practice-option.correct {
  border-color: #81c784;
  background: #f0faf1;
}

.practice-option.wrong {
  border-color: #ef9a9a;
  background: #fff5f5;
}

.practice-explanation {
  margin: 12px 0 0;
  padding: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #eff8fb;
  line-height: 1.55;
}

.lesson-panel p {
  color: #344054;
  line-height: 1.65;
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.pattern-grid code {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  white-space: normal;
}

.example-list {
  display: grid;
  gap: 8px;
}

.example-list p {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
}

.strategy-list {
  margin: 10px 0 0;
  padding-left: 22px;
  line-height: 1.65;
}

.strategy-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.strategy-table > div,
.strategy-drill {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.strategy-table strong,
.strategy-drill strong {
  color: var(--accent);
}

.strategy-table span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.strategy-table p,
.strategy-drill p {
  margin: 8px 0 0;
  line-height: 1.55;
}

.strategy-drill + .strategy-drill {
  margin-top: 10px;
}

@media (max-width: 980px) {
  .summary,
  .toolbar,
  .content-grid,
  .learning-layout,
  .goal-strip {
    grid-template-columns: 1fr;
  }

  .question-list,
  .day-list {
    position: static;
  }

  .list-body {
    max-height: 360px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .file-loader {
    justify-content: center;
  }

  .topbar-actions {
    display: grid;
    justify-content: stretch;
  }

  .question-detail {
    padding: 16px;
  }

  .prompt {
    font-size: 18px;
  }

  .learning-detail {
    padding: 16px;
  }

  .learning-head {
    display: block;
  }

  .tabbar,
  .flashcard-grid,
  .practice-options,
  .pattern-grid,
  .strategy-table {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .tabbar {
    display: grid;
    margin-top: 14px;
  }
}
