:root {
  color-scheme: light;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f1f4f7;
  --ink: #20242c;
  --muted: #697282;
  --line: #d8dee7;
  --primary: #315f9d;
  --primary-soft: #e8f0fb;
  --accent: #a55a43;
  --success: #24745f;
  --warning: #9a6a22;
  --error: #b34848;
  --button-radius: 8px;
  --card-radius: 12px;
  --dialog-radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
select,
textarea {
  font: inherit;
}

a,
pre,
code {
  overflow-wrap: anywhere;
}

pre,
code {
  max-width: 100%;
  white-space: pre-wrap;
}

button,
select {
  cursor: pointer;
}

.lesson-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 0 var(--space-5);
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--button-radius);
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
  overflow-wrap: anywhere;
}

.brand > span:last-child {
  min-width: 0;
}

.brand small,
.muted,
.scene-meta,
.status-text,
.translation {
  color: var(--muted);
}

.brand strong {
  font-size: 17px;
}

.brand small {
  margin-top: 2px;
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: flex-end;
  min-width: 0;
}

.select {
  min-width: 280px;
  max-width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 var(--space-3);
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.reader {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: minmax(320px, 40%) minmax(0, 60%);
  overflow: hidden;
}

.dialogue-pane {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  padding: var(--space-6);
  background: #f0f3f6;
}

.analysis-pane {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6);
  background: var(--surface);
}

.pane-head h1 {
  margin: var(--space-2) 0 var(--space-2);
  font-size: 26px;
  line-height: 1.2;
}

.status-text,
.scene-meta,
.section-kicker {
  margin: 0;
  font-size: 13px;
}

.scene-brief,
.analysis-card,
.core-block,
.personal-box,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
}

.scene-brief {
  margin: var(--space-5) 0;
  padding: var(--space-4);
}

.scene-brief strong {
  display: block;
  margin-bottom: var(--space-2);
}

.scene-brief p {
  margin: 0;
  color: #4d5664;
  line-height: 1.7;
}

#sceneTitle,
#sceneMeta,
.scene-brief p,
.utterance-original,
.utterance-zh,
#lineOriginal,
.translation,
.core-block h3,
.core-block p,
.analysis-card p,
.analysis-section,
.compact-list,
.example-item strong,
.example-item p,
.fold-body,
.info-block,
.personal-example {
  overflow-wrap: anywhere;
}

.transcript-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.utterance-button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--button-radius);
  background: transparent;
  padding: var(--space-3);
  text-align: left;
  color: inherit;
}

.utterance-button:hover,
.utterance-button:focus {
  border-color: #c7d4e4;
  background: rgba(255, 255, 255, 0.7);
  outline: none;
}

.utterance-button.is-key {
  background: #fff;
  border-color: var(--line);
}

.utterance-button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.utterance-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 12px;
  margin-bottom: var(--space-2);
}

.utterance-original {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 800;
}

.utterance-zh {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.detail-panel {
  width: 100%;
  max-width: 880px;
  min-width: 0;
}

.detail-topline,
.scene-nav,
.action-row,
.analysis-grid {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.scene-nav {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.scene-progress {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.detail-topline {
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.timecode,
.speaker-pill,
.score-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 var(--space-3);
  font-size: 12px;
  font-weight: 800;
}

.timecode {
  background: var(--surface-soft);
  color: #4d5664;
}

.speaker-pill {
  background: var(--primary-soft);
  color: var(--primary);
}

.score-pill {
  background: #f5ece5;
  color: var(--accent);
}

#lineOriginal {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
}

.translation {
  margin: var(--space-2) 0 var(--space-5);
  font-size: 17px;
}

.action-row {
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.button {
  min-height: 40px;
  border: 0;
  border-radius: var(--button-radius);
  padding: 0 var(--space-4);
  font-weight: 800;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: #4d5664;
}

.button.ghost.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.core-block {
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.section-kicker {
  display: block;
  color: var(--primary);
  font-weight: 900;
  margin-bottom: var(--space-2);
}

.core-block h3 {
  margin: 0 0 var(--space-2);
  font-size: 24px;
  line-height: 1.25;
}

.core-block p,
.analysis-card p,
.analysis-section p {
  line-height: 1.7;
}

.chunk-relation {
  display: inline-flex;
  max-width: 100%;
  margin: var(--space-3) 0 0;
  border-radius: var(--button-radius);
  background: var(--primary-soft);
  color: var(--primary);
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
  font-weight: 800;
}

.analysis-grid {
  align-items: stretch;
  margin-bottom: var(--space-5);
  min-width: 0;
}

.analysis-card {
  flex: 1;
  min-width: 0;
  padding: var(--space-4);
}

.analysis-section {
  margin-bottom: var(--space-5);
}

.compact-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.example-list {
  display: grid;
  gap: var(--space-3);
}

.example-item {
  min-width: 0;
  border-left: 3px solid var(--primary);
  background: var(--surface-soft);
  padding: var(--space-3) var(--space-4);
}

.example-item strong {
  display: block;
  font-size: 17px;
  line-height: 1.45;
}

.example-item p {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.fold {
  border-top: 1px solid var(--line);
  padding: var(--space-4) 0;
}

.fold summary {
  cursor: pointer;
  font-weight: 900;
}

.fold-body {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-4);
  line-height: 1.7;
}

.info-block {
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  padding: var(--space-3);
  background: #fbfcfe;
}

.info-block strong {
  display: block;
  margin-bottom: var(--space-1);
}

.personal-box {
  padding: var(--space-4);
  margin-top: var(--space-5);
}

.personal-box textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  padding: var(--space-3);
  line-height: 1.5;
  margin-bottom: var(--space-3);
}

.personal-examples {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.personal-example {
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  background: var(--surface-soft);
  padding: var(--space-3);
  line-height: 1.6;
}

.empty-state {
  width: 100%;
  max-width: 520px;
  padding: var(--space-6);
}

.empty-state p {
  color: var(--muted);
  line-height: 1.7;
}

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

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .lesson-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: var(--space-4);
    position: sticky;
    top: 0;
  }

  .topbar-actions,
  .select {
    width: 100%;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .reader {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .dialogue-pane {
    max-height: 46vh;
    overflow-y: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: var(--space-4);
  }

  .analysis-pane {
    overflow: visible;
    padding: var(--space-4);
  }

  .analysis-grid {
    flex-direction: column;
  }

  #lineOriginal {
    font-size: 24px;
  }
}
