:root {
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-subtle: #f8f9fc;
  --surface-raised: #ffffff;
  --ink: #152033;
  --ink-soft: #43516a;
  --muted: #5f6b80;
  --border: #dfe4ec;
  --border-strong: #cbd3df;
  --nav: #111a2b;
  --nav-raised: #1a263a;
  --nav-text: #dce5f4;
  --nav-muted: #95a3ba;
  --accent: #5b5bd6;
  --accent-hover: #4b4bc4;
  --accent-soft: #eeeeff;
  --accent-faint: #f7f7ff;
  --cyan: #3fc8c8;
  --success: #0f704c;
  --success-soft: #e7f6ef;
  --warning: #9b6508;
  --warning-soft: #fff6dc;
  --danger: #c4384b;
  --danger-soft: #fff0f2;
  --info: #2463aa;
  --info-soft: #edf5ff;
  --shadow-sm: 0 1px 2px rgb(25 36 55 / 5%), 0 4px 12px rgb(25 36 55 / 4%);
  --shadow-md: 0 12px 32px rgb(20 30 48 / 10%), 0 2px 8px rgb(20 30 48 / 5%);
  --shadow-lg: 0 24px 70px rgb(10 19 35 / 22%);
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --control-height: 42px;
  color: var(--ink);
  font-family: var(--font);
  font-synthesis: none;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { color: inherit; font: inherit; }
button, select, summary, input[type="range"] { cursor: pointer; }
button { border: 0; }
a { color: inherit; text-decoration: none; }
img, video, svg { display: block; max-width: 100%; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.75; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, strong { text-wrap: balance; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid rgb(91 91 214 / 32%); outline-offset: 2px; }
::selection { background: #dcdcff; color: #161642; }
.skip-link { position: fixed; z-index: 1000; top: 10px; left: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: #fff; color: var(--ink); box-shadow: var(--shadow-md); transform: translateY(-160%); transition: transform .18s ease; }
.skip-link:focus { transform: translateY(0); }

.brand { display: inline-flex; align-items: center; gap: 10px; width: fit-content; }
.brand-mark { position: relative; display: inline-flex; align-items: flex-end; gap: 2px; width: 25px; height: 25px; transform: rotate(-8deg); }
.brand-mark i { display: block; width: 6px; border-radius: 5px; background: linear-gradient(180deg, #8f8fff, #5b5bd6); box-shadow: 0 0 18px rgb(112 111 255 / 25%); }
.brand-mark i:nth-child(1) { height: 14px; }
.brand-mark i:nth-child(2) { height: 23px; }
.brand-mark i:nth-child(3) { height: 18px; }
.brand-name { font-size: 20px; font-weight: 650; letter-spacing: -.5px; }
.brand-name span { color: #8585ff; }
.brand-on-dark { color: #fff; }
.overline { display: block; margin-bottom: 9px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .13em; line-height: 1.3; }
.overline-light { color: #a9dede; }
.optional { color: var(--muted); font-size: 12px; font-weight: 400; }
.muted { color: var(--muted); }

.button { min-height: var(--control-height); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 600; line-height: 1; transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; white-space: nowrap; }
.button svg { width: 18px; height: 18px; }
.button:not(:disabled):active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .58; }
.button[aria-busy="true"] { position: relative; color: transparent !important; }
.button[aria-busy="true"]::after { content: ""; position: absolute; width: 17px; height: 17px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; color: #fff; animation: spin .7s linear infinite; }
.button.secondary[aria-busy="true"]::after, .button.ghost[aria-busy="true"]::after { color: var(--accent); }
.icon-button[aria-busy="true"] svg { opacity: 0; }
.icon-button[aria-busy="true"]::after { content: ""; width: 16px; height: 16px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.button.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgb(91 91 214 / 18%); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 6px 18px rgb(91 91 214 / 24%); }
.button.secondary { border-color: var(--border-strong); background: var(--surface); color: var(--ink); }
.button.secondary:hover:not(:disabled) { border-color: #aeb8c8; background: var(--surface-subtle); }
.button.ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.button.ghost:hover { background: #eef1f6; color: var(--ink); }
.button.danger, .danger-button { border-color: #ebbdc5; background: #fff; color: var(--danger); }
.button.danger:hover, .danger-button:hover { background: var(--danger-soft); border-color: #df8d9a; }
.button-full { width: 100%; }
.button-large { min-height: 48px; padding-inline: 20px; border-radius: 9px; }
.text-button { padding: 2px 0; background: transparent; color: var(--accent); font-weight: 600; }
.text-button:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
.icon-button { width: 42px; height: 42px; display: inline-grid; flex: 0 0 auto; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-soft); transition: .16s ease; }
.icon-button:hover { border-color: var(--border-strong); background: var(--surface-subtle); color: var(--ink); }
.icon-button svg { width: 20px; height: 20px; }

input, select, textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
input, select { min-height: var(--control-height); padding: 0 12px; }
textarea { padding: 12px 14px; line-height: 1.55; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #aab4c5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px rgb(91 91 214 / 13%); }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; border-color: var(--border); background: #f1f3f6; color: #8c95a5; }
input::placeholder, textarea::placeholder { color: #98a1b1; }
label { display: block; color: var(--ink-soft); font-size: 13px; font-weight: 600; }
label > input, label > select, label > textarea { margin-top: 7px; }
label small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; font-weight: 400; }
select { padding-right: 34px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #667085 50%), linear-gradient(135deg, #667085 50%, transparent 50%); background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-repeat: no-repeat; background-size: 5px 5px; }
input[type="range"] { min-height: auto; padding: 0; border: 0; accent-color: var(--accent); box-shadow: none; }
kbd { min-width: 20px; display: inline-block; padding: 2px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: #fff; color: var(--ink-soft); font: 11px/1.2 var(--font); text-align: center; }

.form-stack { display: grid; gap: 10px; }
.form-stack.compact { margin-top: 18px; }
.form-stack.compact p { margin-bottom: 2px; color: var(--muted); font-size: 13px; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; z-index: 1; left: 12px; top: 12px; width: 18px; height: 18px; color: #778399; pointer-events: none; }
.input-wrap input { padding-left: 40px; }
.input-wrap .reveal-password { position: absolute; top: 1px; right: 1px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 6px; background: transparent; color: #778399; }
.input-wrap .reveal-password:hover { background: #f1f3f7; color: var(--ink); }
.input-wrap .reveal-password svg { width: 18px; }

/* Sign in */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(430px, 1.05fr) minmax(420px, .95fr); background: #fff; }
.auth-brand { position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; padding: clamp(32px, 5vw, 72px); background: radial-gradient(circle at 85% 18%, rgb(87 189 191 / 18%), transparent 30%), radial-gradient(circle at 0 88%, rgb(100 92 222 / 24%), transparent 38%), linear-gradient(145deg, #111b2d 0%, #17253a 52%, #101929 100%); color: #fff; }
.auth-brand::before { content: ""; position: absolute; right: -15%; bottom: -35%; width: 80%; aspect-ratio: 1; border: 1px solid rgb(255 255 255 / 7%); border-radius: 50%; box-shadow: 0 0 0 80px rgb(255 255 255 / 2%), 0 0 0 160px rgb(255 255 255 / 2%); }
.auth-brand::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .12; background-image: linear-gradient(rgb(255 255 255 / 7%) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 7%) 1px, transparent 1px); background-size: 64px 64px; mask-image: linear-gradient(to bottom, #000, transparent 75%); }
.auth-brand > * { position: relative; z-index: 1; }
.auth-hero { max-width: 650px; margin: auto 0 52px; }
.auth-hero h1 { margin-bottom: 24px; font-size: clamp(42px, 5vw, 72px); font-weight: 550; letter-spacing: -.055em; line-height: .99; }
.auth-hero h1 span { color: #92dfdc; }
.auth-hero p { max-width: 580px; margin-bottom: 0; color: #bac6d9; font-size: clamp(16px, 1.5vw, 19px); line-height: 1.65; }
.auth-proof { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.auth-proof article { display: flex; gap: 12px; padding: 16px; border: 1px solid rgb(255 255 255 / 9%); border-radius: var(--radius-md); background: rgb(255 255 255 / 4%); backdrop-filter: blur(12px); }
.auth-proof svg { width: 21px; height: 21px; flex: 0 0 auto; color: #91d9d7; }
.auth-proof strong, .auth-proof span { display: block; }
.auth-proof strong { margin-bottom: 4px; font-size: 13px; }
.auth-proof span { color: #9eabc0; font-size: 11px; line-height: 1.45; }
.auth-footnote { margin-top: 22px; color: #77869e; }
.auth-form-side { display: grid; place-items: center; padding: 40px; background: linear-gradient(180deg, #fff, #fafbfc); }
.auth-card { width: min(100%, 410px); }
.auth-card-heading { margin-bottom: 28px; }
.auth-card-heading h2 { margin-bottom: 8px; font-size: 30px; font-weight: 650; letter-spacing: -.035em; }
.auth-card-heading p { color: var(--muted); }
.auth-card .form-stack { gap: 9px; }
.auth-card .button.primary { margin-top: 12px; }
.mobile-brand { display: none; }
.access-details { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.access-details summary { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--accent); font-weight: 600; list-style: none; }
.access-details summary::-webkit-details-marker { display: none; }
.access-details summary svg { width: 16px; transition: transform .16s ease; }
.access-details[open] summary svg { transform: rotate(180deg); }
.security-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 24px 0 0; color: var(--muted); font-size: 11px; }
.security-note svg { width: 15px; }

/* Application chrome */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr); }
.app-sidebar { position: sticky; z-index: 20; top: 0; grid-row: 1 / 3; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 18px; overflow-y: auto; background: linear-gradient(180deg, #111a2b, #121d30); color: var(--nav-text); }
.app-sidebar .brand { margin: 0 10px 38px; }
.app-navigation { display: grid; gap: 4px; }
.nav-label { padding: 0 12px 9px; color: #73829a; font-size: 10px; font-weight: 700; letter-spacing: .13em; }
.nav-item { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: var(--radius-sm); background: transparent; color: var(--nav-muted); font-weight: 550; text-align: left; transition: .15s ease; }
.nav-link { text-decoration: none; }
.nav-item svg { width: 20px; height: 20px; flex: 0 0 auto; }
.nav-item:hover { background: rgb(255 255 255 / 5%); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgb(110 107 237 / 23%), rgb(110 107 237 / 10%)); color: #fff; box-shadow: inset 3px 0 #8987ff; }
.nav-item b { min-width: 20px; height: 20px; display: grid; place-items: center; margin-left: auto; padding: 0 6px; border-radius: 10px; background: #706eea; color: #fff; font-size: 10px; }
.sidebar-spacer { flex: 1; min-height: 30px; }
.privacy-card { display: flex; gap: 10px; padding: 13px; border: 1px solid rgb(255 255 255 / 7%); border-radius: var(--radius-md); background: rgb(255 255 255 / 4%); }
.privacy-card svg { width: 19px; height: 19px; flex: 0 0 auto; color: #63d1ca; }
.privacy-card strong, .privacy-card span { display: block; }
.privacy-card strong { margin-bottom: 3px; color: #eaf1fa; font-size: 12px; }
.privacy-card span { color: #8493a9; font-size: 10px; line-height: 1.4; }
.sidebar-profile { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 14px 8px 0; border-top: 1px solid rgb(255 255 255 / 8%); min-width: 0; }
.avatar { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 9px; background: linear-gradient(135deg, #7270e8, #4847b8); color: #fff; font-weight: 700; }
.sidebar-profile div { min-width: 0; }
.sidebar-profile strong, .sidebar-profile span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile strong { color: #e7edf7; font-size: 11px; }
.sidebar-profile span { margin-top: 2px; color: #77869d; font-size: 10px; }
.app-header { position: sticky; z-index: 15; top: 0; grid-column: 2; display: flex; align-items: center; gap: 16px; padding: 0 26px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 91%); backdrop-filter: blur(18px); }
.header-context { display: flex; flex-direction: column; min-width: 0; }
.header-context strong { font-size: 14px; }
.header-context span { color: var(--muted); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }
.provider-status { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; font-weight: 600; }
.provider-status i { width: 7px; height: 7px; border-radius: 50%; background: #9aa4b4; }
.provider-status.ready { border-color: #bee3d3; background: var(--success-soft); color: var(--success); }
.provider-status.ready i { background: var(--success); box-shadow: 0 0 0 3px rgb(22 131 92 / 12%); }
.provider-status.limited { border-color: #ecd498; background: var(--warning-soft); color: var(--warning); }
.provider-status.limited i { background: #d29318; }
.provider-status.offline { border-color: #f0c4cb; background: var(--danger-soft); color: var(--danger); }
.provider-status.offline i { background: var(--danger); }
.credit-chip { height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid #dcdcf5; border-radius: 18px; background: var(--accent-faint); color: var(--accent); }
.credit-chip svg { width: 16px; }
.credit-chip strong { font-size: 14px; }
.credit-chip span { color: #676e81; font-size: 11px; }
.header-button { min-height: 36px; padding-inline: 12px; font-size: 12px; }
.mobile-menu { display: none; }
.workspace { grid-column: 2; min-width: 0; padding: 38px clamp(24px, 4vw, 58px) 72px; }
.view { max-width: 1380px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.page-heading h1 { margin-bottom: 8px; font-size: clamp(28px, 3vw, 38px); font-weight: 650; letter-spacing: -.045em; line-height: 1.15; }
.page-heading p { max-width: 700px; margin-bottom: 0; color: var(--muted); font-size: 15px; }

/* Notices and tabs */
.notice { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid; border-radius: var(--radius-md); }
.notice > svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.notice strong { display: block; margin-bottom: 3px; }
.notice p { margin: 0; color: inherit; font-size: 12px; opacity: .84; }
.notice.warning { margin-bottom: 20px; border-color: #ecd498; background: var(--warning-soft); color: var(--warning); }
.notice.info { margin-top: 20px; border-color: #c9def7; background: var(--info-soft); color: var(--info); }
.mode-switch { width: fit-content; display: flex; gap: 4px; margin-bottom: 20px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-md); background: #e9edf3; }
.mode-tab { min-width: 230px; min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); text-align: left; transition: .15s ease; }
.mode-tab svg { width: 21px; height: 21px; }
.mode-tab strong, .mode-tab small { display: block; }
.mode-tab strong { color: inherit; font-size: 13px; }
.mode-tab small { margin-top: 1px; color: inherit; font-size: 10px; opacity: .8; }
.mode-tab:hover { color: var(--ink); }
.mode-tab.active { border-color: var(--border); background: #fff; color: var(--accent); box-shadow: var(--shadow-sm); }

/* Creator */
.generator-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 20px; }
.creator-card { overflow: clip; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.form-section { padding: 28px 30px; border-bottom: 1px solid var(--border); }
.form-section-main { padding-top: 30px; }
.section-heading { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 23px; }
.step-number { width: 26px; height: 26px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.section-heading h2 { margin-bottom: 4px; font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.field-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.field-header label { color: var(--ink-soft); }
.field-header small { color: var(--muted); font-size: 11px; }
.prompt-area { min-height: 150px; border-radius: var(--radius-md); background: #fcfcfe; font-size: 14px; }
.prompt-area:focus { background: #fff; }
.prompt-tools { min-height: 29px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 2px 12px; color: var(--muted); font-size: 10px; }
.prompt-tools .text-button { font-size: 11px; }
.preset-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.preset-grid-four { grid-template-columns: repeat(4, 1fr); }
.preset { position: relative; overflow: hidden; min-height: 92px; display: flex; flex-direction: column; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: #fff; color: var(--ink-soft); text-align: left; transition: .15s ease; }
.preset::after { content: ""; position: absolute; top: 8px; right: 8px; width: 14px; height: 14px; border: 1px solid var(--border-strong); border-radius: 50%; background: #fff; }
.preset:hover { border-color: #b8b8e8; transform: translateY(-1px); }
.preset.selected { border-color: var(--accent); background: var(--accent-faint); box-shadow: inset 0 0 0 1px var(--accent); }
.preset.selected::after { border: 4px solid var(--accent); }
.preset-swatch { width: 34px; height: 22px; margin-bottom: 9px; border-radius: 5px; }
.preset-swatch.cinematic { background: linear-gradient(135deg, #182949, #d6805c); }
.preset-swatch.photo { background: linear-gradient(135deg, #b2c7d8, #ebe0cf); }
.preset-swatch.editorial { background: linear-gradient(135deg, #e5d7c6 0 48%, #26364d 49%); }
.preset-swatch.illustration { background: linear-gradient(135deg, #7857c3, #5ccaca); }
.preset-swatch.render { background: radial-gradient(circle at 35% 32%, #fff, #9aa7ca 28%, #4e567b 60%, #1e2238); }
.preset strong { margin-bottom: 2px; color: var(--ink); font-size: 11px; }
.preset small { color: var(--muted); font-size: 9px; }
.control-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.video-controls { margin-top: 22px; }
.advanced { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-subtle); }
.advanced summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; color: var(--ink-soft); font-weight: 600; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary span { display: flex; align-items: center; gap: 8px; }
.advanced summary svg { width: 18px; }
.advanced summary .chevron { transition: transform .16s ease; }
.advanced[open] summary .chevron { transform: rotate(180deg); }
.advanced-grid { padding: 4px 14px 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.advanced output { float: right; color: var(--accent); }
.disabled-control { opacity: .62; }
.upload-zone { position: relative; min-height: 76px; display: flex; align-items: center; gap: 14px; margin-top: 18px; padding: 12px 13px; border: 1px dashed #bcc6d4; border-radius: var(--radius-md); background: #fafbfc; }
.upload-zone:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(91 91 214 / 10%); }
.upload-copy { min-width: 0; display: flex; align-items: center; gap: 11px; flex: 1; }
.upload-copy > svg { width: 25px; height: 25px; flex: 0 0 auto; color: var(--accent); }
.upload-copy strong, .upload-copy span { display: block; }
.upload-copy strong { font-size: 12px; }
.upload-copy span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.upload-button { min-height: 36px; font-size: 11px; }
.upload-button input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.reference-preview { width: 50px; height: 50px; flex: 0 0 auto; overflow: hidden; border-radius: 7px; background: #e8ebf0; }
.reference-preview img { width: 100%; height: 100%; object-fit: cover; }
.remove-reference { width: 36px; height: 36px; }
.reference-state { min-height: 18px; margin: 7px 2px 0; color: var(--muted); font-size: 11px; }
.reference-state.success { color: var(--success); }
.reference-state.error { color: var(--danger); }
.duration-control { display: block; }
.duration-control > span:first-child { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.duration-control output { color: var(--accent); font-size: 13px; }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.segment-plan { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-faint); color: var(--accent); font-size: 11px; font-weight: 600; }
.submit-bar { position: sticky; z-index: 3; bottom: 0; min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 30px; background: rgb(255 255 255 / 95%); box-shadow: 0 -8px 24px rgb(25 36 55 / 5%); backdrop-filter: blur(12px); }
.submit-bar > div span, .submit-bar > div strong, .submit-bar > div small { display: block; }
.submit-bar > div span { color: var(--muted); font-size: 10px; }
.submit-bar > div strong { margin: 1px 0; font-size: 17px; }
.submit-bar > div small { color: var(--muted); font-size: 10px; }
.context-rail { position: sticky; top: 84px; display: grid; gap: 14px; }
.rail-card { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.rail-card h3 { margin-bottom: 16px; font-size: 17px; letter-spacing: -.02em; }
.prompt-guide ol { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }
.prompt-guide li { display: flex; gap: 10px; }
.prompt-guide li > span { color: var(--accent); font-size: 10px; font-weight: 700; }
.prompt-guide strong, .prompt-guide small { display: block; }
.prompt-guide strong { margin-bottom: 2px; font-size: 12px; }
.prompt-guide small { color: var(--muted); font-size: 10px; }
.rail-icon { width: 32px; height: 32px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.rail-icon svg { width: 18px; }
.example-card p { color: var(--ink-soft); font-size: 12px; font-style: italic; line-height: 1.65; }
.example-card .text-button { font-size: 11px; }
.sequence-card > p { color: var(--muted); font-size: 12px; line-height: 1.65; }
.sequence-card ul { display: grid; gap: 8px; margin: 16px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: 11px; }
.sequence-visual { display: flex; align-items: center; margin: 20px 0; }
.sequence-visual span { width: 31px; height: 31px; display: grid; flex: 0 0 auto; place-items: center; border: 1px solid #c7c7f2; border-radius: 8px; background: var(--accent-faint); color: var(--accent); font-size: 9px; font-weight: 700; }
.sequence-visual i { height: 1px; flex: 1; background: #c7cfdb; }

/* Library */
.library-heading { align-items: center; }
.library-heading .button svg { width: 17px; }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.search-box { position: relative; width: min(360px, 100%); }
.search-box svg { position: absolute; z-index: 1; top: 11px; left: 12px; width: 18px; color: var(--muted); }
.search-box input { padding-left: 39px; border-color: transparent; background: var(--surface-subtle); }
.filter-pills { display: flex; gap: 3px; overflow-x: auto; }
.filter-pills button { min-height: 34px; padding: 0 12px; border-radius: 17px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.filter-pills button:hover { background: #f0f2f6; color: var(--ink); }
.filter-pills button.active { background: var(--accent-soft); color: var(--accent); }
.library-summary { min-height: 20px; margin-bottom: 24px; color: var(--muted); font-size: 11px; }
.library-section { margin-top: 30px; }
.library-section > .section-title { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 13px; }
.library-section > .section-title h2 { margin-bottom: 2px; font-size: 18px; }
.library-section > .section-title p { margin: 0; color: var(--muted); font-size: 11px; }
.library-section > .section-title > span { color: var(--muted); font-size: 11px; }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.media-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); transition: box-shadow .18s ease, transform .18s ease; }
.media-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.media-preview { position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; background: linear-gradient(135deg, #eceef5, #f7f8fb); }
.media-card.ratio-1-1 .media-preview { aspect-ratio: 1 / 1; }
.media-card.ratio-3-2 .media-preview { aspect-ratio: 3 / 2; }
.media-card.ratio-2-3 .media-preview { aspect-ratio: 2 / 3; }
.media-card.ratio-4-3 .media-preview { aspect-ratio: 4 / 3; }
.media-card.ratio-3-4 .media-preview { aspect-ratio: 3 / 4; }
.media-card.ratio-4-5 .media-preview { aspect-ratio: 4 / 5; }
.media-card.ratio-5-4 .media-preview { aspect-ratio: 5 / 4; }
.media-card.ratio-16-9 .media-preview { aspect-ratio: 16 / 9; }
.media-card.ratio-9-16 .media-preview { aspect-ratio: 9 / 16; }
.media-card.ratio-21-9 .media-preview { aspect-ratio: 21 / 9; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.media-card:hover .media-preview img { transform: scale(1.015); }
.media-preview-overlay { position: absolute; inset: auto 10px 10px auto; display: flex; gap: 6px; opacity: 0; transform: translateY(4px); transition: .16s ease; }
.media-card:hover .media-preview-overlay, .media-card:focus-within .media-preview-overlay { opacity: 1; transform: none; }
@media (hover: none) { .media-preview-overlay { opacity: 1; transform: none; } }
.preview-action { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; background: rgb(15 24 39 / 82%); color: #fff; backdrop-filter: blur(8px); }
.preview-action:hover { background: #0f1827; }
.preview-action svg { width: 17px; }
.job-visual { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.job-visual svg { width: 31px; height: 31px; }
.job-visual.active svg { color: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
.job-visual.failed { background: var(--danger-soft); color: var(--danger); }
.job-visual.manual_review { background: var(--warning-soft); color: var(--warning); }
.media-body { padding: 14px 15px 15px; }
.media-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.status { width: fit-content; display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 8px; border-radius: 11px; background: #eef1f5; color: #596579; font-size: 9px; font-weight: 700; letter-spacing: .025em; text-transform: uppercase; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.succeeded, .status.active { background: var(--success-soft); color: var(--success); }
.status.failed { background: var(--danger-soft); color: var(--danger); }
.status.queued, .status.submitted, .status.processing, .status.submitting { background: var(--accent-soft); color: var(--accent); }
.status.manual_review { background: var(--warning-soft); color: var(--warning); }
.status.canceled, .status.disabled, .status.rejected { background: #eef1f5; color: #657084; }
.media-topline time { color: var(--muted); font-size: 9px; }
.media-body h3 { display: -webkit-box; margin-bottom: 7px; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.media-body > p { min-height: 34px; display: -webkit-box; margin-bottom: 11px; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.media-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 9px; }
.media-actions { display: flex; align-items: center; gap: 6px; margin-top: 11px; }
.media-actions .button { min-height: 34px; padding-inline: 10px; font-size: 10px; }
.video-list { display: grid; gap: 12px; }
.video-card { display: grid; grid-template-columns: minmax(220px, 30%) minmax(0, 1fr); overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.video-preview { min-height: 190px; display: grid; place-items: center; overflow: hidden; background: #151c2a; }
.video-preview video { width: 100%; height: 100%; object-fit: cover; }
.video-content { min-width: 0; padding: 18px 20px; }
.video-content h3 { margin: 9px 0 6px; font-size: 16px; }
.video-content > p { display: -webkit-box; margin-bottom: 14px; overflow: hidden; color: var(--muted); font-size: 11px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.video-meta-line { display: flex; gap: 14px; color: var(--muted); font-size: 10px; }
.segment-progress { display: flex; gap: 6px; margin: 16px 0 12px; }
.segment-progress span { flex: 1; min-width: 0; height: 6px; border-radius: 4px; background: #e4e8ee; color: transparent; font-size: 0; }
.segment-progress span.succeeded { background: var(--success); }
.segment-progress span.processing, .segment-progress span.submitted, .segment-progress span.submitting { background: var(--accent); animation: pulse 1.8s infinite; }
.segment-progress span.failed { background: var(--danger); }
.segment-progress span.manual_review { background: #d29318; }
.segment-links { display: flex; flex-wrap: wrap; gap: 7px; }
.segment-links a { color: var(--accent); font-size: 10px; font-weight: 600; }
.empty-state { grid-column: 1 / -1; display: grid; place-items: center; min-height: 220px; padding: 28px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: rgb(255 255 255 / 60%); text-align: center; }
.empty-state svg { width: 34px; margin-bottom: 12px; color: #8995a8; }
.empty-state h3 { margin-bottom: 5px; font-size: 15px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 11px; }
.skeleton-card, .skeleton-row { min-height: 300px; border-radius: var(--radius-lg); background: linear-gradient(100deg, #e9edf2 20%, #f5f7f9 45%, #e9edf2 70%); background-size: 220% 100%; animation: shimmer 1.5s infinite linear; }
.skeleton-row { min-height: 190px; }

/* Account */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.profile-settings { display: flex; align-items: center; gap: 18px; }
.large-avatar { width: 64px; height: 64px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 18px; background: linear-gradient(135deg, #7270e8, #4241ae); color: #fff; font-size: 24px; font-weight: 700; box-shadow: 0 8px 20px rgb(91 91 214 / 22%); }
.profile-settings h2 { margin-bottom: 3px; font-size: 18px; }
.profile-settings p, .meta-line { margin: 0; color: var(--muted); font-size: 11px; }
.meta-line { display: block; margin-top: 5px; }
.balance-settings { display: flex; align-items: center; gap: 17px; }
.settings-icon { width: 42px; height: 42px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 12px; background: #eff2f7; color: var(--ink-soft); }
.settings-icon.accent { background: var(--accent-soft); color: var(--accent); }
.settings-icon svg { width: 22px; }
.balance-settings strong { display: block; font-size: 21px; }
.balance-settings p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.security-settings { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.settings-card-heading { display: flex; align-items: center; gap: 14px; }
.settings-card-heading h2 { margin-bottom: 3px; font-size: 16px; }
.settings-card-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.privacy-settings { grid-column: 1 / -1; }
.privacy-settings h2 { margin-bottom: 20px; font-size: 19px; }
.privacy-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.privacy-list article { display: flex; gap: 11px; }
.privacy-list svg { width: 20px; flex: 0 0 auto; color: var(--accent); }
.privacy-list strong { display: block; margin-bottom: 4px; font-size: 12px; }
.privacy-list p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

/* Toasts and dialogs */
.toast { position: fixed; z-index: 200; top: 18px; left: 50%; width: min(520px, calc(100% - 28px)); padding: 13px 16px 13px 44px; border: 1px solid #b8dfcd; border-radius: var(--radius-md); background: #f1faf6; color: #116244; box-shadow: var(--shadow-md); font-size: 12px; font-weight: 600; transform: translateX(-50%); animation: toast-in .2s ease both; }
.toast::before { content: "✓"; position: absolute; left: 16px; top: 12px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--success); color: #fff; font-size: 11px; }
.toast.error { border-color: #efbbc4; background: #fff3f5; color: #9f2437; }
.toast.error::before { content: "!"; background: var(--danger); }
.modal { width: min(500px, calc(100% - 28px)); max-height: calc(100vh - 32px); padding: 0; overflow: visible; border: 0; border-radius: var(--radius-xl); background: transparent; color: var(--ink); }
.modal::backdrop { background: rgb(10 17 30 / 58%); backdrop-filter: blur(5px); }
.modal[open] { animation: modal-in .18s ease both; }
.modal-card { position: relative; max-height: calc(100vh - 32px); padding: 28px; overflow-y: auto; border: 1px solid rgb(255 255 255 / 50%); border-radius: var(--radius-xl); background: #fff; box-shadow: var(--shadow-lg); }
.modal-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.modal-icon svg { width: 23px; }
.modal-heading h2 { margin-bottom: 7px; font-size: 22px; letter-spacing: -.025em; }
.modal-heading p { margin-bottom: 18px; color: var(--muted); font-size: 12px; }
.confirm-details { display: grid; gap: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-subtle); }
.confirm-details div { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 13px; border-bottom: 1px solid var(--border); }
.confirm-details div:last-child { border: 0; }
.confirm-details span { color: var(--muted); font-size: 11px; }
.confirm-details strong { text-align: right; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.dialog-close { position: absolute; top: 17px; right: 17px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: transparent; color: var(--muted); }
.dialog-close:hover { background: #f0f2f6; color: var(--ink); }
.dialog-close svg { width: 18px; }
.password-requirements { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
.password-requirements span { padding: 4px 7px; border-radius: 5px; background: #f1f3f6; color: var(--muted); font-size: 9px; }
.password-requirements span.met { background: var(--success-soft); color: var(--success); }
.form-error { margin: 2px 0 0; padding: 9px 11px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 11px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .46; } }
@keyframes shimmer { to { background-position-x: -120%; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }

@media (max-width: 1180px) {
  .auth-proof { grid-template-columns: 1fr; max-width: 430px; }
  .auth-proof article { padding: 11px 13px; }
  .generator-layout { grid-template-columns: minmax(0, 1fr) 260px; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
  .control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form-side { min-height: 100vh; padding: 28px; background: radial-gradient(circle at 90% 0, #ededff, transparent 35%), #fff; }
  .mobile-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 56px; color: var(--ink); font-size: 18px; font-weight: 650; }
  .mobile-brand .brand-mark { transform: scale(.88) rotate(-8deg); }
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 60px minmax(0, 1fr); }
  .app-sidebar { position: fixed; z-index: 50; left: 0; width: 260px; transform: translateX(-105%); box-shadow: var(--shadow-lg); transition: transform .2s ease; }
  .app-shell.menu-open .app-sidebar { transform: translateX(0); }
  .app-shell.menu-open::after { content: ""; position: fixed; z-index: 45; inset: 0; background: rgb(8 14 25 / 45%); }
  .app-header, .workspace { grid-column: 1; }
  .mobile-menu { display: inline-grid; }
  .workspace { padding: 28px 22px 60px; }
  .generator-layout { grid-template-columns: 1fr; }
  .context-rail { position: static; grid-template-columns: 1fr 1fr; }
  #videoMode .context-rail { grid-template-columns: 1fr; }
  .video-card { grid-template-columns: 240px minmax(0, 1fr); }
}

@media (max-width: 700px) {
  .app-header { padding: 0 14px; }
  .header-context { display: none; }
  .provider-status { min-width: 32px; justify-content: center; padding-inline: 9px; font-size: 10px; }
  .credit-chip span { display: none; }
  .header-button { display: none; }
  .workspace { padding: 24px 14px 50px; }
  .page-heading { align-items: flex-start; margin-bottom: 22px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading p { font-size: 13px; }
  .mode-switch { width: 100%; }
  .mode-tab { min-width: 0; flex: 1; }
  .mode-tab small { display: none; }
  .form-section { padding: 23px 18px; }
  .prompt-area { min-height: 135px; }
  .preset-grid, .preset-grid-four { grid-template-columns: repeat(2, 1fr); }
  .control-grid, .advanced-grid { grid-template-columns: 1fr; }
  .upload-zone { flex-wrap: wrap; }
  .upload-copy { min-width: calc(100% - 52px); }
  .upload-button { flex: 1; }
  .submit-bar { padding: 14px 18px; }
  .submit-bar .button { min-width: 0; }
  .context-rail { grid-template-columns: 1fr; }
  .library-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .filter-pills { padding-bottom: 2px; }
  .media-grid { grid-template-columns: 1fr; }
  .video-card { grid-template-columns: 1fr; }
  .video-preview { min-height: 210px; }
  .account-grid { grid-template-columns: 1fr; }
  .security-settings, .privacy-settings { grid-column: 1; }
  .security-settings { align-items: stretch; flex-direction: column; }
  .privacy-list { grid-template-columns: 1fr; }
  .modal-card { padding: 24px 20px; }
}

@media (max-width: 430px) {
  .auth-form-side { padding: 22px; }
  .mobile-brand { margin-bottom: 42px; }
  .auth-card-heading h2 { font-size: 27px; }
  .mode-tab { padding-inline: 10px; }
  .mode-tab svg { display: none; }
  .prompt-tools span { display: none; }
  .preset { min-height: 86px; }
  .submit-bar { align-items: stretch; flex-direction: column; }
  .submit-bar .button { width: 100%; }
  .page-heading.library-heading { align-items: stretch; flex-direction: column; }
  .library-heading .button { width: fit-content; }
  .credit-chip { padding-inline: 9px; }
  .credit-chip svg { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@supports (padding: max(0px)) {
  .app-header { padding-top: env(safe-area-inset-top); }
  .toast { top: max(18px, env(safe-area-inset-top)); }
  .submit-bar { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
}

@media (forced-colors: active) {
  .status, .provider-status, .preset.selected, .nav-item.active { border: 1px solid currentColor; }
}
