:root {
  color-scheme: light;
  --bg: #f3f7f8;
  --surface: #ffffff;
  --surface-strong: #f8fbfc;
  --ink: #10212b;
  --muted: #687782;
  --line: #dce7ea;
  --brand: #123c69;
  --brand-2: #1f7a8c;
  --accent: #f29f05;
  --ok: #1d8f64;
  --danger: #b84a4a;
  --shadow: 0 14px 34px rgba(18, 60, 105, 0.08);
}

body.theme-workspace {
  --bg: #f3f7f8;
  --brand: #123c69;
  --brand-2: #1f7a8c;
  --accent: #f29f05;
  --line: #dce7ea;
  --shadow: 0 14px 34px rgba(18, 60, 105, 0.08);
}

body.theme-materials {
  --bg: #f7f4ed;
  --brand: #5d3a1a;
  --brand-2: #b05f2c;
  --accent: #2d8c6f;
  --line: #e7d9c9;
  --shadow: 0 14px 34px rgba(93, 58, 26, 0.08);
}

body.theme-exam {
  --bg: #f5f3fa;
  --brand: #3f2b69;
  --brand-2: #7657a6;
  --accent: #d79b2b;
  --line: #e3dced;
  --shadow: 0 14px 34px rgba(63, 43, 105, 0.09);
}

body.theme-specials {
  --bg: #f2f7f1;
  --brand: #1f4f3a;
  --brand-2: #4c8b5f;
  --accent: #d28a2d;
  --line: #dbe8d8;
  --shadow: 0 14px 34px rgba(31, 79, 58, 0.08);
}

body.theme-report {
  --bg: #f8f3f5;
  --brand: #6a2f4d;
  --brand-2: #b2527a;
  --accent: #2f8b91;
  --line: #ead8df;
  --shadow: 0 14px 34px rgba(106, 47, 77, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #0d2d4d;
  color: #edf7fb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #16120a;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.sidebar-card small {
  color: rgba(237, 247, 251, 0.72);
}

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

.nav-link {
  padding: 11px 12px;
  border-radius: 8px;
  color: rgba(237, 247, 251, 0.78);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-card {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.mobile-goal {
  display: none;
}

.progress-line {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
}

.progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.main {
  min-width: 0;
  padding: 28px;
  padding-bottom: 96px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.08;
  max-width: 860px;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions,
.section-heading,
.recorder-row,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.primary-button,
.ghost-button,
.icon-button,
.chip,
.segment,
.record-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button {
  padding: 0 18px;
  background: var(--brand);
  color: #fff;
}

.ghost-button,
.chip,
.segment {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-button:hover,
.chip.active,
.segment.active {
  border-color: var(--brand-2);
  background: #eaf6f8;
  color: var(--brand);
}

.admin-locked {
  opacity: 0.62;
}

.admin-state,
.sync-state {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-state.is-admin {
  border-color: rgba(29, 143, 100, 0.32);
  background: rgba(29, 143, 100, 0.1);
  color: var(--ok);
}

.sync-state {
  border-color: rgba(31, 122, 140, 0.24);
  color: var(--brand-2);
}

.auth-status {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.icon-button {
  width: 42px;
  background: #eaf6f8;
  color: var(--brand);
  font-size: 24px;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(360px, 1.35fr) minmax(260px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel,
.feature-card,
.diagram-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.filter-row,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.material-list {
  display: grid;
  gap: 10px;
}

.material-item {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  text-align: left;
}

.material-item.active {
  border-color: var(--brand-2);
  background: #eaf6f8;
}

.material-item strong,
.material-item small {
  display: block;
}

.material-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.material-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  border-color: rgba(184, 74, 74, 0.45);
  background: rgba(184, 74, 74, 0.08);
  color: var(--danger);
}

.tag,
.level-pill,
.score-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef3f5;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.training-panel {
  min-height: 720px;
}

.training-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #eaf6f8, #fff7e7);
}

.audio-console {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.play-button {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
}

.waveform {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.waveform i {
  display: block;
  width: 100%;
  min-width: 8px;
  border-radius: 99px;
  background: var(--brand-2);
  opacity: 0.85;
  height: 20%;
  transition: height 0.2s ease;
}

.waveform i:nth-child(2) { height: 55%; }
.waveform i:nth-child(3) { height: 80%; }
.waveform i:nth-child(4) { height: 36%; }
.waveform i:nth-child(5) { height: 68%; }
.waveform i:nth-child(6) { height: 44%; }
.waveform i:nth-child(7) { height: 88%; }
.waveform i:nth-child(8) { height: 58%; }
.waveform i:nth-child(9) { height: 30%; }
.waveform i:nth-child(10) { height: 66%; }

.is-playing .waveform i {
  animation: pulse 0.9s infinite ease-in-out alternate;
}

.is-playing .waveform i:nth-child(odd) {
  animation-duration: 1.2s;
}

@keyframes pulse {
  from { transform: scaleY(0.72); }
  to { transform: scaleY(1.18); }
}

.audio-meta {
  min-width: 110px;
}

.voice-select {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
}

.voice-select span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.voice-select select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.speed-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 12px;
}

.speed-control > span {
  color: var(--muted);
  font-weight: 800;
}

.speed-option {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.speed-option.active,
.speed-option:hover {
  border-color: var(--brand-2);
  background: #eaf6f8;
  color: var(--brand);
}

.mode-brief,
.source-preview {
  display: grid;
  gap: 5px;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.mode-brief strong,
.source-preview span {
  font-weight: 800;
  color: var(--brand);
}

.mode-brief p,
.source-preview p {
  margin: 0;
}

.source-preview {
  display: none;
}

.source-preview.visible {
  display: grid;
}

.dialogue-practice,
.translation-panel {
  display: none;
  gap: 12px;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.dialogue-practice.visible,
.translation-panel.visible {
  display: grid;
}

.dialogue-header,
.translation-panel > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialogue-actions,
.dialogue-role-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dialogue-role-controls {
  justify-content: space-between;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.dialogue-role-controls > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.role-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 7px 10px;
  font-weight: 800;
  cursor: pointer;
}

.role-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--brand);
}

.dialogue-header span,
.dialogue-reply span,
.translation-panel span,
.translation-grid span {
  color: var(--brand);
  font-weight: 800;
}

.dialogue-turns {
  display: grid;
  gap: 8px;
}

.dialogue-bubble {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.dialogue-bubble.user,
.dialogue-bubble.guest {
  background: #eaf6f8;
}

.dialogue-bubble.host {
  background: #fff;
}

.dialogue-bubble.practice-target {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.dialogue-bubble strong {
  display: block;
  margin-bottom: 4px;
  color: var(--brand);
}

.dialogue-bubble p {
  margin: 0;
}

.dialogue-reply {
  display: grid;
  gap: 7px;
}

.voice-dialogue-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.voice-dialogue-box strong,
.voice-dialogue-box small {
  display: block;
}

.voice-dialogue-box small {
  color: var(--muted);
}

.translation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.translation-grid label {
  display: grid;
  gap: 7px;
}

.recorder-row.hidden {
  display: none;
}

.exam-hint {
  grid-column: 1 / -1;
  margin: -4px 0 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  line-height: 1.45;
}

.audio-meta strong,
.audio-meta small,
.recorder-row strong,
.recorder-row small {
  display: block;
}

.note-box {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.note-box span,
.form-grid span,
.generator-card label > span {
  color: var(--ink);
  font-weight: 800;
}

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

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

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

.record-button {
  min-width: 136px;
  padding: 0 18px;
  background: var(--danger);
  color: #fff;
}

.record-button.recording {
  background: var(--ok);
}

.full-width {
  width: 100%;
  margin-top: 8px;
}

.score-badge {
  width: 54px;
  height: 54px;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 19px;
}

.score-list {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.score-row {
  display: grid;
  gap: 6px;
}

.score-row > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef0;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-2);
}

.feedback-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.feedback-block ul,
.task-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.75;
  color: var(--muted);
}

.rss-picker {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.compact-heading {
  margin: 0;
}

.compact-heading h3 {
  margin: 0;
  font-size: 15px;
}

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

.rss-preview {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.rss-preview[hidden] {
  display: none;
}

.rss-preview h3,
.rss-preview p {
  margin: 0;
}

.rss-preview h3 {
  font-size: 15px;
  line-height: 1.35;
}

.rss-preview-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rss-preview-badges span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef3f5;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
}

.rss-topic-hint {
  color: var(--brand-2);
  font-weight: 800;
}

.rss-preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rss-preview-actions a {
  color: var(--brand-2);
  font-weight: 800;
  text-decoration: none;
}

.glossary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.glossary-library-panel {
  display: grid;
  gap: 14px;
}

.glossary-count {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--brand);
  background: var(--surface-strong);
  font-weight: 800;
}

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

.glossary-tools {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) 1.2fr;
  gap: 12px;
  align-items: end;
}

.glossary-tools label {
  display: grid;
  gap: 6px;
}

.glossary-tools label span {
  color: var(--brand);
  font-weight: 800;
}

.glossary-tools input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  color: var(--text);
  background: #fff;
}

.glossary-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.glossary-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.glossary-filter {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 7px 11px;
  font-weight: 800;
  cursor: pointer;
}

.glossary-filter.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--brand);
}

.glossary-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.glossary-card > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.glossary-card strong {
  color: var(--brand);
}

.glossary-card span,
.glossary-card small {
  color: var(--muted);
}

.glossary-definition {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  border-radius: 8px;
  padding: 5px 8px;
  background: var(--surface-strong);
  color: var(--brand);
  font-style: normal;
  font-weight: 800;
  line-height: 1.35;
}

.glossary-card p {
  margin: 0;
  line-height: 1.55;
}

.memory-state {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--brand);
  padding: 6px 10px;
  font-weight: 800;
  cursor: pointer;
}

.wide {
  margin-bottom: 18px;
}

.cards-grid,
.special-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.library-filters {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.library-sync-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.library-sync-panel div {
  display: grid;
  gap: 2px;
}

.library-sync-panel span,
.report-sync-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.library-sync-panel strong {
  color: var(--ink);
  font-size: 18px;
}

.library-filters > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.library-filters span {
  color: var(--muted);
  font-weight: 800;
}

.library-filters small {
  color: var(--muted);
}

.library-filter {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 800;
}

.library-filter.active,
.library-filter:hover {
  border-color: var(--brand-2);
  background: #eaf6f8;
  color: var(--brand);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.large-textarea {
  min-height: 220px;
}

.feature-card {
  padding: 18px;
}

.feature-card .ghost-button {
  margin-top: 8px;
}

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

.special-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.special-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff3d8;
  color: #8d5c00;
  font-weight: 900;
}

.report-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.practice-history-panel {
  margin-top: 18px;
}

.practice-history {
  display: grid;
  gap: 10px;
}

.practice-record {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.practice-record strong,
.practice-record span {
  display: block;
}

.practice-record span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.practice-record b {
  min-width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--brand);
}

.practice-record p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.practice-record .weak-terms {
  grid-column: 1 / -1;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--accent-soft);
  color: var(--brand);
  font-weight: 800;
}

.implementation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.implementation-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.step-index {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.implementation-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
}

.api-panel {
  margin-top: 0;
}

.api-table {
  display: grid;
  gap: 8px;
}

.api-table > div {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) 1fr;
  gap: 12px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.api-table strong {
  color: var(--brand);
}

.api-table span {
  color: var(--muted);
  line-height: 1.45;
}

.handoff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.handoff-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.check-grid {
  display: grid;
  grid-template-columns: minmax(100px, 0.45fr) 1fr;
  gap: 8px 12px;
  margin-top: 14px;
}

.check-grid span,
.check-grid strong {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.check-grid span {
  color: var(--muted);
}

.check-grid strong {
  color: var(--brand);
}

.blueprint-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.config-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.config-list > div {
  display: grid;
  grid-template-columns: minmax(90px, 0.35fr) 1fr;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.config-list strong,
.rubric-grid strong {
  color: var(--brand);
}

.config-list span {
  color: var(--muted);
  line-height: 1.45;
}

.rubric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 12px;
}

.rubric-grid div {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  text-align: center;
}

.rubric-grid strong {
  font-size: 22px;
}

.rubric-grid span,
.rubric-note {
  color: var(--muted);
}

.mode-comparison {
  margin-top: 18px;
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.comparison-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.comparison-grid p {
  margin-bottom: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric-grid div {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-strong);
}

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

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

.chart-bars {
  height: 180px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#f9fcfd 49%, #e8eef0 50%, #f9fcfd 51%);
}

.chart-bars span {
  flex: 1;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--accent), var(--brand-2));
}

.architecture-grid {
  display: grid;
  gap: 18px;
}

.diagram-card {
  margin: 0;
  padding: 16px;
  overflow: auto;
}

.diagram-card figcaption {
  margin-bottom: 12px;
  font-weight: 800;
}

.diagram-card img {
  display: block;
  width: 100%;
  min-width: 720px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.bottom-nav {
  display: none;
}

.generator-dialog {
  width: min(720px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(13, 45, 77, 0.22);
}

.generator-dialog::backdrop {
  background: rgba(10, 25, 36, 0.46);
}

.generator-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label,
.generator-card label {
  display: grid;
  gap: 7px;
}

body.compact .sidebar {
  background: #173b37;
}

body.compact {
  --brand: #173b37;
  --brand-2: #6a7f52;
  --accent: #d88c35;
}

@media (min-width: 1181px) {
  body {
    overflow: hidden;
    font-size: 13px;
  }

  .app-shell {
    grid-template-columns: 236px minmax(0, 1fr);
    max-height: 100vh;
  }

  .sidebar {
    gap: 14px;
    padding: 16px;
    overflow-y: auto;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

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

  .brand small,
  .sidebar-card small,
  small {
    font-size: 11px;
  }

  .nav-list {
    gap: 4px;
  }

  .nav-link {
    padding: 8px 10px;
    border-radius: 7px;
  }

  .sidebar-card {
    margin-top: 8px;
    gap: 8px;
    padding: 12px;
  }

  .main {
    height: 100vh;
    overflow-y: auto;
    padding: 14px;
    padding-bottom: 18px;
  }

  .topbar {
    gap: 14px;
    margin-bottom: 10px;
  }

  h1 {
    font-size: clamp(22px, 2.4vw, 31px);
    line-height: 1.05;
    max-width: 680px;
  }

  h2 {
    font-size: 17px;
  }

  h3 {
    margin-bottom: 5px;
    font-size: 14px;
  }

  p {
    margin-bottom: 6px;
    line-height: 1.42;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 10px;
  }

  .primary-button,
  .ghost-button,
  .icon-button,
  .chip,
  .segment,
  .record-button {
    min-height: 34px;
    border-radius: 7px;
    font-size: 12px;
  }

  .primary-button,
  .ghost-button,
  .chip,
  .segment,
  .record-button {
    padding-left: 11px;
    padding-right: 11px;
  }

  .icon-button {
    width: 34px;
    font-size: 19px;
  }

  .workspace-grid {
    height: calc(100vh - 86px);
    grid-template-columns: minmax(220px, 0.78fr) minmax(360px, 1.32fr) minmax(245px, 0.86fr);
    gap: 12px;
  }

  .panel {
    max-height: 100%;
    overflow: auto;
    padding: 12px;
  }

  .materials-panel,
  .training-panel,
  .feedback-panel {
    min-height: 0;
  }

  .section-heading,
  .recorder-row,
  .dialog-actions {
    gap: 8px;
  }

  .filter-row,
  .segmented {
    gap: 6px;
    margin: 9px 0;
  }

  .material-list {
    gap: 7px;
  }

  .material-item {
    padding: 9px;
    border-radius: 7px;
  }

  .material-meta {
    gap: 5px;
    margin-top: 6px;
  }

  .tag,
  .level-pill {
    min-height: 22px;
    padding: 0 8px;
    font-size: 10px;
  }

  .training-hero {
    gap: 10px;
    padding: 12px;
  }

  .training-hero p {
    margin-bottom: 0;
  }

  .audio-console {
    grid-template-columns: auto minmax(0, 1fr) 76px;
    gap: 10px;
    margin: 10px 0;
    padding: 10px;
  }

  .play-button {
    width: 44px;
    height: 44px;
    font-size: 17px;
  }

  .waveform {
    height: 42px;
    gap: 4px;
  }

  .waveform i {
    min-width: 5px;
  }

  .audio-meta {
    min-width: 84px;
  }

  .speed-control {
    gap: 6px;
    margin: -3px 0 8px;
  }

  .speed-option {
    min-height: 28px;
    padding: 0 9px;
    font-size: 11px;
  }

  .mode-brief,
  .source-preview,
  .dialogue-practice,
  .translation-panel {
    margin: 7px 0;
    padding: 9px;
  }

  .note-box {
    gap: 5px;
    margin: 8px 0;
  }

  textarea {
    padding: 9px;
    line-height: 1.42;
    font-size: 12px;
  }

  #noteInput {
    min-height: 92px;
    max-height: 120px;
  }

  #answerInput {
    min-height: 74px;
    max-height: 96px;
  }

  .record-button {
    min-width: 104px;
  }

  .full-width {
    margin-top: 5px;
  }

  .score-badge {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .score-list {
    gap: 9px;
    margin: 12px 0;
  }

  .score-row {
    gap: 5px;
  }

  .score-row > div {
    font-size: 12px;
  }

  .meter {
    height: 6px;
  }

  .feedback-block {
    margin-top: 12px;
    padding-top: 10px;
  }

  .feedback-block ul,
  .task-list {
    padding-left: 17px;
    line-height: 1.48;
  }

  .glossary-tags {
    gap: 6px;
  }

  .wide {
    margin-bottom: 12px;
  }

  .cards-grid,
  .glossary-library,
  .special-grid,
  .report-layout,
  .implementation-grid,
  .handoff-grid,
  .blueprint-grid {
    gap: 12px;
  }

  .feature-card,
  .special-card,
  .implementation-card,
  .diagram-card {
    padding: 12px;
  }

  .implementation-card {
    gap: 10px;
  }

  .step-index {
    width: 34px;
    height: 34px;
  }

  .api-table > div {
    grid-template-columns: minmax(190px, 0.7fr) 1fr;
    padding: 9px 10px;
  }

  .library-filters {
    margin-bottom: 12px;
    padding: 10px;
  }

  .library-filter {
    min-height: 30px;
    padding: 0 10px;
    font-size: 11px;
  }

  .config-list > div {
    padding: 9px 10px;
  }

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

  .metric-grid {
    gap: 8px;
    margin: 12px 0;
  }

  .metric-grid div {
    padding: 11px;
  }

  .metric-grid strong {
    font-size: 22px;
  }

  .chart-bars {
    height: 135px;
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
  }

  .nav-list {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
  }

  .sidebar-card {
    min-width: 190px;
    max-width: 240px;
    margin-top: 0;
    gap: 6px;
    padding: 10px;
  }

  .sidebar-card .eyebrow {
    margin-bottom: 0;
  }

  .sidebar-card strong {
    font-size: 13px;
    line-height: 1.2;
  }

  .sidebar-card small {
    font-size: 11px;
    line-height: 1.25;
  }

  .workspace-grid {
    grid-template-columns: minmax(280px, 0.92fr) minmax(360px, 1.08fr);
  }

  .feedback-panel {
    grid-column: 1 / -1;
  }

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

@media (max-width: 760px) {
  .main {
    padding: 18px;
    padding-bottom: 88px;
  }

  .library-sync-panel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .topbar,
  .training-hero,
  .recorder-row,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .mobile-goal {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .mobile-goal > div:first-child {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-goal .eyebrow {
    margin-bottom: 0;
  }

  .mobile-goal .progress-line {
    background: #e8eef0;
  }

  .mobile-goal small {
    color: var(--muted);
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .workspace-grid,
  .cards-grid,
  .glossary-tools,
  .special-grid,
  .report-layout,
  .implementation-grid,
  .handoff-grid,
  .blueprint-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .api-table > div {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .translation-grid,
  .dialogue-header,
  .voice-dialogue-box,
  .translation-panel > div:first-child {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .dialogue-actions,
  .dialogue-role-controls {
    width: 100%;
  }

  .dialogue-role-controls .role-chip {
    flex: 1;
  }

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

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

  .config-list > div,
  .rubric-grid {
    grid-template-columns: 1fr;
  }

  .training-panel {
    min-height: unset;
  }

  .audio-console {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .play-button {
    justify-self: center;
  }

  .audio-meta {
    min-width: 0;
  }

  .speed-control {
    justify-content: center;
    margin-top: 0;
  }

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

  .exam-hint {
    grid-column: auto;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
  }

  .bottom-nav a {
    min-width: 0;
    min-height: 52px;
    display: grid;
    place-items: center;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
  }

  .bottom-nav a.active {
    color: var(--brand);
  }

  .diagram-card img {
    min-width: 620px;
  }
}

@media (max-width: 380px) {
  .bottom-nav a {
    min-height: 48px;
    font-size: 11px;
  }
}
