:root {
  --bg: #0b0e14;
  --panel: #141a24;
  --fg: #e6ebf2;
  --muted: #8b97a8;
  --accent: #5b9dff;
  --ok: #3ecf8e;
  --err: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Notch / dynamic-island safe area: pad the header past the inset. */
.app-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  background: var(--panel);
  border-bottom: 1px solid #222b39;
}

.app-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.net-status {
  font-size: 0.85rem;
  color: var(--muted);
}
.net-status[data-online="true"]  { color: var(--ok); }
.net-status[data-online="false"] { color: var(--err); }
/* State-aware colouring: offline (red), online-not-cached (muted), ready (ok). */
.net-status[data-state="offline"] { color: var(--err); }
.net-status[data-state="online"]  { color: var(--muted); }
.net-status[data-state="ready"]   { color: var(--ok); }

.offline-precache {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line, #263041);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.offline-precache:hover:not(:disabled) { color: var(--fg, #e6ebf2); border-color: #5b9dff; }
.offline-precache:disabled { opacity: 0.6; cursor: default; }

/* Non-blocking service-worker update prompt (never interrupts a presentation). */
.sw-update-bar {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: #141a24;
  border: 1px solid #5b9dff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  font-size: 0.9rem;
}
.sw-update-btn {
  padding: 0.35rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: #5b9dff;
  color: #06101f;
  font-weight: 600;
  cursor: pointer;
}
.sw-update-btn:disabled { opacity: 0.6; cursor: default; }
.sw-update-dismiss {
  padding: 0.35rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.app-main {
  padding: 1rem;
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  max-width: 800px;
  margin: 0 auto;
}

.card {
  background: var(--panel);
  border: 1px solid #222b39;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.card h2 { margin-top: 0; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* --- Navigation ----------------------------------------------------------- */
.app-nav, .lib-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.app-nav { flex: 1; margin: 0 1rem; }
.lib-nav { margin: 0 0 1rem; }

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}
.nav-link:hover { color: var(--fg); }
.nav-link.active { color: var(--fg); background: #1d2634; }

.app-main [data-view][hidden] { display: none; }
.library-outlet { margin-top: 0.5rem; }

/* --- Bible view ----------------------------------------------------------- */
.bible-view h2 { margin-top: 0; }

.bible-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.bible-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }

.bible-select, .bible-input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid #222b39;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
}

.bible-refrow {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.bible-refrow .bible-input { flex: 1 1 240px; }

.bible-btn {
  background: #1d2634;
  color: var(--fg);
  border: 1px solid #2a3547;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.bible-btn:hover { background: #24314480; border-color: var(--accent); }
.bible-btn.primary { background: var(--accent); color: #06101f; border-color: var(--accent); font-weight: 600; }
.bible-btn.tiny { padding: 0.15rem 0.5rem; font-size: 0.75rem; }
.bible-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.bible-status { min-height: 1.2em; margin: 0.25rem 0 1rem; }
.bible-status[data-state="ok"]    { color: var(--ok); }
.bible-status[data-state="error"] { color: var(--err); }

.bible-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 720px) {
  .bible-columns { grid-template-columns: 1fr minmax(200px, 0.6fr); }
}

.bible-panel {
  background: var(--bg);
  border: 1px solid #222b39;
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.bible-panel h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }

.bible-seg { margin-bottom: 1rem; }
.bible-seg-title { margin: 0 0 0.35rem; font-size: 0.9rem; color: var(--accent); }
.bible-verse { margin: 0 0 0.35rem; }
.bible-vnum { color: var(--muted); font-size: 0.7rem; margin-right: 0.15rem; }
.bible-error { color: var(--err); font-size: 0.9rem; }

.bible-order { margin: 0; padding-left: 1.2rem; }
.bible-order-item { margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
.bible-order-title { flex: 1; font-size: 0.9rem; }

/* --- Songs & lyrics -------------------------------------------------------- */
.song-view h2 { margin-top: 0; }
.song-status { min-height: 1.2em; margin: 0.25rem 0 1rem; }
.song-status[data-state="ok"]    { color: var(--ok); }
.song-status[data-state="error"] { color: var(--err); }

.song-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 900px) {
  .song-columns { grid-template-columns: minmax(160px, 0.5fr) 1.4fr minmax(180px, 0.7fr); }
}

.song-panel {
  background: var(--bg);
  border: 1px solid #222b39;
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.song-panel h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }

.song-list { list-style: none; margin: 0; padding: 0; }
.song-list-item { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.song-link {
  flex: 1; text-align: left; background: none; border: none; color: var(--fg);
  cursor: pointer; font-size: 0.9rem; padding: 0.15rem 0;
}
.song-link:hover { color: var(--accent); }

.song-input, .song-select, .song-textarea {
  background: #10151f; color: var(--fg); border: 1px solid #2a3546;
  border-radius: 6px; padding: 0.35rem 0.5rem; font: inherit; width: 100%;
}
.song-textarea { resize: vertical; font-family: inherit; }

.song-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem; margin-bottom: 0.75rem;
}
.song-field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.75rem; color: var(--muted); }

.song-section {
  border: 1px solid #222b39; border-radius: 8px; padding: 0.5rem;
  margin-bottom: 0.6rem; background: #0e131c;
}
.song-sec-head { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.song-sec-num { color: var(--muted); font-size: 0.75rem; }
.song-sec-head .song-select { width: auto; }
.song-sec-head .song-input { flex: 1 1 120px; }
.song-sec-controls { display: flex; gap: 0.25rem; }

.song-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

.song-btn {
  background: #24314480; color: var(--fg); border: 1px solid #2a3546;
  border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer; font: inherit;
}
.song-btn:hover { border-color: var(--accent); }
.song-btn.primary { background: var(--accent); color: #06101f; border-color: var(--accent); font-weight: 600; }
.song-btn.tiny { padding: 0.15rem 0.5rem; font-size: 0.75rem; }

.song-import { margin-top: 0.75rem; }
.song-import summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }

.song-preview { display: flex; flex-direction: column; gap: 0.6rem; }
.song-slide {
  border: 1px solid #222b39; border-radius: 8px; padding: 0.6rem 0.75rem;
  background: #0e131c;
}
.song-slide-label { color: var(--accent); font-size: 0.75rem; margin-bottom: 0.3rem; }
.song-slide-line { margin: 0.1rem 0; text-align: center; }

/* --- Live presenter (operator) -------------------------------------------- */
.present-outlet { margin: 0; }
.present-header { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.present-header h2 { margin: 0; }
.present-pos { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.present-status { color: var(--muted); font-size: 0.8rem; }
.present-transition-controls {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  margin: 0.5rem 0 0.75rem; font-size: 0.85rem; color: var(--muted);
}
.present-transition-controls label {
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.present-transition-select {
  padding: 0.25rem 0.4rem; border-radius: 4px; border: 1px solid #2a3550;
  background: #0e1422; color: inherit; font-size: 0.85rem;
}
.present-transition-controls input[type="range"] {
  width: 80px; accent-color: var(--accent); vertical-align: middle;
}
.present-dur-label {
  font-variant-numeric: tabular-nums; min-width: 3em;
}

.present-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }
.present-btn {
  background: #24314480; color: var(--fg); border: 1px solid #2a3546;
  border-radius: 6px; padding: 0.4rem 0.8rem; cursor: pointer; font: inherit;
}
.present-btn:hover { border-color: var(--accent); }
.present-btn.primary { background: var(--accent); color: #06101f; border-color: var(--accent); font-weight: 600; }
.present-btn.tiny { padding: 0.15rem 0.5rem; font-size: 0.75rem; }

.present-grid {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
}
@media (min-width: 860px) {
  .present-grid { grid-template-columns: minmax(220px, 0.7fr) 1.3fr; }
}
.present-panel {
  background: var(--bg); border: 1px solid #222b39; border-radius: 10px; padding: 0.75rem 1rem;
}
.present-panel h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.present-order-actions { margin-bottom: 0.5rem; }

.present-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.present-list-item {
  display: flex; gap: 0.5rem; align-items: center; padding: 0.35rem 0.5rem;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.present-list-item:hover { background: #161d29; }
.present-list-item.active { background: #1d2634; border-color: var(--accent); }
.present-list-type {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); border: 1px solid #2a3546; border-radius: 4px; padding: 0 0.3rem;
}
.present-list-title { flex: 1; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 16:9 preview stages that reuse the audience slide look, scaled down. */
.present-current-stage, .present-next-stage {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  border-radius: 8px; overflow: hidden; margin-bottom: 0.75rem;
}
.present-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* --- Transition animations (present mode slide transitions) ----------------- */
:root { --transition-duration: 400ms; }

/* Slide transition container — stacks children for crossfade/slide */
.cp-stage-transition { position: relative; }
.cp-stage-transition > .cp-slide,
.cp-stage-transition > .cp-slide-mode {
  position: absolute; inset: 0;
}

/* Fade transition */
.cp-transition-fade {
  will-change: opacity;
  pointer-events: none;
}
.cp-transition-fade.cp-transition-out {
  opacity: 1;
  transition: opacity var(--transition-duration, 400ms) ease;
}
.cp-transition-fade.cp-transition-out-active {
  opacity: 0;
}
.cp-transition-fade.cp-transition-in {
  opacity: 0;
  transition: opacity var(--transition-duration, 400ms) ease;
}
.cp-transition-fade.cp-transition-in-active {
  opacity: 1;
}

/* Crossfade — both layers fade simultaneously */
.cp-transition-crossfade {
  will-change: opacity;
  pointer-events: none;
}
.cp-transition-crossfade.cp-transition-out {
  opacity: 1;
  transition: opacity var(--transition-duration, 400ms) ease;
}
.cp-transition-crossfade.cp-transition-out-active {
  opacity: 0;
}
.cp-transition-crossfade.cp-transition-in {
  opacity: 0;
  transition: opacity var(--transition-duration, 400ms) ease;
}
.cp-transition-crossfade.cp-transition-in-active {
  opacity: 1;
}

/* Slide left — current slides out to the left, next slides in from the right */
.cp-transition-slide-left {
  will-change: transform;
  pointer-events: none;
}
.cp-transition-slide-left.cp-transition-out {
  transform: translateX(0);
  transition: transform var(--transition-duration, 400ms) ease;
}
.cp-transition-slide-left.cp-transition-out-active {
  transform: translateX(-100%);
}
.cp-transition-slide-left.cp-transition-in {
  transform: translateX(100%);
  transition: transform var(--transition-duration, 400ms) ease;
}
.cp-transition-slide-left.cp-transition-in-active {
  transform: translateX(0);
}

/* Slide right — current slides out to the right, next slides in from the left */
.cp-transition-slide-right {
  will-change: transform;
  pointer-events: none;
}
.cp-transition-slide-right.cp-transition-out {
  transform: translateX(0);
  transition: transform var(--transition-duration, 400ms) ease;
}
.cp-transition-slide-right.cp-transition-out-active {
  transform: translateX(100%);
}
.cp-transition-slide-right.cp-transition-in {
  transform: translateX(-100%);
  transition: transform var(--transition-duration, 400ms) ease;
}
.cp-transition-slide-right.cp-transition-in-active {
  transform: translateX(0);
}

/* Fullscreen overlay for audience */
.cp-fullscreen-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.85);
  cursor: pointer;
}
.cp-fullscreen-overlay button {
  padding: 1rem 2rem; font-size: 1.2rem;
  border-radius: 12px; border: 2px solid var(--accent);
  background: #0b0e14; color: var(--accent); cursor: pointer;
}
.cp-fullscreen-overlay button:hover {
  background: var(--accent); color: #06101f;
}

/* --- Slide renderer (shared operator preview + audience) ------------------- */
.cp-slide {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: #000; color: #fff; text-align: center;
  will-change: opacity, transform; /* GPU-friendly cross-fade */
}
.cp-slide-media { width: 100%; height: 100%; object-fit: contain; background: #000; }
.cp-slide-text { padding: 4%; max-width: 92%; }
.cp-slide-title { font-size: 2vw; color: #9db7d8; margin-bottom: 0.6em; }
.cp-slide-body { font-size: 4.4vw; line-height: 1.25; font-weight: 600; }
.cp-slide-line { margin: 0.1em 0; }
.cp-slide-mode[data-mode="blank"] { background: #000; }
.cp-slide-logo { font-size: 3vw; color: #5b9dff; letter-spacing: 0.04em; }

/* Operator previews use smaller type than a real projector. */
.present-current-stage .cp-slide-title,
.present-next-stage .cp-slide-title { font-size: 0.8rem; }
.present-current-stage .cp-slide-body,
.present-next-stage .cp-slide-body { font-size: 1.4rem; }
.present-current-stage .cp-slide-logo,
.present-next-stage .cp-slide-logo { font-size: 1.1rem; }

/* --- Audience full-screen output ------------------------------------------ */
.audience-body { margin: 0; height: 100vh; background: #000; overflow: hidden; }
.audience-stage {
  position: fixed; inset: 0; background: #000;
  /* Notch-safe on the audience surface too. */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}
.audience-stage .cp-slide-body { font-size: 6vw; }
.audience-stage .cp-slide-title { font-size: 2.4vw; }

/* --- Media library (YouTube search & import) ------------------------------ */
.media-view h3 { margin: 0.6rem 0 0.2rem; }
.media-search { display: flex; gap: 0.5rem; margin: 0.6rem 0; }
.media-search-input { flex: 1; padding: 0.5rem 0.6rem; border-radius: 6px;
  border: 1px solid #2a3550; background: #0e1422; color: inherit; }
.media-search-btn, .media-import-btn, .media-library-add, .media-library-remove {
  padding: 0.4rem 0.7rem; border-radius: 6px; border: 1px solid #2a3550;
  background: #16203a; color: inherit; cursor: pointer; }
.media-search-btn:hover, .media-import-btn:hover { background: #1e2b4d; }
.media-status { min-height: 1.2em; margin: 0.3rem 0; }
.media-status[data-state="error"] { color: #ff8a8a; }
.media-status[data-state="ok"] { color: #7fd28a; }
.media-preview { margin: 0.6rem 0; }
.media-preview-head { font-size: 0.85rem; color: #9db7d8; margin-bottom: 0.3rem; }
.media-preview .cp-youtube-frame, .media-preview iframe {
  width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #000; }
.media-results { list-style: none; padding: 0; margin: 0.5rem 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.8rem; }
.media-result { display: flex; flex-direction: column; gap: 0.4rem;
  background: #0e1422; border: 1px solid #1d2740; border-radius: 8px; padding: 0.5rem; }
.media-thumb-btn { position: relative; padding: 0; border: 0; background: none; cursor: pointer; }
.media-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; display: block; }
.media-thumb-empty { background: #1a2338; }
.media-duration { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,0.8);
  color: #fff; font-size: 0.72rem; padding: 1px 5px; border-radius: 4px; }
.media-result-title { font-weight: 600; font-size: 0.9rem; line-height: 1.25; }
.media-result-channel { font-size: 0.8rem; }
.media-result-actions { margin-top: 0.2rem; }
.media-library-list { list-style: none; padding: 0; margin: 0.4rem 0; }
.media-library-item { display: flex; align-items: center; gap: 0.6rem;
  padding: 0.35rem 0; border-bottom: 1px solid #1a2338; }
.media-library-link { background: none; border: 0; color: #8fb6ff; cursor: pointer;
  text-align: left; flex: 1; font-size: 0.9rem; }
.media-library-channel, .media-library-duration { font-size: 0.78rem; }
.cp-youtube-frame { border: 0; }

/* --- Video editor (timeline core) ------------------------------------------ */
.editor-view { display: flex; flex-direction: column; gap: 0.6rem; }
.editor-header { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.editor-title-input { flex: 1; min-width: 160px; padding: 0.4rem 0.6rem; border-radius: 6px;
  border: 1px solid #2a3550; background: #0e1422; color: inherit; font-size: 0.95rem; }
.editor-project-select { padding: 0.35rem 0.5rem; border-radius: 6px; border: 1px solid #2a3550;
  background: #0e1422; color: inherit; max-width: 220px; }
.editor-status { min-height: 1.2em; margin: 0; font-size: 0.85rem; }
.editor-status[data-state="error"] { color: #ff8a8a; }
.editor-status[data-state="ok"] { color: #7fd28a; }

.editor-toolbar { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.editor-toolbar-sep { width: 1px; align-self: stretch; background: #263041; margin: 0 0.2rem; }
.editor-btn { padding: 0.35rem 0.6rem; border-radius: 6px; border: 1px solid #2a3550;
  background: #16203a; color: inherit; cursor: pointer; font-size: 0.85rem; }
.editor-btn:hover { background: #1e2b4d; }
.editor-btn.primary { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 600; }
.editor-btn.tiny { padding: 0.2rem 0.4rem; font-size: 0.75rem; }

.editor-picker { border: 1px solid #263041; border-radius: 8px; padding: 0.6rem;
  background: #0e1422; max-height: 260px; overflow: auto; }
.editor-picker-head { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.4rem; font-weight: 600; }
.editor-picker-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.editor-picker-btn { width: 100%; text-align: left; padding: 0.35rem 0.5rem; border-radius: 6px;
  border: 1px solid transparent; background: none; color: inherit; cursor: pointer; }
.editor-picker-btn:hover { background: #161d29; border-color: #2a3550; }

/* Preview: one lane per track stacked full-bleed, later tracks compositing on top. */
.editor-preview { position: relative; aspect-ratio: 16 / 9; max-width: 640px;
  background: #000; border-radius: 8px; overflow: hidden; }
.editor-preview-lane { position: absolute; inset: 0; }
.editor-preview-video, .editor-preview-yt, .editor-preview-yt iframe { width: 100%; height: 100%; border: 0; }

/* Timeline: a ruler + stacked track lanes, both horizontally scrollable together. */
.editor-timeline { position: relative; overflow-x: auto; border: 1px solid #263041;
  border-radius: 8px; background: #0b0e14; }
.editor-timeline-inner { position: relative; min-width: 100%; }
.editor-ruler { position: relative; height: 22px; border-bottom: 1px solid #1d2740;
  font-size: 0.7rem; color: var(--muted); }
.editor-ruler-tick { position: absolute; top: 2px; padding-left: 3px; border-left: 1px solid #263041;
  white-space: nowrap; }
.editor-tracks { position: relative; display: flex; flex-direction: column; }
.editor-track { position: relative; border-bottom: 1px solid #171f2c; }
.editor-track-video { background: #0e1422; }
.editor-track-audio { background: #0d1420; }
.editor-playhead { position: absolute; top: 0; left: 0; width: 2px; background: var(--accent);
  pointer-events: none; z-index: 3; }

.editor-clip { position: absolute; top: 4px; bottom: 4px; display: flex; align-items: center;
  gap: 0.3rem; border-radius: 5px; background: #1c2c4d; border: 1px solid #2f4a80;
  overflow: hidden; cursor: grab; touch-action: none; }
.editor-clip:active { cursor: grabbing; }
.editor-clip.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.editor-clip-youtube { background: #2a1c3a; border-color: #5a3f80; }
.editor-clip-generated { background: #1c3a2c; border-color: #3f8060; }
.editor-clip-thumb { width: 32px; height: 100%; object-fit: cover; flex: none; }
.editor-clip-label { font-size: 0.72rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; padding-right: 0.3rem; }
.editor-clip-handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize;
  touch-action: none; z-index: 2; }
.editor-clip-handle-in { left: 0; }
.editor-clip-handle-out { right: 0; }
.editor-clip-handle:hover { background: rgba(91, 157, 255, 0.35); }

/* --- Keyboard shortcuts help overlay (task #98, toggled by '?') ------------- */
.editor-shortcuts-help { border: 1px solid #2a3550; border-radius: 8px; padding: 0.75rem 1rem;
  background: #101828; max-width: 360px; }
.editor-shortcuts-help h4 { margin: 0 0 0.4rem; font-size: 0.9rem; }
.editor-shortcuts-help ul { list-style: none; margin: 0; padding: 0; display: flex;
  flex-direction: column; gap: 0.3rem; font-size: 0.85rem; }
.editor-shortcuts-help kbd { display: inline-block; padding: 0.05rem 0.4rem; border-radius: 4px;
  border: 1px solid #2a3550; background: #1a2338; font-family: inherit; font-size: 0.8em; }

/* --- Export panel (timeline export) ----------------------------------------- */
.editor-export-panel { border: 1px solid #263041; border-radius: 8px; padding: 0.75rem;
  background: #0e1422; max-height: 400px; overflow: auto; }
.editor-export-panel h3 { margin: 0 0 0.3rem; }
.editor-export-panel h4 { margin: 0.5rem 0 0.3rem; font-size: 0.9rem; }

.export-clip-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 0.3rem 0; }
.export-clip-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 0.25rem 0.5rem;
  border-bottom: 1px solid #263041; }
.export-clip-table td { padding: 0.2rem 0.5rem; border-bottom: 1px solid #1a2338; }
.export-clip-ok td { color: var(--ok); }
.export-clip-skipped td { color: var(--muted); }

.export-status { min-height: 1.2em; margin: 0.3rem 0; font-size: 0.85rem; }
.export-status[data-state="error"] { color: #ff8a8a; }
.export-status[data-state="ok"] { color: #7fd28a; }

.export-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.4rem 0; }

.export-job-card { border: 1px solid #1d2740; border-radius: 8px; padding: 0.5rem;
  margin-bottom: 0.5rem; background: #0b0e14; }
.export-job-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.3rem; }
.export-job-header strong { flex: 1; font-size: 0.85rem; }

.export-status-badge { font-size: 0.75rem; padding: 0.15rem 0.4rem; border-radius: 4px; }
.export-done { background: #1a3a2c; color: #7fd28a; }
.export-failed { background: #3a1a1a; color: #ff8a8a; }
.export-unavailable { background: #3a3520; color: #d4b86a; }
.export-running { background: #1a2a4a; color: #8ab8ff; }
.export-queued { background: #222b39; color: var(--muted); }

.export-progress-bar { height: 4px; background: #1d2740; border-radius: 2px; margin: 0.3rem 0; overflow: hidden; }
.export-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.5s; }
.export-progress-text { font-size: 0.78rem; color: var(--muted); }
.export-clip-progress { font-size: 0.75rem; color: #8ab8ff; display: inline-block; margin-right: 0.5rem; }
.export-eta { font-size: 0.75rem; color: var(--muted); }
.cancel-btn { background: #5a1a1a; color: #ff8a8a; border: 1px solid #7a2a2a; cursor: pointer; }
.cancel-btn:hover { background: #7a2a2a; }
.cancel-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.export-note { font-size: 0.8rem; color: #d4b86a; margin: 0.2rem 0; }
.export-error { font-size: 0.8rem; color: var(--err); margin: 0.2rem 0; }
.export-log { font-size: 0.72rem; color: var(--muted); background: #090c12; padding: 0.3rem 0.5rem;
  border-radius: 4px; max-height: 80px; overflow: auto; white-space: pre-wrap; word-break: break-all; }

/* --- Toast notifications (task #100) -------------------------------------- */
.toast-container { position: fixed; bottom: 1rem; right: 1rem; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.75rem 1rem; border-radius: 6px; background: #1e2b4d; color: #fff;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3); font-size: 0.85rem; max-width: 300px;
  animation: toast-in 0.2s ease-out; }
.toast-ok { border-left: 4px solid var(--ok); }
.toast-error { border-left: 4px solid var(--err); }
.toast-info { border-left: 4px solid var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(1rem); } to { opacity: 1; transform: translateY(0); } }

/* --- Present: QR code, confidence monitor, settings ----------------------- */

/* QR code */
.present-qr-code {
  width: 160px; height: 160px; border-radius: 8px;
  border: 2px solid #263041; background: #fff;
}
.present-qr-row { display: flex; align-items: center; gap: 1rem; margin: 0.5rem 0; }
.present-qr-hint { color: var(--muted); font-size: 0.8rem; max-width: 200px; }
.present-url-section { margin: 0.5rem 0; }
.present-url-label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
.present-url-row { display: flex; gap: 0.4rem; align-items: center; }
.present-url-input {
  flex: 1; min-width: 200px; padding: 0.35rem 0.5rem; border-radius: 4px;
  border: 1px solid #2a3550; background: #0e1422; color: inherit; font-size: 0.85rem; font-family: monospace;
}

/* Confidence monitor */
.present-confidence-row { display: flex; align-items: center; gap: 0.4rem; margin: 0.75rem 0; font-size: 0.85rem; }
.present-confidence-toggle { accent-color: var(--accent); }
.present-confidence-container { margin-top: 0.5rem; }

.conf-layout { display: flex; flex-direction: column; gap: 0.75rem; }
.conf-body { display: flex; flex-direction: column; gap: 0.5rem; }
.conf-timer-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; border-radius: 6px;
  background: #0e1422; border: 1px solid #263041;
  font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.conf-timer-value { font-size: 1.2rem; font-weight: 700; min-width: 4em; color: var(--accent); }
.conf-clock-value { color: var(--muted); min-width: 5em; }
.conf-sep { width: 1px; height: 1.5em; background: #263041; margin: 0 0.25rem; }
.conf-tiny { padding: 0.15rem 0.4rem; font-size: 0.75rem; }
.conf-btn {
  padding: 0.3rem 0.6rem; border-radius: 4px; border: 1px solid #2a3550;
  background: #16203a; color: inherit; cursor: pointer; font-size: 0.85rem;
}
.conf-btn:hover { background: #1e2b4d; }
.conf-controls { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.conf-mode { border-color: #3a4a6a; }
.conf-live { border-color: var(--accent); }

.conf-slides { display: grid; grid-template-columns: 2fr 1fr; gap: 0.75rem; }
.conf-section-title { margin: 0 0 0.4rem; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.conf-current-stage, .conf-next-stage {
  position: relative; background: #000; border-radius: 8px; overflow: hidden;
  min-height: 120px;
}
.conf-current-stage { aspect-ratio: 16 / 9; }
.conf-next-stage { aspect-ratio: 16 / 9; }
.conf-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 0.85rem;
}

.conf-current-stage .cp-slide-title,
.conf-next-stage .cp-slide-title { font-size: 0.8rem; }
.conf-current-stage .cp-slide-body,
.conf-next-stage .cp-slide-body { font-size: 1.4rem; }
.conf-current-stage .cp-slide-logo,
.conf-next-stage .cp-slide-logo { font-size: 1.1rem; }

/* Settings panel */
.present-settings { margin: 0.5rem 0; }
.present-settings-header { display: flex; align-items: center; gap: 0.5rem; }
.present-settings-body {
  padding: 0.75rem; margin-top: 0.5rem; border-radius: 8px;
  border: 1px solid #263041; background: #0e1422;
}

/* Media library */
.media-library-empty {
  padding: 1rem; text-align: center; color: var(--muted); font-size: 0.9rem;
}

/* --- Editor drag ghost + snap (Mission #1 UX polish) ---------------------- */
.editor-track-select { padding: 0.35rem 0.5rem; border-radius: 6px; border: 1px solid #2a3550;
  background: #0e1422; color: #e8edf5; font-size: 0.82rem; cursor: pointer; }
.editor-track-select:focus { outline: none; border-color: var(--accent); }

.editor-drag-ghost { position: absolute; top: 4px; bottom: 4px; opacity: 0.5;
  border: 2px dashed #5b9dff; background: rgba(91, 157, 255, 0.12); border-radius: 6px;
  pointer-events: none; z-index: 10; }
.editor-drag-ghost-label { position: absolute; top: -18px; left: 0; font-size: 0.7rem;
  color: #5b9dff; white-space: nowrap; }

.editor-snap-indicator { position: absolute; top: 0; bottom: 0; width: 2px;
  background: #ffd700; box-shadow: 0 0 6px #ffd700; z-index: 9; pointer-events: none;
  transition: opacity 0.1s; }
.editor-snap-badge { position: absolute; top: -16px; left: -18px; font-size: 0.65rem;
  background: #ffd700; color: #000; padding: 0.1rem 0.3rem; border-radius: 3px;
  white-space: nowrap; font-weight: 600; }

.editor-clip.multi-selected { border-color: #7fd28a; box-shadow: 0 0 0 1px #7fd28a; }

/* --- Error boundary overlay (production hardening) ------------------------ */
.error-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(11, 14, 20, 0.85);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.error-dialog {
  background: var(--panel); border: 1px solid #3a2530;
  border-radius: 12px; padding: 2rem; max-width: 480px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.error-dialog h2 {
  margin: 0 0 0.75rem; font-size: 1.25rem; color: var(--err);
}
.error-message {
  margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--fg);
  word-break: break-word; font-family: monospace;
  background: #1a1015; padding: 0.75rem; border-radius: 6px;
  max-height: 200px; overflow-y: auto;
}
.error-hint {
  margin: 0 0 1rem; font-size: 0.85rem; color: var(--muted);
}
.error-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.error-btn {
  padding: 0.5rem 1rem; border: 1px solid #2a3550; border-radius: 6px;
  background: transparent; color: var(--fg); cursor: pointer; font-size: 0.9rem;
}
.error-btn.primary {
  background: var(--err); border-color: var(--err); color: #fff; font-weight: 600;
}
.error-btn:hover { filter: brightness(1.2); }
.error-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Skeleton / loading placeholder (production hardening) ----------------- */
.skeleton {
  display: inline-block; background: linear-gradient(90deg,
    #1e2738 25%, #263041 50%, #1e2738 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 4px; min-height: 1em;
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 1em; margin: 0.5rem 0; width: 80%; }
.skeleton-text.short { width: 40%; }
.skeleton-block { height: 60px; margin: 0.5rem 0; border-radius: 6px; }
.loading-spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid #2a3550; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 0.4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--muted); font-size: 0.9rem; }
