:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #64717f;
  --line: #d9e2e7;
  --paper: #ffffff;
  --soft: #f4f7f6;
  --blue: #154273;
  --blue-2: #0f6f8f;
  --green: #23735a;
  --coral: #b45a4d;
  --cream: #fff7e8;
  --yellow: #f6c85f;
  --shadow: 0 14px 34px rgba(18, 39, 56, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 27px;
}

h2 {
  font-size: 27px;
}

h2 small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 750;
}

.app-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.search,
.group-filter {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input,
.group-filter select {
  width: min(42vw, 360px);
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: white;
}

.group-filter select {
  width: 150px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 16px) 18px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 10px) 18px / 6px 6px no-repeat,
    white;
}

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

.sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
  height: calc(100vh - 86px);
  overflow: auto;
  padding: 22px 18px;
  background: #e8f0ef;
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-grid div {
  padding: 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-grid strong,
.stat-grid span {
  display: block;
}

.stat-grid strong {
  font-size: 28px;
  color: var(--blue);
}

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

.lesson-list {
  display: grid;
  gap: 6px;
}

.lesson-item {
  width: 100%;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.lesson-item:hover {
  background: rgba(255, 255, 255, 0.74);
}

.lesson-item.active {
  border-color: #8eb8c9;
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(21, 66, 115, 0.1);
}

.lesson-item strong {
  display: inline-block;
  margin-right: 6px;
  color: var(--blue);
  font-size: 12px;
}

.lesson-item .lesson-title-nl {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-item .lesson-title-zh {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.lesson-item small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  padding: clamp(18px, 3.4vw, 42px);
}

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

.lesson-actions,
.toolbar,
.audio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button,
.link-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: white;
  background: var(--blue);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 25px;
  font-weight: 850;
  line-height: 1;
}

button:hover,
.link-button:hover {
  filter: brightness(1.06);
}

button:disabled {
  cursor: not-allowed;
  filter: none;
  opacity: 0.55;
}

.ghost {
  border: 1px solid var(--line);
  color: var(--blue);
  background: white;
}

.toolbar {
  margin-bottom: 22px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.view-tab.active {
  background: var(--green);
}

.lesson-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #cfe1da;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #f4fbf7;
  color: #31505e;
  box-shadow: var(--shadow);
}

.lesson-status strong {
  color: var(--green);
  font-size: 15px;
}

.lesson-status span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 720;
}

.lesson-status.needs-work {
  border-color: #edd2ca;
  border-left-color: var(--coral);
  background: #fff8f5;
}

.lesson-status.needs-work strong {
  color: var(--coral);
}

.lesson-meta,
.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lesson-meta {
  margin-top: 12px;
}

.lesson-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: #31505e;
  background: white;
  font-size: 13px;
  font-weight: 700;
}

.content {
  display: grid;
  gap: 18px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.summary-card,
.sentence-card,
.question-card,
.task-set,
.media-card,
.text-block {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-card {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  cursor: pointer;
}

.summary-card:hover {
  border-color: #8eb8c9;
}

.summary-card p,
.summary-card span,
.media-card p {
  margin: 0;
  color: var(--muted);
}

.summary-card strong {
  color: var(--blue);
  font-size: 32px;
}

.section h3,
.task-set h3 {
  margin: 0;
  font-size: 20px;
}

.text-block {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 18px;
  line-height: 1.75;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.word-card {
  position: relative;
  display: grid;
  gap: 16px;
  min-height: 166px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.word-card.marked {
  border-color: var(--yellow);
  background: var(--cream);
}

.sentence-list,
.block-list,
.pronunciation-list,
.task-list {
  display: grid;
  gap: 14px;
}

.practice-sounds .pronunciation-list {
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}

.practice-words .pronunciation-list {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.learning-stack {
  display: grid;
  gap: 18px;
}

.basic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.basic-card,
.audio-image-card,
.practice-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.basic-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.basic-media,
.audio-image-media,
.inline-media {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfd;
}

.basic-media {
  aspect-ratio: 4 / 3;
}

.basic-media img,
.audio-image-media img,
.inline-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.basic-body {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.practice-section {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.practice-section-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.3;
}

.practice-section-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.audio-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.audio-image-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  box-shadow: none;
}

.audio-image-media {
  aspect-ratio: 4 / 3;
}

.audio-image-body .nl,
.basic-body .nl {
  margin-bottom: 4px;
  font-size: 20px;
  line-height: 1.25;
}

.audio-image-body .zh,
.basic-body .zh {
  font-size: 17px;
}

.inline-media {
  width: min(100%, 360px);
  aspect-ratio: 4 / 3;
  margin-top: 12px;
}

.inline-media.multi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  width: min(100%, 620px);
  aspect-ratio: auto;
  gap: 8px;
  padding: 8px;
}

.inline-media.multi img {
  min-height: 110px;
}

.sentence-card,
.block-card,
.pronunciation-card {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
}

.practice-sounds .pronunciation-card {
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  box-shadow: none;
}

.practice-words .pronunciation-card {
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 11px;
  box-shadow: none;
}

.practice-sounds .line-number {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 12px;
}

.practice-words .line-number {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 12px;
}

.practice-sounds .pronunciation-label {
  margin-bottom: 2px;
  font-size: 11px;
}

.practice-words .pronunciation-label {
  margin-bottom: 2px;
  font-size: 11px;
}

.practice-sounds .pronunciation-text {
  font-size: 22px;
  line-height: 1.15;
}

.practice-words .pronunciation-text {
  font-size: 19px;
  line-height: 1.2;
}

.practice-words .zh {
  margin-top: 3px;
  font-size: 14px;
}

.practice-sounds .audio-actions {
  grid-column: 1 / -1;
  gap: 6px;
}

.practice-words .audio-actions {
  grid-column: 1 / -1;
  gap: 6px;
}

.practice-sounds .audio-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.practice-words .audio-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.sentence-card .audio-actions,
.sentence-card .mark-action,
.block-card .audio-actions,
.pronunciation-card .audio-actions {
  grid-column: 2;
}

.sentence-card.marked,
.block-card.marked,
.pronunciation-card.marked {
  border-color: var(--yellow);
  background: #fffaf0;
}

.line-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: white;
  background: var(--green);
  font-weight: 850;
}

.line-body {
  min-width: 0;
}

.line-body .nl {
  font-size: 22px;
  line-height: 1.45;
}

.short-text-card .line-body .nl {
  font-size: 20px;
  font-weight: 780;
}

.line-body .zh {
  font-size: 18px;
  line-height: 1.6;
}

.pronunciation-label {
  margin: 0 0 6px;
  color: var(--blue-2);
  font-size: 13px;
  font-weight: 850;
}

.pronunciation-text {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 850;
  line-height: 1.45;
}

.pronunciation-text.muted {
  color: var(--muted);
  font-size: 18px;
}

.sound-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.sound-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #d4e4eb;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #f8fcfd;
  font-size: 17px;
  font-weight: 850;
}

.pronunciation-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pronunciation-hints span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: #31505e;
  background: white;
  font-size: 13px;
  font-weight: 760;
}

.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.token-chip {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 58px;
  border: 1px solid #d4e4eb;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fcfd;
}

.token-nl {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.2;
}

.token-zh {
  overflow-wrap: anywhere;
  color: #31505e;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.25;
}

.mark {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--green);
  background: transparent;
}

.word-main {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  padding-right: 32px;
}

.word-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  background: var(--blue-2);
  font-weight: 800;
  font-size: 13px;
}

.nl {
  margin: 0 0 8px;
  font-size: 25px;
  font-weight: 850;
}

.lesson-tag {
  display: none;
  margin: 0 0 6px;
  color: var(--blue-2);
  font-size: 12px;
  font-weight: 800;
}

.global-results .lesson-tag {
  display: block;
}

.zh {
  margin: 0;
  color: #31505e;
  font-size: 22px;
  font-weight: 700;
}

.hide-zh .zh {
  visibility: hidden;
}

.hide-zh .token-zh {
  visibility: hidden;
}

.audio-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  background: var(--green);
}

.audio-actions.many {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, max-content));
  gap: 8px;
}

.audio-actions.many button {
  min-width: 72px;
}

.audio-actions .secondary {
  background: var(--blue-2);
}

.mark-action {
  min-height: 34px;
  justify-self: start;
  color: var(--green);
  background: #eef7f2;
}

.task-set {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.task-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.task-pager > span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.task-page {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--blue);
  background: white;
}

.task-page.active {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.task-set-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.task-set-head .zh {
  margin: 6px 0 0;
  font-size: 16px;
}

.question-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  box-shadow: none;
}

.question-card.correct {
  border-color: #80ba9c;
  background: #f1fbf5;
}

.question-card.wrong {
  border-color: #df9b92;
  background: #fff5f3;
}

.task-note {
  margin: 0;
  color: #8a463d;
  font-size: 14px;
  font-weight: 700;
}

.question-top {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.question-top p {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
}

.question-top .question-instruction {
  color: var(--blue);
  font-size: 15px;
  font-weight: 850;
}

.question-top .question-prompt {
  margin-top: 6px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 760;
}

.option {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
  text-align: center;
  font-weight: 760;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.option.has-media {
  padding: 10px;
  min-height: 112px;
}

.option-media {
  display: grid;
  place-items: center;
  width: 100%;
}

.option-media img {
  width: 100%;
  max-width: 180px;
  height: 92px;
  object-fit: contain;
}

.option-label {
  overflow-wrap: anywhere;
}

.option-zh {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.option.selected .option-zh,
.option.right-answer .option-zh {
  color: rgba(255, 255, 255, 0.86);
}

.missing-options {
  grid-column: 1 / -1;
  border: 1px dashed #d9a59d;
  border-radius: 8px;
  padding: 14px;
  color: #8a463d;
  background: #fff8f6;
  font-size: 14px;
  font-weight: 750;
}

.option-wrap {
  display: grid;
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: white;
}

.option-wrap .option {
  width: 100%;
}

.option-wrap .audio-actions {
  gap: 6px;
}

.option-wrap .audio-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.option-wrap.selected {
  border-color: var(--blue);
}

.option.selected {
  border-color: var(--blue);
  color: white;
  background: var(--blue);
}

.option.right-answer {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.ok {
  color: var(--green);
}

.bad {
  color: #a83c31;
}

.question-media img {
  max-width: min(100%, 260px);
  border-radius: 8px;
}

.question-media.multi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  max-width: 560px;
}

.question-media.multi img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  background: #f7fbfd;
  border: 1px solid var(--line);
  padding: 8px;
}

.question-media.compact img {
  max-width: min(100%, 180px);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.media-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.media-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  background: #edf3f6;
}

.media-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.media-card-footer .link-button {
  flex: 0 0 auto;
}

.read-aloud-card {
  gap: 10px;
}

.question-translation {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.task-set.compact-practice-task {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.compact-practice-task .task-set-head {
  grid-column: 1 / -1;
}

.pronunciation-task-card {
  align-content: start;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.pronunciation-task-main {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.pronunciation-task-main .word-index {
  width: 28px;
  height: 28px;
}

.pronunciation-task-main .question-prompt {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 17px;
  font-weight: 780;
}

.pronunciation-task-card .audio-actions {
  gap: 6px;
}

.pronunciation-task-card .audio-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.empty {
  padding: 28px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

@media (max-width: 860px) {
  .topbar,
  .lesson-head,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search input {
    width: 100%;
  }

  .sidebar-head {
    display: grid;
    align-items: stretch;
  }

  .group-filter select {
    width: 100%;
  }

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

  .sidebar {
    position: static;
    height: auto;
    max-height: 360px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar button,
  .toolbar .link-button {
    flex: 1 1 96px;
  }

  .task-set,
  .question-card,
  .practice-section {
    padding: 14px;
  }

  .task-set-head {
    display: grid;
  }

  .question-top {
    align-items: start;
  }

  .option-grid {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }

  .token-grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  }
}

/* Platform UI refresh */
:root {
  --ink: #17212b;
  --muted: #66727f;
  --line: #dce3e8;
  --line-strong: #c7d2da;
  --paper: #ffffff;
  --soft: #f5f7f8;
  --blue: #18558a;
  --blue-2: #15708a;
  --green: #18745b;
  --coral: #b44f45;
  --cream: #fff8e8;
  --yellow: #e4b546;
  --shadow: 0 8px 24px rgba(23, 33, 43, 0.07);
  --shadow-small: 0 2px 8px rgba(23, 33, 43, 0.06);
  --header-height: 96px;
}

* {
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--soft);
  line-height: 1.5;
}

button,
input,
select,
.link-button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.link-button:focus-visible,
.lesson-item:focus-visible {
  outline: 3px solid rgba(21, 112, 138, 0.24);
  outline-offset: 2px;
}

.mobile-menu-button,
.mobile-sidebar-head,
.sidebar-backdrop {
  display: none;
}

.topbar {
  height: var(--header-height);
  min-height: var(--header-height);
  z-index: 20;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 1px 0 var(--line), 0 8px 24px rgba(23, 33, 43, 0.04);
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 3px;
  font-size: 11px;
  letter-spacing: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.15;
}

h2 {
  font-size: 27px;
  line-height: 1.25;
}

.app-subtitle {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 650;
}

.top-actions {
  align-items: end;
  gap: 10px;
}

.search input,
.group-filter select {
  border-color: var(--line-strong);
  background-color: var(--paper);
  box-shadow: inset 0 1px 2px rgba(23, 33, 43, 0.03);
}

.search input {
  width: min(34vw, 380px);
}

.search input::placeholder {
  color: #87919b;
}

.layout {
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  padding: 20px 16px 28px;
  background: #f8fafb;
  border-color: var(--line);
  scrollbar-color: #c3cdd4 transparent;
  scrollbar-width: thin;
}

.sidebar-head {
  align-items: center;
  margin-bottom: 14px;
}

.sidebar-head h2 {
  font-size: 21px;
}

.stat-grid {
  gap: 8px;
  margin-bottom: 14px;
}

.stat-grid div {
  padding: 10px 12px;
  border-color: var(--line);
  box-shadow: var(--shadow-small);
}

.stat-grid strong {
  color: var(--ink);
  font-size: 22px;
}

.stat-grid span {
  margin-top: 1px;
  font-size: 12px;
}

.lesson-list {
  gap: 5px;
}

.lesson-item {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: start;
  gap: 2px 8px;
  min-height: 64px;
  padding: 9px 10px;
  border-radius: 6px;
}

.lesson-item::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: transparent;
  content: "";
}

.lesson-item:hover {
  background: #eef3f5;
}

.lesson-item.active {
  border-color: #b8ccd8;
  background: var(--paper);
  box-shadow: var(--shadow-small);
}

.lesson-item.active::before {
  background: var(--green);
}

.lesson-item strong {
  grid-row: 1 / 4;
  margin: 1px 0 0;
  font-size: 11px;
}

.lesson-item .lesson-title-nl,
.lesson-item .lesson-title-zh,
.lesson-item small {
  grid-column: 2;
  min-width: 0;
}

.lesson-item .lesson-title-nl {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 740;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.lesson-item .lesson-title-zh {
  margin-top: 0;
  font-size: 12px;
}

.lesson-item small {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.3;
}

.workspace {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px clamp(24px, 3vw, 44px) 56px;
}

.lesson-head {
  align-items: center;
  margin-bottom: 16px;
}

.lesson-actions,
.toolbar,
.audio-actions {
  gap: 8px;
}

button,
.link-button {
  min-height: 42px;
  border-radius: 7px;
  font-weight: 740;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover,
.link-button:hover {
  filter: none;
  transform: translateY(-1px);
}

.ghost:hover {
  border-color: #aebec9;
  background: #f7fafb;
}

.icon-button {
  width: 42px;
}

.lesson-meta {
  flex-wrap: nowrap;
  max-width: min(100%, 920px);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.lesson-meta::-webkit-scrollbar,
.toolbar::-webkit-scrollbar,
.task-pager::-webkit-scrollbar {
  display: none;
}

.lesson-meta span {
  flex: 0 0 auto;
  border-color: var(--line-strong);
  color: #42515d;
  background: #fbfcfd;
  font-size: 12px;
}

.toolbar {
  position: sticky;
  top: var(--header-height);
  z-index: 12;
  flex-wrap: nowrap;
  margin-bottom: 22px;
  overflow-x: auto;
  padding: 7px;
  border-color: var(--line-strong);
  background: rgba(245, 247, 248, 0.96);
  box-shadow: 0 5px 16px rgba(23, 33, 43, 0.05);
  backdrop-filter: blur(12px);
  scrollbar-width: none;
}

.toolbar button {
  flex: 0 0 auto;
  min-height: 38px;
  color: #43525e;
  background: transparent;
}

.toolbar .view-tab.active {
  color: white;
  background: var(--blue);
}

.toolbar #toggleZhBtn {
  margin-left: auto;
  border-color: transparent;
  background: var(--paper);
}

.content {
  gap: 16px;
}

.summary-card {
  min-height: 142px;
  padding: 17px;
  border-color: var(--line);
  box-shadow: var(--shadow-small);
}

.summary-card:hover {
  border-color: #a9bfcc;
  box-shadow: var(--shadow);
}

.summary-card strong {
  color: var(--ink);
  font-size: 30px;
}

.lesson-status {
  border-color: #c7ddd4;
  background: #f3faf7;
  box-shadow: none;
}

.practice-section,
.task-set {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.practice-section {
  padding: 0;
}

.practice-section-head,
.task-set-head {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line-strong);
}

.task-set {
  padding: 0;
}

.task-pager {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-small);
}

.sentence-card,
.block-card,
.pronunciation-card,
.question-card,
.basic-card,
.audio-image-card,
.media-card {
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-small);
}

.question-card {
  border-left: 3px solid #c8d7df;
}

.question-card.correct {
  border-left-color: var(--green);
}

.question-card.wrong {
  border-left-color: var(--coral);
}

.option {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: #fbfcfd;
}

.option:hover {
  border-color: #8facbd;
  background: #f2f7f9;
}

.option.selected {
  border-color: var(--blue);
  background: #edf5fb;
}

.empty {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-small);
}

@media (max-width: 1100px) and (min-width: 901px) {
  .topbar {
    padding-inline: 18px;
  }

  .app-subtitle {
    display: none;
  }

  .search input {
    width: min(31vw, 300px);
  }

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

  .sidebar {
    padding-inline: 12px;
  }

  .workspace {
    padding-inline: 24px;
  }

  .lesson-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  :root {
    --mobile-header-height: calc(112px + env(safe-area-inset-top));
  }

  body.course-menu-open {
    overflow: hidden;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    height: var(--mobile-header-height);
    min-height: var(--mobile-header-height);
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  }

  .brand-lockup {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
  }

  .mobile-menu-button {
    display: inline-flex;
    gap: 7px;
    min-height: 40px;
    padding: 0 11px;
    color: white;
    background: var(--blue);
  }

  .mobile-menu-button span[aria-hidden="true"] {
    font-size: 19px;
    line-height: 1;
  }

  .brand-copy .eyebrow {
    margin: 0;
    font-size: 10px;
  }

  .brand-copy h1 {
    overflow: hidden;
    font-size: 21px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-subtitle {
    display: none;
  }

  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
  }

  .search {
    gap: 0;
  }

  .search > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .search input {
    width: 100%;
    height: 42px;
  }

  #showMarkedBtn {
    min-height: 42px;
    padding-inline: 12px;
    white-space: nowrap;
  }

  .layout {
    display: block;
    min-height: calc(100vh - var(--mobile-header-height));
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 38;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    background: rgba(17, 28, 38, 0.45);
    transition: opacity 180ms ease;
  }

  .sidebar-backdrop:hover {
    transform: none;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(88vw, 370px);
    height: 100dvh;
    max-height: none;
    overflow-y: auto;
    padding: max(14px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
    border-right: 1px solid var(--line-strong);
    border-bottom: 0;
    box-shadow: 18px 0 45px rgba(17, 28, 38, 0.2);
    transform: translateX(-104%);
    transition: transform 200ms ease;
  }

  .course-menu-open .sidebar {
    transform: translateX(0);
  }

  .course-menu-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

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

  .mobile-sidebar-head strong {
    font-size: 18px;
  }

  .sidebar-close {
    display: inline-flex;
    width: 40px;
    min-height: 40px;
    color: var(--ink);
    background: #edf2f4;
  }

  .sidebar-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(135px, auto);
    align-items: end;
    gap: 10px;
  }

  .group-filter select {
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat-grid div {
    min-width: 0;
    padding: 9px 6px;
    text-align: center;
  }

  .stat-grid strong {
    font-size: 18px;
  }

  .stat-grid span {
    font-size: 10px;
  }

  .workspace {
    max-width: none;
    padding: 16px max(14px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .lesson-head {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
  }

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

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

  .lesson-actions {
    display: grid;
    grid-template-columns: 44px 44px minmax(0, 1fr);
  }

  .lesson-actions .icon-button {
    width: 44px;
  }

  .lesson-meta {
    margin-top: 10px;
  }

  .toolbar {
    top: var(--mobile-header-height);
    margin: 0 -14px 16px;
    padding: 7px max(14px, env(safe-area-inset-right)) 7px max(14px, env(safe-area-inset-left));
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .toolbar button,
  .toolbar .link-button {
    flex: 0 0 auto;
    min-height: 40px;
    white-space: nowrap;
  }

  .toolbar #toggleZhBtn {
    margin-left: 0;
  }

  .content {
    gap: 12px;
  }

  .overview-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .summary-card {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 0;
    gap: 5px 12px;
    padding: 14px;
  }

  .summary-card strong {
    grid-row: 1 / 3;
    grid-column: 2;
    align-self: center;
    font-size: 25px;
  }

  .summary-card span {
    grid-column: 1 / -1;
  }

  .lesson-status {
    align-items: start;
    padding: 12px 13px;
  }

  .task-pager {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px;
    scrollbar-width: none;
  }

  .task-pager > span,
  .task-page {
    flex: 0 0 auto;
  }

  .task-set-head {
    display: grid;
    gap: 10px;
  }

  .task-set-head button {
    justify-self: start;
  }

  .question-card,
  .sentence-card,
  .block-card {
    padding: 14px;
  }

  .question-top {
    align-items: start;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
  }

  .question-top .question-instruction {
    font-size: 14px;
  }

  .question-top .question-prompt {
    font-size: 17px;
    overflow-wrap: anywhere;
  }

  .question-actions button,
  .audio-actions button {
    min-height: 44px;
  }

  .option-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option {
    min-width: 0;
    min-height: 48px;
    overflow-wrap: anywhere;
  }

  .basic-grid,
  .audio-image-grid,
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .practice-sounds .pronunciation-list,
  .practice-words .pronunciation-list,
  .task-set.compact-practice-task {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pronunciation-card,
  .practice-words .pronunciation-card,
  .practice-sounds .pronunciation-card {
    min-width: 0;
  }

  .pronunciation-text,
  .practice-sounds .pronunciation-text,
  .practice-words .pronunciation-text {
    overflow-wrap: anywhere;
  }

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

  .inline-media,
  .question-media.multi {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 560px) {
  .lesson-meta span {
    min-height: 26px;
    padding-inline: 8px;
    font-size: 11px;
  }

  .option-grid,
  .cards {
    grid-template-columns: 1fr;
  }

  .basic-grid,
  .audio-image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .basic-card,
  .audio-image-card {
    padding: 9px;
  }

  .audio-image-body .nl,
  .basic-body .nl {
    font-size: 17px;
  }

  .audio-image-body .zh,
  .basic-body .zh {
    font-size: 14px;
  }

  .audio-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .audio-actions button {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
    font-size: 13px;
  }

  .basic-card .audio-actions,
  .audio-image-card .audio-actions {
    grid-template-columns: 1fr;
  }

  .practice-section-head h3,
  .task-set h3 {
    font-size: 18px;
  }

  .sentence-card,
  .block-card {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
  }

  .sentence-card .line-number,
  .block-card .line-number {
    width: 32px;
    height: 32px;
  }

  .line-body .nl,
  .short-text-card .line-body .nl {
    font-size: 18px;
  }

  .line-body .zh {
    font-size: 15px;
  }

  .task-set.compact-practice-task {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 380px) {
  .brand-copy h1 {
    font-size: 19px;
  }

  .mobile-menu-button {
    padding-inline: 9px;
  }

  .mobile-menu-button span:last-child {
    display: none;
  }

  .basic-grid,
  .audio-image-grid,
  .practice-words .pronunciation-list,
  .task-set.compact-practice-task {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Restrained color pass */
:root {
  --ink: #172438;
  --muted: #637184;
  --line: #d7e1e9;
  --line-strong: #c4d2dd;
  --soft: #f2f5f8;
  --blue: #245f9e;
  --blue-2: #147b88;
  --green: #2b765d;
  --coral: #bd5b50;
  --yellow: #d5a43b;
  --blue-soft: #edf5fc;
  --teal-soft: #edf8f7;
  --green-soft: #eef8f2;
  --yellow-soft: #fff8e7;
  --coral-soft: #fff3f0;
  --shadow: 0 10px 28px rgba(31, 59, 82, 0.09);
  --shadow-small: 0 3px 10px rgba(31, 59, 82, 0.07);
}

body {
  background: var(--soft);
}

.topbar {
  border-bottom: 2px solid #d5e4ee;
  background: rgba(252, 253, 254, 0.97);
  box-shadow: 0 8px 24px rgba(31, 59, 82, 0.05);
}

.brand-copy h1 {
  color: #173f68;
}

.eyebrow {
  color: var(--blue-2);
}

.search input:focus,
.group-filter select:focus {
  border-color: var(--blue-2);
  box-shadow: 0 0 0 3px rgba(20, 123, 136, 0.13);
}

#showMarkedBtn {
  border-color: #e3ce91;
  color: #805d12;
  background: var(--yellow-soft);
}

#showMarkedBtn:hover {
  border-color: #d5b65f;
  background: #fff3d3;
}

.sidebar {
  background: #edf3f4;
}

.stat-grid div {
  border-top: 3px solid var(--blue);
  background: #fafdff;
}

.stat-grid div:nth-child(2) {
  border-top-color: var(--blue-2);
  background: #f6fbfb;
}

.stat-grid div:nth-child(3) {
  border-top-color: var(--green);
  background: #f7fbf8;
}

.stat-grid div:nth-child(4) {
  border-top-color: var(--yellow);
  background: #fffbf1;
}

.stat-grid div:nth-child(1) strong {
  color: var(--blue);
}

.stat-grid div:nth-child(2) strong {
  color: var(--blue-2);
}

.stat-grid div:nth-child(3) strong {
  color: var(--green);
}

.stat-grid div:nth-child(4) strong {
  color: #966f1c;
}

.lesson-item:hover {
  background: #e2ecef;
}

.lesson-item.active {
  border-color: #aac9dc;
  background: var(--blue-soft);
  box-shadow: 0 4px 14px rgba(36, 95, 158, 0.1);
}

.lesson-item.active::before {
  background: var(--blue);
}

.lesson-meta span:first-child {
  border-color: #b9d2e4;
  color: var(--blue);
  background: var(--blue-soft);
}

.toolbar {
  border-color: #c4d4df;
  background: rgba(234, 240, 245, 0.96);
  box-shadow: 0 5px 16px rgba(31, 59, 82, 0.07);
}

.toolbar button:hover {
  color: var(--blue);
  background: rgba(255, 255, 255, 0.72);
}

.toolbar .view-tab.active {
  color: white;
  background: var(--blue);
  box-shadow: 0 3px 10px rgba(36, 95, 158, 0.22);
}

.summary-card {
  border-top: 4px solid var(--blue);
  background: #f9fcff;
}

.summary-card:nth-child(2) {
  border-top-color: var(--green);
  background: #f7fbf9;
}

.summary-card:nth-child(3) {
  border-top-color: var(--yellow);
  background: #fffbf2;
}

.summary-card:nth-child(1) strong {
  color: var(--blue);
}

.summary-card:nth-child(2) strong {
  color: var(--green);
}

.summary-card:nth-child(3) strong {
  color: #966f1c;
}

.lesson-status {
  border-color: #badbcb;
  background: var(--green-soft);
}

.lesson-status.needs-work {
  border-color: #e8c4bd;
  background: var(--coral-soft);
}

.practice-section-head {
  border-left: 4px solid var(--blue-2);
  border-bottom-color: #c9dce1;
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--teal-soft);
}

.practice-words .practice-section-head {
  border-left-color: var(--green);
  border-bottom-color: #c7ddcf;
  background: var(--green-soft);
}

.basic-card {
  border-top: 3px solid var(--blue-2);
}

.audio-image-card {
  border-top: 3px solid #69a88f;
}

.sentence-card,
.block-card {
  border-left: 3px solid #79aebe;
}

.short-text-card {
  border-left-color: var(--blue);
}

.pronunciation-card {
  border-color: #cfe1dc;
  background: #fbfefd;
}

.line-number {
  background: var(--green);
}

.word-index {
  background: var(--blue);
}

.sound-chip,
.token-chip {
  border-color: #c8dce2;
  background: var(--teal-soft);
}

.audio-actions button {
  background: var(--green);
  box-shadow: 0 2px 7px rgba(43, 118, 93, 0.16);
}

.audio-actions .secondary {
  background: var(--blue-2);
}

.mark-action {
  border: 1px solid #e6d397;
  color: #805d12;
  background: var(--yellow-soft);
}

.word-card.marked,
.sentence-card.marked,
.block-card.marked,
.pronunciation-card.marked {
  border-color: #dfbf68;
  background: var(--yellow-soft);
}

.task-pager {
  border-color: #bfd3e1;
  background: var(--blue-soft);
}

.task-page.active {
  border-color: var(--blue);
  background: var(--blue);
}

.question-card {
  border-left-color: #79a8c8;
}

.option:hover {
  border-color: #88adc5;
  background: var(--blue-soft);
}

.option.selected {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.option.selected .option-zh {
  color: #4d6880;
}

.option.right-answer,
.option.right-answer .option-zh {
  color: white;
}

.media-card {
  border-top: 3px solid var(--blue);
}

.media-card video {
  background: #e4edf3;
}

.empty {
  border-left: 4px solid var(--blue-2);
  background: #fbfdfe;
}

@media (max-width: 900px) {
  .topbar {
    background: rgba(250, 252, 254, 0.98);
  }

  .mobile-menu-button {
    background: var(--blue);
    box-shadow: 0 3px 10px rgba(36, 95, 158, 0.2);
  }

  .toolbar {
    background: rgba(232, 239, 244, 0.98);
  }

  .sidebar {
    background: #edf3f4;
  }
}
