/* glosSub: a calm place to watch, read and learn. All assets stay local.
 * Type scale is rem-based on a 17px root so every control stays readable. */
:root {
  --paper: #f6f5fb;
  --surface: #ffffff;
  --ink: #1f2036;
  --muted: #5d5e74;
  --faint: #8a8aa0;
  --action: #5a4bd0;
  --action-hover: #4838bb;
  --action-ink: #ffffff;
  --divider: #e2e1ee;
  --soft: #efecfc;
  --warn-bg: #fff7e8;
  --warn-ink: #7b5214;
  --warn-line: #efd6a4;
  --err-bg: #fff0ef;
  --err-ink: #a42e34;
  --err-line: #edbdbe;
  --ok-bg: #ecf8f1;
  --ok-ink: #1f6545;
  --ok-line: #b9deca;
  --stage-dark: #13121c;
  --title: "Avenir Next", "Avenir", "Segoe UI", system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ja: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 20px;
  --wide: 1360px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; font-size: 17px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 1rem; line-height: 1.55; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
a { color: var(--action); }
kbd { font-family: var(--mono); font-size: .82em; border: 1px solid var(--divider); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; background: var(--action); color: white; border-radius: 8px; padding: 12px 16px; }
.skip-link:focus { top: 12px; }
:where(select, input, button, a, summary):focus-visible { outline: 3px solid #9d8de9; outline-offset: 3px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 28px; min-height: 80px; max-width: var(--wide); margin: auto; padding: 14px 32px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; flex: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px 12px 12px 4px; background: var(--action); color: white; display: grid; place-items: center; }
.brand-mark span { font-family: var(--title); font-size: 31px; font-weight: 700; line-height: 1; transform: translateY(-3px); }
.brand-name { font-family: var(--title); font-size: 1.55rem; font-weight: 700; letter-spacing: -.045em; }
.brand-name > span { color: var(--action); }
.brand-sub { font-size: .85rem; color: var(--muted); margin-left: auto; }
.topbar:has(.account-toolbar:not([hidden])) .brand-sub { display: none; }
.views { display: flex; gap: 4px; padding: 4px; background: #eae8f4; border-radius: 13px; }
.view-tab { background: transparent; border: 0; border-radius: 10px; color: var(--muted); font-size: .94rem; font-weight: 600; padding: 10px 20px; cursor: pointer; white-space: nowrap; }
.view-tab.is-active { color: var(--action); background: var(--surface); box-shadow: 0 2px 6px #2520460f; }
.view-tab:hover:not(:disabled) { color: var(--action); }
.view-tab:disabled { opacity: .45; cursor: not-allowed; }
.account-toolbar { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.account-toolbar > span { font-size: .82rem; color: var(--muted); max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-gate { max-width: var(--wide); margin: 48px auto; padding: 30px; text-align: center; color: var(--muted); font-size: 1rem; }
.offline { max-width: var(--wide); margin: 12px auto 0; padding: 14px 20px; border: 1px solid var(--warn-line); border-radius: 12px; background: var(--warn-bg); color: var(--warn-ink); font-size: .94rem; }

/* ---------- flow heading + steps ---------- */
.flow-head { max-width: var(--wide); margin: 0 auto; padding: 28px 32px 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; }
.flow-title { min-width: 0; }
.eyebrow { margin: 0 0 8px; color: var(--action); font-size: .76rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-family: var(--title); font-size: clamp(1.75rem, 2.6vw, 2.5rem); line-height: 1.15; font-weight: 700; letter-spacing: -.035em; max-width: 22ch; }
.intro-copy { margin: 12px 0 0; color: var(--muted); font-size: 1rem; max-width: 560px; }
.journey { display: flex; gap: 6px; list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--divider); border-radius: 999px; flex: none; }
.journey li { display: flex; align-items: center; gap: 10px; padding: 8px 18px 8px 8px; border-radius: 999px; color: var(--muted); font-size: .9rem; font-weight: 600; white-space: nowrap; }
.journey-number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--soft); color: var(--action); font-size: .85rem; font-weight: 750; flex: none; }
.journey li[data-state="current"] { background: var(--soft); color: var(--action); }
.journey li[data-state="current"] .journey-number { background: var(--action); color: white; }
.journey li[data-state="complete"] .journey-number { background: #dcefe3; color: #1f6545; font-size: 0; }
.journey li[data-state="complete"] .journey-number::before { content: "✓"; font-size: .95rem; }
.journey li[data-state="locked"] { opacity: .5; }

/* Once the video is ready the steps alone are enough context. */
[data-phase="ready"] .flow-title, [data-phase="processing"] .flow-title, [data-phase="error"] .flow-title { display: none; }
[data-phase="ready"] .flow-head, [data-phase="processing"] .flow-head, [data-phase="error"] .flow-head { justify-content: center; padding-bottom: 22px; }

/* ---------- layout ---------- */
.desk { max-width: var(--wide); margin: 0 auto; padding: 0 32px 64px; }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r); padding: 28px; box-shadow: 0 6px 24px #1f203608; }
.card h2, .setup-heading { margin: 0; font-family: var(--title); font-size: 1.3rem; letter-spacing: -.02em; line-height: 1.25; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- step 1: setup ---------- */
.setup-panel { padding: 0; overflow: hidden; }
.setup-controls { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.setup-file, .setup-options { padding: 34px 36px 36px; min-width: 0; }
.setup-options { border-left: 1px solid var(--divider); background: #fcfcfe; }
.setup-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.step-number { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); color: var(--action); display: grid; place-items: center; font-size: .85rem; font-weight: 750; flex: none; font-family: var(--body); letter-spacing: 0; }
.upload-zone { position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; min-height: 260px; border: 2px dashed #c3b8ee; background: #faf8ff; border-radius: 18px; padding: 32px 24px; text-align: center; color: var(--action); cursor: pointer; transition: background .15s, border-color .15s; }
.upload-zone:hover { background: #f4f1ff; border-color: var(--action); }
.upload-title { font-size: 1.12rem; font-weight: 650; max-width: 22ch; line-height: 1.35; }
.upload-formats { color: var(--muted); font-size: .9rem; }
.upload-symbol { display: grid; place-items: center; width: 60px; height: 60px; background: var(--action); color: white; border-radius: 50%; font-size: 1.75rem; margin-bottom: 4px; box-shadow: 0 8px 20px #5a4bd033; }
.upload-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-zone:has(input:focus-visible) { outline: 3px solid #9d8de9; outline-offset: 3px; }
.upload-zone.is-dragging { border-style: solid; background: var(--soft); border-color: var(--action); }
.upload-zone.is-busy { cursor: progress; opacity: .75; }
.upload-zone.is-busy .upload-input { cursor: progress; }
.setup-file:has(.chosen.has) .upload-zone { min-height: 150px; padding: 22px; }
.setup-file:has(.chosen.has) .upload-symbol { width: 44px; height: 44px; font-size: 1.3rem; }
.setup-file:has(.chosen.has) .upload-title::after { content: " · cambiar archivo"; font-weight: 500; color: var(--muted); }
.upload-progress { width: 100%; height: 10px; border: 0; border-radius: 50px; margin-top: 16px; accent-color: var(--action); }
.upload-progress::-webkit-progress-bar { background: var(--soft); border-radius: 50px; }
.upload-progress::-webkit-progress-value { background: var(--action); border-radius: 50px; transition: width .3s; }
.upload-status { font-size: .95rem; font-weight: 600; color: var(--action); }
.upload-status:empty { display: none; }
.chosen { display: flex; align-items: center; gap: 10px; background: var(--paper); color: var(--muted); font-size: .95rem; padding: 14px 16px; border-radius: 12px; margin: 16px 0 0; overflow-wrap: anywhere; }
.chosen.has { color: var(--ok-ink); background: var(--ok-bg); border: 1px solid var(--ok-line); font-weight: 650; }
.chosen.has::before { content: "✓"; display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: #1f6545; color: white; font-size: .8rem; }
.upload-note { font-size: .85rem; margin-top: 16px; }
.local-browser { margin-top: 18px; border-top: 1px solid var(--divider); padding-top: 14px; }
.local-browser > summary { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.local-browser > summary::after { content: " +"; color: var(--action); }
.local-browser[open] > summary::after { content: " −"; }
.folder-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.file-path { color: var(--muted); font-size: .9rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.search-field { margin-bottom: 8px; }
.listing { list-style: none; margin: 8px -8px 0; padding: 0; max-height: 260px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.listing li { border-radius: 8px; }
.listing button { width: 100%; text-align: left; background: transparent; border: 0; border-radius: 10px; color: var(--ink); font-size: .95rem; min-height: 50px; padding: 9px 10px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.listing button:hover { background: var(--paper); }
.listing button:focus-visible { outline-offset: -3px; }
.listing .tag { display: grid; place-items: center; width: 30px; height: 32px; background: #efedf8; border-radius: 7px; font-size: 1rem; color: var(--action); flex: none; }
.listing button[data-kind="dir"] .tag { background: #faf3e1; color: #94733c; }
.listing .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing .sz { font-size: .8rem; color: var(--muted); flex: none; }
.listing li.picked button { color: var(--action); background: var(--soft); font-weight: 600; }
.listing .empty { padding: 12px; color: var(--muted); font-size: .95rem; }

.field { margin-bottom: 18px; min-width: 0; }
label, .label-as-text, legend { display: block; font-size: .9rem; font-weight: 650; color: var(--ink); margin-bottom: 8px; }
.opt { font-weight: 400; font-size: .85rem; color: var(--muted); }
select, input[type="text"], input[type="number"], input[type="search"] { width: 100%; min-width: 0; background: var(--surface); border: 1px solid #d6d5e4; color: var(--ink); border-radius: 12px; min-height: 52px; padding: 11px 14px; font-size: 1rem; }
select:hover, input[type="text"]:hover, input[type="search"]:hover { border-color: #b9b2df; }
input::placeholder { color: var(--faint); }
select { padding-right: 28px; }
select:disabled { color: var(--faint); background: var(--paper); cursor: not-allowed; }
.language-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 12px; }
.language-row .field { margin-bottom: 0; }
.language-arrow { font-size: 1.4rem; color: var(--action); padding-bottom: 12px; }
.check { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 8px; color: var(--ink); font-size: .95rem; font-weight: 400; cursor: pointer; }
.check input { flex: none; accent-color: var(--action); width: 20px; height: 20px; margin: 2px 0 0; }
.check.confirm { margin-top: 10px; }
.learning-option { margin: 22px 0 6px; padding: 16px 18px; border: 1px solid var(--divider); border-radius: 14px; background: var(--surface); }
.learning-option:has(input:checked) { border-color: #c9bff0; background: #f9f7ff; }
.learning-option strong { display: block; font-size: 1rem; font-weight: 650; }
.learning-option small { display: block; font-size: .88rem; color: var(--muted); margin-top: 3px; }
.advanced { margin: 6px 0 22px; border-bottom: 1px solid var(--divider); }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.advanced > summary { padding: 16px 0; display: flex; align-items: center; justify-content: space-between; font-size: .95rem; font-weight: 650; color: var(--muted); }
.advanced > summary span { color: var(--action); font-size: 1.4rem; font-weight: 400; line-height: 1; transition: transform .15s; }
.advanced[open] > summary span { transform: rotate(45deg); }
.advanced-body { padding: 4px 0 10px; }
.source-options { border: 0; padding: 0; margin-inline: 0; }
.source-options legend { padding: 0; }
.modes { display: grid; gap: 10px; margin-top: 4px; }
.radio { display: flex; align-items: flex-start; gap: 10px; margin: 0; color: var(--ink); font-size: .95rem; font-weight: 400; cursor: pointer; }
.radio input { accent-color: var(--action); margin: 4px 0 0; width: 17px; height: 17px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { margin: 0; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--divider); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: .9rem; font-weight: 500; color: var(--muted); }
.pill input { accent-color: var(--action); margin: 0; }
.pill small { color: var(--muted); font-size: .8rem; }
.pill:has(input:checked) { border-color: #bfb5ec; color: var(--action); background: #f8f6ff; }
.rerun-field { border-top: 1px solid var(--divider); padding-top: 16px; margin-top: 18px; }
.go { width: 100%; min-height: 60px; padding: 14px 22px; border: 0; border-radius: 14px; background: var(--action); color: var(--action-ink); font-size: 1.1rem; font-weight: 700; cursor: pointer; box-shadow: 0 8px 20px #5a4bd02e; transition: background .15s, transform .1s; }
.go:hover:not(:disabled) { background: var(--action-hover); }
.go:active:not(:disabled) { transform: translateY(1px); }
.go:disabled { background: #e4e1f1; color: #7e788f; cursor: not-allowed; box-shadow: none; }
.generation-note { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: .88rem; }
.ghost { background: var(--surface); border: 1px solid var(--divider); color: var(--ink); border-radius: 11px; min-height: 44px; padding: 9px 16px; font-size: .92rem; font-weight: 550; cursor: pointer; }
.ghost:hover:not(:disabled) { border-color: #b8aced; color: var(--action); background: #fbfaff; }
.ghost:disabled { color: #9a9aab; cursor: not-allowed; }
.ghost[aria-pressed="true"] { border-color: #ccc3ef; color: var(--action); background: #f5f2ff; }
.ghost.compact { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.save-button:not(:disabled) { color: white; background: var(--action); border-color: var(--action); }
.err, .warn, .ok { margin: 14px 0 0; padding: 13px 16px; border-radius: 12px; font-size: .95rem; overflow-wrap: anywhere; }
.err { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err-ink); }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); }
.ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok-ink); }
.hint { color: var(--muted); font-size: .88rem; margin: 8px 0 0; overflow-wrap: anywhere; }
.state { color: var(--muted); font-size: .92rem; margin: 10px 0 0; overflow-wrap: anywhere; }

/* ---------- step 2: processing ---------- */
.processing-panel { max-width: 860px; margin: 0 auto; padding: clamp(26px, 4.5vw, 48px); }
.processing-head { display: flex; align-items: center; gap: 20px; }
.processing-heading { min-width: 0; }
.processing-panel h2 { font-size: clamp(1.4rem, 2.4vw, 1.9rem); line-height: 1.2; }
.processing-file { margin: 6px 0 0; color: var(--muted); font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.processing-file:empty { display: none; }
.processing-symbol { flex: none; width: 52px; height: 52px; border: 5px solid #e6e2f4; border-top-color: var(--action); border-radius: 50%; animation: processing-spin 1s linear infinite; }
.processing-meter { margin: 30px 0 8px; }
.meter-labels { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.processing-stage { margin: 0; font-size: 1.1rem; font-weight: 650; color: var(--action); }
.processing-percent { font-family: var(--title); font-size: 2rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }
.processing-meter progress { display: block; width: 100%; height: 16px; border: 0; border-radius: 99px; overflow: hidden; accent-color: var(--action); background: var(--soft); }
.processing-meter progress::-webkit-progress-bar { background: var(--soft); border-radius: 99px; }
.processing-meter progress::-webkit-progress-value { border-radius: 99px; transition: width .6s ease; background: linear-gradient(90deg, #6d5fe0, #5a4bd0) , repeating-linear-gradient(45deg, #ffffff22 0 10px, transparent 10px 20px); background-blend-mode: overlay; }
.processing-meter progress::-moz-progress-bar { background: var(--action); border-radius: 99px; }
.processing-meter progress:not([value])::-webkit-progress-bar { background: repeating-linear-gradient(-45deg, #e3defa 0 14px, #f1eefd 14px 28px); background-size: 40px 40px; animation: meter-indeterminate 1s linear infinite; }
.stage-list { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 4px; }
.stage-list li { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 12px; font-size: 1rem; color: var(--faint); }
.stage-dot { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #d9d6e8; display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.stage-list li[data-state="done"] { color: var(--ink); }
.stage-list li[data-state="done"] .stage-dot { background: #1f6545; border-color: #1f6545; color: white; }
.stage-list li[data-state="done"] .stage-dot::before { content: "✓"; }
.stage-list li[data-state="active"] { color: var(--action); background: var(--soft); font-weight: 650; }
.stage-list li[data-state="active"] .stage-dot { border-color: #cfc7f3; border-top-color: var(--action); animation: processing-spin .9s linear infinite; }
.stage-list li[data-state="failed"] { color: var(--err-ink); background: var(--err-bg); font-weight: 650; }
.stage-list li[data-state="failed"] .stage-dot { background: var(--err-ink); border-color: var(--err-ink); color: white; }
.stage-list li[data-state="failed"] .stage-dot::before { content: "!"; }
.processing-meta { display: flex; flex-wrap: wrap; gap: 8px 28px; color: var(--muted); font-size: .92rem; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--divider); }
.processing-meta p { margin: 0; }
.processing-meta p:empty { display: none; }
#processing-eta { color: var(--ink); font-weight: 650; }
.processing-detail { color: var(--muted); font-size: .95rem; margin: 14px 0 0; }
.processing-detail:empty { display: none; }
.processing-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.processing-actions:not(:has(button:not([hidden]))) { display: none; }
.processing-actions .go { width: auto; min-height: 52px; font-size: 1rem; }
[data-phase="error"] .processing-symbol { animation: none; border-color: var(--err-line); background: var(--err-bg); position: relative; }
[data-phase="error"] .processing-symbol::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--err-ink); font-weight: 800; font-size: 1.4rem; }
[data-phase="error"] .processing-stage { color: var(--err-ink); }
[data-phase="error"] .processing-percent { display: none; }
[data-phase="error"] .processing-meter progress { display: none; }
[data-phase="error"] .meter-labels { margin-bottom: 0; }
@keyframes processing-spin { to { transform: rotate(360deg); } }
@keyframes meter-indeterminate { to { background-position: 40px 0; } }

/* ---------- step 3: results ---------- */
.results { display: grid; gap: 22px; }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.result-ready { display: flex; align-items: center; gap: 14px; margin: 0; font-size: 1.05rem; min-width: 0; }
.result-ready strong { color: var(--ok-ink); }
.result-check { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: #1f6545; color: white; font-weight: 800; }
.preview-name { color: var(--muted); overflow-wrap: anywhere; }
.player-card { min-width: 0; }
.local-preview-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; padding: 14px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--divider); }
.local-preview-controls:has(#btn-local-preview[hidden]) { display: none; }
/* Only offer re-opening the local file when the picture is missing or failed. */
.player-card:has(#preview[src]):not(:has(#codec-warn:not([hidden]))) .local-preview-controls { display: none; }
.local-preview-controls .hint { margin: 0; flex: 1 1 280px; font-size: .92rem; }
.local-preview-controls .ghost { color: var(--action); border-color: #ccc3ef; }
.local-preview-controls .state { margin: 0; flex-basis: 100%; }
.player-stage { min-width: 0; }
.player-shell { position: relative; background: var(--stage-dark); border-radius: 18px; overflow: hidden; isolation: isolate; box-shadow: 0 18px 50px #1f20362a; }
#preview { width: 100%; aspect-ratio: 16 / 9; max-height: min(70vh, 820px); object-fit: contain; display: block; background: var(--stage-dark); }
.player-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 20px; color: #a7a3c4; font-size: 1rem; pointer-events: none; }
.player-placeholder strong { font-family: var(--title); font-size: 1.3rem; color: #e4e1f4; font-weight: 600; }
.play-symbol { width: 72px; height: 72px; display: grid; place-items: center; border: 2px solid #4b4566; border-radius: 50%; font-size: 2rem; color: #b8afe6; margin-bottom: 8px; }
.player-shell:has(video[src]) .player-placeholder { display: none; }
/* Subtitles live INSIDE the picture, above the native controls. */
.cue-preview { --subtitle-scale: 1; position: absolute; z-index: 3; left: 3%; right: 3%; bottom: clamp(52px, 12%, 86px); pointer-events: none; text-align: center; color: #fff; overflow-wrap: anywhere; min-width: 0; text-shadow: 0 1px 2px #000, 0 0 6px #000c; }
.cue-preview-src, .cue-preview-tgt { width: fit-content; max-width: 100%; margin: 4px auto; padding: 3px 12px; border-radius: 6px; background: #0d0c14b3; white-space: pre-wrap; line-height: 1.32; }
.cue-preview-src { font-family: var(--ja); font-size: calc(clamp(1.05rem, 2.15vw, 1.9rem) * var(--subtitle-scale)); font-weight: 600; color: #f6f4ff; }
.cue-preview-tgt { font-size: calc(clamp(1.1rem, 2.35vw, 2.05rem) * var(--subtitle-scale)); font-weight: 700; }
.cue-preview-src:empty, .cue-preview-tgt:empty { display: none; }
.cue-preview-time, .cue-preview-reviewhint { display: none !important; }
.subtitle-pairs { display: flex; flex-wrap: wrap; justify-content: center; align-items: start; gap: .2rem .9rem; width: fit-content; max-width: 100%; margin: 0 auto; padding: 6px 12px; border-radius: 8px; background: #0d0c14b8; }
.subtitle-pair { display: grid; grid-template-rows: auto auto; text-align: center; max-width: 100%; min-width: 0; padding: 2px 0; }
.subtitle-pair-src, .subtitle-pair-tgt { max-width: 100%; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.3; }
.subtitle-pair-src { font-family: var(--ja); font-size: calc(clamp(1rem, 2vw, 1.75rem) * var(--subtitle-scale)); min-height: var(--pair-source-height, 0px); padding-bottom: 4px; font-weight: 600; }
.subtitle-pair-tgt { font-size: calc(clamp(1.05rem, 2.2vw, 1.9rem) * var(--subtitle-scale)); font-weight: 700; }
.transport { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.phrase-controls, .language-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.transport .ghost { min-height: 48px; padding: 10px 18px; font-size: .95rem; }
.player-stage:fullscreen, .player-stage:-webkit-full-screen { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 16px 24px; background: #000; color: white; }
.player-stage:fullscreen .player-shell, .player-stage:-webkit-full-screen .player-shell { flex: 1; min-height: 0; width: 100%; border-radius: 0; box-shadow: none; background: #000; }
.player-stage:fullscreen #preview, .player-stage:-webkit-full-screen #preview { height: 100%; max-height: none; aspect-ratio: auto; background: #000; }
.player-stage:fullscreen .cue-preview, .player-stage:-webkit-full-screen .cue-preview { bottom: 80px; }
.player-stage:fullscreen .cue-preview-src, .player-stage:-webkit-full-screen .cue-preview-src { font-size: clamp(1.4rem, 2.9vw, 2.9rem); }
.player-stage:fullscreen .cue-preview-tgt, .player-stage:-webkit-full-screen .cue-preview-tgt { font-size: clamp(1.5rem, 3.1vw, 3.1rem); }
.player-stage:fullscreen .transport, .player-stage:-webkit-full-screen .transport { flex: none; margin-top: 12px; }
.player-stage:fullscreen .ghost, .player-stage:-webkit-full-screen .ghost { background: #24222f; color: #e6e2f5; border-color: #3f3a52; }
.player-stage:fullscreen .ghost[aria-pressed="true"], .player-stage:-webkit-full-screen .ghost[aria-pressed="true"] { background: #3b315c; border-color: #8170b3; color: #f1ecff; }
.shortcuts-hint { margin-top: 14px; }
.result-extras { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 22px; align-items: start; }
.download-card h2 { font-size: 1.2rem; }
.downloads { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.downloads a { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; font-weight: 650; color: var(--action); text-decoration: none; border: 1px solid #d3caef; border-radius: 12px; background: white; padding: 12px 16px; overflow-wrap: anywhere; max-width: 100%; }
.downloads a::before { content: "↓"; font-weight: 800; }
.downloads a:hover { border-color: var(--action); background: var(--soft); }
.downloads .dl-job { font-size: .85rem; color: var(--muted); }
.editor-card > summary { font-family: var(--title); font-size: 1.2rem; font-weight: 700; color: var(--ink); display: flex; align-items: baseline; gap: 8px; }
.editor-card > summary .opt { font-family: var(--body); font-size: .9rem; }
.editor-card > summary::after { content: "+"; margin-left: auto; color: var(--action); font-size: 1.5rem; font-weight: 400; transition: transform .15s; }
.editor-card[open] > summary::after { transform: rotate(45deg); }
.editor-body { padding-top: 20px; }

/* ---------- editor ---------- */
.cue-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-search { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.editor-search .field { flex: 1 1 260px; margin-bottom: 0; }
.editor-search .check { margin: 0; }
.cues { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; max-height: 560px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.cues:empty { min-height: 76px; border: 1px dashed #dedbe9; border-radius: 12px; background: #fbfbfd; }
.cues:empty::before { content: "Tus frases aparecerán aquí cuando los subtítulos estén listos."; color: var(--muted); font-size: .92rem; padding: 22px 18px; text-align: center; align-self: center; }
.cue-row { border: 1px solid var(--divider); border-radius: 14px; background: #fcfcfe; padding: 16px; min-width: 0; }
.cue-row.active { border-color: #a397df; box-shadow: inset 4px 0 0 var(--action); background: #faf8ff; }
.cue-row-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cue-id { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cue-flags { font-size: .85rem; color: var(--warn-ink); }
.cue-times { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cue-times label { flex: 1 1 130px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.cue-times input { min-height: 40px; padding: 7px 10px; font-size: .92rem; margin-top: 4px; }
.cue-texts { display: grid; gap: 10px; }
.cue-texts label { margin: 0; font-size: .82rem; font-weight: 600; color: var(--muted); }
.cue-texts input { margin-top: 5px; background: white; }
.cue-src-input { font-family: var(--ja); }
:lang(zh) { font-family: "Hiragino Sans GB", "PingFang SC", "Noto Sans SC", sans-serif; }
:lang(ko) { font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; }
.cue-tgt-input { font-weight: 550; }
.cue-seek { margin-top: 12px; min-height: 38px; font-size: .88rem; }
.conflict { margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); font-size: .95rem; }
.conflict p { margin: 0 0 10px; }

/* ---------- history ---------- */
.history-wrap { max-width: 1100px; margin: 0 auto; padding: 0 32px 64px; }
.history-intro { padding-inline: 0; }
.jobs { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; }
.jobs .empty { color: var(--muted); font-size: 1rem; padding: 32px 0; text-align: center; }
.job { border: 1px solid var(--divider); border-radius: 16px; background: var(--surface); padding: 20px 22px; min-width: 0; }
.job-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-width: 0; }
.job-name { min-width: 0; background: none; border: 0; color: inherit; font: inherit; font-size: 1.05rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; padding: 0; text-align: left; }
button.job-name:hover { color: var(--action); }
.job-state { font-size: .82rem; font-weight: 650; padding: 5px 12px; border-radius: 50px; background: var(--paper); color: var(--muted); flex: none; }
.job-state[data-s="running"], .job-state[data-s="pending"] { color: var(--warn-ink); background: var(--warn-bg); }
.job-state[data-s="done"] { color: var(--ok-ink); background: var(--ok-bg); }
.job-state[data-s="error"] { color: var(--err-ink); background: var(--err-bg); }
.track { height: 6px; border-radius: 999px; background: #edebf5; overflow: hidden; }
.fill { height: 100%; background: var(--action); border-radius: 999px; transition: width .6s ease; }
.job[data-s="done"] .fill { background: #5ea67b; }
.job[data-s="error"] .fill { background: #d78589; }
.job-msg { font-size: .92rem; color: var(--muted); margin: 10px 0 0; overflow-wrap: anywhere; }
.job-out { margin: 12px 0 0; padding: 0; list-style: none; display: flex; gap: 14px; flex-wrap: wrap; }
.job-out a { font-size: .9rem; font-weight: 600; color: var(--action); overflow-wrap: anywhere; }
.job-retry { margin-top: 14px; }

.page-footer { border-top: 1px solid var(--divider); display: flex; justify-content: center; align-items: center; gap: 12px; padding: 26px; color: var(--muted); font-size: .85rem; }
.page-footer > span { font-family: var(--title); font-weight: 700; color: var(--action); font-size: 1rem; }
.page-footer p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .brand-sub { display: none; }
  .flow-head { flex-direction: column; align-items: flex-start; gap: 20px; }
  .result-extras { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  html { font-size: 16px; }
  .topbar { padding: 14px 20px; gap: 14px; flex-wrap: wrap; }
  .views { order: 3; width: 100%; }
  .view-tab { flex: 1; }
  .flow-head { padding: 22px 20px 20px; }
  .desk, .history-wrap { padding: 0 20px 44px; }
  .offline { margin-inline: 20px; }
  .setup-controls { grid-template-columns: 1fr; }
  .setup-options { border-left: 0; border-top: 1px solid var(--divider); }
  .setup-file, .setup-options { padding: 26px 22px 28px; }
  .upload-zone { min-height: 200px; }
  .journey { width: 100%; border-radius: 16px; }
  .journey li { flex: 1; min-width: 0; padding: 8px; gap: 8px; }
  .journey-label { overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .account-toolbar { gap: 6px; }
  .account-toolbar > span { display: none; }
  .account-toolbar .ghost { min-height: 34px; padding: 5px 10px; font-size: .8rem; white-space: nowrap; }
  h1 { font-size: 1.6rem; }
  .journey li[data-state="current"] { border-radius: 12px; }
  .brand-name { font-size: 1.35rem; }
  .account-toolbar > span { max-width: 120px; }
  .flow-head { padding: 18px 16px 16px; }
  .desk, .history-wrap { padding: 0 16px 36px; }
  .offline { margin-inline: 16px; }
  .card { padding: 20px; border-radius: 16px; }
  .setup-panel { padding: 0; }
  .setup-file, .setup-options { padding: 22px 18px 24px; }
  .journey li { flex-direction: column; text-align: center; gap: 4px; font-size: .78rem; white-space: normal; padding: 8px 4px; }
  .journey-number { width: 28px; height: 28px; }
  .language-row { grid-template-columns: 1fr; }
  .language-arrow { display: none; }
  .processing-head { gap: 14px; }
  .processing-symbol { width: 40px; height: 40px; border-width: 4px; }
  .processing-meta { display: grid; gap: 6px; }
  .processing-actions { flex-direction: column; }
  .processing-actions button, .processing-actions .go { width: 100%; }
  .player-shell { border-radius: 12px; }
  .cue-preview { left: 2%; right: 2%; bottom: 44px; }
  .cue-preview-src, .cue-preview-tgt { padding: 2px 8px; }
  .transport .ghost { flex: 1 1 auto; padding: 10px 12px; }
  .phrase-controls, .language-controls { width: 100%; }
  .result-toolbar .ghost { width: 100%; }
  .job { padding: 16px; }
  .page-footer { gap: 8px; padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
