/* The teacher's editor. */

.page-teach {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar-teach {
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.deck-head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.deck-title {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 520px;
  padding: 7px 10px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 1.0625rem;
  font-weight: 700;
  text-overflow: ellipsis;
}

.deck-title:hover {
  border-color: var(--line);
}

.deck-title:focus {
  outline: none;
  border-color: var(--tile);
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--ring);
}

.save-status {
  color: var(--ink-faint);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.save-status.is-error {
  color: var(--pomegranate);
  white-space: normal;
}

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

.editor {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 390px;
}

/* ----- slide list ----- */

.slides-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 16px 10px 14px 12px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.pane-title {
  padding: 0 8px;
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-weight: 700;
}

.slide-list {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 4px;
  overflow-y: auto;
  padding: 2px;
}

.slide-item {
  border-radius: 12px;
}

.slide-item.is-selected {
  background: var(--tile-wash);
}

.slide-pick {
  appearance: none;
  display: grid;
  grid-template-columns: 20px 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}

.slide-pick:hover {
  background: var(--paper-sunk);
}

.slide-item.is-selected .slide-pick:hover {
  background: transparent;
}

.slide-num {
  color: var(--ink-faint);
  font: 600 0.8125rem/1 var(--font-display);
  text-align: center;
}

.slide-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--paper-sunk);
  color: var(--tile);
}

.slide-item.is-selected .slide-icon {
  background: var(--tile);
  color: var(--tile-ink);
}

.slide-icon .icon {
  width: 17px;
  height: 17px;
}

.slide-text {
  display: grid;
  min-width: 0;
}

.slide-type {
  color: var(--ink-faint);
  font-size: 0.75rem;
  font-weight: 600;
}

.slide-title {
  overflow: hidden;
  font-size: 0.9375rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-warn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pomegranate);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 800;
}

.slide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  padding: 0 6px 6px;
}

.slide-actions .icon-btn {
  width: 34px;
  height: 34px;
}

.icon-btn.danger:hover:not([disabled]),
.btn.danger {
  color: var(--pomegranate);
}

.slide-empty {
  padding: 12px 8px;
  color: var(--ink-faint);
  font-size: 0.9375rem;
}

.add-slide {
  width: 100%;
}

/* ----- slide form ----- */

.edit-col {
  min-height: 0;
  overflow-y: auto;
  padding: 24px clamp(16px, 3vw, 44px) 72px;
}

.problem-banner {
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--pomegranate-wash);
  color: var(--pomegranate);
  font-weight: 600;
}

.edit-pane {
  display: grid;
  gap: 24px;
  max-width: 720px;
  margin: 0 auto;
}

.edit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.edit-type-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--tile);
  color: var(--tile-ink);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2), 0 3px 0 var(--tile-edge);
}

.edit-slide-n {
  color: var(--ink-soft);
  font-weight: 700;
}

.type-switch {
  width: auto;
  min-width: 220px;
  margin-left: auto;
}

.preview-toggle {
  display: none;
}

.edit-form {
  display: grid;
  gap: 24px;
}

.textarea-big {
  min-height: 64px;
  overflow: hidden;
  resize: none;
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.35;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
}

.field-row .field {
  flex: 1 1 200px;
}

.field-row .field-narrow,
.field-narrow {
  flex: 0 1 240px;
  max-width: 260px;
}

.opt-list {
  display: grid;
  gap: 8px;
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opt-row .input {
  flex: 1;
  min-width: 0;
}

.opt-shape {
  display: grid;
  place-items: center;
  width: 40px;
  height: 46px;
  flex: none;
  border-radius: 10px;
  background: var(--c);
  color: #fff;
  box-shadow: 0 3px 0 var(--edge);
}

.opt-shape .shape {
  width: 20px;
  height: 20px;
}

.opt-correct {
  appearance: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
  color: transparent;
  cursor: pointer;
}

.opt-correct .icon {
  width: 20px;
  height: 20px;
}

.opt-correct:hover {
  border-color: var(--leaf);
  color: var(--leaf);
}

.opt-correct[aria-pressed='true'] {
  border-color: var(--leaf);
  background: var(--leaf);
  color: #fff;
}

.opt-row.is-correct .input {
  border-color: var(--leaf);
}

.add-row {
  justify-self: start;
  margin-top: 2px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
}

.segment[aria-checked='true'] {
  border-color: var(--c);
  background: var(--c);
  color: #fff;
  box-shadow: 0 3px 0 var(--edge);
}

.edit-settings {
  display: grid;
  gap: 18px;
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--paper);
}

.settings-title {
  font-size: 1rem;
  font-weight: 700;
}

.edit-settings .field-row:empty {
  display: none;
}

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

.check-hint {
  display: block;
  margin-top: 2px;
}

.edit-empty {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 64px 0;
  color: var(--ink-soft);
  text-align: center;
}

/* ----- phone preview ----- */

.preview-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--paper-sunk);
}

.preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 344px;
}

.preview-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-weight: 700;
}

.preview-title .icon {
  width: 18px;
  height: 18px;
}

.preview-close {
  display: none;
}

.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 344px;
  flex: 1 1 auto;
  min-height: 500px;
  max-height: 720px;
  overflow: hidden;
  border: 10px solid #1b2742;
  border-radius: 38px;
  background: var(--ground);
  box-shadow: var(--lift);
}

.phone-notch {
  position: absolute;
  top: 7px;
  left: 50%;
  z-index: 6;
  width: 84px;
  height: 20px;
  border-radius: 12px;
  background: #1b2742;
  transform: translateX(-50%);
}

.phone-screen.play {
  flex: 1;
  max-width: none;
  margin: 0;
  overflow-y: auto;
  padding: 36px 14px 0;
}

.sv-actions.in-phone {
  position: sticky;
  bottom: 0;
  margin: 10px -14px 0;
  padding: 10px 14px 14px;
}

.mini-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.mini-seg-btn {
  appearance: none;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.mini-seg-btn[aria-pressed='true'] {
  background: var(--tile);
  color: var(--tile-ink);
}

.btn-tiny {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.8125rem;
}

/* ----- dialogs ----- */

.dialog-wide {
  width: min(780px, calc(100% - 24px));
}

.type-groups {
  display: grid;
  gap: 20px;
}

.type-group-title {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 700;
}

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

.type-card {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}

.type-card:hover {
  border-color: var(--tile);
  background: var(--tile-wash);
}

.type-card-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: var(--tile-wash);
  color: var(--tile-deep);
}

.type-card:hover .type-card-icon {
  background: var(--tile);
  color: var(--tile-ink);
}

.type-card-text {
  display: grid;
  gap: 2px;
}

.type-card-name {
  font-weight: 700;
}

.type-card-desc {
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.35;
}

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

.deck-list {
  display: grid;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}

.deck-open {
  appearance: none;
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}

.deck-open:hover {
  border-color: var(--ink-faint);
}

.deck-row.is-current .deck-open {
  border-color: var(--tile);
  background: var(--tile-wash);
}

.deck-name {
  font-weight: 700;
}

.deck-meta {
  color: var(--ink-faint);
  font-size: 0.8125rem;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-list {
  display: grid;
  gap: 2px;
}

.recent-list .btn {
  justify-content: flex-start;
}

.paste {
  display: grid;
  gap: 12px;
}

.paste-area {
  min-height: 220px;
}

.paste-foot {
  display: flex;
  justify-content: flex-end;
}

.settings {
  display: grid;
  gap: 22px;
}

/* ----- smaller screens ----- */

@media (max-width: 1100px) {
  .topbar-teach {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .deck-head {
    order: 3;
    flex-basis: 100%;
  }
}

@media (max-width: 1180px) {
  .editor {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .preview-pane {
    display: none;
  }

  .editor.show-preview .preview-pane {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    justify-content: center;
    padding: 20px 16px;
    border: 0;
    background: rgba(14, 23, 44, 0.6);
  }

  .editor.show-preview .preview-head {
    padding: 8px 8px 8px 14px;
    border-radius: 12px;
    background: var(--paper);
  }

  .editor.show-preview .phone {
    flex: 0 1 720px;
  }

  .preview-close,
  .preview-toggle {
    display: inline-flex;
  }
}

@media (max-width: 760px) {
  .page-teach {
    height: auto;
    overflow: visible;
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .topbar-teach .brand-word,
  .wide-only {
    display: none;
  }

  .top-actions .lang-picker {
    max-width: 140px;
  }

  .present-btn {
    position: fixed;
    left: var(--gutter);
    right: var(--gutter);
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 30;
    min-height: 56px;
    font-size: 1.0625rem;
    box-shadow: 0 3px 0 var(--tile-edge), var(--lift);
  }

  .editor {
    display: block;
  }

  .slides-pane {
    padding: 10px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .pane-title {
    display: none;
  }

  .slide-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 12px;
  }

  .slide-item {
    flex: 0 0 220px;
  }

  .add-slide {
    width: auto;
    margin: 0 12px;
  }

  .edit-col {
    overflow: visible;
    padding: 18px var(--gutter) 48px;
  }

  .type-switch {
    flex-basis: 100%;
    margin-left: 0;
  }

  .phone {
    width: min(344px, 100%);
  }
}
