.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.88);
  /* Pin layout: dialog fills height; only meta scrolls (not the iframe). */
  overflow: hidden;
  align-items: center;
  justify-content: center;
  padding: 2vh 0;
  box-sizing: border-box;
}

.modal.open {
  display: flex;
}

.modal-dialog {
  display: flex;
  flex-direction: column;
  width: min(920px, 94vw);
  max-height: 96vh;
  margin: 0 auto;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
}

.modal-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #1a1a1a;
  color: #fff;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.modal-close {
  background: none;
  border: 0;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.player-frame {
  flex: 0 0 auto;
  position: relative;
  padding-top: 56.25%;
  background: #000;
}

.player-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-meta {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fffff8;
  color: var(--ink);
  padding: 16px 18px 20px;
}

.player-meta h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.chapter-heading {
  margin: 16px 0 8px;
  font-size: 1rem;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--mist);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.chapter-row:hover,
.chapter-row.active {
  border-color: var(--selected-bg);
  background: var(--accent-soft);
}

.chapter-time {
  color: var(--muted-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.media-action-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: #fffff8;
  border-bottom: 1px solid var(--mist);
}

.media-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--mist);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.media-action-btn:hover {
  border-color: var(--selected-bg);
  background: var(--accent-soft);
}

.media-action-icon {
  font-size: 1rem;
  line-height: 1;
}

.handout-dialog {
  width: min(920px, 94vw);
  max-height: 96vh;
}

.handout-frame {
  flex: 1 1 auto;
  min-height: 50vh;
  background: #f4f7fa;
  position: relative;
}

.handout-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.handout-footer {
  flex: 0 0 auto;
  padding: 12px 18px 16px;
  background: #fffff8;
  border-top: 1px solid var(--mist);
}

.handout-footer a {
  font-weight: 600;
  color: var(--ink);
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  z-index: 2000;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(20, 32, 44, 0.92);
  color: #fff;
  font-size: 0.95rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
