:root {
  color-scheme: light;
  --paper: #f6f4ee;
  --surface: #fffefa;
  --ink: #202c25;
  --muted: #526158;
  --forest: #23543c;
  --forest-dark: #153e2a;
  --leaf: #e7efe2;
  --line: #dedfd4;
  --soft: #f0f3ea;
  --warm: #745126;
  --warm-light: #f8edd9;
  --focus: #1b694c;
  --primary-fill: var(--forest);
  --primary-hover: var(--forest-dark);
  --primary-text: var(--surface);
  --control-border: var(--line);
  --field-border: #a7b7a4;
  --accent-border: #a6b8a0;
  --selected-border: #9bb49b;
  --tinted-border: #d7e0d2;
  --accent-rule: #8eab8c;
  --scope-background: #efeee6;
  --group-hover: #efefe5;
  --quiet-hover: #f4f7ef;
  --translation-ink: #394b41;
  --warm-border: #ead5af;
  --alert-ink: #663c18;
  --alert-border: #ecd8b7;
  --alert-rule: #ccac79;
  --panel-shadow: #303c2610;
  --ui: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --reading-en: Verdana, "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #000000;
  --surface: #101010;
  --ink: #e6e6e6;
  --muted: #b0b0b0;
  --forest: #cccccc;
  --forest-dark: #ededed;
  --leaf: #292929;
  --line: #303030;
  --soft: #171717;
  --warm: #d0d0d0;
  --warm-light: #202020;
  --focus: #f0f0f0;
  --primary-fill: #cccccc;
  --primary-hover: #e2e2e2;
  --primary-text: #101010;
  --control-border: #686868;
  --field-border: #787878;
  --accent-border: #727272;
  --selected-border: #8b8b8b;
  --tinted-border: #363636;
  --accent-rule: #9a9a9a;
  --scope-background: #141414;
  --group-hover: #1c1c1c;
  --quiet-hover: #242424;
  --translation-ink: #c5c5c5;
  --warm-border: #707070;
  --alert-ink: #e0e0e0;
  --alert-border: #707070;
  --alert-rule: #a0a0a0;
  --panel-shadow: transparent;
}

:root[data-theme="dark"] ::selection {
  background: var(--primary-fill);
  color: var(--primary-text);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 400 15px/1.6 var(--ui);
}

[lang="en"] {
  font-family: var(--reading-en);
  font-variant-ligatures: none;
  letter-spacing: .016em;
}

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

button,
select,
summary {
  cursor: pointer;
}

button,
select,
textarea {
  border: 1px solid var(--line);
  background: var(--surface);
}

select,
textarea {
  border-color: var(--control-border);
}

button:disabled {
  cursor: default;
  opacity: .45;
}

a {
  color: var(--forest);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}

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

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.sr-only,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link:focus {
  position: fixed;
  z-index: 2;
  top: 10px;
  left: 10px;
  padding: 8px 14px;
  background: var(--surface);
  border-radius: 8px;
}

.page-width {
  width: min(1200px, calc(100% - 80px));
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: .04em;
  white-space: nowrap;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary-fill);
}

.brand-mark i {
  width: 2px;
  height: 9px;
  border-radius: 2px;
  background: var(--primary-text);
}

.brand-mark i:nth-child(2) {
  height: 17px;
}

.brand-mark i:nth-child(3) {
  height: 12px;
}

.overall {
  width: 184px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.overall-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.overall-label strong {
  color: var(--forest);
}

.overall progress {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 5px;
  border: 0;
  border-radius: 5px;
  overflow: hidden;
  background: var(--leaf);
  accent-color: var(--forest);
}

.overall progress::-webkit-progress-bar {
  background: var(--leaf);
}

.overall progress::-webkit-progress-value {
  background: var(--forest);
}

.overall progress::-moz-progress-bar {
  background: var(--forest);
}

.layout {
  display: grid;
  grid-template-columns: 251px minmax(0, 1fr);
  gap: clamp(28px, 4vw, 58px);
  align-items: start;
  padding-block: 40px 60px;
}

.directory {
  position: sticky;
  top: 25px;
}

.desktop-directory h2,
.listening-directory-title {
  margin: 0 0 13px;
  font-size: 16px;
  font-weight: 750;
}

.scope-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--scope-background);
}

.scope-controls button {
  min-height: 36px;
  padding: 5px 4px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
}

.scope-controls button[aria-pressed="true"] {
  border-color: var(--line);
  color: var(--forest);
  background: var(--surface);
  font-weight: 700;
}

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

.group-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 10px;
  width: 100%;
  min-height: 51px;
  padding: 9px 12px 9px 15px;
  border-color: transparent;
  border-radius: 11px;
  text-align: left;
  background: transparent;
}

.group-button:hover {
  background: var(--group-hover);
}

.group-button[aria-current="true"] {
  border-color: var(--tinted-border);
  background: var(--leaf);
}

.group-label {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.group-meter {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.group-meter {
  padding: 0 6px;
}

.group-button[aria-current="true"] .group-label,
.group-button[aria-current="true"] .group-meter {
  color: var(--forest);
}

.mobile-directory {
  display: none;
}

.practice {
  min-width: 0;
}

.session-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.session-heading h1 {
  font-size: clamp(28px, 3.8vw, 43px);
  font-weight: 750;
  letter-spacing: -.035em;
  line-height: 1.18;
}

.session-count {
  flex-shrink: 0;
  padding-bottom: 2px;
  color: var(--forest);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.session-tip {
  margin-top: 11px;
  color: var(--muted);
  font-size: 14px;
}

.archive-message {
  margin-bottom: 13px;
  padding: 8px 12px;
  border: 1px solid var(--tinted-border);
  border-radius: 8px;
  background: var(--leaf);
  color: var(--forest-dark);
  font-size: .875rem;
}

.empty-shelf h1 {
  font-size: clamp(23px, 3vw, 32px);
  line-height: 1.3;
}

.empty-shelf p {
  margin-top: 6px;
  color: var(--muted);
}

.empty-shelf button {
  margin-top: 13px;
}

.clip-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-block: 20px 16px;
}

.clip-button {
  position: relative;
  min-width: 0;
  min-height: 42px;
  padding: 7px 4px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.clip-button:hover {
  border-color: var(--accent-border);
  color: var(--forest);
}

.clip-button[aria-current="true"] {
  border-color: var(--selected-border);
  background: var(--leaf);
  color: var(--forest-dark);
  font-weight: 750;
}

.clip-button[data-status="done"]::after,
.clip-button[data-status="retry"]::after {
  position: absolute;
  top: 5px;
  right: 7px;
  color: var(--forest);
  font-size: 11px;
  content: "✓";
}

.clip-button[data-status="retry"]::after {
  color: var(--warm);
  content: "↻";
}

.clip-panel,
.study-extras details {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 17px;
  box-shadow: 0 4px 16px var(--panel-shadow);
}

.clip-panel {
  padding: clamp(22px, 3.1vw, 37px);
}

.clip-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.clip-heading h2 {
  font-size: clamp(23px, 3vw, 32px);
  font-weight: 750;
  letter-spacing: -.025em;
  line-height: 1.24;
}

.clip-reference {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-bottom: 17px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.source-label {
  color: var(--forest);
  font-weight: 700;
}

.source-time {
  white-space: nowrap;
}

.pdf-link {
  flex-shrink: 0;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.pdf-link:hover {
  background: var(--leaf);
}

.player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(10px, 2vw, 18px);
  min-height: 76px;
  padding: 11px 14px;
  border: 1px solid var(--tinted-border);
  border-radius: 12px;
  background: var(--soft);
}

.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 94px;
  min-height: 44px;
  padding: 8px 13px;
  border-color: var(--primary-fill);
  border-radius: 8px;
  background: var(--primary-fill);
  color: var(--primary-text);
  font-size: 14px;
  font-weight: 700;
}

.play-button:hover,
.next-button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.play-icon {
  display: block;
  width: 10px;
  height: 12px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
}

.play-button[data-playing="true"] .play-icon {
  width: 10px;
  height: 12px;
  border: 0;
  border-inline: 3px solid currentColor;
}

.timeline {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.timeline input {
  width: 100%;
  height: 19px;
  margin: 0;
  accent-color: var(--forest);
  cursor: pointer;
}

.timeline input:disabled {
  cursor: default;
}

.audio-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  white-space: nowrap;
}

.speed,
.clip-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.speed select,
.clip-status select,
.mobile-directory select {
  min-height: 38px;
  padding: 3px 9px;
  border-radius: 8px;
  color: var(--ink);
}

.speed select {
  min-width: 68px;
}

.transcript {
  padding-top: 23px;
  margin-top: 23px;
  border-top: 1px solid var(--line);
}

.transcript-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.transcript-heading h3 {
  font-size: 15px;
  font-weight: 750;
}

.quiet-button,
.next-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--forest);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.quiet-button:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--quiet-hover);
}

.transcript-content {
  overflow-wrap: break-word;
}

.transcript-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-inline-start: 2px solid var(--accent-rule);
  border-radius: 4px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.transcript-columns,
.transcript-row {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  column-gap: 25px;
}

.transcript-columns {
  padding: 9px 0;
  color: var(--forest);
  font-size: 13px;
  font-weight: 700;
}

.transcript-row {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.original-text {
  font-size: clamp(1.0625rem, 1.5vw, 1.1875rem);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.translated-text {
  color: var(--translation-ink);
  font-size: 15px;
  line-height: 1.75;
}

.transcript-hidden {
  padding-block: 7px 11px;
  color: var(--muted);
  font-size: 14px;
}

.clip-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 17px;
  margin-top: 26px;
  border-top: 1px solid var(--line);
}

.clip-action-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.clip-status select[data-status="done"] {
  border-color: var(--tinted-border);
  background: var(--leaf);
  color: var(--forest-dark);
}

.clip-status select[data-status="retry"] {
  border-color: var(--warm-border);
  background: var(--warm-light);
  color: var(--warm);
}

.step-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.next-button {
  border-color: var(--primary-fill);
  background: var(--primary-fill);
  color: var(--primary-text);
}

.study-extras {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.study-extras details {
  border-radius: 11px;
  box-shadow: none;
}

.study-extras summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 47px;
  padding: 11px 17px;
  font-size: 14px;
  font-weight: 700;
  list-style: none;
}

.study-extras summary::-webkit-details-marker {
  display: none;
}

.study-extras summary::after {
  color: var(--forest);
  content: "+";
}

.study-extras details[open] summary::after {
  content: "−";
}

.details-content {
  padding: 0 17px 15px;
  overflow-wrap: break-word;
}

.details-content textarea {
  display: block;
  width: 100%;
  min-height: 82px;
  padding: 9px 12px;
  border-radius: 8px;
  resize: vertical;
  font-size: 14px;
}

.review-content {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.review-vocabulary {
  display: grid;
  justify-items: start;
  gap: 3px;
}

.review-grammar {
  color: var(--ink);
  font-weight: 700;
  white-space: pre-line;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.error-message {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--alert-border);
  border-radius: 8px;
  background: var(--warm-light);
  color: var(--alert-ink);
  font-size: 13px;
}

@media (max-width: 900px) {
  .page-width {
    width: calc(100% - 48px);
  }

  .layout {
    grid-template-columns: 205px minmax(0, 1fr);
    gap: 25px;
  }
}

@media (max-width: 700px) {
  .page-width {
    width: calc(100% - 32px);
  }

  .header-inner {
    min-height: 60px;
  }

  .brand {
    font-size: 17px;
    gap: 8px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
  }

  .overall {
    width: min(35vw, 140px);
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 19px;
    padding-block: 20px 36px;
  }

  .directory {
    position: static;
  }

  .desktop-directory {
    display: none;
  }

  .mobile-directory {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
  }

  .mobile-directory span {
    flex-shrink: 0;
  }

  .mobile-directory select {
    width: 100%;
    min-width: 0;
  }

  .session-tip {
    margin-top: 8px;
  }

  .clip-list {
    margin-block: 14px 11px;
    gap: 6px;
  }

  .clip-panel {
    padding: 17px;
    border-radius: 13px;
  }

  .clip-heading {
    margin-bottom: 5px;
  }

  .clip-reference {
    gap: 2px 7px;
    margin-bottom: 13px;
    font-size: 12px;
  }

  .player {
    gap: 9px;
    min-height: 66px;
    padding: 8px 9px;
  }

  .play-button {
    min-width: 71px;
    padding-inline: 8px;
    gap: 5px;
  }

  .speed {
    gap: 4px;
  }

  .speed span {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
  }

  .speed select {
    min-width: 0;
    padding-inline: 6px;
    font-size: 12px;
  }

  .transcript {
    padding-top: 15px;
    margin-top: 17px;
  }

  .transcript-columns {
    display: none;
  }

  .transcript-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .translated-text {
    padding: 8px 11px;
    border-radius: 7px;
    background: var(--soft);
  }

  .clip-actions {
    margin-top: 20px;
  }
}
