:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #69777c;
  --line: #dbe7e6;
  --paper: #ffffff;
  --panel: #f6faf9;
  --accent: #177e89;
  --accent-dark: #0e5965;
  --mint: #74c7a6;
  --coral: #df7c5f;
  --lavender: #7b74c7;
  --green: #2f8a5e;
  --red: #b64a3a;
  --gold: #b98522;
  --shadow: 0 22px 70px rgba(25, 52, 60, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 16%, rgba(116, 199, 166, 0.28), transparent 24%),
    radial-gradient(circle at 88% 10%, rgba(223, 124, 95, 0.18), transparent 22%),
    linear-gradient(140deg, #eaf4f3 0%, #f8fbf8 48%, #eef1fb 100%);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(23, 126, 137, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 126, 137, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.68), transparent 72%);
}

.page-art {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.art-shape {
  position: absolute;
  display: block;
  opacity: 0.42;
}

.art-headphones {
  top: 78px;
  left: max(18px, calc((100vw - 1320px) / 2 - 112px));
  width: 96px;
  height: 78px;
  border: 9px solid rgba(23, 126, 137, 0.24);
  border-bottom: 0;
  border-radius: 70px 70px 18px 18px;
}

.art-headphones::before,
.art-headphones::after {
  position: absolute;
  bottom: -25px;
  width: 23px;
  height: 42px;
  content: "";
  background: rgba(23, 126, 137, 0.22);
  border-radius: 12px;
}

.art-headphones::before {
  left: -12px;
}

.art-headphones::after {
  right: -12px;
}

.art-book {
  right: max(18px, calc((100vw - 1320px) / 2 - 118px));
  bottom: 86px;
  width: 108px;
  height: 76px;
  border: 8px solid rgba(123, 116, 199, 0.22);
  border-radius: 12px 12px 18px 18px;
  transform: rotate(-7deg);
}

.art-book::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 4px;
  content: "";
  background: rgba(123, 116, 199, 0.2);
  border-radius: 999px;
}

.art-book::after {
  position: absolute;
  top: 17px;
  left: 17px;
  width: 22px;
  height: 5px;
  content: "";
  background: rgba(223, 124, 95, 0.24);
  border-radius: 999px;
  box-shadow: 0 16px 0 rgba(23, 126, 137, 0.18), 48px 0 0 rgba(223, 124, 95, 0.2), 48px 16px 0 rgba(23, 126, 137, 0.16);
}

.art-wave {
  width: 120px;
  height: 64px;
  background:
    linear-gradient(90deg, transparent 0 10px, rgba(223, 124, 95, 0.28) 10px 16px, transparent 16px 26px),
    linear-gradient(90deg, transparent 0 16px, rgba(23, 126, 137, 0.24) 16px 23px, transparent 23px 36px);
  background-size: 28px 64px, 44px 64px;
  border-radius: 12px;
}

.art-wave-one {
  top: 42px;
  right: max(20px, calc((100vw - 1320px) / 2 - 96px));
  transform: rotate(8deg);
}

.art-wave-two {
  left: max(20px, calc((100vw - 1320px) / 2 - 118px));
  bottom: 118px;
  transform: rotate(-10deg);
}

.art-bubble {
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.92), transparent 34%),
    rgba(116, 199, 166, 0.2);
  box-shadow: 0 0 0 12px rgba(255, 255, 255, 0.18);
}

.art-bubble-one {
  top: 48%;
  left: max(22px, calc((100vw - 1320px) / 2 - 76px));
  width: 34px;
  height: 34px;
}

.art-bubble-two {
  top: 34%;
  right: max(26px, calc((100vw - 1320px) / 2 - 72px));
  width: 44px;
  height: 44px;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.88), transparent 34%),
    rgba(223, 124, 95, 0.18);
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  width: min(1320px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(221, 228, 227, 0.9);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(246, 250, 249, 0.94)),
    var(--panel);
  border-right: 1px solid var(--line);
}

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

.logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(145deg, var(--accent), var(--lavender));
  border-radius: 14px;
  font-weight: 850;
  box-shadow: 0 12px 26px rgba(23, 126, 137, 0.28);
}

.logo-mark {
  position: relative;
  z-index: 1;
}

.logo-wave {
  position: absolute;
  right: -10px;
  bottom: 8px;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
}

.logo-wave::before {
  position: absolute;
  inset: 7px;
  content: "";
  border: 3px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p,
.hint,
.empty,
#audioHint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(219, 231, 230, 0.85);
  border-radius: 12px;
}

.panel h2,
.section-row h2 {
  font-size: 15px;
}

.file-picker {
  display: grid;
  place-items: center;
  min-height: 46px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(23, 126, 137, 0.2);
}

.file-picker input {
  display: none;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.text-button {
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.set-list {
  display: grid;
  gap: 8px;
  max-height: 460px;
  overflow: auto;
}

.set-item {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.set-item:hover,
.set-item.active {
  border-color: rgba(34, 108, 131, 0.5);
  background: linear-gradient(135deg, #eef9f7, #f5f4ff);
  transform: translateY(-1px);
}

.set-item strong {
  font-size: 14px;
  line-height: 1.25;
}

.set-item span {
  color: var(--muted);
  font-size: 12px;
}

.practice {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
  min-width: 0;
  position: relative;
}

.practice::before {
  position: absolute;
  top: 20px;
  right: 28px;
  width: 170px;
  height: 72px;
  pointer-events: none;
  content: "";
  opacity: 0.18;
  background:
    linear-gradient(90deg, transparent 0 8px, var(--accent) 8px 13px, transparent 13px 20px),
    linear-gradient(90deg, transparent 0 16px, var(--coral) 16px 22px, transparent 22px 32px);
  background-size: 32px 72px, 44px 72px;
  border-radius: 12px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.12;
  letter-spacing: 0;
  max-width: 760px;
}

.toolbar,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
}

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

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

.secondary-button {
  color: var(--accent-dark);
  background: #e8f1f3;
  border: 1px solid #cfe0e5;
  transition: transform 0.15s ease, background 0.15s ease;
}

.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

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

.audio-card {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 16px;
  background: linear-gradient(135deg, rgba(238, 249, 247, 0.95), rgba(248, 247, 255, 0.95));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(28, 48, 56, 0.08);
}

audio {
  width: 100%;
}

.audio-controls {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.seek-controls,
.sleep-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sleep-controls {
  align-items: center;
}

#sleepStatus {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #d6e4e5;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.seek-button,
.sleep-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid #cfe0e5;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
}

.seek-button:hover,
.sleep-button:hover,
.sleep-button.active {
  background: #e8f1f3;
}

.sleep-button.active {
  border-color: rgba(23, 126, 137, 0.45);
}

.sleep-button.ghost {
  color: var(--red);
}

.sleep-button:disabled {
  color: #98a3a6;
  cursor: not-allowed;
  background: #f2f5f5;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.meta-grid div {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbfb);
  box-shadow: 0 8px 20px rgba(28, 48, 56, 0.05);
}

.meta-grid span {
  display: block;
  font-size: 24px;
  font-weight: 850;
}

.meta-grid small {
  color: var(--muted);
}

.questions-list {
  display: grid;
  gap: 13px;
  margin-top: 14px;
}

.question-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfd;
  box-shadow: 0 8px 20px rgba(28, 48, 56, 0.05);
}

.question-group {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
}

.question-group span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-dark), var(--lavender));
  border-radius: 8px;
  font-size: 13px;
  font-weight: 850;
}

.material-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  color: #263235;
  background: linear-gradient(135deg, #f8fbfb, #f4f7ff);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(28, 48, 56, 0.05);
}

.material-title {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 850;
}

.material-body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.4;
}

.segment-play-button,
.segment-transcript-button,
.segment-questions-button,
.segment-answer-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 850;
}

.segment-play-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.segment-play-button:hover {
  background: var(--accent-dark);
}

.segment-transcript-button,
.segment-questions-button,
.segment-answer-button {
  color: var(--accent-dark);
  background: #eef7f6;
  border: 1px solid #cfe0e5;
}

.segment-transcript-button:hover,
.segment-questions-button:hover,
.segment-answer-button:hover {
  background: #dff0ee;
}

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

.segment-loop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid #cfe0e5;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.segment-loop input {
  accent-color: var(--accent);
}

.segment-questions-panel {
  display: grid;
  grid-column: 1 / -1;
  gap: 10px;
  margin-top: 4px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #e1ecea;
  border-radius: 10px;
}

.segment-questions-panel[hidden] {
  display: none;
}

.segment-question-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #fbfdfd;
  border: 1px solid #e4ece8;
  border-radius: 10px;
}

.segment-question-card h5 {
  margin: 0;
  color: #142326;
  font-size: 14px;
  line-height: 1.45;
}

.segment-question-card ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.segment-question-card li {
  padding: 9px 10px;
  overflow-wrap: anywhere;
  background: #fff;
  border: 1px solid #e1e8e7;
  border-radius: 8px;
  line-height: 1.45;
}

.segment-question-card li strong {
  color: var(--accent-dark);
}

.segment-question-answer {
  display: none;
  gap: 8px;
  padding: 10px;
  color: #334044;
  background: #f0f8f6;
  border: 1px solid #d4e6e3;
  border-radius: 8px;
  line-height: 1.5;
}

.show-answers .segment-question-answer {
  display: grid;
}

.show-segment-answers .segment-question-answer {
  display: grid;
}

.show-answers .segment-question-card li.correct-option {
  border-color: rgba(47, 138, 94, 0.44);
  background: #eef8f3;
}

.show-segment-answers .segment-question-card li.correct-option {
  border-color: rgba(47, 138, 94, 0.44);
  background: #eef8f3;
}

.segment-question-answer p,
.segment-question-empty {
  margin: 0;
}

.segment-evidence-line {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  width: 100%;
  padding: 9px 10px;
  color: #243235;
  text-align: left;
  background: #fff;
  border: 1px solid #cfe0e5;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.5;
}

.segment-evidence-line span,
.segment-evidence-line strong {
  color: var(--accent-dark);
  font-weight: 850;
  white-space: nowrap;
}

.segment-evidence-line:hover {
  background: #e9f4f2;
}

.segment-evidence-empty {
  color: var(--muted);
}

.segment-locate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment-locate-button {
  min-height: 32px;
  padding: 0 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.segment-locate-button:hover {
  background: var(--accent-dark);
}

.segment-transcript {
  display: grid;
  grid-column: 1 / -1;
  gap: 0;
  margin-top: 4px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid #e1ecea;
  border-radius: 10px;
}

.segment-transcript[hidden] {
  display: none;
}

.segment-transcript-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid #e6eeec;
}

button.segment-transcript-row {
  width: 100%;
  color: inherit;
  text-align: left;
  background: transparent;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  cursor: pointer;
}

.segment-transcript-row.clickable:hover,
.segment-transcript-row.playing {
  background: #f0f8f6;
}

.segment-transcript-row:last-child {
  border-bottom: 0;
}

.segment-transcript-row p,
.segment-transcript-empty {
  margin: 0;
  line-height: 1.58;
}

.segment-transcript-time {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.58;
}

.segment-transcript-en {
  color: #172126;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.58;
}

.segment-transcript-zh,
.segment-transcript-empty {
  color: #465558;
  line-height: 1.58;
}

.question-card.correct {
  border-color: rgba(47, 125, 85, 0.5);
}

.question-card.wrong {
  border-color: rgba(182, 74, 58, 0.55);
}

.question-card h4 {
  margin: 0 0 12px;
  font-size: 16px;
  line-height: 1.45;
  color: #142326;
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e1e8e7;
  border-radius: 10px;
  line-height: 1.42;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option input {
  flex: 0 0 auto;
  margin-top: 3px;
}

.option span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.option strong {
  color: var(--accent-dark);
}

.option:hover {
  border-color: rgba(23, 126, 137, 0.45);
  background: #f4fbfa;
}

.answer-line {
  display: none;
  margin-top: 12px;
  color: var(--green);
  font-weight: 850;
}

.explanation {
  display: none;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.45;
}

.show-answers .answer-line,
.show-answers .explanation,
.submitted .answer-line,
.submitted .explanation {
  display: block;
}

.source-note {
  margin-top: 10px;
  color: var(--gold);
  font-size: 12px;
  line-height: 1.4;
}

.transcript {
  display: none;
  margin-top: 14px;
  padding: 16px;
  color: #273235;
  background: #fbfdfd;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(28, 48, 56, 0.05);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.72;
  white-space: pre-wrap;
}

.transcript.bilingual {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  white-space: normal;
}

.bilingual-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #e6eeec;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.72), rgba(248, 251, 251, 0.72));
}

.bilingual-row:last-child {
  border-bottom: 0;
}

.bilingual-row p {
  margin: 0;
}

.bilingual-en {
  color: #1e2a2d;
}

.bilingual-zh {
  color: #435153;
}

.transcript.visible {
  display: block;
}

.transcript-frame {
  display: none;
  width: 100%;
  min-height: 620px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.transcript-frame.visible {
  display: block;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    width: 100%;
    min-height: 100vh;
    margin: 0;
  }

  .page-art {
    display: none;
  }

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

  .topbar,
  .audio-card {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .material-card,
  .segment-transcript-row {
    grid-template-columns: 1fr;
  }

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

  .bilingual-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
