@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap");

:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-elevated: #0b0e14;
  --panel: rgba(16, 20, 28, .88);
  --panel-solid: #111620;
  --panel-soft: #151b25;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .15);
  --text: #f5f7fa;
  --muted: #8994a5;
  --muted-strong: #b3bdca;
  --accent: #b6f36b;
  --accent-bright: #d2ff8a;
  --accent-ink: #10170a;
  --blue: #74b8ff;
  --amber: #f7c66a;
  --danger: #ff8f98;
  --danger-bg: rgba(255, 93, 108, .1);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255,255,255,.025);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    radial-gradient(900px 520px at 7% -8%, rgba(129, 190, 82, .12), transparent 64%),
    radial-gradient(760px 460px at 96% 3%, rgba(65, 132, 213, .09), transparent 63%),
    linear-gradient(180deg, #090c11 0%, var(--bg) 40%, #080a0e 100%);
  color: var(--text);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .22;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 65%);
}

.shell, .grid, .card, .job, .job-actions, .topbar { min-width: 0; max-width: 100%; }
button, input, textarea, select { max-width: 100%; font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.shell { width: min(1380px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 88px; }
.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, rgba(20, 25, 34, .95), rgba(12, 16, 23, .96));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.14), transparent);
  pointer-events: none;
}

.auth-card { width: min(460px, 100%); margin: 12vh auto 0; padding: 42px; }
.auth-card::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  top: -85px;
  right: -45px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(60px);
  opacity: .13;
}

.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .19em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Manrope", sans-serif; }
h1 { margin-bottom: 9px; font-size: clamp(35px, 5vw, 58px); letter-spacing: -.055em; line-height: .96; }
h2 { margin: 5px 0 0; font-size: 21px; letter-spacing: -.035em; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12px; line-height: 1.55; margin: 11px 0 0; }

form { display: grid; gap: 12px; }
label { color: var(--muted-strong); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.optional { color: var(--muted); font-weight: 400; }
input, textarea, select {
  width: 100%;
  min-height: 46px;
  color: var(--text);
  background: rgba(5, 8, 12, .68);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input::placeholder, textarea::placeholder { color: #697385; }
textarea { min-height: 212px; resize: vertical; line-height: 1.58; }
input:hover, textarea:hover, select:hover { border-color: rgba(255,255,255,.22); background-color: rgba(7, 10, 15, .82); }
input:focus, textarea:focus, select:focus { border-color: rgba(182, 243, 107, .72); box-shadow: 0 0 0 4px rgba(182, 243, 107, .1); background-color: #080c11; }

button, .button-secondary, .download {
  border-radius: 12px;
  transition: transform .15s ease, opacity .15s ease, border-color .15s ease, background .15s ease;
}
button {
  min-height: 46px;
  border: 1px solid rgba(210, 255, 138, .22);
  padding: 11px 17px;
  background: linear-gradient(135deg, var(--accent-bright), #a3e657);
  box-shadow: 0 8px 24px rgba(151, 220, 75, .13), inset 0 1px 0 rgba(255,255,255,.35);
  color: var(--accent-ink);
  font-weight: 800;
}
button:hover, .download:hover { transform: translateY(-1px); }
button:active { transform: translateY(0) scale(.985); }
button:disabled { cursor: wait; opacity: .55; transform: none; }
.button-secondary {
  color: var(--text);
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}
.button-secondary:hover { background: rgba(255,255,255,.085); border-color: rgba(255,255,255,.22); }
.button-danger { color: #ffd9dc; background: var(--danger-bg); border: 1px solid rgba(255, 113, 125, .28); box-shadow: none; }
.button-danger:hover { background: rgba(255, 93, 108, .16); }
.button-small { min-height: 34px; padding: 7px 11px; font-size: 11px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  margin-bottom: 24px;
  padding: 0 3px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid rgba(182,243,107,.3);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(182,243,107,.18), rgba(116,184,255,.06));
  color: var(--accent);
  font-family: "Manrope", sans-serif;
  font-size: 15px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 30px rgba(0,0,0,.25);
}
.topbar h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: -.045em; }
.topbar-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions, .button-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.topbar-actions button { min-height: 38px; padding: 8px 13px; font-size: 11px; }
.queue-jump {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 13px;
  color: var(--accent);
  border-color: rgba(182,243,107,.22);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}
#video-library { scroll-margin-top: 18px; }
.pill, .model-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted-strong);
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #687384; box-shadow: 0 0 0 4px rgba(104,115,132,.1); }
.model-tag { color: var(--accent); background: rgba(182,243,107,.07); border-color: rgba(182,243,107,.22); }

#notice-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.notice { padding: 13px 15px; color: #f8dfa9; background: rgba(91, 68, 24, .28); border: 1px solid rgba(247,198,106,.25); border-radius: 14px; font-size: 13px; line-height: 1.45; }
.notice strong { color: #fff1c8; }

.grid { display: grid; grid-template-columns: minmax(0, 1.56fr) minmax(330px, .72fr); gap: 20px; align-items: start; }
.compose-card { padding: 30px; }
.status-card, .billing-card, .guide-card { padding: 22px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 22px; }
.compose-card > .card-heading { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.compose-card form > label { margin-top: 3px; }
.compose-card #prompt {
  background:
    linear-gradient(180deg, rgba(9,13,18,.96), rgba(6,9,13,.96));
  border-color: rgba(255,255,255,.13);
  font-size: 14px;
}
.compose-card #generate-button {
  position: relative;
  min-height: 58px;
  margin-top: 5px;
  border-radius: 15px;
  font-family: "Manrope", sans-serif;
  font-size: 15px;
  letter-spacing: -.01em;
}
.compose-card #generate-button::after { content: "  →"; }
.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 3px 0 7px; }
.field-grid > div { display: grid; gap: 7px; min-width: 0; }
.mode-grid { grid-template-columns: minmax(0, 1fr) 118px; }
.upload-panel { display: grid; gap: 9px; padding: 15px; border: 1px dashed rgba(255,255,255,.18); border-radius: 15px; background: rgba(6,9,13,.38); }
.upload-panel input[type="file"] { padding: 9px; background: rgba(255,255,255,.025); }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quality-grid { grid-template-columns: 1fr; }
.director-panel { border-color: rgba(182,243,107,.24); background: linear-gradient(145deg, rgba(182,243,107,.055), rgba(6,9,13,.6)); }
.director-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.director-title { color: var(--accent); font-size: 12px; font-weight: 800; }
.director-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-strong); font-size: 11px; cursor: pointer; }
.director-toggle input { width: auto; min-height: 0; accent-color: var(--accent); }
.director-controls { margin-bottom: 8px; }
.director-controls .hint { margin: 0 0 8px; }
.director-button { width: 100%; }
.segment-prompts { gap: 10px; }
.stack { display: grid; gap: 18px; }
.grid > .stack { position: sticky; top: 18px; }

.status-card { background: linear-gradient(155deg, rgba(18,25,31,.96), rgba(10,14,20,.97)); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #687384; box-shadow: 0 0 0 5px rgba(104,115,132,.09); }
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 5px rgba(182,243,107,.1), 0 0 18px rgba(182,243,107,.38); }
.status-dot.preparing { background: var(--amber); box-shadow: 0 0 0 5px rgba(247,198,106,.11); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 16px; }
.stats div { min-width: 0; padding: 11px 12px; border: 1px solid rgba(255,255,255,.055); border-radius: 11px; background: rgba(255,255,255,.025); }
.stats dt { margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.stats dd { margin: 0; overflow: hidden; color: #e8edf3; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; }
.provider-summary { position: relative; margin: 0 0 14px; padding: 13px 14px 16px; overflow: hidden; color: #dfe5ec; background: rgba(4,7,10,.53); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; line-height: 1.45; }
.provider-summary::after { content: ""; position: absolute; left: 0; bottom: 0; width: var(--provider-progress, 0%); height: 2px; background: linear-gradient(90deg, var(--accent), var(--blue)); transition: width .35s ease; }
.provider-error:empty { display: none; }
.provider-error { margin-top: 10px; padding: 10px; background: var(--danger-bg); border: 1px solid rgba(255,113,125,.28); border-radius: 10px; overflow-wrap: anywhere; }
.error { min-height: 18px; color: var(--danger); font-size: 12px; line-height: 1.45; margin: 0; }

.billing-live { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.billing-live.online { color: var(--accent); border-color: rgba(182,243,107,.25); background: rgba(182,243,107,.06); }
.billing-balance { position: relative; display: grid; gap: 4px; margin: -2px 0 13px; padding: 17px; overflow: hidden; border: 1px solid rgba(182,243,107,.2); border-radius: 15px; background: linear-gradient(135deg, rgba(182,243,107,.09), rgba(116,184,255,.035)); }
.billing-balance::after { content: "$"; position: absolute; right: 11px; bottom: -22px; color: rgba(182,243,107,.055); font-family: "Manrope", sans-serif; font-size: 96px; font-weight: 800; }
.billing-balance span, .topup-box span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.billing-balance strong { position: relative; z-index: 1; color: var(--accent-bright); font-family: "Manrope", sans-serif; font-size: 32px; line-height: 1.1; letter-spacing: -.045em; }
.billing-balance small, .topup-box small { position: relative; z-index: 1; color: var(--muted); font-size: 10px; line-height: 1.45; }
.billing-stats { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.billing-stats div:last-child { grid-column: 1 / -1; }
.topup-box { display: grid; gap: 3px; margin-bottom: 11px; padding: 12px; border: 1px solid rgba(255,255,255,.055); border-radius: 11px; background: rgba(4,7,10,.45); }
.topup-box strong { font-size: 18px; }
.billing-link { display: flex; align-items: center; justify-content: center; min-height: 42px; text-decoration: none; font-size: 11px; font-weight: 800; }
.guide-card { background: linear-gradient(155deg, rgba(15,20,27,.88), rgba(10,13,18,.94)); }
.guide-card p { position: relative; margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.guide-card p::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--accent); font-weight: 800; }

.history-card { margin-top: 20px; padding: 28px; }
.history-card > .card-heading { margin-bottom: 12px; }
.queue-submit-panel { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; padding: 15px; border: 1px solid rgba(182,243,107,.2); border-radius: 15px; background: linear-gradient(135deg, rgba(182,243,107,.075), rgba(116,184,255,.025)); }
.queue-submit-panel > div { display: grid; gap: 4px; min-width: 0; }
.queue-submit-panel strong { color: var(--text); font-size: 13px; }
.queue-submit-panel span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.queue-submit-panel button { flex: 0 0 auto; min-width: 220px; }
.queue-summary { display: inline-flex; margin: 0 0 18px; padding: 6px 9px; color: var(--muted-strong); background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 8px; font-size: 10px; font-weight: 700; }
.history-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(4,7,10,.35); }
.history-search-wrap { flex: 1; min-width: 210px; }
#history-search { min-height: 38px; margin: 0; padding: 8px 12px; font-size: 12px; }
.history-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.jobs-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.jobs-list > .muted, .job-section-title { grid-column: 1 / -1; }
.job-section-title { margin: 10px 2px 0; color: var(--muted); font-size: 10px; letter-spacing: .15em; text-transform: uppercase; }
.job {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(8,11,16,.62);
  transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.job:not(.video-tile) { grid-column: 1 / -1; }
.job:hover { border-color: rgba(255,255,255,.15); background: rgba(11,15,21,.76); }
.job-detail { min-width: 0; }
.video-tile { display: block; padding: 0; overflow: hidden; background: #090c11; }
.video-tile:hover { transform: translateY(-2px); }
.video-tile .job-detail { display: grid; }
.video-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #030405; border-bottom: 1px solid var(--line); }
.video-wrap::after { content: ""; position: absolute; inset: auto 0 0; height: 34%; pointer-events: none; background: linear-gradient(to top, rgba(0,0,0,.28), transparent); }
.clip-video { position: relative; z-index: 1; display: block; width: 100%; height: 100%; object-fit: contain; background: #030405; }
.video-tile .job-prompt { margin: 15px 15px 6px; -webkit-line-clamp: 2; }
.video-tile .job-meta { margin: 0 15px 13px; }
.video-tile .job-actions { justify-content: flex-start; padding: 0 15px 15px; }
.video-tile .download { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; }
.job-prompt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; margin: 0 0 7px; overflow: hidden; overflow-wrap: anywhere; color: #e5eaf0; font-size: 13px; line-height: 1.45; }
.job-meta { color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; white-space: normal; }
.job-progress { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: #252c36; }
.job-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--blue), var(--accent)); background-size: 200% 100%; animation: progressGlow 2s infinite linear; box-shadow: 0 0 12px rgba(182,243,107,.35); transition: width .35s ease; }
@keyframes progressGlow { to { background-position: 200% 50%; } }
.job-stage { margin-top: 6px; color: var(--muted); font-size: 10px; }
.job-error-detail { margin-top: 9px; padding: 9px 11px; overflow-wrap: anywhere; color: #ffd9dc; background: var(--danger-bg); border: 1px solid rgba(255,113,125,.25); border-radius: 9px; font-size: 10px; line-height: 1.45; }
.job-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.job-status { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.job-status.succeeded { color: var(--accent); }
.job-status.running { color: var(--accent); animation: pulse 1.5s infinite ease-in-out; }
.job-status.failed { color: var(--danger); }
.job-status.cancelled, .job-status.cancel_requested, .job-status.waiting { color: var(--amber); }
.job-status.draft, .draft-stage { color: var(--blue); }
.history-filter-btn.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); box-shadow: none; }
.download { padding: 8px 11px; color: var(--text); background: rgba(255,255,255,.055); border: 1px solid var(--line-strong); font-size: 11px; font-weight: 700; text-decoration: none; }
.quality-warning { margin-top: 8px; padding: 10px 12px; border-radius: 10px; color: #f8dfa9; background: rgba(91,68,24,.28); border: 1px solid rgba(247,198,106,.25); font-size: 12px; line-height: 1.45; }
.quality-warning.hidden { display: none; }
.mode-guidance { margin: -5px 0 14px; padding: 10px 12px; border-left: 3px solid rgba(116,184,255,.65); border-radius: 0 10px 10px 0; color: var(--muted); background: rgba(116,184,255,.055); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.tag-turbo { color: var(--accent); background: rgba(182,243,107,.07); border-color: rgba(182,243,107,.22); }
.tag-standard { color: var(--blue); background: rgba(116,184,255,.07); border-color: rgba(116,184,255,.22); }
.tag-max { color: var(--amber); background: rgba(247,198,106,.07); border-color: rgba(247,198,106,.22); }
select option:disabled { color: #555; }

@media (max-width: 980px) {
  .shell { width: min(900px, calc(100% - 32px)); }
  .grid { grid-template-columns: 1fr; }
  .grid > .stack { position: static; grid-template-columns: 1fr 1fr; }
  .guide-card { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .shell { width: 100%; padding: 0 0 82px; }
  .topbar { min-height: 0; margin: 0; padding: 18px 16px 16px; border-bottom: 1px solid var(--line); background: rgba(7,9,13,.78); backdrop-filter: blur(18px); }
  .brand-mark { width: 39px; height: 39px; border-radius: 12px; }
  .topbar h1 { font-size: 22px; }
  .topbar-subtitle, .topbar .eyebrow { display: none; }
  .topbar-actions { justify-content: flex-end; }
  .topbar-actions button { min-height: 36px; }
  .pill { padding: 7px 9px; font-size: 9px; }
  .auth-card { width: calc(100% - 28px); margin-top: 7vh; padding: 28px 22px; }
  .grid { gap: 12px; padding: 12px; }
  .grid > .stack { grid-template-columns: 1fr; gap: 12px; }
  .guide-card { grid-column: auto; }
  .compose-card, .status-card, .billing-card, .guide-card, .history-card { padding: 20px 17px; border-radius: 20px; }
  .compose-card { padding: 21px 17px; }
  .card-heading { margin-bottom: 17px; }
  .compose-card > .card-heading { padding-bottom: 16px; }
  h1 { font-size: 30px; }
  h2 { font-size: 18px; }
  button { min-height: 46px; }
  .button-small { min-height: 38px; font-size: 12px; padding: 8px 12px; }
  input, textarea, select { min-height: 48px; padding: 13px; font-size: 16px; }
  textarea { min-height: 170px; font-size: 15px; }
  label { font-size: 12px; }
  .field-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .mode-grid { grid-template-columns: minmax(0, 1fr) 100px; }
  .upload-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .history-card { margin: 0 12px; }
  .queue-submit-panel { align-items: stretch; flex-direction: column; }
  .queue-submit-panel button { width: 100%; min-width: 0; }
  .history-controls { align-items: stretch; }
  .history-search-wrap { min-width: 100%; }
  .history-filters { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .history-filter-btn { min-width: 0; padding: 7px 5px; font-size: 10px; }
  .jobs-list { grid-template-columns: 1fr; gap: 12px; }
  .job { grid-template-columns: 1fr; }
  .job-actions { justify-content: stretch; }
  .job-actions > * { flex: 1 1 auto; text-align: center; }
  .video-tile .job-actions { justify-content: stretch; }
  .video-tile .job-actions > * { flex: 1 1 calc(33% - 6px); }
  .provider-summary { font-size: 12px; }
  #notice-stack { margin: 12px; }
}

@media (max-width: 410px) {
  .topbar { gap: 10px; }
  .brand { gap: 9px; }
  .brand-mark { width: 36px; height: 36px; }
  .topbar h1 { font-size: 19px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions button { padding: 7px 9px; font-size: 10px; }
  .pill { padding: 6px 8px; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-grid > div:last-child { grid-template-columns: 1fr; }
  .stats { gap: 6px; }
  .stats div { padding: 10px; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .shell { padding-top: env(safe-area-inset-top); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.prompt-director-bar {
  margin: -0.25rem 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(190, 245, 95, 0.2);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(190, 245, 95, 0.08), rgba(92, 225, 230, 0.04));
}

.smart-enhance-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.8rem;
  margin: 0;
  cursor: pointer;
}

.smart-enhance-toggle > input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 46px; height: 26px; border-radius: 99px; padding: 3px; background: #454b54; transition: 160ms ease; }
.toggle-track span { display: block; width: 20px; height: 20px; border-radius: 50%; background: white; transition: 160ms ease; }
.smart-enhance-toggle input:checked + .toggle-track { background: var(--accent); }
.smart-enhance-toggle input:checked + .toggle-track span { transform: translateX(20px); background: #10140b; }
.smart-enhance-toggle strong, .smart-enhance-toggle small { display: block; }
.smart-enhance-toggle small { margin-top: 0.2rem; color: var(--muted); font-weight: 500; line-height: 1.35; }

.enhancement-preview { border-color: rgba(190, 245, 95, 0.32); box-shadow: inset 0 1px rgba(255, 255, 255, 0.03); }
.enhancement-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.enhancement-method { flex: none; padding: 0.38rem 0.62rem; border: 1px solid rgba(190, 245, 95, 0.3); border-radius: 999px; color: var(--accent); background: rgba(190, 245, 95, 0.08); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; }
.enhancement-preview textarea { min-height: 250px; font-size: 0.92rem; line-height: 1.55; }
.enhancement-warning { margin: 0.75rem 0 0; color: #f4c76b; font-size: 0.84rem; }
.enhancement-actions { margin-top: 0.8rem; flex-wrap: wrap; }

@media (max-width: 560px) {
  .enhancement-heading { align-items: flex-start; flex-direction: column; gap: 0.5rem; }
  .enhancement-actions button { flex: 1 1 100%; }
}
.character-bank { margin-top: 14px; padding: 14px; border: 1px solid rgba(116,184,255,.22); border-radius: 14px; background: rgba(116,184,255,.045); }
.character-bank-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.character-bank-heading strong { font-size: 13px; }
.character-bank-heading span { color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.character-bank p { margin: 7px 0 11px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.character-card { min-height: 0; padding: 5px; border-radius: 11px; background: rgba(0,0,0,.22); border: 1px solid var(--line-strong); overflow: hidden; }
.character-card img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 7px; }
.character-card span { display: block; padding: 6px 2px 2px; color: var(--muted); font-size: 9px; font-weight: 800; text-align: center; }
.character-card.approved { border-color: rgba(182,243,107,.48); box-shadow: inset 0 0 0 1px rgba(182,243,107,.08); }
.character-card.approved span { color: var(--accent); }
.character-card.disabled img { opacity: .35; filter: grayscale(1); }

.studio-tabs { display: inline-flex; gap: 6px; margin: 10px 0 18px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: rgba(7,10,14,.72); }
.studio-tab { min-height: 40px; padding: 9px 18px; color: var(--muted-strong); background: transparent; border: 0; box-shadow: none; }
.studio-tab span { margin-left: 5px; color: var(--accent); font-size: 9px; letter-spacing: .08em; }
.studio-tab.active { color: #10140b; background: var(--accent); }
.studio-tab.active span { color: #10140b; }
.image-workspace { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(0, 1.28fr); gap: 18px; align-items: start; }
.image-compose-card { position: sticky; top: 18px; }
.image-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.image-jobs-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.image-job-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(7,10,14,.7); }
.image-job-card img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: #040506; border-bottom: 1px solid var(--line); }
.image-job-body { padding: 14px; }
.image-job-body .job-actions { margin-top: 12px; }
.image-job-card:not(.succeeded) { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .image-workspace { grid-template-columns: 1fr; padding: 12px; }
  .image-compose-card { position: static; }
}
@media (max-width: 680px) {
  .studio-tabs { display: grid; grid-template-columns: 1fr 1fr; width: calc(100% - 24px); margin: 12px; }
  .image-jobs-list { grid-template-columns: 1fr; }
  .image-workspace .card { padding: 20px 17px; border-radius: 20px; }
}
