/* Clipper: the auto-clipper review studio theme.
 *
 * Ivory and light gold on a deep, warm brown-black, with pill buttons and
 * soft raised panels. Dark does real work here: the job is judging video in
 * a preview window, and a bright surround makes footage look washed out. */

:root {
  /* grounds: the brand's deep brown, darkened */
  --ground:      #120d08;
  --glow:        #1d150d;
  --surface:     #1c150e;   /* panels */
  --surface-2:   #241b12;   /* raised: buttons, selected tabs */
  --surface-3:   #2c2116;   /* hover */
  --field:       #16100a;   /* inputs and caption cards */

  /* lines */
  --line:        #34281b;
  --line-strong: #4a3926;

  /* type: ivory */
  --ink:         #f5f0e1;
  --muted:       #cdbfa3;
  --faint:       #96866d;

  /* brand: gold */
  --gold:        #d6b676;
  --gold-soft:   #e0c48a;
  --gold-deep:   #a88444;
  --gold-wash:   rgba(214, 182, 118, .1);
  --gold-ring:   rgba(214, 182, 118, .45);
  --on-gold:     #1a1209;

  /* semantic: warm, so they sit with the palette */
  --ok:          #b4c98d;
  --warn:        #e6bd62;
  --crit:        #ec9478;
  --crit-bg:     rgba(236, 148, 120, .07);
  --crit-line:   rgba(236, 148, 120, .4);
  --ok-bg:       rgba(180, 201, 141, .08);

  --sans: Montserrat, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --arabic: Amiri, "Noto Naskh Arabic", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 14px;
  --radius-small: 9px;
  --shadow: 0 1px 0 rgba(255, 240, 210, .03) inset, 0 12px 32px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--ground); }
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  background: radial-gradient(1200px 520px at 50% -180px, var(--glow), transparent 70%), var(--ground);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); }
::selection { background: rgba(214, 182, 118, .35); }
h1, h2, p { margin: 0; }
p { color: var(--muted); font-size: 14px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

main { max-width: 1200px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem) 6rem; }

/* --- masthead --- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(18, 13, 8, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  margin-bottom: clamp(1.5rem, 4vw, 2.6rem);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; text-decoration: none; }
.brand strong {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* A segmented pill, as auto-clipper's library filter. */
nav {
  display: flex; gap: .3rem; align-items: center; flex-wrap: wrap;
  padding: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
nav button { border: 0; background: none; color: var(--muted); padding: .42rem .85rem; font-size: .8rem; }
nav button:hover:not(:disabled) { background: none; color: var(--ink); }
nav [aria-current] { color: var(--gold); background: var(--surface-2); box-shadow: 0 0 0 1px var(--line-strong); }
nav [aria-current]:hover:not(:disabled) { background: var(--surface-2); color: var(--gold); }

/* --- page titles --- */

h1 {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 20px;
}
.heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.heading h1 { margin-bottom: 0; min-width: 0; overflow-wrap: anywhere; }
#review > .heading { margin-bottom: 22px; }
#templates > p { margin: -8px 0 20px; }

/* --- panel --- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}

.panel h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
legend, summary { font-size: .8rem; font-weight: 600; color: var(--muted); }
.panel h2 { margin: 0 0 16px; }
.panel .heading h2 { margin: 0; }

.access { max-width: 440px; margin: 48px auto; }

/* --- form --- */

form, .stack { display: grid; gap: 14px; }
.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

label {
  display: grid;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  min-width: 0;
  padding: .6rem .75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: var(--field);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="range"] { width: auto; padding: 0; accent-color: var(--gold); }
input[type="range"] { width: 100%; }
input[type="color"] { height: 38px; padding: 3px; cursor: pointer; }

/* The file picker as the v1 drop zone: a dashed target, not a bare control. */
input[type="file"] {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 22px 16px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
input[type="file"]:hover { border-color: var(--gold); background: var(--gold-wash); }
input[type="file"]::file-selector-button {
  margin-right: 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: .38rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
}
legend { padding: 0 6px; }

details { border-top: 1px solid var(--line); padding-top: 14px; }
details[open] { display: grid; gap: 14px; }
summary { cursor: pointer; }
summary:hover { color: var(--muted); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

/* --- buttons ---
 * Pills. Gold is the one primary action on a screen, so the eye lands on
 * the action that moves the clip forward. */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font: 600 .85rem/1.2 var(--sans);
  padding: .55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
button:hover:not(:disabled) { background: var(--surface-3); border-color: var(--gold-ring); }
button:focus-visible, a:focus-visible, input[type="file"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--on-gold);
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ead19e, #dcbd80); border-color: var(--gold); }

/* --- notices: a toast pinned to the bottom of the window, so a message is
   seen wherever the action was (a caption far down the list, say) --- */

#notice {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(36rem, calc(100vw - 2rem));
  display: flex;
  align-items: center;
  gap: .9rem;
  font-size: .86rem;
  line-height: 1.45;
  padding: .7rem .7rem .7rem 1.1rem;
  border-radius: var(--radius);
  color: var(--ink);
  background: #2a2015;
  border: 1px solid var(--gold-ring);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
  animation: toast-in .16s ease-out;
}
#notice.error { background: #2c1912; border-color: var(--crit-line); color: #f6c9ba; }
#notice-text { flex: 1; }
#notice button { padding: .35rem .85rem; font-size: .8rem; white-space: nowrap; }
#notice-close { border-color: transparent; background: transparent; color: var(--muted); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { #notice { animation: none; } }

/* --- upload --- */

/* Heading and guidance on top; the fields and button in one row underneath. */
.upload { grid-template-columns: minmax(0, 1.4fr) minmax(0, .7fr) minmax(0, 1.4fr) auto; align-items: end; gap: 14px; }
.upload > .upload-head { grid-column: 1 / -1; }
.upload h2 { margin-bottom: 4px; }
.upload-head p { font-size: 13px; color: var(--faint); }
.upload input[type="file"] { padding: 6px 8px; border-radius: var(--radius-small); }
.upload input[type="file"]::file-selector-button { padding: 3px 10px; }
.upload button.primary { padding: 9px 18px; }
.upload progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--line-strong);
  appearance: none;
}
.upload progress::-webkit-progress-bar { background: var(--line-strong); }
.upload progress::-webkit-progress-value { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width .3s; }
.upload progress::-moz-progress-bar { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }

/* --- clip list ---
 * Each clip is one row: what it is on the left, where it is on the right. */

#videos { gap: 10px; }
#videos > p {
  text-align: center;
  padding: 52px 20px;
  color: var(--muted);
}

.card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  color: var(--ink);
  transition: border-color .15s, transform .15s, background .15s;
}
button.card:hover:not(:disabled) { background: var(--surface-2); border-color: var(--gold-ring); transform: translateY(-1px); }
button.card:hover:not(:disabled) strong { color: var(--gold); }
button.card:disabled { opacity: .6; }
.card > div { min-width: 0; }
.card strong {
  display: block;
  font-weight: 650;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.12s;
}
.card p { margin-top: 4px; font-size: 13px; color: var(--muted); }
/* Red is reserved for errors. */
.error-text { color: var(--crit) !important; }
#template-list .card { font-weight: 650; }

/* --- status pills --- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex: none;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  padding: .22rem .65rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, currentColor 35%, transparent);
  background: color-mix(in srgb, currentColor 10%, transparent);
  white-space: nowrap;
  color: var(--faint);
}
.badge:empty { display: none; }
.badge[data-status="pending"],
.badge[data-status="uploaded"],
.badge[data-status="transcribing"],
.badge[data-status="translating"],
.badge[data-status="rendering"] { color: var(--warn); }
.badge[data-status="completed"],
.badge[data-status="rendered"] { color: var(--ok); background: var(--ok-bg); }
.badge[data-status="failed"],
.badge[data-status="render-failed"] { color: var(--crit); }

.badge::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
/* The dot pulses while the pipeline works, without a spinner per row. */
.badge[data-status="uploaded"]::before,
.badge[data-status="transcribing"]::before,
.badge[data-status="translating"]::before,
.badge[data-status="rendering"]::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .badge::before { animation: none !important; } }

#more { margin-top: 14px; }

/* --- review --- */

#back { margin-bottom: 18px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
@media (min-width: 1000px) {
  .workspace { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  /* The transcript stays in view while the left column scrolls. */
  #captions { position: sticky; top: 20px; }
}

.preview video {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  margin-bottom: 12px;
}

/* --- transcript ---
 * One row per caption: its time on the left, the English to edit, and the
 * Arabic it came from underneath. */

#captions { margin-bottom: 0; }
#captions > .heading { margin-bottom: 12px; }
.cue-grid.cue-head { display: none; }

#cues {
  display: grid;
  gap: .6rem;
  align-content: start;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: .3rem;
  scroll-behavior: smooth;
  scrollbar-color: var(--line-strong) transparent;
}
@media (prefers-reduced-motion: reduce) { #cues { scroll-behavior: auto; } }

.cue-grid {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  column-gap: 10px;
  padding: .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--field);
  transition: border-color .15s, background .15s;
}
.cue-grid:focus-within { border-color: var(--gold-ring); background: #1f170e; }

.cue-grid > button {
  grid-row: 1 / span 2;
  align-self: start;
  background: none;
  border: none;
  padding: .35rem 0;
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  color: var(--faint);
  justify-content: flex-start;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.cue-grid > button:hover:not(:disabled) { background: none; color: var(--gold); }
.cue-grid:focus-within > button { color: var(--gold); font-weight: 700; }

.cue-grid > textarea {
  grid-column: 2;
  grid-row: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: transparent;
  font-size: .95rem;
  line-height: 1.45;
  resize: none;
  padding: .35rem .45rem;
  min-height: 2.5rem;
  overflow-y: hidden;
}
.cue-grid > textarea:hover { border-color: var(--line-strong); }
.cue-grid > textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); }

.cue-grid > p[lang="ar"] {
  grid-column: 2;
  grid-row: 2;
  margin: .25rem .45rem 0;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--faint);
  font-family: var(--arabic);
  overflow-wrap: anywhere;
}

#cues::-webkit-scrollbar { width: 10px; }
#cues::-webkit-scrollbar-track { background: transparent; }
#cues::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 5px;
  border: 2px solid var(--surface);
}
#cues::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* --- templates --- */

.sample {
  display: grid;
  place-items: center;
  padding: 36px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.sample span {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 4px;
}

/* --- small screens ---
 * Below this width rows stack instead of squeezing the text column, and
 * touch gets controls that are always visible and large enough to hit. */

@media (max-width: 760px) {
  main { padding-left: 14px; padding-right: 14px; padding-bottom: 72px; }
  .masthead { padding: .6rem 14px; margin-bottom: 22px; gap: 12px; }
  .brand { gap: 8px; flex-wrap: wrap; }
  .brand strong { font-size: 23px; }
  h1 { font-size: 22px; }

  .panel { padding: 1rem; margin-bottom: 18px; }
  .upload, .columns { grid-template-columns: minmax(0, 1fr); }
  input[type="file"] { padding: 18px 12px; }

  .card { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; }
  .card strong { white-space: normal; overflow: visible; line-height: 1.3; }

  .workspace { gap: 16px; }
  .preview video { margin-bottom: 10px; }

  /* One scroll surface on a phone: a nested scroller inside a scrolling page
     is hard to hit and traps momentum scrolling. */
  #cues { max-height: none; overflow-y: visible; }
  .cue-grid { grid-template-columns: 50px minmax(0, 1fr); column-gap: 8px; padding: .6rem; }
  .cue-grid > textarea { font-size: 15px; }
  .cue-grid > p[lang="ar"] { font-size: 14px; }
}

@media (max-width: 420px) {
  .brand strong { font-size: 20px; }
  /* 16px keeps iOS from zooming the viewport when a field takes focus. */
  input, select, textarea, .cue-grid > textarea { font-size: 16px; }
}


/* Review controls keep the existing two-column layout. */
.cue-grid.is-playing { border-color: var(--gold-ring); background: #1f170e; }
.cue-timing { grid-column: 2; grid-row: 3; display: flex; flex-wrap: wrap; gap: .45rem .8rem; margin: 6px; }
.cue-timing label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); }
.cue-timing input { width: 6.2rem; padding: .4rem .55rem; font-size: .84rem; text-align: center; font-variant-numeric: tabular-nums; }
.cue-grid .cue-actions { grid-column: 2; grid-row: 4; margin: .2rem 6px 0; opacity: 0; transition: opacity .12s; }
.cue-grid:hover .cue-actions, .cue-grid:focus-within .cue-actions, .cue-grid.is-playing .cue-actions,
.cue-needs-fit .cue-actions { opacity: 1; }
.cue-overflow { grid-column: 2; grid-row: 5; margin: .25rem 6px; color: var(--gold); font-size: .8rem; }
.cue-actions button { border-color: transparent; background: transparent; color: var(--muted); }
@media (hover: none) { .cue-grid .cue-actions { opacity: 1; } }
.cue-actions button, .clip-actions button { padding: .38rem .8rem; font-size: .78rem; }
#captions:not(.show-arabic) [lang="ar"] { display: none; }
#crop-preview { display: block; max-width: min(100%, 14rem); height: auto; background: #0b0805; margin: .75rem auto; }
.template-thumb { width: 54px; height: 76px; object-fit: cover; border-radius: 7px; flex: none; }
.landscape-thumb { width: 96px; height: 54px; }
#template-list .card { justify-content: flex-start; }
#save-status { font-size: .8rem; color: var(--muted); }
/* One row per video: what it is, where it is, what you can do with it. */
.clip-row {
  display: grid;
  /* Fixed status and action columns keep every row's badge in line. */
  grid-template-columns: minmax(0, 1fr) 9.5rem 17rem;
  align-items: center;
  gap: 16px;
  padding: 1.1rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, background .15s, transform .15s;
}
.clip-row:hover { border-color: var(--gold-ring); background: var(--surface-2); transform: translateY(-1px); }
.clip-open {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 0;
  border: 0;
  text-align: left;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  justify-content: stretch;
  border-radius: 0;
  color: var(--ink);
  background: none;
}
.clip-open:hover:not(:disabled) { background: none; }
.clip-open:hover:not(:disabled) strong { color: var(--gold); }
.clip-open:disabled { opacity: .6; }
.clip-open strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .12s; }
.clip-open .meta { font-size: .8rem; font-weight: 500; color: var(--faint); }
.clip-open .error-text { font-size: 12.5px; margin-top: 2px; }
.clip-row > .badge { justify-self: start; }
.clip-row .clip-actions { justify-content: flex-end; flex-wrap: nowrap; }
.review-head .clip-actions:empty { display: none; }
.clip-row .clip-actions button { border-color: transparent; background: transparent; color: var(--muted); }
.clip-row .clip-actions button:hover:not(:disabled) { color: var(--ink); background: var(--surface-3); }
@media (max-width: 700px) {
  .clip-row { grid-template-columns: minmax(0, 1fr) auto; }
  .clip-row > .badge { justify-self: end; }
  .clip-row .clip-actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .clip-row .clip-actions:empty { display: none; }
  .clip-open strong { white-space: normal; }
}

/* --- clip editor: the auto-clipper layout in the Clipper palette ---
 * A sticky 9:16 preview on the left is also the player; the settings,
 * subtitles and render controls stack on the right. */

.editor-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.editor-nav #back { margin: 0; }
.review-head { margin-bottom: 22px; }
.review-head .actions { justify-content: flex-end; }
.title-line { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.title-line h1 { margin: 0; overflow-wrap: anywhere; }
.review-head .clip-actions button { border-color: transparent; background: transparent; color: var(--muted); }
.review-head .clip-actions button:hover:not(:disabled) { color: var(--ink); background: var(--surface-3); }
#review > .heading { margin-bottom: 22px; }

.editor-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
.editor-stage { position: sticky; top: 90px; display: grid; gap: 12px; }
.editor-side { display: grid; gap: 18px; min-width: 0; }
.editor-side .panel, .editor-side form { margin: 0; }
.editor-side form { display: grid; gap: 18px; }
.editor-side .panel h2 { margin-bottom: 1rem; }
.editor-side .panel .heading h2 { margin: 0; }
/* The transcript scrolls inside its panel; the stage is what stays in view. */
.editor-side #captions { position: static; }

/* Title card / Clip / End card */
.stage-tabs {
  display: flex;
  gap: .3rem;
  padding: .25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.stage-tabs button {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: .42rem .85rem;
  font-size: .8rem;
  color: var(--muted);
  background: transparent;
}
.stage-tabs button:hover:not(:disabled) { background: transparent; color: var(--ink); }
.stage-tabs button[aria-selected="true"],
.stage-tabs button[aria-selected="true"]:hover:not(:disabled) { background: var(--surface-2); color: var(--gold); box-shadow: 0 0 0 1px var(--line-strong); }
#review:not(.long-form) [data-long-form-only],
#review.long-form [data-clip-only],
#review.long-form:not(.has-video-intro) [data-card="intro"],
#review.long-form:not(.has-video-intro) [data-intro-control] { display: none; }
@media (min-width: 960px) {
  #review.long-form .editor-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.portrait {
  position: relative;
  aspect-ratio: 9 / 16;
  width: 100%;
  overflow: hidden;
  cursor: pointer;
  border-radius: 18px;
  background: #000;
  box-shadow: 0 0 0 1px var(--line-strong), 0 24px 60px rgba(0, 0, 0, 0.55);
}
.portrait canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.play-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  color: rgba(245, 240, 225, .85);
  background: rgba(0, 0, 0, .15);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.stage-source { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* Tabs, picture and transport each get room to breathe. */
.player-dock { display: grid; gap: 14px; }
.transport { display: flex; align-items: center; gap: 10px; }
.transport .play {
  width: 2.4rem;
  height: 2.4rem;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  color: var(--on-gold);
  font-size: .85rem;
}
.transport .play:hover:not(:disabled) { background: #e3c589; }
.scrubber { position: relative; flex: 1; height: 1.6rem; display: flex; align-items: center; }
.scrubber::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 4px;
  background: var(--line-strong);
}
/* The kept part of the source, highlighted on the timeline. */
.trim-band { position: absolute; height: 4px; border-radius: 4px; background: var(--gold-deep); }
.scrubber input {
  position: relative;
  width: 100%;
  height: 1.6rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
}
.scrubber input:focus { outline: none; }
.scrubber input:focus { box-shadow: none; }
.scrubber input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--gold-ring); }
.scrubber input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 3px var(--gold-wash);
}
.scrubber input::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--ink); }
.time { flex: none; font-size: .78rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { font-size: .82rem; color: var(--faint); }
.center { text-align: center; }
#stage-note:empty { display: none; }

/* Length: start and end, each settable from the playhead. */
.trim { padding-top: 1.2rem; border-top: 1px solid var(--line); }
.trim-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.trim-head h3 {
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink);
}
.trim-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trim-field { display: grid; gap: 8px; align-content: start; }
.trim-field button { justify-self: start; }
.link-button {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: .8rem;
}
.link-button:hover:not(:disabled) { background: none; text-decoration: underline; }
.count { font-size: .85rem; font-weight: 500; color: var(--faint); letter-spacing: 0; text-transform: none; margin-left: .3rem; }

.render-card {
  display: grid;
  gap: 12px;
  margin-top: 6px;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.render-card h2 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.render-card p { font-size: 13px; }
.button-link, .action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 600 .85rem/1.2 var(--sans);
  padding: .55rem 1.1rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  transition: background .15s, border-color .15s;
}
.button-link:hover, .action-link:hover { background: var(--surface-3); border-color: var(--gold-ring); }
.action-link { border-color: transparent; background: transparent; color: var(--muted); }
.button-link.primary-link { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); border-color: var(--gold); color: var(--on-gold); }
.button-link.primary-link:hover { background: linear-gradient(180deg, #ead19e, #dcbd80); }
#save-status { font-weight: 600; }

@media (max-width: 860px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-stage { position: static; width: 100%; max-width: 340px; margin: 0 auto; }
  #review.long-form .editor-stage { max-width: 600px; }
  .trim-fields { grid-template-columns: minmax(0, 1fr); }
}

.scrubber { overflow: hidden; }
.trim-band[hidden] { display: none; }

/* --- library tools: search, filters, type --- */

.library-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
}
.library-tools #search { flex: 1 1 14rem; min-width: 0; }
.library-tools select { flex: 0 0 auto; width: auto; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  padding: .25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.chips button { border: 0; border-radius: 999px; padding: .4rem .85rem; font-size: .8rem; color: var(--muted); background: transparent; }
.chips button:hover:not(:disabled) { background: transparent; color: var(--ink); }
.chips button[aria-pressed="true"],
.chips button[aria-pressed="true"]:hover:not(:disabled) { background: var(--surface-2); color: var(--gold); box-shadow: 0 0 0 1px var(--line-strong); }
.empty { color: var(--faint); font-size: .9rem; margin: 1.2rem 0 .4rem; }

/* A row's thumbnail: the poster frame, its length, and a placeholder until it exists. */
.clip-open { grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center; }
.clip-thumb {
  position: relative;
  width: 44px;
  height: 78px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(160deg, var(--surface-3), var(--field));
  box-shadow: 0 0 0 1px var(--line);
}
.clip-thumb.wide { width: 112px; height: 63px; }
.clip-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.clip-thumb .duration {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: rgba(12, 8, 4, .78);
}
.clip-text { display: grid; gap: 2px; min-width: 0; }
.progress-text { font-size: .8rem; color: var(--warn); }
.badge[data-status="edited"] { color: var(--warn); }

/* --- editor: the side column's tabs --- */

.side-tabs { display: flex; gap: .3rem; padding: .25rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.side-tabs button { flex: 1; border: 0; border-radius: 999px; padding: .5rem .85rem; font-size: .85rem; color: var(--muted); background: transparent; }
.side-tabs button:hover:not(:disabled) { background: transparent; color: var(--ink); }
.side-tabs button[aria-selected="true"],
.side-tabs button[aria-selected="true"]:hover:not(:disabled) { background: var(--surface-2); color: var(--gold); box-shadow: 0 0 0 1px var(--line-strong); }
.side-tabs .count { margin-left: .2rem; }
.editor-side[data-pane="subtitles"] [data-pane]:not([data-pane="subtitles"]),
.editor-side[data-pane="details"] [data-pane]:not([data-pane="details"]),
.editor-side[data-pane="framing"] [data-pane]:not([data-pane="framing"]) { display: none; }
/* The list fills the column beside the sticky player. */
#cues { max-height: calc(100vh - 330px); min-height: 16rem; }

/* --- processing --- */

.processing h2 { margin-bottom: .8rem; }
.steps { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .55rem; }
.steps li { display: flex; align-items: center; gap: .7rem; font-size: .92rem; color: var(--faint); }
.steps li::before {
  content: "";
  width: .7rem;
  height: .7rem;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
}
.steps li.done { color: var(--muted); }
.steps li.done::before { border-color: var(--ok); background: var(--ok); }
.steps li.current { color: var(--ink); font-weight: 600; }
.steps li.current::before { border-color: var(--warn); background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.processing-detail { font-size: .88rem; color: var(--warn); margin: 0 0 .6rem; }
@media (prefers-reduced-motion: reduce) { .steps li.current::before { animation: none; } }

/* --- subtitles: tools, find, compact rows --- */

.cue-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.cue-tools button, .find-bar button, .export-row button { padding: .38rem .85rem; font-size: .78rem; }
.find-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.find-bar input { flex: 1 1 8rem; min-width: 0; padding: .45rem .7rem; font-size: .85rem; }
.find-bar .count { margin: 0; }
.export-row { margin-top: 12px; align-items: center; }
.export-row .hint { margin-right: .3rem; }
.cue-grid.cue-match { border-style: dashed; border-color: rgba(230, 189, 98, .55); }

/* Timing and actions belong to the caption being worked on: the rest stay
   two lines tall, so a long talk's list is scannable. */
.cue-grid:not(:focus-within):not(.is-playing) .cue-timing,
.cue-grid:not(:focus-within):not(.is-playing):not(.cue-needs-fit) .cue-actions { display: none; }
.cue-grid .cue-actions { opacity: 1; }

/* --- timeline: caption marks and trim handles --- */

#cue-strip { position: absolute; left: 0; right: 0; top: 1px; width: 100%; height: 4px; pointer-events: none; }
.trim-handle {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 10px;
  height: 22px;
  margin-left: -5px;
  transform: translateY(-50%);
  border-radius: 4px;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--ground);
  cursor: ew-resize;
  touch-action: none;
}
.trim-handle:hover { background: var(--gold-soft); }
.shortcuts kbd {
  display: inline-block;
  min-width: 1.3em;
  padding: 0 .3em;
  margin: 0 1px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font: 600 .72rem/1.5 var(--sans);
  color: var(--muted);
  background: var(--surface);
}
@media (max-width: 760px) {
  #cues { max-height: none; min-height: 0; }
  .clip-thumb { width: 36px; height: 64px; }
  .clip-thumb.wide { width: 88px; height: 50px; }
}
.processing .hint { margin: 0 0 .9rem; }
@media (max-width: 700px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .chips button { flex: none; }
  .library-tools select { flex: 1 1 auto; }
  .clip-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .clip-row > .badge { justify-self: start; grid-row: 2; }
}
/* Keys are no help on a touch screen. */
@media (hover: none) { .shortcuts { display: none; } }

/* --- upload: collapsed once the library has videos; a drop target --- */

.upload-panel > summary { list-style: none; }
.upload-panel > summary::-webkit-details-marker { display: none; }
.upload-panel[open] > summary { display: none; }
.upload-summary span {
  display: inline-flex;
  align-items: center;
  padding: .6rem 1.2rem;
  margin-bottom: 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
  color: var(--on-gold);
  background: linear-gradient(180deg, #e3c68c, var(--gold));
  cursor: pointer;
}
.upload.dragging { border-color: var(--gold); border-style: dashed; background: var(--gold-wash); }
.upload-progress { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-progress progress { flex: 1 1 12rem; }
#upload-detail { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-progress button { padding: .38rem .9rem; font-size: .8rem; }

/* --- editor header: the save state as a chip, actions behind ⋯ --- */

.save-chip:empty { display: none; }
.save-chip { font-size: .75rem; font-weight: 600; padding: .2rem .65rem; border-radius: 999px; color: var(--faint); border: 1px solid var(--line); }
.save-chip.error-text { border-color: var(--crit-line); }
.menu { position: relative; }
.menu > summary {
  list-style: none;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-3); }
.menu-items {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  display: grid;
  min-width: 12rem;
  padding: .35rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: var(--surface-2);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .5);
}
.menu-items .clip-actions { display: grid; gap: 2px; }
.menu-items button { justify-content: flex-start; width: 100%; border: 0; border-radius: 7px; background: transparent; color: var(--ink); padding: .55rem .75rem; font-size: .85rem; }
.menu-items button:hover:not(:disabled) { background: var(--surface-3); }

/* --- render card extras --- */

#render-used:empty { display: none; }
.render-history summary { cursor: pointer; font-size: .82rem; color: var(--muted); }
.render-history ul { margin: .5rem 0 0; padding-left: 1.1rem; display: grid; gap: .3rem; font-size: .82rem; color: var(--muted); }
.render-history a { color: var(--gold); }

/* --- framing: long-form footage pans only once zoomed --- */

.crop-note { display: none; margin: 0; }
#review.long-form:not(.zoomed) .crop-control { display: none; }
#review.long-form:not(.zoomed) .crop-note { display: block; }

/* --- phones: keep the player pinned above the captions --- */

@media (max-width: 760px) {
  .editor-grid { display: block; }
  .editor-stage { display: contents; }
  .player-dock {
    position: sticky;
    top: 58px;
    z-index: 6;
    display: grid;
    gap: 10px;
    padding: 8px 0 10px;
    background: var(--ground);
  }
  /* Sized from the video's shape: never wider than the column, never taller
   * than about a third of the screen, so the captions stay reachable. */
  .player-dock .portrait {
    width: min(100%, calc(32svh * var(--stage-ratio, .5625)));
    height: auto;
    margin: 0 auto;
  }
  .player-dock .stage-tabs button { padding: .3rem .6rem; }
  .editor-stage > .hint, .editor-stage > p { margin: 6px 0; }
  .editor-stage > .shortcuts { display: none; }
  .render-card { margin: 10px 0 18px; }
}
/* These are disclosure widgets, not the form sections the bare details rule styles. */
.menu, .upload-panel, .render-history { border-top: 0; padding-top: 0; }
.menu[open], .upload-panel[open] { display: block; }
.render-history[open] { gap: 0; }

/* --- a caption's controls: flush with its text, not floating pills ---
 * Everything under the English starts where the English starts (the
 * textarea's padding plus its border). The actions are a quiet text toolbar:
 * no box until hover, dots between them, and Delete set apart on the right. */

.cue-grid { --cue-inset: calc(.45rem + 1px); }
.cue-timing { margin: .5rem var(--cue-inset) 0; gap: .4rem 1.1rem; }
.cue-timing label { gap: .5rem; font-size: .78rem; font-weight: 600; color: var(--faint); }
.cue-timing input { width: 5.6rem; padding: .32rem .55rem; font-size: .84rem; text-align: left; }
.cue-grid .cue-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .9rem;
  margin: .55rem var(--cue-inset) 0;
  padding-top: .5rem;
  border-top: 1px solid var(--line);
}
.cue-grid .cue-actions button {
  position: relative;
  padding: .15rem 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline 1px transparent;
  text-underline-offset: 4px;
  transition: color .12s, text-decoration-color .12s;
}
.cue-grid .cue-actions button:hover:not(:disabled),
.cue-grid .cue-actions button:focus-visible {
  background: none;
  color: var(--ink);
  text-decoration-color: var(--gold);
}
.cue-grid .cue-actions button:disabled { color: var(--line-strong); }
/* A faint dot between neighbouring actions. */
.cue-grid .cue-actions button:not(:first-child):not(.cue-delete):not([hidden])::before {
  content: "·";
  position: absolute;
  left: -.6rem;
  color: var(--line-strong);
  pointer-events: none;
}
.cue-grid .cue-actions .cue-delete { margin-left: auto; }
.cue-grid .cue-actions .cue-delete:hover:not(:disabled) { color: var(--crit); text-decoration-color: var(--crit); }
/* Split to fit is the answer to the warning, so it reads as the next step. */
.cue-grid .cue-actions .cue-fit { color: var(--gold); }
.cue-overflow { grid-row: 4; margin: .4rem var(--cue-inset) 0; font-size: .78rem; }
.cue-grid .cue-actions { grid-row: 5; }
