.teacher-page {
  width: min(1500px, 100%);
}

.teacher-hero {
  align-items: center;
}

.teacher-hero code {
  padding: 1px 5px;
  border-radius: 6px;
  color: #31539a;
  background: #edf3ff;
  font: 0.92em ui-monospace, SFMono-Regular, Menlo, monospace;
}

.local-seal {
  min-width: 220px;
  padding: 15px 17px;
  border: 1px solid #cedaf0;
  border-radius: 16px;
  background: linear-gradient(145deg, #f9fbff, #eef4ff);
  box-shadow: var(--shadow-soft);
}

.local-seal strong {
  display: block;
  color: var(--blue);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.local-seal span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.teacher-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.85fr) minmax(520px, 1.45fr);
  align-items: start;
  gap: 17px;
}

.setup-card,
.timeline-card {
  min-width: 0;
}

.teacher-form {
  display: grid;
  gap: 14px;
  padding: 17px 20px 20px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  color: #40536f;
  font-size: 11px;
  font-weight: 900;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  background: #fbfcff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.field input,
.field select {
  height: 39px;
  padding: 7px 10px;
  font-size: 13px;
}

.field textarea {
  min-height: 220px;
  padding: 11px 12px;
  resize: vertical;
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #83a5ec;
  outline: 0;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49, 94, 251, 0.1);
}

.file-drop {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 13px;
  border: 1px dashed #b8cae8;
  border-radius: 13px;
  background: #f8faff;
  cursor: pointer;
}

.file-drop:hover {
  border-color: #82a5e6;
  background: #f2f7ff;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-icon {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: #5578d9;
  font-size: 18px;
}

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

.file-copy strong,
.file-copy small {
  display: block;
}

.file-copy strong {
  color: #39547f;
  font-size: 12px;
}

.file-copy small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-action {
  padding: 5px 8px;
  border-radius: 8px;
  color: #315b9c;
  background: #e9f0ff;
  font-size: 10px;
  font-weight: 900;
}

.field-transcript textarea {
  min-height: 255px;
}

.format-help {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}

.format-help summary {
  padding: 10px 12px;
  color: #49648e;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.format-help > div {
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 11px;
}

.format-help p {
  margin: 7px 0 4px;
}

.format-help pre {
  margin: 0;
  padding: 9px 10px;
  overflow-x: auto;
  border-radius: 9px;
  color: #2d405f;
  background: #f1f4f9;
  font: 10px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.setup-actions {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-wrap: wrap;
}

.setup-actions > span {
  min-width: 180px;
  color: var(--muted);
  font-size: 10px;
}

.timeline-card {
  position: sticky;
  top: 80px;
  overflow: hidden;
}

.timeline-heading {
  align-items: center;
}

.timeline-stats {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.timeline-stats strong {
  color: #315b9c;
  font-size: 15px;
}

.teacher-player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 17px 20px 0;
  padding: 13px;
  border: 1px solid #d7e1f2;
  border-radius: 15px;
  background: linear-gradient(135deg, #f9fbff, #f0f5ff);
}

.teacher-player-main {
  min-width: 0;
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 20px;
  color: var(--muted);
  font-size: 10px;
}

.timeline-toolbar > div {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.timeline-mark-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin: 0 20px 10px;
  padding: 9px 10px;
  border: 1px solid #dbe4f2;
  border-radius: 11px;
  background: #f8faff;
}

.timeline-mark-tools > span {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
}

#freePlay[aria-pressed="true"] {
  border-color: #8facdf;
  color: #214a9a;
  background: #eaf1ff;
}

.waveform-wrap {
  margin: 0 20px 10px;
  padding: 9px 10px 7px;
  border: 1px solid #dbe4f2;
  border-radius: 12px;
  background: #fbfcff;
}

#teacherWaveform {
  display: block;
  width: 100%;
  height: 92px;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
  background: linear-gradient(180deg, #f8fbff, #f1f5fb);
}

.waveform-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
}

#waveformStatus {
  color: #6f819c;
}

.timeline-validation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 20px 10px;
  padding: 9px 11px;
  border: 1px solid #d8e4df;
  border-radius: 11px;
  color: #4e6f65;
  background: #f4fbf8;
  font-size: 10px;
}

.timeline-validation.is-warning {
  border-color: #e6c77a;
  color: #765a13;
  background: #fffaf0;
}

.timeline-validation > div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.validation-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #26a073;
}

.timeline-validation.is-warning .validation-dot {
  background: #d99b1b;
}

.preview-list {
  max-height: calc(100vh - 390px);
  min-height: 230px;
  overflow-y: auto;
  padding: 0 10px 10px;
  overscroll-behavior: contain;
}

.preview-group + .preview-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.preview-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px 5px;
  color: #3e5c91;
  font-size: 11px;
  font-weight: 900;
}

.preview-group-head input {
  width: 130px;
  height: 27px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #3e5c91;
  background: #f8faff;
  font-size: 10px;
  font-weight: 800;
}

.sentence-editor {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 62px 92px 92px 32px;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
}

.sentence-editor:hover {
  border-color: #dae4f2;
  background: #fbfcff;
}

.sentence-editor.active {
  border-color: #9db9ee;
  background: #f3f7ff;
  box-shadow: 0 4px 13px rgba(49, 94, 251, 0.08);
}

.sentence-editor.has-warning {
  border-color: #e7c36a;
  background: #fffbf1;
}

.sentence-editor .sentence-number {
  width: 28px;
  height: 28px;
}

.editor-play {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: #5c7ed0;
  font-size: 10px;
}

.editor-main {
  min-width: 0;
}

.editor-main input {
  width: 100%;
  height: 30px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #263750;
  background: #fff;
  font-size: 12px;
}

.editor-speaker,
.editor-time {
  width: 100%;
  height: 28px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #506179;
  background: #fff;
  font-size: 10px;
  text-align: center;
}

.editor-speaker {
  font-weight: 900;
}

.editor-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  color: #9b5260;
  background: #fff0f2;
  font-size: 13px;
}

.editor-remove:hover {
  background: #ffe2e7;
}

.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 20px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcff;
}

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

.export-bar strong,
.export-bar span {
  display: block;
}

.export-bar strong {
  color: #37537e;
  font-size: 12px;
}

.export-bar span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.teacher-page .toast {
  position: fixed;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.listening-editor-card {
  margin-top: 17px;
  overflow: hidden;
}

.listening-editor-heading {
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.listening-section-tabs {
  display: flex;
  gap: 7px;
  padding: 11px 15px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.listening-section-tabs::-webkit-scrollbar {
  display: none;
}

.listening-section-tabs button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #536783;
  background: #f7f9fd;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.listening-section-tabs button.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.listening-editor {
  display: grid;
  gap: 13px;
  padding: 15px;
}

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

.editor-block {
  display: grid;
  gap: 6px;
}

.editor-block > span,
.editor-block > label > span {
  color: #40536f;
  font-size: 10px;
  font-weight: 900;
}

.editor-block input,
.editor-block select,
.editor-block textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: #fbfcff;
  padding: 7px 9px;
  font-size: 12px;
}

.editor-block textarea {
  min-height: 72px;
  resize: vertical;
}

.choice-editor-row,
.expression-editor-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
}

.expression-editor-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.choice-letter {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #45617f;
  background: #edf3fb;
  font-size: 10px;
  font-weight: 900;
}

.listening-editor .btn {
  justify-self: start;
}

.library-card {
  margin-top: 17px;
  overflow: hidden;
}

.library-heading {
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.library-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.lesson-library-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  padding: 15px;
}

.library-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcff;
}

.library-item.is-current {
  border-color: #94b2ea;
  background: #f3f7ff;
  box-shadow: 0 5px 15px rgba(49, 94, 251, 0.08);
}

.library-item h3 {
  margin: 0;
  overflow: hidden;
  color: #304b76;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

.library-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

@media (max-width: 1120px) {
  .teacher-grid {
    grid-template-columns: 1fr;
  }

  .timeline-card {
    position: static;
  }

  .preview-list {
    max-height: 520px;
  }
}

@media (max-width: 760px) {
  .local-seal {
    margin-top: 15px;
  }

  .teacher-form,
  .setup-card .card-heading,
  .timeline-card .card-heading,
  .library-heading {
    padding-right: 15px;
    padding-left: 15px;
  }

  .heading-actions {
    width: 100%;
  }

  .heading-actions .btn {
    flex: 1 1 auto;
  }

  .lesson-library-list {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .editor-grid-2 {
    grid-template-columns: 1fr;
  }

  .expression-editor-row {
    grid-template-columns: 1fr 1fr auto;
  }

  .teacher-player {
    grid-template-columns: auto minmax(0, 1fr);
    margin-right: 15px;
    margin-left: 15px;
  }

  .teacher-player .loop-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .timeline-toolbar {
    display: block;
    padding-right: 15px;
    padding-left: 15px;
  }

  .timeline-toolbar > div {
    margin-top: 7px;
  }

  .timeline-mark-tools,
  .waveform-wrap,
  .timeline-validation {
    margin-right: 15px;
    margin-left: 15px;
  }

  .timeline-validation {
    align-items: flex-start;
    flex-direction: column;
  }

  .timeline-mark-tools .btn {
    flex: 1 1 130px;
  }

  .timeline-mark-tools > span {
    width: 100%;
    margin-left: 0;
  }

  .sentence-editor {
    grid-template-columns: 30px 56px minmax(0, 1fr) 30px;
    gap: 6px;
  }

  .editor-main {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .editor-time {
    width: 56px;
  }

  .export-bar {
    align-items: flex-start;
    flex-direction: column;
    padding-right: 15px;
    padding-left: 15px;
  }

  .export-actions {
    width: 100%;
  }

  .export-bar .btn {
    flex: 1 1 auto;
  }
}
