:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --surface: #ffffff;
  --surface-soft: #eef4ee;
  --ink: #1e2720;
  --muted: #66706a;
  --line: #dce4dc;
  --accent: #0f7c6b;
  --accent-dark: #0b5e52;
  --orange: #c96d22;
  --blue: #4267b2;
  --shadow: 0 16px 42px rgba(32, 48, 37, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Segoe UI",
    "Microsoft YaHei",
    Arial,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
}

.topbar {
  min-height: 78px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.topbar h1,
.lesson-head h2,
.section-title h2,
.control-panel h2,
.now-playing h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 25px;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.voice-area {
  min-width: 260px;
  display: grid;
  gap: 6px;
}

.browser-voice-controls {
  display: none;
  gap: 6px;
}

.voice-area.show-browser-voice .browser-voice-controls {
  display: grid;
}

.voice-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select {
  min-height: 38px;
  padding: 0 34px 0 10px;
}

textarea {
  min-height: 126px;
  padding: 10px;
  resize: vertical;
  line-height: 1.55;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: calc(100vh - 79px);
}

.sidebar {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid var(--line);
  background: #fbfcf8;
}

.control-panel {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(32, 48, 37, 0.05);
}

.control-panel h2 {
  margin-bottom: 12px;
  font-size: 16px;
}

.control-panel label + select,
.control-panel label + input {
  margin-top: 6px;
}

.control-panel select,
.control-panel input[type="range"] {
  margin-bottom: 13px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-button,
.secondary-button,
.primary-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 13px;
  font-weight: 750;
}

.mode-button {
  background: var(--surface-soft);
  color: var(--ink);
}

.mode-button.active {
  background: var(--accent);
  color: #fff;
}

.mode-help {
  margin-top: 10px;
  padding: 10px;
  display: grid;
  gap: 9px;
  border: 1px solid #d7e5dc;
  border-radius: 8px;
  background: #f8fbf7;
}

.mode-help p {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.mode-help span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.mode-help .primary-button {
  width: 100%;
}

.primary-button {
  min-width: 112px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 124, 107, 0.24);
}

.primary-button:hover,
.mode-button.active:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #e9f0ec;
  color: var(--accent-dark);
}

.icon-button {
  background: #f0eee8;
  color: #594f3f;
}

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

.toggle-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 650;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.source-tools {
  gap: 10px;
}

.source-tools button {
  width: 100%;
  margin-top: 8px;
}

.scan-result {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.scan-result strong {
  color: var(--ink);
}

.workspace {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 116px;
  padding: 20px;
  border-radius: 8px;
  background: #123b35;
  color: #fff;
  box-shadow: var(--shadow);
}

.player-band .eyebrow {
  color: #89e4d2;
}

.now-playing {
  min-width: 0;
}

.now-playing h2 {
  font-size: 23px;
  line-height: 1.28;
}

.now-meta {
  margin: 7px 0 0;
  color: #9be8d8;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.now-playing p:last-child {
  margin: 7px 0 0;
  color: #d5ebe5;
  line-height: 1.5;
}

.player-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.lesson-head {
  padding: 19px 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lesson-head h2 {
  font-size: 24px;
}

.lesson-head p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.mini-wave {
  width: 114px;
  min-width: 114px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mini-wave span {
  width: 8px;
  border-radius: 8px;
  background: var(--accent);
}

.mini-wave span:nth-child(1) {
  height: 22px;
}
.mini-wave span:nth-child(2) {
  height: 42px;
  background: var(--orange);
}
.mini-wave span:nth-child(3) {
  height: 62px;
}
.mini-wave span:nth-child(4) {
  height: 38px;
  background: var(--blue);
}
.mini-wave span:nth-child(5) {
  height: 54px;
}
.mini-wave span:nth-child(6) {
  height: 30px;
  background: var(--orange);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.scene-panel,
.chunk-panel,
.shadow-panel {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-title {
  min-height: 58px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.section-title h2 {
  font-size: 17px;
}

.scene-heading {
  display: grid;
  gap: 4px;
}

.scene-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.scene-tools {
  width: min(520px, 68%);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.section-title select {
  min-width: 0;
}

.dialogue-list,
.chunk-list {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.line-card,
.chunk-card {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.line-card {
  grid-template-columns: 108px minmax(0, 1fr) auto;
  align-items: start;
}

.line-card.has-notes {
  background: #fffdfa;
}

.speaker {
  color: var(--accent-dark);
  font-weight: 800;
}

.line-text {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.english {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}

.glossary-inline {
  display: inline;
  min-height: 0;
  padding: 0 2px 1px;
  border: 0;
  border-bottom: 1px dotted #b45f18;
  border-radius: 0;
  background: transparent;
  color: #8f4d14;
  font-weight: 800;
  line-height: inherit;
}

.glossary-inline:hover,
.glossary-inline.active {
  background: #fff0dc;
  color: #6f3807;
}

.chinese,
.chunk-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.line-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.line-notes > span {
  color: #8a4b19;
  font-size: 12px;
  font-weight: 850;
}

.line-note-chip {
  min-height: 26px;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #ead7bd;
  border-radius: 999px;
  background: #fff7ed;
  color: #7b4210;
}

.line-note-chip strong,
.line-note-chip em {
  font-size: 12px;
  line-height: 1.25;
}

.line-note-chip strong {
  font-weight: 850;
}

.line-note-chip em {
  color: #81634b;
  font-style: normal;
}

.line-note-chip:hover,
.line-note-chip.active {
  border-color: #c96d22;
  background: #ffecd4;
}

.line-card.active,
.line-card.active,
.line-card.shadow-selected,
.chunk-card.active {
  border-color: rgba(15, 124, 107, 0.55);
  background: #f2faf6;
  box-shadow: 0 8px 20px rgba(15, 124, 107, 0.12);
}

.play-line {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #edf4f0;
  color: var(--accent-dark);
  font-weight: 900;
}

.chunk-card {
  gap: 10px;
}

.chunk-main {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.chunk-phrase {
  font-size: 17px;
  font-weight: 850;
  line-height: 1.35;
}

.chunk-tag {
  height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f5efe8;
  color: #8a4b19;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.chunk-meta {
  display: grid;
  gap: 6px;
  padding: 9px;
  border-radius: 7px;
  background: #f7faf8;
  border: 1px solid #e2ebe5;
}

.chunk-meta div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.chunk-meta strong {
  color: #3f544c;
  font-size: 12px;
  line-height: 1.45;
}

.chunk-meta span {
  color: #26342e;
  font-size: 13px;
  line-height: 1.45;
}

.examples {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.examples li {
  padding: 7px 9px;
  border-radius: 7px;
  background: #f4f7f3;
  color: #2f3933;
  font-size: 14px;
  line-height: 1.45;
}

.authentic-examples {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid #d8e8df;
  border-radius: 7px;
  background: #fbfdf9;
}

.authentic-title {
  color: #41675b;
  font-size: 12px;
  font-weight: 700;
}

.authentic-examples ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.authentic-examples li {
  color: #26342e;
  font-size: 13px;
  line-height: 1.45;
}

.glossary-panel {
  border-top: 1px solid var(--line);
  background: #fcfbf6;
}

.glossary-title {
  min-height: 0;
  align-items: flex-start;
}

.glossary-detail {
  margin: 12px;
  padding: 12px;
  border: 1px solid #eadfce;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.glossary-detail-term {
  color: #17241f;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.glossary-detail-zh {
  margin-top: 3px;
  color: #8a4b19;
  font-weight: 850;
}

.glossary-detail-ipa {
  margin-top: 6px;
  color: #2f635a;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
}

.glossary-detail p {
  margin: 8px 0 0;
}

.glossary-detail-example {
  margin-top: 9px;
  padding: 8px 9px;
  border-radius: 7px;
  background: #f5f8f5;
  color: #303b35;
}

.glossary-list {
  padding: 0 12px 12px;
  display: grid;
  gap: 7px;
}

.glossary-item {
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #e3e9e2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.glossary-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.glossary-item strong {
  color: #8a4b19;
  font-size: 13px;
  white-space: nowrap;
}

.glossary-item:hover,
.glossary-item.active {
  border-color: rgba(201, 109, 34, 0.6);
  background: #fff7ed;
}

.hidden-text .english,
.hidden-cn .chinese {
  display: none;
}

.hidden-notes .line-notes {
  display: none;
}

.shadow-panel {
  min-height: 0;
}

.shadow-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.shadow-label {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.shadow-english {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.55;
}

.shadow-chinese,
.record-status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.shadow-chinese {
  margin-top: 5px;
}

.shadow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.shadow-actions button {
  min-width: 116px;
}

.record-status {
  margin: 0;
}

.storybook-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.storybook-hidden {
  display: none !important;
}

.storybook-stage {
  padding: 14px;
}

.storybook-scene {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 410px;
  overflow: hidden;
  border-radius: 8px;
  background: #18241f;
  border: 1px solid #d4dfd8;
  isolation: isolate;
}

.storybook-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
}

.storybook-photo-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(8, 18, 16, 0.12), rgba(8, 18, 16, 0.2) 44%, rgba(8, 18, 16, 0.75)),
    linear-gradient(90deg, rgba(8, 18, 16, 0.45), rgba(8, 18, 16, 0.04) 52%, rgba(8, 18, 16, 0.28));
}

.storybook-props,
.storybook-caption {
  position: absolute;
  z-index: 2;
}

.storybook-props {
  left: 16px;
  right: 16px;
  top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.storybook-prop {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(6, 16, 14, 0.48);
  color: #fff;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.storybook-prop.active {
  background: rgba(255, 214, 76, 0.92);
  border-color: #ffe486;
  color: #2a2208;
  box-shadow: 0 0 0 4px rgba(255, 220, 92, 0.28), 0 10px 28px rgba(0, 0, 0, 0.22);
}

.storybook-prop strong,
.storybook-prop span {
  display: block;
  line-height: 1.25;
}

.storybook-prop strong {
  font-size: 13px;
}

.storybook-prop span {
  color: inherit;
  opacity: 0.82;
  font-size: 12px;
}

.storybook-caption {
  left: 18px;
  right: 18px;
  bottom: 18px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  align-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 40px rgba(28, 38, 33, 0.16);
}

.caption-speaker {
  align-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e7f1ed;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.caption-english {
  color: #17241f;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.35;
}

.caption-chinese {
  grid-column: 2;
  color: #5e6b64;
  font-size: 15px;
  line-height: 1.45;
}

.storybook-empty {
  height: 100%;
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 1080px) {
  .layout {
    display: flex;
    flex-direction: column;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .workspace {
    order: 1;
  }

  .sidebar {
    order: 2;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .topbar,
  .player-band,
  .lesson-head,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .voice-area,
  .scene-tools,
  .section-title select {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .scene-tools {
    grid-template-columns: 1fr;
  }

  .line-card {
    grid-template-columns: 1fr auto;
  }

  .speaker {
    grid-column: 1 / -1;
  }

  .player-actions {
    width: 100%;
  }

  .player-actions button {
    flex: 1;
  }

  .shadow-actions button {
    flex: 1 1 42%;
  }

  .storybook-scene {
    min-height: 470px;
  }

  .storybook-props {
    max-width: calc(100% - 28px);
  }

  .storybook-prop {
    min-width: 0;
    flex: 1 1 42%;
  }

  .caption-english {
    font-size: 17px;
  }
}
