/* Video-cover editor. Warm-clinic controls surround one approved dark preview
   stage, matching the style guide's player/editor exception. */

#view-thumbed {
  max-width: 1240px;
  padding-bottom: 48px;
}

.thed-header {
  position: sticky;
  top: 0;
  z-index: 24;
  padding: 8px 0 12px;
  background: var(--bg);
}

.thed-head-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.thed-head-tools .icon-btn {
  width: 42px;
  height: 42px;
}

.thed-head-tools .btn-text {
  min-height: 42px;
  padding: 8px 10px;
}

.thed-save.btn-primary {
  width: auto;
  flex: none;
  min-height: 44px;
  padding: 11px 20px;
  font-size: .95rem;
  white-space: nowrap;
}

.thed-error {
  margin: 0 0 12px;
  padding: 11px 14px;
  color: var(--rec);
  background: rgba(229, 72, 77, .08);
  border: 1px solid rgba(229, 72, 77, .25);
  border-radius: 12px;
  line-height: 1.45;
}

.thed-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(470px, 590px);
  gap: 22px;
  align-items: start;
}

.thed-preview-pane {
  position: sticky;
  top: 76px;
  min-width: 0;
}

.thed-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 170px);
  max-height: 650px;
  padding: 16px;
  background: #241f18;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.thed-canvas {
  display: block;
  width: auto;
  height: min(calc(100vh - 205px), 610px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  background: #241f18;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.thed-canvas:active { cursor: grabbing; }

.thed-instruction {
  margin: 10px auto 2px;
  max-width: 520px;
  color: var(--muted);
  font-size: .86rem;
  text-align: center;
  line-height: 1.45;
}

.thed-slot-live { margin: 4px 0 0; }

.thed-inspector.card {
  margin: 0;
  padding: 0;
  max-height: calc(100vh - 76px);
  overflow: auto;
  overscroll-behavior: contain;
}

.thed-tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.thed-tab {
  min-width: 0;
  min-height: 44px;
  padding: 8px 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: 600 .9rem/1.1 inherit;
  cursor: pointer;
}

.thed-tab:hover { background: var(--card-2); }
.thed-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.thed-tab:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }

.thed-panel { padding: 18px; }
.thed-panel > h2 { margin: 0 0 8px; font-size: 1.08rem; }
.thed-panel > h3, .thed-source-block h3, .thed-crop-block h3 {
  margin: 0 0 10px;
  font-size: .96rem;
}
.thed-panel .field { margin-bottom: 14px; }

.thed-seg,
.thed-text-targets,
.thed-option-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 999px;
}

.thed-seg button,
.thed-text-targets button,
.thed-option-row button {
  min-height: 42px;
  min-width: 0;
  padding: 8px 10px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: 600 .88rem/1.15 inherit;
  cursor: pointer;
}

.thed-seg button.sel,
.thed-text-targets button.sel,
.thed-option-row button.sel {
  background: var(--card);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.thed-slots {
  display: grid;
  gap: 8px;
  margin: 12px 0 18px;
}

.thed-slot {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 72px;
  padding: 8px 12px 8px 8px;
  text-align: left;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
}

.thed-slot:hover { background: var(--card-3); }
.thed-slot.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thed-slot-thumb {
  width: 48px;
  height: 54px;
  border-radius: 9px;
  background: #241f18 center / cover no-repeat;
}
.thed-slot-copy { min-width: 0; }
.thed-slot-copy b, .thed-slot-copy small { display: block; }
.thed-slot-copy b { font-size: .92rem; }
.thed-slot-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thed-slot-action { color: var(--accent); font-size: .78rem; font-weight: 700; }

.thed-source-block,
.thed-crop-block {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.thed-source-actions,
.thed-zoom-controls,
.thed-dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.thed-source-actions .btn-secondary,
.thed-zoom-controls .btn-secondary,
.thed-callout-types .btn-secondary {
  min-height: 44px;
  padding: 10px 12px;
  font-size: .88rem;
}

.thed-source-block .patient-notice {
  margin: 10px 0 14px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 10px;
}

.thed-control-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}

.thed-moments,
.thed-more-moments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.thed-moment {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  color: var(--muted);
  background: var(--card-2);
  border: 2px solid transparent;
  border-radius: 10px;
  font: 600 .64rem/1.2 inherit;
  cursor: pointer;
}
.thed-moment img { display: block; width: 100%; aspect-ratio: 9 / 12; object-fit: cover; }
.thed-moment span { display: block; padding: 5px 3px 6px; }
.thed-moment:hover { border-color: var(--border-2); }
.thed-moment.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.thed-more-details,
.thed-style-details,
.thed-callout-add {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-2);
}
.thed-more-details > summary,
.thed-style-details > summary,
.thed-callout-add > summary {
  min-height: 44px;
  padding: 12px 14px;
  color: var(--accent);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}
.thed-more-moments,
.thed-style-more,
.thed-callout-types { padding: 0 10px 10px; }

.thed-crop-block { margin-top: 16px; }
.thed-move-grid {
  display: grid;
  grid-template-columns: repeat(4, 44px);
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
}
.thed-quiet-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
}

.thed-text-targets { margin-bottom: 14px; }
.thed-option-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.thed-control-group { margin-top: 16px; }
.thed-subline-wrap { margin-top: 14px; }
.thed-subline-wrap .btn-text { margin-top: -10px; }
.thed-reset-text { margin-top: 8px; }

.thed-style-recommended,
.thed-style-more { display: grid; gap: 8px; }
.thed-style-choice {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 82px;
  padding: 8px;
  color: var(--text);
  text-align: left;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.thed-style-choice:hover { background: var(--card-3); }
.thed-style-choice.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thed-style-choice canvas {
  display: block;
  width: 50px;
  height: auto;
  border-radius: 7px;
  background: #241f18;
}
.thed-style-choice b, .thed-style-choice small { display: block; }
.thed-style-choice small { margin-top: 4px; color: var(--muted); font-size: .78rem; }
.thed-legacy-style, .thed-legacy-callouts { line-height: 1.45; }

.thed-callout-list { display: grid; gap: 7px; }
.thed-callout-item {
  min-height: 44px;
  padding: 10px 13px;
  text-align: left;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font: 600 .9rem/1.2 inherit;
  cursor: pointer;
}
.thed-callout-item.active { border-color: var(--accent); color: var(--accent); }
.thed-callout-types {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.thed-callout-controls { margin-top: 16px; }
.thed-remove-callout { color: var(--rec); }

.thed-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  color: var(--bg);
  background: var(--text);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  text-align: center;
  font-size: .9rem;
  transition: opacity .5s ease;
}
.thed-toast-out { opacity: 0; }

.thed-leave-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(36, 31, 24, .5);
}
.thed-dialog-card.card {
  width: min(100%, 440px);
  margin: 0;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.thed-dialog-card h2 { margin: 0 0 8px; font-size: 1.2rem; }
.thed-dialog-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }

@media (max-width: 900px) {
  #view-thumbed { max-width: 760px; }
  .thed-workspace { grid-template-columns: minmax(300px, .9fr) minmax(390px, 1.1fr); gap: 14px; }
}

@media (max-width: 760px) {
  #view-thumbed { max-width: 560px; padding: 8px 10px 40px; }
  .thed-header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 7px 0 8px;
  }
  .thed-header h1 { min-width: 0; font-size: 1.18rem; }
  .thed-header > .thed-back { grid-column: 1; grid-row: 1; }
  .thed-header > h1 { grid-column: 2; grid-row: 1; }
  .thed-header > .thed-save { grid-column: 3; grid-row: 1; }
  .thed-save.btn-primary { padding: 10px 14px; font-size: .88rem; }
  .thed-head-tools {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
    min-height: 42px;
  }
  .thed-head-tools .btn-text { width: auto; padding: 8px 10px; font-size: .86rem; }
  .thed-workspace { display: block; }
  .thed-preview-pane { position: static; }
  .thed-stage {
    min-height: 0;
    max-height: none;
    padding: 12px;
  }
  .thed-canvas {
    width: auto;
    height: min(43vh, 390px);
    max-width: 100%;
  }
  .thed-instruction { margin-top: 8px; padding: 0 6px; }
  .thed-inspector.card {
    margin-top: 12px;
    max-height: none;
    overflow: visible;
  }
  .thed-tabs { top: 102px; }
  .thed-panel { padding: 15px 12px 18px; }
}

@media (max-width: 420px) {
  .thed-tabs { gap: 2px; padding: 8px 6px; }
  .thed-tab { padding: 7px 2px; font-size: .81rem; }
  .thed-source-actions { grid-template-columns: 1fr; }
  .thed-moments, .thed-more-moments { gap: 6px; }
  .thed-slot { grid-template-columns: 50px minmax(0, 1fr); }
  .thed-slot-action { grid-column: 2; }
  .thed-dialog-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .thed-toast { transition: none; }
}
