:root {
  color-scheme: light;
  --canvas: #f7f8fa;
  --surface: #ffffff;
  --surface-muted: #f5f6f8;
  --ink: #191b22;
  --ink-quiet: #626570;
  --ink-faint: #6d707c;
  --border: #e2e3e8;
  --border-strong: #d0d2da;
  --primary: #5558d9;
  --primary-hover: #4548c5;
  --on-primary: #ffffff;
  --primary-wash: #eeeefe;
  --success: #287b5d;
  --danger: #b13e4c;
  --shadow: 0 2px 8px rgba(28, 30, 39, .035), 0 14px 38px rgba(28, 30, 39, .035);
  --overlay: rgba(17, 18, 23, .58);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  scrollbar-color: var(--border-strong) var(--canvas);
  scrollbar-width: thin;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #111216;
  --surface: #191a20;
  --surface-muted: #202127;
  --ink: #f1f2f5;
  --ink-quiet: #a3a6b2;
  --ink-faint: #9699a6;
  --border: #303139;
  --border-strong: #454751;
  --primary: #a5a7ff;
  --primary-hover: #bcbefd;
  --on-primary: #191a2b;
  --primary-wash: #303047;
  --success: #80cfab;
  --danger: #ff9aa5;
  --shadow: 0 2px 8px rgba(0, 0, 0, .12), 0 14px 38px rgba(0, 0, 0, .12);
  --overlay: rgba(0, 0, 0, .72);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --canvas: #111216; --surface: #191a20; --surface-muted: #202127;
    --ink: #f1f2f5; --ink-quiet: #a3a6b2; --ink-faint: #9699a6;
    --border: #303139; --border-strong: #454751; --primary: #a5a7ff;
    --primary-hover: #bcbefd; --on-primary: #191a2b; --primary-wash: #303047;
    --success: #80cfab; --danger: #ff9aa5;
    --shadow: 0 2px 8px rgba(0, 0, 0, .12), 0 14px 38px rgba(0, 0, 0, .12);
    --overlay: rgba(0, 0, 0, .72);
  }
}
* { box-sizing: border-box; }
/* A component's display rule must not override its hidden state. */
[hidden] { display: none !important; }
html { min-width: 320px; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font-sans); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
a { color: var(--primary); text-underline-offset: 3px; }
svg { display: block; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--canvas); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 2px solid var(--canvas); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { background: var(--ink-faint); }
.topbar { height: 68px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { max-width: 1120px; height: 100%; margin: 0 auto; display: flex; align-items: center; padding: 0 4px; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); font-size: 19px; font-weight: 700; letter-spacing: -.055em; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; color: var(--primary); }
.topbar-context { display: flex; gap: 14px; margin-left: 47px; align-items: center; color: var(--ink-faint); font-size: 13px; }
.topbar-context strong { color: var(--ink-quiet); font-weight: 500; }
.context-divider, .footer-divider { color: var(--border-strong); }
.theme-toggle, .icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--ink-quiet); background: var(--surface); }
.theme-toggle { margin-left: auto; }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle:hover, .icon-button:hover { color: var(--ink); background: var(--surface-muted); border-color: var(--border-strong); }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .theme-sun { display: block; } :root:not([data-theme]) .theme-moon { display: none; } }
.shell { max-width: 1120px; margin: 0 auto; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 32px; padding: 69px 0 38px; }
.eyebrow { margin: 0 0 12px; color: var(--ink-faint); font: 600 10px/1.2 var(--font-mono); letter-spacing: .12em; }
.eyebrow span { padding: 0 7px; color: var(--border-strong); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(36px, 4.1vw, 52px); font-weight: 650; letter-spacing: -.057em; line-height: 1.08; }
h1 span { color: var(--ink-quiet); }
.intro-copy { max-width: 260px; margin: 0 0 4px; color: var(--ink-quiet); font-size: 14px; line-height: 1.7; }
.workflow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0 0 19px; padding: 0; border-top: 1px solid var(--border); list-style: none; }
.workflow li { position: relative; display: flex; align-items: center; gap: 10px; padding: 15px 0 0; color: var(--ink-faint); font-size: 12px; font-weight: 600; }
.workflow li[data-current="true"] { color: var(--ink); }
.workflow li[data-current="true"]::before { content: ""; position: absolute; top: -1px; left: 0; width: 48px; height: 2px; background: var(--primary); }
.workflow-number { color: var(--ink-faint); font: 500 10px/1 var(--font-mono); }
.workflow li[data-current="true"] .workflow-number { color: var(--primary); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: 16px; align-items: stretch; }
.panel { min-width: 0; padding: 29px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.section-heading, .result-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.section-heading { margin-bottom: 27px; }
.section-heading .eyebrow, .result-heading .eyebrow { margin-bottom: 9px; }
h2 { margin-bottom: 0; font-size: 19px; font-weight: 650; letter-spacing: -.035em; line-height: 1.25; }
.section-heading p:not(.eyebrow) { margin: 8px 0 0; color: var(--ink-quiet); font-size: 13px; }
.field-label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 12px; font-weight: 650; }
.input-shell, .token-shell { display: flex; align-items: center; width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.input-shell:focus-within, .token-shell:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-wash); }
.input-shell:has([aria-invalid="true"]), .token-shell:has([aria-invalid="true"]) { border-color: var(--danger); }
.input-shell svg { flex: 0 0 18px; width: 18px; height: 18px; margin-left: 14px; color: var(--ink-faint); }
.input-shell input, .token-shell input { min-width: 0; width: 100%; height: 48px; padding: 0 13px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
input::placeholder { color: var(--ink-faint); opacity: 1; }
.field-help, .field-error { margin: 7px 0 0; font-size: 12px; line-height: 1.5; }
.field-help { color: var(--ink-quiet); }
.field-error { color: var(--danger); }
.access-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; margin: 26px 0 20px; padding: 10px 15px; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--ink-quiet); font-size: 12px; }
.access-status[data-state="saved"], .access-status[data-state="open"] { color: var(--ink); font-weight: 650; }
.access-status[data-state="saved"] #session-message::before, .access-status[data-state="open"] #session-message::before { content: "✓"; display: inline-block; margin-right: 9px; color: var(--success); }
.access-status[data-state="error"] { color: var(--danger); }
.access-action { flex: 0 0 auto; padding: 5px 0; border: 0; background: transparent; color: var(--ink-quiet); font-size: 11px; font-weight: 650; }
.access-action:hover:not(:disabled) { color: var(--primary); }
.access-status:not([hidden]) + .access-settings:not([hidden]) { margin-top: -12px; }
.access-settings { margin: 26px 0 20px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.access-settings summary { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 10px; padding: 0 15px; color: var(--ink); cursor: pointer; list-style: none; font-size: 12px; font-weight: 650; }
.access-settings summary::-webkit-details-marker { display: none; }
.access-settings summary > span:first-child { display: flex; align-items: center; gap: 9px; }
.access-settings summary svg { width: 16px; height: 16px; color: var(--ink-quiet); }
.access-settings summary:hover { background: var(--surface-muted); }
.access-required { color: var(--ink-faint); font: 600 9px var(--font-mono); letter-spacing: .05em; white-space: nowrap; }
.access-required span { display: inline-block; margin-left: 6px; font: 15px var(--font-sans); }
.access-settings[open] .access-required span { transform: rotate(180deg); }
.access-body { padding: 1px 15px 15px; }
.token-shell input { height: 42px; }
.token-toggle { align-self: stretch; padding: 0 13px; border: 0; background: transparent; color: var(--ink-quiet); font-size: 12px; font-weight: 650; }
.token-toggle:hover { color: var(--primary); }
.save-access { min-height: 38px; min-width: 112px; margin-top: 13px; font-size: 12px; }
.primary-button, .download-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 47px; padding: 0 17px; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 13px; font-weight: 650; text-decoration: none; transition: background .15s, border-color .15s; }
.primary-button, .download-button { background: var(--primary); color: var(--on-primary); }
.primary-button:hover:not(:disabled), .download-button:hover:not(:disabled) { background: var(--primary-hover); }
.primary-button:active:not(:disabled), .download-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button svg, .download-button svg { width: 17px; height: 17px; }
#preview-button { width: 100%; justify-content: space-between; }
.permission-note { margin: 12px 0 0; color: var(--ink-faint); font-size: 11px; text-align: center; }
.result-panel { display: flex; flex-direction: column; }
.stage-pill { flex: 0 0 auto; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--ink-quiet); font: 600 9px/1 var(--font-mono); letter-spacing: .06em; }
.stage-pill[data-stage="working"] { color: var(--primary); border-color: var(--primary); }
.stage-pill[data-stage="success"] { color: var(--success); border-color: var(--success); }
.stage-pill[data-stage="error"] { color: var(--danger); border-color: var(--danger); }
.job-id { margin: 14px 0 0; color: var(--ink-quiet); font: 11px/1.5 var(--font-mono); overflow-wrap: anywhere; }
.empty-state, .working-state, .error-state { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; min-height: 315px; padding: 26px 5px; text-align: center; }
.empty-art { position: relative; display: grid; place-items: center; width: min(100%, 240px); height: 143px; margin-bottom: 27px; color: var(--ink-faint); }
.empty-art svg { width: 39px; height: 39px; }
.frame-corner { position: absolute; width: 28px; height: 28px; border-color: var(--border-strong); border-style: solid; }
.top-left { top: 0; left: 0; border-width: 1px 0 0 1px; border-radius: 5px 0 0 0; }
.top-right { top: 0; right: 0; border-width: 1px 1px 0 0; border-radius: 0 5px 0 0; }
.bottom-left { bottom: 0; left: 0; border-width: 0 0 1px 1px; border-radius: 0 0 0 5px; }
.bottom-right { right: 0; bottom: 0; border-width: 0 1px 1px 0; border-radius: 0 0 5px 0; }
.empty-state h3, .working-state h3, .error-state h3, .success-heading h3 { margin: 0 0 7px; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.empty-state p, .working-state p, .error-state p { max-width: 330px; margin: 0; color: var(--ink-quiet); font-size: 12px; line-height: 1.65; }
.spinner { width: 29px; height: 29px; margin-bottom: 22px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-area { width: min(100%, 280px); margin-top: 24px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ink-quiet); font-size: 11px; }
progress { display: block; width: 100%; height: 5px; overflow: hidden; border: 0; border-radius: 5px; background: var(--border); }
progress::-webkit-progress-bar { background: var(--border); } progress::-webkit-progress-value { background: var(--primary); } progress::-moz-progress-bar { background: var(--primary); }
.subtle-button, .new-video { padding: 8px 2px; border: 0; background: transparent; color: var(--ink-quiet); font-size: 12px; font-weight: 650; }
.subtle-button:hover, .new-video:hover { color: var(--primary); }
.working-state .subtle-button { margin-top: 19px; }
.success-state { padding-top: 24px; min-width: 0; }
.success-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.success-heading h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.03em; }
.media-viewport { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-md); background: #101116; color: #d4d6df; }
.result-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #101116; }
.audio-presentation { display: flex; height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px 24px; }
.audio-mark, .preview-mark { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #5a5c68; border-radius: 10px; color: #d4d6df; }
.audio-mark svg, .preview-mark svg { width: 27px; height: 27px; }
.audio-caption { color: #d4d6df; font-size: 12px; font-weight: 650; }
.result-audio { display: block; width: min(100%, 320px); height: 40px; }
.preview-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 18px; background: #101116; text-align: center; }
.preview-overlay p { max-width: 300px; margin: 0; color: #d4d6df; font-size: 12px; line-height: 1.5; }
.preview-action { min-height: 34px; padding: 0 12px; border: 1px solid #858895; border-radius: 7px; background: transparent; color: #f1f2f5; font-size: 12px; font-weight: 650; }
.preview-action:hover:not(:disabled) { background: #2a2b34; }
#work-heading, #success-title, #error-title { scroll-margin-block: 24px; }
.file-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 17px 0; }
.file-details { min-width: 0; }
.file-row strong, .file-row span { display: block; }
.file-row strong { overflow-wrap: anywhere; font-size: 13px; line-height: 1.45; }
.file-row span { margin-top: 4px; color: var(--ink-quiet); font-size: 11px; }
.file-row .file-extension { flex: 0 0 auto; padding: 5px 7px; border: 1px solid var(--border); border-radius: 5px; color: var(--ink-quiet); font: 600 10px var(--font-mono); }
.download-button { width: 100%; }
.download-button:hover:not(:disabled) { background: var(--primary-hover); }
.download-status { margin: 10px 0 0; color: var(--ink-quiet); font-size: 12px; line-height: 1.5; }
.download-status[data-tone="error"] { color: var(--danger); }
.new-video { display: flex; align-items: center; gap: 5px; margin: 10px auto 0; }
.new-video svg { width: 14px; height: 14px; }
.error-glyph { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 18px; border: 1px solid var(--danger); border-radius: 8px; color: var(--danger); font-weight: 700; }
.error-state p { overflow-wrap: anywhere; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 20px; }
.secondary-button { min-height: 43px; border-color: var(--border-strong); background: var(--surface); color: var(--ink); }
.secondary-button:hover { background: var(--surface-muted); }
.footer { display: flex; justify-content: space-between; gap: 16px; padding: 27px 0 36px; color: var(--ink-faint); font-size: 11px; }
.footer > span:first-child { font: 600 9px var(--font-mono); letter-spacing: .08em; }
.footer-divider { padding: 0 5px; }
.confirm-dialog { width: min(640px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 26px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.confirm-dialog::backdrop { background: var(--overlay); }
.dialog-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 21px; }
.dialog-top .eyebrow { margin-bottom: 8px; }
.icon-button { flex: 0 0 auto; font-size: 23px; font-weight: 300; line-height: 1; }
.embed-wrap { overflow: hidden; aspect-ratio: 16/9; border-radius: var(--radius-sm); background: #0c0d10; }
.embed-wrap iframe { width: 100%; height: 100%; border: 0; }
.dialog-help { margin: 15px 0 22px; color: var(--ink-quiet); font-size: 12px; line-height: 1.65; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.toast-region { position: fixed; z-index: 10; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(360px, calc(100% - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 12px; }
.toast[data-tone="error"] { border-left: 3px solid var(--danger); }
.toast[data-tone="success"] { border-left: 3px solid var(--success); }
.toast-message { flex: 1; }
.toast-close { padding: 0 2px; border: 0; background: transparent; color: var(--ink-quiet); font-size: 18px; line-height: 1; }
@media (max-width: 1190px) { .topbar-inner, .shell { margin-left: 32px; margin-right: 32px; } }
@media (max-width: 760px) {
  .topbar-inner, .shell { margin-left: 20px; margin-right: 20px; }
  .intro { display: block; padding: 48px 0 31px; }
  .intro-copy { margin: 17px 0 0; max-width: 340px; }
  .workspace { grid-template-columns: 1fr; }
  .panel { padding: 24px; }
  .empty-state, .working-state, .error-state { min-height: 300px; }
  .footer { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .topbar-inner, .shell { margin-left: 16px; margin-right: 16px; }
  .topbar-context { margin-left: 25px; gap: 8px; }
  .topbar-context > span:first-child, .context-divider { display: none; }
  .panel { padding: 20px; }
  .audio-presentation { gap: 6px; padding: 8px 12px; }
  .audio-mark { width: 36px; height: 36px; }
  .workflow li { gap: 7px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}
/* Apply the user's reduced-motion preference across every component. */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media (forced-colors: active) { * { scrollbar-color: auto; } .frame-corner, .stage-pill { border-color: CanvasText; } }
.configuration { margin-top: 29px; padding-top: 25px; border-top: 1px solid var(--border); }
.configuration-heading { display: flex; justify-content: space-between; align-items: end; gap: 10px; margin-bottom: 19px; }
.configuration-heading .eyebrow { margin-bottom: 9px; }
.configuration-heading h2 { font-size: 16px; }
.configuration-note { color: var(--ink-faint); font-size: 11px; }
.fields-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.field { min-width: 0; }
.field select, .bitrate-input { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 12px; }
.field select { cursor: pointer; }
.field select:hover, .bitrate-input:hover { border-color: var(--ink-faint); }
.field select:focus-visible { outline-offset: 2px; }
.bitrate-input { display: flex; align-items: center; padding: 0; }
.bitrate-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-wash); }
.bitrate-input:has([aria-invalid="true"]) { border-color: var(--danger); }
.bitrate-input input { min-width: 0; width: 100%; height: 100%; padding: 0 4px 0 11px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.bitrate-input span { padding-right: 10px; color: var(--ink-quiet); font: 10px var(--font-mono); }
.optional { float: right; color: var(--ink-faint); font-weight: 400; }
.confirm-selection { display: inline-block; margin: 15px 0 0; padding: 6px 9px; border-radius: 6px; background: var(--surface-muted); color: var(--ink-quiet); font: 11px var(--font-mono); }
.confirm-selection + .dialog-help { margin-top: 12px; }
@media (max-width: 480px) { .fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .configuration-note { display: none; } }
