:root {
  color-scheme: dark;
  --bg: #080a0f;
  --surface: #10131b;
  --surface-2: #151a24;
  --panel: rgba(16, 19, 27, 0.94);
  --panel-2: rgba(21, 26, 36, 0.96);
  --text: #f7f7fb;
  --muted: #a2a9b8;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --songs: #a3e635;
  --warning: #f59e0b;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.06), transparent 280px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 0 42px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.brand-lockup {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.captions-logo {
  display: block;
  width: min(290px, 58vw);
  height: auto;
}

body.is-editing main {
  width: min(1600px, calc(100vw - 24px));
  padding-top: 10px;
}

body.is-editing .app-header {
  margin-bottom: 10px;
  padding-bottom: 8px;
}

body.is-editing .brand-lockup {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

body.is-editing .captions-logo {
  width: min(210px, 44vw);
}

body.is-editing #context-label {
  margin: 0;
  font-size: 0.84rem;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  font-size: 1.72rem;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.2rem;
}

h3 {
  margin: 0;
  font-size: 0.88rem;
}

.app-header p:not(.eyebrow),
#job-state,
.notice {
  color: var(--muted);
}

.eyebrow {
  color: var(--accent-2);
  margin-bottom: 6px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
  padding: 18px;
}

.editor-panel {
  overflow: hidden;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 180px),
    var(--surface);
}

#auth-panel,
.setup-panel {
  max-width: 1180px;
  margin: 22px auto 0;
  padding: 0;
  overflow: hidden;
}

.entry-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.74fr) minmax(520px, 1.26fr);
  min-height: 456px;
}

.entry-copy {
  display: grid;
  align-content: center;
  padding: 34px;
  border-right: 1px solid var(--line);
}

.state-pill {
  width: max-content;
  margin-bottom: 12px;
  border: 1px solid rgba(56, 189, 248, 0.36);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(56, 189, 248, 0.1);
  color: #bae6fd;
  font-size: 0.72rem;
  font-weight: 840;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.entry-copy h2,
.setup-copy h2 {
  margin-bottom: 8px;
  font-size: 1.62rem;
}

.entry-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.1), transparent 38%),
    var(--surface);
}

.demo-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.demo-toolbar span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 820;
  text-align: center;
}

.demo-toolbar .active {
  border-color: rgba(45, 212, 191, 0.62);
  background: rgba(45, 212, 191, 0.18);
  color: #ccfbf1;
}

.demo-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 178px;
  gap: 12px;
  min-height: 0;
}

.preview-video {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background:
    radial-gradient(circle at 25% 20%, rgba(56, 189, 248, 0.16), transparent 24%),
    radial-gradient(circle at 78% 12%, rgba(236, 72, 153, 0.12), transparent 26%),
    linear-gradient(145deg, #111827, #05070b 64%),
    #05070b;
}

.preview-video span {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 13%;
  height: 14%;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.68);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.preview-video strong {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 16%;
  color: white;
  font-size: clamp(0.82rem, 1.25vw, 1.05rem);
  text-align: center;
  text-shadow: 0 2px 8px black;
}

.demo-cues {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.demo-cues i {
  display: block;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
}

.demo-cues i::before,
.demo-cues i::after {
  content: "";
  display: block;
  height: 7px;
  margin: 9px 10px 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.demo-cues i::after {
  width: 62%;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.demo-cues .active {
  border-color: rgba(56, 189, 248, 0.48);
  background: rgba(56, 189, 248, 0.12);
}

.demo-timeline {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 1.4fr 0.65fr 1fr;
  gap: 5px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.demo-timeline i {
  display: block;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
}

.demo-timeline i:nth-child(2),
.demo-timeline i:nth-child(4) {
  background: rgba(45, 212, 191, 0.28);
}

.setup-panel {
  padding: 22px;
}

.setup-copy {
  margin-bottom: 16px;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.35fr) auto;
  gap: 14px;
  align-items: end;
}

.setup-action {
  display: flex;
}

.setup-action button {
  min-width: 156px;
}

.grid,
.style-grid {
  display: grid;
  gap: 12px;
}

.grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.style-grid {
  grid-template-columns: repeat(5, minmax(128px, 1fr));
  align-items: end;
  margin-top: 12px;
}

.context-options {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(220px, max-content) minmax(220px, max-content);
  gap: 10px 16px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.context-options > span {
  color: var(--muted);
  font-size: 0.86rem;
}

.style-card,
.mask-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.026);
}

.mask-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, auto);
  gap: 18px;
  align-items: start;
}

.mask-copy {
  display: grid;
  gap: 9px;
}

.mask-panel p {
  max-width: 68ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.mask-controls {
  display: grid;
  grid-template-columns: 128px minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  line-height: 1.25;
}

input,
select,
button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

input,
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input[type="checkbox"],
input[type="radio"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
}

input[type="color"] {
  padding: 3px;
  height: 42px;
}

input[type="range"] {
  accent-color: var(--accent);
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
summary:focus-visible,
.file-button:focus-within {
  outline: 2px solid rgba(56, 189, 248, 0.9);
  outline-offset: 2px;
}

button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 15px;
  background: var(--accent);
  color: #06100f;
  font-weight: 760;
  cursor: pointer;
  text-decoration: none;
}

button.secondary,
.file-button,
button.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

button.ghost {
  min-height: 36px;
  padding: 8px 11px;
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

button.ghost:hover,
button.secondary:hover,
.file-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.11);
  color: var(--text);
}

.oauth-button {
  display: inline-flex;
  gap: 12px;
  min-width: 236px;
  border-radius: 999px;
  background: #fff;
  color: #1f1f1f;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.oauth-button:hover {
  filter: brightness(0.96);
}

.oauth-button.apple {
  background: #050505;
  color: #fff;
}

.oauth-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-weight: 900;
}

.oauth-button.google .oauth-icon {
  color: #4285f4;
  font-family: Arial, sans-serif;
}

.oauth-button.apple .oauth-icon {
  color: #fff;
  font-size: 1.25rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.file-button input {
  display: none;
}

.actions,
.toolbar,
.topbar,
.session-actions,
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.language-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.language-switch button {
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.language-switch button.active,
.language-switch button:hover {
  background: var(--accent);
  color: #06110f;
}

.actions {
  margin-top: 16px;
}

.actions.small {
  justify-content: space-between;
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.cue-actions-main,
.srt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.srt-menu {
  position: relative;
  color: var(--muted);
  margin-left: auto;
}

.srt-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 0;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 860;
  line-height: 1;
}

.srt-menu summary::-webkit-details-marker {
  display: none;
}

.srt-menu summary::marker {
  content: "";
}

.srt-menu summary:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

.srt-actions {
  position: absolute;
  right: 0;
  z-index: 12;
  width: max-content;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #11151d;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.36);
}

.lyrics-import-modal {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.64);
}

.lyrics-import-dialog {
  display: grid;
  gap: 12px;
  width: min(760px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 34px));
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px;
  background: #11151d;
  box-shadow: 0 24px 74px rgba(0, 0, 0, 0.54);
}

.lyrics-import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lyrics-import-head h3 {
  font-size: 1rem;
}

.lyrics-import-head button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1.1rem;
}

.lyrics-import-dialog textarea {
  min-height: min(420px, 52vh);
  resize: vertical;
  line-height: 1.4;
}

.lyrics-import-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.lyrics-reference {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.lyrics-reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lyrics-reference-head span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 860;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lyrics-reference-head button {
  min-height: 30px;
  padding: 5px 9px;
}

.lyrics-reference pre {
  max-height: 170px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font: 0.84rem/1.42 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.topbar {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.026);
}

.topbar h2,
.topbar p {
  margin-bottom: 0;
}

.flow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  align-items: stretch;
  margin: 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  counter-reset: flow;
}

.flow-step {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  justify-content: start;
  min-height: 50px;
  padding: 10px 12px;
  border-radius: 12px;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
}

.flow-step::after {
  content: "";
  position: absolute;
  left: calc(100% + 2px);
  top: 50%;
  width: 5px;
  height: 1px;
  background: var(--line-strong);
}

.flow-step:last-child::after,
.flow-step[hidden]::after {
  display: none;
}

.flow-step span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 880;
}

.flow-step-quiet {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.flow-step[data-state="next"] {
  border-color: rgba(45, 212, 191, 0.78);
  background: rgba(45, 212, 191, 0.14);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.08);
}

.flow-step[data-state="next"] .step-number {
  background: var(--accent);
  color: #06100f;
}

.flow-step[data-state="active"] {
  border-color: rgba(245, 158, 11, 0.78);
  background: rgba(245, 158, 11, 0.15);
}

.flow-step[data-state="active"] .step-number {
  background: var(--warning);
  color: #160d02;
}

.flow-step[data-state="done"] {
  border-color: rgba(163, 230, 53, 0.45);
  background: rgba(163, 230, 53, 0.09);
}

.flow-step[data-state="done"] .step-number {
  background: rgba(163, 230, 53, 0.86);
  color: #111904;
}

.flow-step[data-state="locked"] {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  opacity: 0.72;
}

.editor-utilities {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 0 18px 18px;
  background: #080a0f;
}

.inspector-panel,
.secondary-options {
  color: var(--muted);
}

.inspector-panel {
  min-width: 0;
}

.inspector-panel summary,
.secondary-options summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  width: max-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 780;
  color: var(--muted);
}

.inspector-panel summary:hover,
.secondary-options summary:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.inspector-panel summary span {
  color: var(--text);
}

.inspector-panel summary small,
.secondary-options summary small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 620;
}

.secondary-options summary span {
  color: var(--text);
}

.inspector-content {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.toolbar.compact {
  margin: 10px 0 0;
  gap: 8px;
}

.quiet {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0.82;
}

.render-progress {
  display: grid;
  gap: 8px;
  margin: 12px 18px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.error {
  color: var(--danger);
  margin: 12px 0 0;
}

.notice {
  width: max-content;
  max-width: calc(100% - 36px);
  margin: 10px 18px 0;
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(56, 189, 248, 0.06);
  font-size: 0.82rem;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  grid-template-areas: "video captions";
  gap: 14px;
  padding: 14px 18px 16px;
  background: #080a0f;
  overflow: hidden;
}

.lyrics,
.video-side {
  min-width: 0;
}

.video-side {
  grid-area: video;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: hidden;
}

.lyrics {
  grid-area: captions;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  min-height: min(70vh, 760px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  padding: 12px;
}

.lyrics::before {
  content: "Sous-titres";
  display: block;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 860;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cues {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: min(62vh, 700px);
  overflow: auto;
  padding-right: 4px;
}

.empty-cues {
  display: grid;
  gap: 6px;
  min-height: 180px;
  place-content: center;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.empty-cues strong {
  color: var(--text);
  font-size: 1rem;
}

.empty-cues span,
.empty-timeline {
  color: var(--muted);
  font-size: 0.84rem;
}

.cue {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 76px 34px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.cue.active {
  border-color: rgba(34, 211, 238, 0.8);
  background: rgba(34, 211, 238, 0.1);
}

.cue input {
  border-color: transparent;
}

.cue .time {
  padding: 8px 6px;
  font-size: 0.75rem;
  text-align: center;
  color: var(--muted);
}

.cue .text {
  font-size: 0.95rem;
}

.cue .trash {
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
  background: rgba(251, 113, 133, 0.16);
  color: #fecdd3;
  font-size: 1.18rem;
  line-height: 1;
}

.video-frame {
  position: sticky;
  top: 10px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #000;
  aspect-ratio: 16 / 9;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

.caption-mask {
  position: absolute;
  z-index: 2;
  min-width: 28px;
  min-height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.78), 0 8px 22px rgba(0, 0, 0, 0.28);
  cursor: move;
  touch-action: none;
}

.caption-mask::before {
  content: "";
  position: absolute;
  inset: -8px;
}

.mask-label {
  position: absolute;
  left: 8px;
  top: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.mask-handle {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 18px;
  height: 18px;
  border-radius: 8px 0 3px;
  background:
    linear-gradient(135deg, transparent 45%, rgba(255, 255, 255, 0.9) 46%, rgba(255, 255, 255, 0.9) 54%, transparent 55%),
    rgba(56, 189, 248, 0.82);
  cursor: nwse-resize;
  touch-action: none;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.subtitle-preview {
  pointer-events: none;
  position: absolute;
  z-index: 3;
  inset: auto 8% 9% 8%;
  display: grid;
  justify-items: center;
  gap: 0.25em;
  text-align: center;
  font-weight: 800;
  line-height: 1.15;
}

.subtitle-preview .context {
  opacity: 0.46;
  font-size: 0.72em;
}

.subtitle-preview span {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 160ms ease-out, transform 160ms ease-out;
  white-space: pre-wrap;
}

.timeline-shell {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
}

.timeline-head > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 860;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-controls {
  display: flex;
  gap: 5px;
  align-items: center;
}

.timeline-controls button.ghost {
  min-width: 34px;
  min-height: 30px;
  padding: 5px 9px;
}

.timeline {
  max-width: 100%;
  display: flex;
  gap: 2px;
  align-items: stretch;
  min-height: 62px;
  margin-top: 0;
  overflow-x: auto;
  padding: 7px;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.empty-timeline {
  display: grid;
  place-items: center;
  width: 100%;
}

.segment {
  position: relative;
  display: grid;
  align-content: center;
  min-width: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.68rem;
  overflow: hidden;
  padding: 6px 7px;
  text-align: left;
}

.segment-handle {
  position: absolute;
  top: 5px;
  bottom: 5px;
  display: none;
  width: 8px;
  border-radius: 999px;
  background: rgba(204, 251, 241, 0.9);
  box-shadow: 0 0 0 2px rgba(8, 10, 15, 0.75);
  cursor: ew-resize;
  touch-action: none;
}

.segment-handle-start {
  left: 2px;
}

.segment-handle-end {
  right: 2px;
}

.segment.active {
  padding-inline: 13px;
}

.segment.active .segment-handle {
  display: block;
}

.segment-time,
.segment-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-time {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
}

.segment-text {
  margin-top: 4px;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 780;
}

.segment.active {
  background: rgba(45, 212, 191, 0.3);
  border-color: rgba(45, 212, 191, 0.86);
  color: #fff;
}

.segment.active .segment-time {
  color: #ccfbf1;
}

@media (max-width: 1120px) {
  .workbench {
    grid-template-columns: 1fr;
    grid-template-areas:
      "video"
      "captions";
  }

  .editor-utilities {
    grid-template-columns: 1fr;
  }

  .style-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .context-options {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .flow-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mask-panel {
    grid-template-columns: 1fr;
  }

  .entry-shell,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .demo-workspace {
    grid-template-columns: 1fr;
  }

  .demo-cues {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-copy {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .setup-action button {
    width: 100%;
  }

  .mask-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mask-controls button {
    grid-column: 1 / -1;
  }

  .video-frame {
    position: relative;
    top: auto;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100vw - 18px, 1480px);
    padding-top: 18px;
  }

  body.is-editing main {
    width: min(100vw - 12px, 1480px);
    padding-top: 8px;
  }

  .panel {
    padding: 14px;
    border-radius: 12px;
  }

  .editor-panel {
    padding: 0;
  }

  #auth-panel,
  .setup-panel {
    margin-top: 16px;
  }

  .entry-copy,
  .entry-preview {
    padding: 18px;
  }

  .entry-shell {
    min-height: 0;
  }

  .app-header {
    align-items: start;
    flex-direction: column;
  }

  body.is-editing .brand-lockup {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  body.is-editing .captions-logo {
    width: min(188px, 58vw);
  }

  .session-actions {
    width: 100%;
  }

  .session-actions button {
    flex: 1;
  }

  .flow-strip {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .flow-step::after {
    display: none;
  }

  .notice {
    width: auto;
    max-width: none;
    margin-inline: 12px;
    border-radius: 10px;
  }

  .workbench,
  .editor-utilities {
    padding-inline: 12px;
  }

  .actions.small,
  .cue-actions-main {
    align-items: stretch;
    flex-direction: column;
  }

  .srt-menu {
    width: 100%;
  }

  .srt-menu summary {
    justify-content: center;
    margin-left: auto;
    border-radius: 10px;
  }

  .srt-actions {
    position: static;
    width: 100%;
    margin-top: 8px;
  }

  .srt-actions > * {
    flex: 1;
  }

  .lyrics {
    min-height: auto;
  }

  .cues {
    max-height: none;
  }

  .empty-cues {
    min-height: 150px;
  }

  .inspector-panel summary small,
  .secondary-options summary small {
    display: none;
  }

  .style-grid,
  .mask-controls {
    grid-template-columns: 1fr;
  }

  .inspector-panel summary,
  .secondary-options summary {
    width: 100%;
    border-radius: 10px;
  }

  .mask-controls {
    grid-template-columns: 1fr;
  }

  .cue {
    grid-template-columns: 1fr 1fr 38px;
    grid-template-areas:
      "start end trash"
      "text text text";
    gap: 7px;
  }

  .cue .start {
    grid-area: start;
  }

  .cue .end {
    grid-area: end;
  }

  .cue .text {
    grid-area: text;
  }

  .cue .trash {
    grid-area: trash;
  }
}
