:root {
  color-scheme: light;
  --ink: #182027;
  --muted: #66737f;
  --line: #d9e1e7;
  --paper: #fbfcfd;
  --soft: #eef5f3;
  --accent: #18736a;
  --accent-dark: #115d56;
  --accent-soft: #d9f0eb;
  --warn: #c9583f;
  --gold: #f1b84b;
  --blue: #3977b8;
  --shadow: 0 20px 60px rgba(39, 54, 69, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body.lock-page-scroll {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

body {
  background: #edf2f4;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

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

button {
  cursor: pointer;
}

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

body.lock-page-scroll .app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

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

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

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel-header h3,
.panel-header p {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
}

.app-version {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.brand p,
.panel-header p,
.sidebar-note span,
.eyebrow {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 66px;
  padding: 15px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  text-align: left;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.nav-item:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.nav-icon {
  width: 32px;
  font-size: 25px;
  text-align: center;
}

.sidebar-note {
  position: relative;
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.hidden {
  display: none !important;
}

.settings-note-btn {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.settings-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 10;
  display: grid;
  width: 240px;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.settings-popover[hidden] {
  display: none;
}

.main {
  padding: 28px;
  overflow: auto;
}

body.lock-page-scroll .main {
  min-height: 0;
  overflow: hidden;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

body.lock-page-scroll .view.active:not(#dictation-view) {
  height: calc(100dvh - 56px);
  overflow: auto;
  overscroll-behavior: contain;
}

body.lock-page-scroll #library-view.view.active {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: calc(100dvh - 56px);
  overflow: hidden;
}

#dictation-view.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 56px);
}

body.lock-page-scroll #dictation-view.view.active {
  height: calc(100dvh - 56px);
  overflow: hidden;
}

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

.topbar-actions,
.writing-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.eyebrow {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.primary-btn:disabled {
  cursor: not-allowed;
  background: #9eb3b0;
}

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

.ghost-btn {
  background: transparent;
  color: var(--accent-dark);
  border-color: var(--line);
}

.import-band,
.library-layout,
.dictation-grid {
  display: grid;
  gap: 18px;
}

.import-band {
  grid-template-columns: minmax(260px, 1fr) minmax(360px, 1.2fr);
  margin-bottom: 18px;
}

.upload-tile,
.recognition-summary,
.lesson-list-panel,
.word-editor-panel,
.practice-panel,
.record-card,
.mistake-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 30px rgba(60, 80, 96, 0.06);
}

.upload-tile {
  display: grid;
  min-height: 132px;
  place-items: center;
  gap: 4px;
  padding: 18px;
  text-align: center;
}

.upload-tile input {
  display: none;
}

.upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 26px;
}

.upload-tile span:last-child {
  color: var(--muted);
}

.recognition-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: center;
  gap: 12px;
  padding: 18px;
}

.recognition-summary div {
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 0;
}

.metric {
  color: var(--accent-dark);
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
}

.library-layout {
  grid-template-columns: minmax(330px, 0.9fr) minmax(390px, 1.4fr);
  min-height: 0;
}

.lesson-list-panel,
.word-editor-panel,
.practice-panel {
  padding: 18px;
}

.lesson-list-panel,
.word-editor-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

body.lock-page-scroll #library-view .library-layout {
  overflow: hidden;
}

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

.panel-header > div:first-child {
  min-width: 0;
}

.add-lesson-main-btn {
  min-height: 44px;
  padding: 0 18px;
  font-size: 16px;
}

.lesson-list {
  display: grid;
  min-height: 0;
  max-height: calc(100vh - 330px);
  overflow: auto;
  gap: 8px;
  padding-right: 4px;
  align-content: start;
}

body.lock-page-scroll #library-view .lesson-list,
body.lock-page-scroll #library-view .word-chips {
  flex: 1 1 auto;
  max-height: none;
}

.lesson-swipe {
  position: relative;
  min-height: 56px;
  overflow: hidden;
  border-radius: 8px;
  touch-action: pan-y;
}

.lesson-row-actions {
  position: absolute;
  inset: 0 0 0 auto;
  display: grid;
  width: 144px;
  grid-template-columns: 80px 64px;
}

.lesson-action {
  min-width: 0;
  padding: 0 8px;
  border: 0;
  color: #fff;
  font-weight: 700;
}

.lesson-action.rename {
  background: var(--blue);
}

.lesson-action.delete {
  background: var(--warn);
}

.lesson-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: transform 180ms ease;
  touch-action: pan-y;
}

.lesson-row.dragging {
  transition: none;
}

.lesson-swipe.revealed .lesson-row {
  transform: translateX(-144px);
}

.lesson-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.lesson-name {
  min-width: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lesson-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.editor-heading {
  display: grid;
  height: 58px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.editor-heading h3 {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.editor-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.word-entry-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  margin-top: 14px;
}

.word-entry-toolbar textarea {
  min-height: 104px;
  resize: none;
}

.word-entry-actions {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.word-entry-actions button {
  width: 100%;
  min-height: 0;
  padding: 0 12px;
}

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

input,
select {
  min-height: 48px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 92px;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 115, 106, 0.14);
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  max-height: calc(100vh - 470px);
  overflow: auto;
  padding-right: 4px;
  align-content: flex-start;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.word-edit-trigger {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  line-height: 1.4;
  text-align: left;
}

.word-edit-trigger:hover,
.word-edit-trigger:focus-visible {
  color: var(--accent-dark);
}

.word-chip.missing-word {
  align-items: stretch;
  background: #fff8e6;
  border-color: #efcf86;
}

.missing-word-form {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(160px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.missing-word-form input {
  min-height: 36px;
  border-color: #e6c371;
}

.hint-only-label {
  color: #8b680d;
  font-weight: 800;
}

.chip-delete {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #f3f5f6;
  color: var(--warn);
  font-weight: 800;
}

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

.dictation-topbar {
  align-items: flex-start;
  margin-bottom: 12px;
}

.dictation-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 420px);
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 100%;
}

.dictation-header h2 {
  overflow: hidden;
  margin: 0;
  font-size: clamp(22px, 2.2vw, 30px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-panel h3 {
  margin: 0;
}

.dictation-course-row {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.practice-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

.broadcast-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 88px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.broadcast-card > div:first-child {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  column-gap: 10px;
  row-gap: 3px;
}

.broadcast-card h3 {
  overflow: hidden;
  margin: 0;
  font-size: clamp(28px, 3.4vw, 42px);
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phonetic-hint {
  grid-column: 1 / -1;
  min-height: 22px;
  margin: 5px 0 0;
  color: #405264;
  font-size: 18px;
  font-weight: 700;
}

.speech-status {
  grid-column: 1 / -1;
  min-height: 16px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.broadcast-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.replay-speech-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 82px;
  height: 44px;
  padding: 0 12px;
  font-size: 15px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.timer {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #f6f0df;
  color: #835d00;
  font-size: 20px;
  font-weight: 900;
}

.timer:empty {
  display: none;
}

.writing-area-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.writing-area-wrap.disabled {
  opacity: 0.58;
}

.writing-area-wrap.disabled #writing-canvas {
  cursor: not-allowed;
}

.writing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
  font-weight: 800;
}

.writing-toolbar > span {
  min-width: 0;
  line-height: 1.25;
}

.icon-btn {
  display: grid;
  width: 48px;
  min-width: 48px;
  padding: 0;
  place-items: center;
  font-size: 26px;
}

.confirm-writing-btn {
  min-width: 116px;
  min-height: 46px;
  font-size: 20px;
}

#writing-canvas {
  display: block;
  color-scheme: light;
  width: 100%;
  height: 100%;
  min-height: 380px;
  background-color: #fffdf8;
  background-image:
    linear-gradient(#eadfcb 1px, transparent 1px),
    linear-gradient(90deg, #eadfcb 1px, transparent 1px);
  background-size: 48px 48px;
  touch-action: none;
}

.feedback {
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 700;
}

.feedback.correct {
  background: #dff3e7;
  color: #167047;
}

.feedback.wrong {
  background: #fae5df;
  color: #a23f2e;
}

.feedback.neutral {
  background: #eef3f8;
  color: #38698f;
}

.record-list,
.mistake-list {
  display: grid;
  gap: 12px;
}

.record-card,
.mistake-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.record-card.has-handwriting {
  cursor: pointer;
}

.record-card-header,
.mistake-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.record-title,
.mistake-title {
  margin: 0;
  font-size: 20px;
}

.record-meta,
.mistake-meta,
.empty-state {
  color: var(--muted);
}

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

.record-actions .metric {
  min-width: 72px;
  text-align: right;
}

.mini-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.mini-chip.wrong {
  border-color: #edb7a9;
  background: #fff1ed;
}

dialog {
  width: min(920px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(20, 30, 38, 0.34);
}

.result-dialog-content {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.result-dialog-content h2,
.result-dialog-content p {
  margin: 0;
}

.result-mistakes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.backup-import-note {
  color: var(--muted);
  line-height: 1.7;
}

.ocr-auth-dialog {
  width: min(520px, calc(100vw - 32px));
}

.ocr-auth-description {
  color: var(--muted);
  line-height: 1.6;
}

.ocr-auth-field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 700;
}

.ocr-auth-field input {
  font-size: 18px;
  letter-spacing: 0;
}

.ocr-auth-error {
  min-height: 24px;
  color: var(--warn);
  font-weight: 700;
}

.handwriting-preview-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
}

.handwriting-image {
  display: block;
  width: 100%;
  max-height: min(68vh, 760px);
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.fullscreen-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  padding: 0;
  border-radius: 0;
  background: #101820;
  overflow: hidden;
}

.fullscreen-dialog::backdrop {
  background: #101820;
}

.fullscreen-viewer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.fullscreen-viewer:active {
  cursor: grabbing;
}

.handwriting-fullscreen-image {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

.fullscreen-close-btn {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 2;
}

@media (max-width: 900px) {
  body.lock-page-scroll {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  body.lock-page-scroll .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }

  .brand {
    justify-content: center;
  }

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

  .nav-item {
    justify-content: center;
    padding: 8px;
  }

  .nav-item span:last-child {
    display: none;
  }

  .sidebar-note {
    margin-top: 0;
  }

  .settings-popover {
    top: calc(100% + 8px);
    right: 0;
    bottom: auto;
    left: auto;
  }

  .main {
    padding: 18px;
  }

  body.lock-page-scroll .main,
  body.lock-page-scroll .view.active:not(#dictation-view),
  body.lock-page-scroll #dictation-view.view.active,
  body.lock-page-scroll #library-view.view.active {
    display: block;
    height: auto;
    overflow: visible;
  }

  body.lock-page-scroll #library-view .library-layout,
  .lesson-list-panel,
  .word-editor-panel {
    overflow: visible;
  }

  .topbar,
  .panel-header,
  .record-card-header,
  .mistake-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dictation-header {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dictation-header h2 {
    white-space: normal;
  }

  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .writing-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .writing-tools {
    justify-content: stretch;
  }

  .writing-tools button {
    flex: 1 1 auto;
  }

  .dictation-course-row {
    max-width: none;
  }

  .import-band,
  .library-layout,
  .dictation-grid {
    grid-template-columns: 1fr;
  }

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

  .lesson-list,
  .word-chips {
    max-height: none;
  }

  body.dictation-active {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  body.dictation-active .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.dictation-active .sidebar {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
  }

  body.dictation-active .brand {
    display: none;
  }

  body.dictation-active .nav {
    grid-template-columns: repeat(4, minmax(42px, 1fr));
    gap: 4px;
  }

  body.dictation-active .nav-item {
    min-height: 44px;
    padding: 4px;
  }

  body.dictation-active .nav-icon {
    width: auto;
    font-size: 22px;
  }

  body.dictation-active .sidebar-note {
    width: auto;
  }

  body.dictation-active .settings-note-btn {
    min-height: 44px;
    padding: 6px 9px;
    text-align: center;
  }

  body.dictation-active .settings-note-btn strong {
    font-size: 12px;
  }

  body.dictation-active .settings-summary {
    display: none;
  }

  body.dictation-active #settings-summary {
    display: none;
  }

  body.dictation-active .main {
    min-height: 0;
    padding: 8px;
    overflow: hidden;
  }

  body.dictation-active #dictation-view.view.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.dictation-active .dictation-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
  }

  body.dictation-active .dictation-header {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  body.dictation-active .dictation-header h2 {
    overflow: hidden;
    font-size: 18px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.dictation-active .dictation-course-row {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
    font-size: 13px;
  }

  body.dictation-active .dictation-course-row select {
    min-height: 36px;
    padding: 0 8px;
  }

  body.dictation-active .topbar-actions {
    align-items: center;
    flex-direction: row;
  }

  body.dictation-active #start-btn {
    min-height: 38px;
    padding: 0 12px;
  }

  body.dictation-active .dictation-grid,
  body.dictation-active .practice-panel {
    height: 100%;
    min-height: 0;
  }

  body.dictation-active .practice-panel {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 7px;
    padding: 8px;
  }

  body.dictation-active .broadcast-card {
    align-items: center;
    flex-direction: row;
    min-height: 68px;
    gap: 8px;
    padding: 5px 9px;
  }

  body.dictation-active .broadcast-card > div:first-child {
    min-width: 0;
  }

  body.dictation-active .broadcast-card h3 {
    overflow: hidden;
    margin-top: 2px;
    font-size: 23px;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.dictation-active .status-pill {
    min-height: 19px;
    padding: 0 7px;
    font-size: 10px;
  }

  body.dictation-active .phonetic-hint {
    min-height: 15px;
    margin-top: 2px;
    font-size: 14px;
    line-height: 1.1;
  }

  body.dictation-active .speech-status {
    min-height: 11px;
    margin-top: 1px;
    font-size: 10px;
    line-height: 1.1;
  }

  body.dictation-active .replay-speech-btn {
    min-width: 70px;
    height: 38px;
    padding: 0 8px;
    font-size: 13px;
  }

  body.dictation-active .timer {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  body.dictation-active .writing-area-wrap {
    min-height: 0;
  }

  body.dictation-active .writing-toolbar {
    min-height: 48px;
    padding: 5px;
  }

  body.dictation-active .writing-toolbar > span {
    display: none;
  }

  body.dictation-active .writing-tools {
    display: grid;
    grid-template-columns: 44px 44px minmax(58px, 0.8fr) minmax(92px, 1.2fr) minmax(72px, 1fr);
    width: 100%;
    gap: 5px;
  }

  body.dictation-active .writing-tools button {
    min-width: 0;
    min-height: 38px;
    padding: 0 7px;
    font-size: 13px;
  }

  body.dictation-active .writing-tools .icon-btn {
    width: auto;
    font-size: 22px;
  }

  body.dictation-active #writing-canvas {
    height: 100%;
    min-height: 0;
  }

  body.dictation-active .feedback {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 12px;
    line-height: 1.2;
  }
}

@media (max-width: 520px) {
  .recognition-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand h1 {
    font-size: 18px;
  }

  .topbar h2 {
    font-size: 28px;
  }

  body:not(.dictation-active) .broadcast-card {
    align-items: stretch;
    flex-direction: column;
  }

  .timer {
    width: 100%;
    height: 56px;
  }

  .word-entry-toolbar {
    grid-template-columns: minmax(0, 1fr) 84px;
  }

  .dictation-course-row {
    grid-template-columns: 1fr;
  }

  body:not(.dictation-active) #writing-canvas {
    min-height: 330px;
  }
}

@media (max-width: 900px) and (max-height: 600px) {
  body.dictation-active .sidebar {
    padding-top: 3px;
    padding-bottom: 3px;
  }

  body.dictation-active .nav-item,
  body.dictation-active .settings-note-btn {
    min-height: 40px;
  }

  body.dictation-active .main {
    padding: 5px 7px;
  }

  body.dictation-active .dictation-header h2 {
    display: none;
  }

  body.dictation-active .dictation-course-row select {
    min-height: 34px;
  }

  body.dictation-active #start-btn {
    min-height: 34px;
  }

  body.dictation-active .broadcast-card {
    min-height: 62px;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  body.dictation-active .broadcast-card > div:first-child {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    row-gap: 2px;
  }

  body.dictation-active .broadcast-card h3 {
    margin: 0;
    font-size: 22px;
  }

  body.dictation-active .phonetic-hint {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 13px;
  }

  body.dictation-active .speech-status {
    display: none;
  }

  body.dictation-active .writing-toolbar {
    min-height: 44px;
    padding: 3px;
  }

  body.dictation-active .writing-tools button {
    min-height: 36px;
  }

  body.dictation-active .feedback {
    min-height: 30px;
    padding: 5px 8px;
  }
}
