:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #eef5f1;
  --ink: #172026;
  --muted: #5d6872;
  --line: #d9e0e3;
  --accent: #0f8b8d;
  --accent-dark: #0b6264;
  --danger: #b42318;
  --warning: #9a6700;
  --success: #16703c;
  --shadow: 0 14px 40px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #f8fbfb 0%, #edf3f4 48%, #f5f7f8 100%);
}

a {
  color: inherit;
}

.site-body {
  background: #f6f8f7;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
}

.brand {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active {
  background: #e7f2ef;
  color: var(--accent-dark);
}

.nav-logout {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
}

.nav-logout:hover:not(:disabled) {
  border-color: #efc0bb;
  background: #fff4f2;
  color: #8f1d14;
}

.site-main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.hero {
  max-width: 760px;
  padding: 54px 0 42px;
}

.hero h1,
.narrow-panel h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.18;
}

.lead {
  max-width: 680px;
  margin: 18px 0 0;
  color: #253039;
  font-size: 20px;
  line-height: 1.75;
}

.quiet {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

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

.button-secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-dark);
}

.button-secondary:hover {
  background: #edf6f4;
}

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

.danger-button:hover {
  background: #8f1d14;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

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

.info-card {
  padding: 20px;
}

.info-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.info-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.narrow-panel {
  max-width: 620px;
  margin: 20px auto 0;
  padding: 28px;
}

.public-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.public-form label {
  display: grid;
  gap: 8px;
}

.public-form label span {
  color: #27333b;
  font-weight: 800;
}

.public-form textarea {
  min-height: 120px;
}

.form-message {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
  line-height: 1.6;
}

.form-message.success {
  border: 1px solid #b7dfc7;
  background: #edf8f1;
  color: var(--success);
}

.form-message.error {
  border: 1px solid #f0b8b2;
  background: #fff0ee;
  color: var(--danger);
}

.form-note {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.admin-body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  background: #f4f6f5;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.admin-brand {
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
}

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

.admin-nav-link,
.admin-logout {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.admin-nav-link:hover,
.admin-nav-link.is-active {
  background: #e7f2ef;
  color: var(--accent-dark);
}

.admin-logout {
  width: 100%;
  margin-top: auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  cursor: pointer;
}

.admin-logout:hover:not(:disabled) {
  border-color: #efc0bb;
  background: #fff4f2;
  color: #8f1d14;
}

.admin-main {
  min-width: 0;
  padding: 24px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 800;
}

.admin-panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-panel h1,
.admin-panel h2 {
  margin: 0 0 16px;
}

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

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

.stat-card strong {
  font-size: 30px;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.admin-form label,
.inline-form {
  display: grid;
  gap: 8px;
}

.admin-form label span {
  color: #27333b;
  font-weight: 800;
}

.wide-field {
  grid-column: 1 / -1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.admin-filter-form {
  grid-template-columns: minmax(220px, 360px) auto;
  align-items: end;
  margin-top: 18px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: #38434b;
  font-size: 13px;
  white-space: nowrap;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-inline-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.compact-stat-grid {
  margin-bottom: 16px;
}

.admin-practice-table-wrap {
  max-height: none;
}

.admin-practice-table {
  min-width: 1280px;
}

.admin-practice-student,
.admin-practice-content,
.admin-practice-score,
.admin-practice-audio-cell,
.admin-practice-feedback {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.admin-practice-student strong,
.admin-practice-content strong,
.admin-practice-score strong {
  color: var(--ink);
}

.admin-practice-student span,
.admin-practice-content p,
.admin-practice-score span,
.admin-practice-audio-cell span,
.admin-practice-feedback p,
.admin-practice-feedback small {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.admin-practice-content {
  max-width: 320px;
}

.admin-practice-score {
  min-width: 92px;
  font-variant-numeric: tabular-nums;
}

.admin-practice-audio-cell {
  min-width: 360px;
}

.admin-practice-audio {
  display: block;
  width: 380px;
  max-width: 100%;
}

.admin-actions {
  margin-top: 18px;
}

.admin-dialog {
  width: min(720px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(20, 28, 34, 0.22);
}

.admin-dialog::backdrop {
  background: rgba(20, 28, 34, 0.38);
}

.admin-dialog h2 {
  margin: 0 0 16px;
}

.dialog-close-form {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.inline-form {
  grid-template-columns: minmax(120px, 1fr) auto;
  align-items: center;
}

.inline-form input {
  min-width: 120px;
  padding: 8px 10px;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.small-button:hover:not(:disabled) {
  background: var(--accent-dark);
  color: #fff;
}

.small-button.outline {
  border: 1px solid var(--accent);
  background: #ffffff;
  color: var(--accent-dark);
}

.small-button.outline:hover:not(:disabled) {
  border-color: #9ed6d7;
  background: #e9f7f7;
  color: var(--accent-dark);
}

.small-button.danger {
  background: var(--danger);
}

.small-button.danger:hover:not(:disabled) {
  background: #8f1d14;
  color: #fff;
}

.text-link {
  color: var(--accent-dark);
  font-weight: 800;
}

.muted-text {
  color: var(--muted);
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-badge.active,
.status-badge.approved {
  background: #edf8f1;
  color: var(--success);
}

.status-badge.pending {
  background: #fff8dc;
  color: var(--warning);
}

.status-badge.rejected,
.status-badge.disabled,
.status-badge.expired {
  background: #fff0ee;
  color: var(--danger);
}

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

.detail-list div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.detail-list dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
}

.detail-list dd {
  margin: 0;
  font-weight: 800;
}

.wide-detail {
  grid-column: 1 / -1;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 22px;
}

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

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
}

.status-pill {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--surface-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1120px);
  justify-content: center;
  gap: 16px;
  align-items: start;
}

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

.panel {
  padding: 18px;
}

.compose-pane {
  padding: 22px;
}

.form,
.field {
  display: flex;
  flex-direction: column;
}

.field span,
.field-heading,
h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}

.field-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#char-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

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

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

textarea {
  resize: vertical;
  height: 180px;
  min-height: 180px;
  line-height: 1.7;
}

.language-hint {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  margin: 12px 0 0;
  padding: 9px 13px;
  border: 0;
  border-radius: 8px;
  background: #e8f7f2;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
}

.auto-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.translation-result,
.result-panel {
  display: grid;
  gap: 10px;
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}

.audio-panel {
  min-height: 220px;
}

.translation-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.translation-result h2 {
  margin: 0;
  font-size: 16px;
}

.translation-result p,
.translation-output {
  margin: 0;
  color: #2e3a42;
  line-height: 1.75;
  white-space: pre-wrap;
}

.translation-result .muted-translation {
  color: var(--muted);
  font-weight: 700;
}

.translation-tag.working {
  border-color: #d8c073;
  background: #fff8dc;
  color: var(--warning);
}

.translation-tag.ready {
  border-color: #b7dfc7;
  background: #edf8f1;
  color: var(--success);
}

.translation-tag.error {
  border-color: #f0b8b2;
  background: #fff0ee;
  color: var(--danger);
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.actions #submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  width: 100%;
  padding: 0 22px;
  background: var(--accent);
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(15, 139, 141, 0.2);
}

.actions #submit-button:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 16px 32px rgba(11, 98, 100, 0.24);
}

.actions #submit-button.is-loading::before {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.46);
  border-top-color: #fff;
  border-radius: 50%;
  content: "";
  animation: spin 800ms linear infinite;
}

.synth-status-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.6;
}

.synth-status-text.submitting,
.synth-status-text.processing,
.synth-status-text.translating,
.synth-status-text.synthesizing,
.synth-status-text.generating {
  color: var(--warning);
}

.synth-status-text.success {
  color: var(--success);
}

.synth-status-text.error {
  color: var(--danger);
}

.text-action {
  justify-self: start;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
  box-shadow: none;
}

.text-action:hover:not(:disabled),
.text-action:focus-visible {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

.debug-details {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.debug-details pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  color: #33414a;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, opacity 160ms ease;
}

button:not([class]):hover:not(:disabled) {
  background: var(--accent-dark);
}

button.button-secondary:hover:not(:disabled) {
  background: #edf6f4;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
}

.log {
  margin: 0;
  padding: 16px;
  min-height: 140px;
  border-radius: 8px;
  background: #172026;
  color: #eaf2f2;
  overflow: auto;
  line-height: 1.65;
  white-space: pre-wrap;
}

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

.audio-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f8f9;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.audio-state.working,
.audio-state.loading {
  border-color: #d8c073;
  background: #fff8dc;
  color: var(--warning);
}

.audio-state.ready {
  border-color: #b7dfc7;
  background: #edf8f1;
  color: var(--success);
}

.audio-state.playing {
  border-color: #9ed6d7;
  background: #e8f7f7;
  color: var(--accent-dark);
}

.audio-state.error {
  border-color: #f0b8b2;
  background: #fff0ee;
  color: var(--danger);
}

.player-shell {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf9 100%);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.player-shell:focus-within,
.player-shell:hover {
  border-color: #b7cdcf;
  box-shadow: 0 12px 26px rgba(23, 32, 38, 0.08);
}

.play-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  box-shadow: 0 12px 22px rgba(11, 98, 100, 0.22);
  color: #fff;
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.play-toggle:hover:not(:disabled) {
  background: linear-gradient(135deg, #10a1a3 0%, var(--accent-dark) 100%);
  box-shadow: 0 16px 28px rgba(11, 98, 100, 0.28);
  transform: translateY(-1px) scale(1.02);
}

.play-toggle:active:not(:disabled) {
  box-shadow: 0 8px 16px rgba(11, 98, 100, 0.24);
  transform: translateY(0) scale(0.96);
}

.play-toggle:focus-visible {
  outline: 3px solid rgba(15, 139, 141, 0.24);
  outline-offset: 4px;
}

.play-toggle:disabled {
  cursor: not-allowed;
  box-shadow: none;
}

.play-icon {
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid currentColor;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.14));
  transition: transform 160ms ease;
}

.play-toggle:hover:not(:disabled) .play-icon {
  transform: scale(1.06);
}

.play-toggle.is-playing .play-icon {
  position: relative;
  width: 18px;
  height: 20px;
  margin-left: 0;
  border: 0;
}

.play-toggle.is-playing .play-icon::before,
.play-toggle.is-playing .play-icon::after {
  position: absolute;
  top: 0;
  width: 6px;
  height: 20px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.play-toggle.is-playing .play-icon::before {
  left: 1px;
}

.play-toggle.is-playing .play-icon::after {
  right: 1px;
}

.player-main {
  min-width: 0;
  width: 100%;
}

.time-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 700;
}

.audio-progress {
  position: relative;
  display: block;
  width: 100%;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  transition: none;
}

.audio-progress:hover:not(:disabled),
.audio-progress:active:not(:disabled),
.audio-progress:focus-visible {
  background: transparent;
  box-shadow: none;
}

.audio-progress::before {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 6px;
  border-radius: 999px;
  background: #d5dde0;
  content: "";
  transform: translateY(-50%);
  transition: background-color 160ms ease;
}

.progress-fill {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0%;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
  transition: background-color 160ms ease;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 16px;
  height: 16px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 7px rgba(23, 32, 38, 0.18);
  transform: translate(-50%, -50%);
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.audio-progress:hover .progress-thumb,
.audio-progress:focus-visible .progress-thumb {
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.08), 0 2px 7px rgba(23, 32, 38, 0.18);
  transform: translate(-50%, -50%) scale(1.02);
}

.audio-progress:hover::before,
.audio-progress:focus-visible::before {
  background: #cbd6d8;
}

.audio-progress:hover .progress-fill,
.audio-progress:focus-visible .progress-fill {
  background: var(--accent-dark);
}

.audio-progress:focus-visible {
  outline: 0;
}

.audio-progress:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.audio-meta {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.audio-meta div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.audio-meta span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.audio-meta strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

audio {
  display: none;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
}

.download {
  display: inline-block;
  margin-top: 14px;
  color: var(--accent-dark);
  font-weight: 700;
}

.favorite-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.favorite-actions .download {
  margin-top: 0;
}

.compact-action {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
}

.favorite-status,
.library-message {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.favorite-status.success,
.library-message.success {
  color: var(--success);
}

.favorite-status.error,
.library-message.error {
  color: var(--danger);
}

.library-page {
  display: grid;
  gap: 18px;
}

.library-header,
.library-toolbar,
.audio-card-header,
.audio-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.library-header,
.audio-card-header {
  justify-content: space-between;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto max-content;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.library-toolbar input {
  min-width: 0;
}

.library-toolbar > button[type="submit"] {
  min-width: 76px;
  white-space: nowrap;
}

.play-mode-field {
  display: grid;
  grid-template-columns: auto minmax(120px, 150px);
  align-items: center;
  gap: 8px;
  justify-self: end;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.play-mode-field select {
  padding: 10px 12px;
}

.audio-library-list {
  display: grid;
  gap: 14px;
}

.audio-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.audio-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.audio-card.is-playing {
  border-color: #9ed6d7;
  box-shadow: 0 16px 42px rgba(15, 139, 141, 0.12);
}

.audio-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.audio-card-date,
.audio-card-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.audio-card-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.audio-text-preview,
.audio-text-full,
.audio-translation-preview,
.audio-translation-full p,
.bilingual-text-block p {
  margin: 0;
  color: #2e3a42;
  line-height: 1.75;
}

.audio-text-preview,
.audio-translation-preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.audio-translation-preview {
  padding-left: 12px;
  border-left: 3px solid #b7dfc7;
  color: #354b44;
}

.audio-text-full,
.audio-translation-full {
  display: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  white-space: pre-wrap;
}

.audio-translation-full {
  border-left: 3px solid #7dbb94;
}

.audio-translation-label {
  display: block;
  margin-bottom: 8px;
  color: var(--success);
  font-size: 13px;
  font-weight: 800;
}

.audio-card.is-expanded .audio-text-preview {
  display: none;
}

.audio-card.is-expanded .audio-translation-preview {
  display: none;
}

.audio-card.is-expanded .audio-text-full,
.audio-card.is-expanded .audio-translation-full {
  display: block;
}

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

.bilingual-text-block {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.bilingual-text-block h3 {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 14px;
}

.bilingual-text-block p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  white-space: pre-wrap;
}

.audio-card.is-expanded .bilingual-text-block p {
  display: block;
}

.audio-card audio {
  display: block;
  width: 100%;
}

.practice-panel-mount:empty {
  display: none;
}

.practice-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid #cce8e8;
  border-radius: 12px;
  background: #f0fbfb;
}

.practice-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.practice-title-block {
  min-width: 0;
}

.practice-title-block h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 18px;
}

.practice-title-icon {
  position: relative;
  width: 16px;
  height: 22px;
  flex: 0 0 16px;
  border: 2px solid currentColor;
  border-radius: 10px;
}

.practice-title-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 2px;
  height: 6px;
  background: currentColor;
  transform: translateX(-50%);
}

.practice-title-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translateX(-50%);
}

.practice-title-block p,
.practice-muted,
.practice-score-empty p,
.practice-feedback p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.practice-collapse-button,
.practice-text-toggle {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 800;
  cursor: pointer;
}

.practice-collapse-button:hover:not(:disabled),
.practice-text-toggle:hover:not(:disabled) {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

.practice-collapse-button {
  min-height: 36px;
  white-space: nowrap;
}

.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 14px;
}

.practice-column {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.practice-section {
  min-width: 0;
  padding: 14px;
  border: 1px solid #d7eeee;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.practice-section h4 {
  margin: 0 0 10px;
  color: #21343a;
  font-size: 15px;
}

.practice-button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.practice-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

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

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

.practice-button.secondary:hover {
  background: #e9f7f7;
}

.practice-button.danger,
.practice-button.danger-soft {
  background: var(--danger);
}

.practice-button.danger-soft {
  border-color: #efc0bb;
  background: #fff4f2;
  color: var(--danger);
}

.practice-button:disabled {
  border-color: #d7e1e2;
  background: #e9eeee;
  color: #829095;
  cursor: not-allowed;
}

.practice-timer {
  min-width: 54px;
  color: var(--danger);
  font-size: 15px;
  font-weight: 900;
}

.practice-recording-audio {
  margin-top: 12px;
  max-width: 100%;
}

.practice-recording-playback {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e0eeee;
  border-radius: 8px;
  background: #fbffff;
}

.practice-recording-playback h4 {
  margin: 0;
  color: #20323a;
  font-size: 14px;
}

.practice-recording-playback audio {
  display: block;
  width: 100%;
}

.practice-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #f0b8b2;
  border-radius: 8px;
  background: #fff4f2;
  color: var(--danger);
  font-weight: 700;
  line-height: 1.6;
}

.practice-text-wrap {
  position: relative;
  min-width: 0;
}

.practice-text-toggle {
  float: right;
  min-height: 30px;
  padding-left: 10px;
}

.practice-reference-text {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #20323a;
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.practice-reference-text.is-expanded {
  display: block;
}

.practice-score-section {
  background: #ffffff;
}

.practice-score-empty {
  padding: 12px;
  border: 1px dashed #b9d9d9;
  border-radius: 8px;
  background: #f8ffff;
}

.practice-score-empty strong {
  display: block;
  margin-bottom: 4px;
  color: #28434a;
}

.practice-score-layout {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.practice-overall-score {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 132px;
  border-radius: 10px;
  background: #e4f6f6;
  color: var(--accent-dark);
}

.practice-overall-score strong {
  font-size: 42px;
  line-height: 1;
}

.practice-overall-score span {
  margin-top: 6px;
  font-weight: 900;
}

.practice-score-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.practice-score-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #d7eeee;
  border-radius: 8px;
  background: #fbffff;
}

.practice-score-metric span {
  color: var(--muted);
  font-weight: 800;
}

.practice-score-metric strong {
  color: #20323a;
  white-space: nowrap;
}

.practice-feedback {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #f6fbfb;
}

.practice-feedback summary {
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.practice-feedback p {
  margin-top: 8px;
}

.practice-feedback h4 {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 15px;
}

.practice-panel {
  gap: 12px;
  padding: 16px 18px;
  border-color: #bfe5e7;
  border-radius: 10px;
  background: #f2fcfc;
  box-shadow: none;
}

.practice-panel-header {
  display: block;
}

.practice-title-block h3 {
  font-size: 17px;
}

.practice-empty-line {
  color: var(--muted);
  font-weight: 800;
}

.practice-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid #d3ecec;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.practice-summary-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 14px;
  border-right: 1px solid #d3ecec;
}

.practice-summary-item:last-child {
  border-right: 0;
}

.practice-summary-item span,
.practice-summary-item small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.practice-summary-item strong {
  color: var(--accent-dark);
  font-size: 18px;
  line-height: 1.2;
}

.practice-live,
.practice-submitting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid #d3ecec;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.practice-live-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #20323a;
}

.practice-waveform {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 170px;
}

.practice-waveform span {
  width: 4px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  animation: practiceWave 860ms ease-in-out infinite;
}

.practice-waveform span:nth-child(2n) {
  height: 22px;
  animation-delay: 80ms;
}

.practice-waveform span:nth-child(3n) {
  height: 30px;
  animation-delay: 160ms;
}

@keyframes practiceWave {
  0%,
  100% {
    transform: scaleY(0.55);
    opacity: 0.58;
  }

  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

.practice-submitting p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.practice-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #cce8e8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: practiceSpin 800ms linear infinite;
}

@keyframes practiceSpin {
  to {
    transform: rotate(360deg);
  }
}

.practice-score-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d3ecec;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.practice-score-card > h4 {
  margin: 0;
  color: #20323a;
  font-size: 15px;
}

.practice-score-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.practice-total-score {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 96px;
  border-right: 1px solid #d3ecec;
  color: var(--accent-dark);
}

.practice-total-score span,
.practice-total-score small {
  color: var(--muted);
  font-weight: 900;
}

.practice-total-score strong {
  font-size: 44px;
  line-height: 1;
}

.practice-score-card .practice-score-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.practice-score-card .practice-score-metric {
  align-items: center;
  padding: 10px;
  background: #f8ffff;
}

.practice-score-card .practice-score-metric strong {
  color: var(--accent-dark);
  font-size: 20px;
}

.practice-score-card.is-compact {
  gap: 8px;
  padding: 10px 12px;
}

.practice-score-card.is-compact > h4 {
  color: #40505a;
  font-size: 14px;
}

.practice-compact-score-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.practice-compact-total {
  margin-right: 2px;
  color: var(--accent-dark);
  font-size: 24px;
  line-height: 1;
}

.practice-compact-score-metric {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #d3ecec;
  border-radius: 999px;
  background: #f8ffff;
  color: #4e5d66;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.practice-compact-feedback {
  min-width: 0;
}

.practice-compact-feedback summary {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.practice-compact-feedback p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.practice-feedback {
  margin-top: 0;
  padding: 12px;
  border: 1px solid #e0eeee;
  background: #fbffff;
}

.practice-score-card.is-compact .practice-feedback {
  padding: 10px 12px;
}

.practice-score-card.is-compact .practice-feedback summary {
  font-size: 13px;
}

.practice-score-card.is-compact .practice-feedback p {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.practice-saved-note {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.practice-history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  background: rgba(23, 32, 38, 0.22);
}

.practice-history-drawer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(460px, 100%);
  height: 100%;
  padding: 22px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -18px 0 42px rgba(23, 32, 38, 0.16);
}

.practice-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.practice-history-header h3 {
  margin: 0 0 4px;
}

.practice-history-header p,
.practice-history-tip {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.practice-history-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f3f7f7;
  color: #41545c;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.practice-history-close:hover:not(:disabled) {
  background: #e7f2ef;
  color: var(--accent-dark);
}

.practice-history-list {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.practice-history-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #d3ecec;
  border-radius: 8px;
  background: #fbffff;
}

.practice-history-item-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.practice-history-item audio {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  height: 40px;
}

.practice-history-item strong {
  color: var(--accent-dark);
  font-size: 18px;
}

.practice-history-badges,
.practice-history-item time,
.practice-history-item p,
.practice-history-item summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.practice-history-item p {
  margin: 0;
}

.practice-history-item details p {
  margin-top: 6px;
  font-weight: 700;
  line-height: 1.6;
}

.audio-card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .admin-body {
    grid-template-columns: 1fr;
  }

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

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

  .stat-grid,
  .grid-form,
  .admin-filter-form,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .hero h1,
  .narrow-panel h1 {
    font-size: 34px;
  }

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

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

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

}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1080px);
    padding-top: 28px;
  }

  .panel {
    padding: 18px;
  }

  .admin-main,
  .admin-sidebar {
    padding: 16px;
  }

  .admin-nav {
    grid-template-columns: 1fr;
  }

  .admin-panel {
    padding: 16px;
  }

  .site-header,
  .site-main {
    width: min(100% - 20px, 1080px);
  }

  .site-main {
    padding-top: 14px;
  }

  .hero {
    padding-top: 34px;
  }

  .hero h1,
  .narrow-panel h1 {
    font-size: 30px;
  }

  .lead {
    font-size: 18px;
  }

  textarea {
    height: 160px;
    min-height: 160px;
  }

  .narrow-panel {
    padding: 20px;
  }

  .status-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    align-items: flex-start;
    padding-bottom: 16px;
  }

  .topbar-actions .nav-link {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .library-header,
  .audio-card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .play-mode-field {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
    grid-template-columns: auto minmax(120px, 220px);
  }

  .play-mode-field select {
    max-width: none;
  }

  .audio-card-actions {
    justify-content: flex-start;
  }

  .bilingual-texts {
    grid-template-columns: 1fr;
  }

  .small-button,
  .practice-button {
    min-height: 44px;
  }

  .practice-panel {
    gap: 14px;
    padding: 14px;
    border-radius: 12px;
  }

  .practice-panel-header,
  .practice-grid,
  .practice-score-layout,
  .practice-score-metrics {
    grid-template-columns: 1fr;
  }

  .practice-panel-header {
    display: grid;
  }

  .practice-button-row {
    align-items: stretch;
  }

  .practice-button-row .practice-button {
    flex: 1 1 150px;
  }

  .practice-overall-score {
    min-height: 110px;
  }

  .practice-score-metric {
    align-items: flex-start;
    flex-direction: column;
  }

  .practice-summary-strip,
  .practice-score-grid,
  .practice-score-card .practice-score-metrics {
    grid-template-columns: 1fr;
  }

  .practice-summary-item {
    border-right: 0;
    border-bottom: 1px solid #d3ecec;
  }

  .practice-summary-item:last-child {
    border-bottom: 0;
  }

  .practice-live,
  .practice-submitting {
    align-items: stretch;
    flex-direction: column;
  }

  .practice-waveform {
    min-width: 0;
  }

  .practice-total-score {
    min-height: 86px;
    border-right: 0;
    border-bottom: 1px solid #d3ecec;
  }

  .practice-history-backdrop {
    align-items: flex-end;
  }

  .practice-history-drawer {
    width: 100%;
    height: min(86vh, 680px);
    padding: 18px;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
  }

  .practice-history-item-top {
    grid-template-columns: 1fr auto;
  }

  .practice-history-badges,
  .practice-history-item time {
    grid-column: 2;
  }

  .bilingual-texts {
    grid-template-columns: 1fr;
  }

  .player-shell {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .play-toggle {
    width: 60px;
    height: 60px;
  }

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