:root {
  --bg: #111112;
  --panel: #181819;
  --panel-2: #1d1d1f;
  --panel-3: #242426;
  --line: #2d2d30;
  --line-strong: #3a3a3e;
  --text: #eeeeef;
  --muted: #929297;
  --muted-2: #69696e;
  --purple: #7b5cff;
  --purple-2: #9d89ff;
  --green: #42d39b;
  --red: #ff6b78;
  --radius: 10px;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; background: var(--bg); }
body { color: var(--text); font-size: 12px; overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid rgba(123,92,255,.72); outline-offset: 1px; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #37373a; border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a4f; }

.app-header {
  display: flex;
  height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #131314;
}
.brand { display: flex; min-width: 180px; align-items: center; gap: 9px; }
.brand-mark { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 7px; background: linear-gradient(145deg, #977fff, #6545e8); color: white; font-size: 13px; font-weight: 800; }
.brand-name { font-size: 13px; font-weight: 680; letter-spacing: -.02em; }
.mode-tabs { display: flex; align-self: stretch; gap: 0; }
.mode-tabs button { position: relative; min-width: 112px; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 560; }
.mode-tabs button::after { position: absolute; right: 15px; bottom: 0; left: 15px; height: 2px; border-radius: 2px 2px 0 0; background: var(--purple); content: ""; opacity: 0; }
.mode-tabs button.active { color: #f5f5f6; }
.mode-tabs button.active::after { opacity: 1; }
.header-actions { display: flex; min-width: 280px; align-items: center; justify-content: flex-end; gap: 9px; }
.service-state { display: flex; align-items: center; gap: 6px; color: #7fcaaa; font-size: 10px; }
.service-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(66,211,155,.65); }
.header-button { display: flex; height: 32px; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #1b1b1d; color: #b8b8bd; font-size: 10px; }
.header-button:hover { border-color: var(--line-strong); background: #222225; color: white; }
.header-button svg { width: 14px; height: 14px; }
.avatar-button { width: 31px; height: 31px; border: 1px solid var(--line-strong); border-radius: 8px; background: #242428; color: #d4d4d8; font-size: 9px; font-weight: 700; }

.workspace { display: grid; height: calc(100vh - 54px); grid-template-columns: 410px minmax(0, 1fr); }
.control-panel { position: relative; display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line); background: #151516; }
.control-scroll { display: flex; flex: 1; min-height: 0; flex-direction: column; overflow-y: auto; padding: 16px 14px 0; }
.form-section { flex: 0 0 auto; margin-bottom: 18px; }
.form-section:last-child { margin-bottom: 0; }
.section-head { display: flex; min-height: 24px; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head label, .field-label { color: #c4c4c8; font-size: 11px; font-weight: 620; }
.model-ready { display: flex; align-items: center; gap: 5px; color: #6fc99e; font-size: 9px; }
.model-ready i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.select-control { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; outline: 0; appearance: none; background: #1d1d1f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a90' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; color: #dedee1; font-size: 11px; }
.select-control:focus { border-color: rgba(123,92,255,.7); }
.field-hint { margin: 6px 1px 0; color: var(--muted-2); font-size: 9px; }
.text-action { border: 0; background: transparent; color: #9d89ff; font-size: 10px; }
.text-action:hover { color: #b8aaff; }
.text-action:disabled { color: var(--muted-2); cursor: wait; }
.textarea-wrap { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #1b1b1d; }
.textarea-wrap:focus-within { border-color: rgba(123,92,255,.7); }
textarea { display: block; width: 100%; height: 145px; resize: vertical; padding: 11px 11px 25px; border: 0; outline: 0; background: transparent; color: #d7d7da; font-size: 11px; line-height: 1.7; }
textarea::placeholder { color: #626267; }
.char-count { position: absolute; right: 9px; bottom: 7px; color: #67676c; font-size: 9px; }
.char-count b { font-weight: 500; }
.asset-counts { display: flex; gap: 10px; color: var(--muted-2); font-size: 9px; }
.asset-counts b { color: #adadb2; font-weight: 500; }
.upload-zone { display: flex; width: 100%; height: 58px; align-items: center; justify-content: center; gap: 8px; border: 1px dashed #444448; border-radius: 9px; background: #1a1a1c; color: #838388; font-size: 10px; transition: .16s ease; }
.upload-zone:hover { border-color: #6d58b0; background: #1d1b23; color: #b3b3b8; }
.upload-zone svg { width: 17px; height: 17px; }
.compact-section { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #19191b; }
.field-row { display: flex; min-height: 38px; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid #272729; }
.field-row:last-of-type { border-bottom: 0; }
.field-label { flex: 0 0 58px; color: #9b9ba0; font-size: 10px; }
.segment-control { display: flex; min-width: 0; flex: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #141415; }
.segment-control button { flex: 1; height: 30px; border: 0; border-right: 1px solid var(--line); background: transparent; color: #85858b; font-size: 10px; }
.segment-control button:last-child { border-right: 0; }
.segment-control button.active { background: #47348f; color: white; }
.segment-control button:hover:not(.active) { background: #222225; color: #c7c7cb; }
.range-wrap { flex: 1; min-width: 0; }
.range-wrap input { width: 100%; height: 16px; margin: 0; accent-color: var(--purple); }
.range-scale { display: flex; align-items: center; justify-content: space-between; color: #65656a; font-size: 8px; }
.range-scale b { color: #d6d6d9; font-size: 9px; font-weight: 560; }
.ratio-control { display: flex; flex: 1; gap: 4px; }
.ratio-control button { flex: 1; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: #141415; color: #85858b; font-size: 9px; }
.ratio-control button.active { border-color: #6651c6; background: #3c2c79; color: white; }
.ratio-control button:hover:not(.active) { border-color: var(--line-strong); color: #c7c7cb; }
.count-control button { flex: 1; }
.advanced { margin-top: 7px; padding-top: 8px; border-top: 1px solid #272729; }
.advanced summary { color: #7f7f85; font-size: 9px; list-style: none; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { display: inline-block; margin-right: 6px; content: "›"; transition: transform .16s ease; }
.advanced[open] summary::before { transform: rotate(90deg); }
.advanced-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.advanced-grid label { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.advanced-grid label > span { color: #7c7c82; font-size: 9px; }
.advanced-grid input[type="text"] { height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #141415; color: #c8c8cc; font-size: 10px; }
.advanced-grid input[type="range"] { height: 16px; margin: 0; accent-color: var(--purple); }
.check-row { display: flex !important; flex-direction: row !important; align-items: center; align-self: end; height: 30px; gap: 7px !important; }
.check-row input { width: 14px; height: 14px; accent-color: var(--purple); }
.create-bar { position: fixed; right: auto; bottom: 0; left: 0; z-index: 80; display: flex; width: 410px; height: 63px; margin: 0; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); background: #141415; }
.cost { display: flex; min-width: 95px; flex-direction: column; }
.cost span { color: #6e6e73; font-size: 9px; }
.cost strong { color: #dedee1; font-size: 11px; font-weight: 620; }
.create-button { display: flex; height: 40px; flex: 1; align-items: center; justify-content: center; gap: 8px; border: 1px solid #6b53d9; border-radius: 8px; background: #7658e8; color: white; font-size: 11px; font-weight: 650; }
.create-button:hover { background: #8064ed; }
.create-button:disabled { cursor: wait; opacity: .75; }
.create-button svg { width: 15px; height: 15px; }

.output-panel { display: flex; min-width: 0; flex-direction: column; background: #111112; }
.output-toolbar { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: #151516; }
.output-tabs { display: flex; align-self: stretch; gap: 18px; }
.output-tabs button { position: relative; border: 0; background: transparent; color: #79797f; font-size: 10px; }
.output-tabs button.active { color: #e5e5e7; }
.output-tabs button.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--purple); content: ""; }
.output-tabs b { margin-left: 4px; color: #9b9ba0; font-size: 9px; font-weight: 500; }
.output-actions button { display: flex; height: 30px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: #1c1c1e; color: #a0a0a5; font-size: 9px; }
.output-actions button:hover { border-color: var(--line-strong); color: #d9d9dc; }
.output-scroll { flex: 1; overflow-y: auto; padding: 14px 16px 32px; }
.results-list { width: min(820px, 100%); margin: 0 auto; }
.result-card { overflow: hidden; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; background: #181819; box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.result-head { display: flex; height: 43px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; border-bottom: 1px solid #29292c; }
.result-head h3 { overflow: hidden; margin: 0; color: #ccccd0; font-size: 11px; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.result-controls { display: flex; gap: 3px; }
.icon-button { display: grid; width: 27px; height: 27px; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #818187; }
.icon-button:hover { border-color: var(--line); background: #222225; color: #d2d2d5; }
.icon-button svg { width: 14px; height: 14px; }
.media-stage { position: relative; display: grid; min-height: 320px; place-items: center; overflow: hidden; background: #050505; }
.media-art { width: 100%; height: 100%; min-height: 320px; background: var(--art, radial-gradient(circle at 70% 35%, #e8bd79 0 3%, transparent 15%), linear-gradient(145deg, #4b4c6c, #151a2c 58%, #07080b)); }
.art-neon { --art: radial-gradient(circle at 30% 25%, #eb6ac5 0 4%, transparent 21%), linear-gradient(145deg, #331d4e, #161629 60%, #08090c); }
.art-ocean { --art: radial-gradient(circle at 72% 34%, #63edf0 0 3%, transparent 17%), linear-gradient(145deg, #0f5a65, #10202b 58%, #080a0e); }
.art-desert { --art: radial-gradient(circle at 65% 28%, #ffcb7c 0 5%, transparent 18%), linear-gradient(145deg, #794638, #2a1e21 58%, #0c0b0c); }
.art-city { --art: radial-gradient(circle at 35% 30%, #9f8cff 0 5%, transparent 23%), linear-gradient(145deg, #1f2c56, #171628 60%, #090a0e); }
.media-art::before { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 48%, rgba(0,0,0,.48)), linear-gradient(90deg, rgba(0,0,0,.18), transparent 35%, transparent 70%, rgba(0,0,0,.16)); content: ""; }
.media-art::after { position: absolute; inset: 0; opacity: .04; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); content: ""; }
.media-stage .media-art { position: absolute; inset: 0; }
.ai-badge { position: absolute; z-index: 2; top: 11px; right: 11px; padding: 3px 7px; border-radius: 4px; background: rgba(0,0,0,.65); color: #e1e1e3; font-size: 8px; }
.media-placeholder { position: absolute; z-index: 2; top: 50%; left: 50%; display: flex; flex-direction: column; align-items: center; gap: 8px; color: rgba(255,255,255,.72); transform: translate(-50%,-50%); }
.media-placeholder svg { width: 34px; height: 34px; }
.media-placeholder span { font-size: 10px; }
.result-progress { position: absolute; z-index: 3; right: 0; bottom: 0; left: 0; height: 3px; background: rgba(255,255,255,.1); }
.result-progress i { display: block; width: 0; height: 100%; background: var(--purple); transition: width .3s ease; }
.play-overlay { position: absolute; z-index: 2; top: 50%; left: 50%; display: grid; width: 42px; height: 42px; place-items: center; padding-left: 3px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; background: rgba(0,0,0,.38); color: white; opacity: 0; transform: translate(-50%,-50%); transition: .16s ease; }
.result-card:hover .play-overlay { opacity: 1; }
.play-overlay svg { width: 17px; height: 17px; fill: currentColor; stroke: none; }
.result-media-controls { display: flex; height: 38px; align-items: center; gap: 9px; padding: 0 12px; border-top: 1px solid #28282b; color: #79797e; font-size: 9px; }
.result-media-controls .icon-button { flex: 0 0 24px; width: 24px; height: 24px; }
.result-media-controls .icon-button svg { width: 13px; height: 13px; }
.media-line { position: relative; flex: 1; height: 3px; border-radius: 3px; background: #333337; }
.media-line i { position: absolute; top: 0; bottom: 0; left: 0; width: 34%; border-radius: 3px; background: #a28cff; }
.result-foot { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 12px; }
.status-text { display: flex; align-items: center; gap: 6px; color: #6fc99e; font-size: 9px; }
.status-text i { display: block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-text.pending { color: #d3a35b; }
.status-text.error { color: var(--red); }
.result-meta { display: flex; align-items: center; gap: 4px; }
.result-meta button { height: 27px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: #1d1d20; color: #98989e; font-size: 9px; }
.result-meta button:hover { background: #252529; color: #d2d2d5; }
.result-meta button.icon-button { width: 27px; padding: 0; }
.tasks-view { display: block; }
.task-list { width: min(820px, 100%); margin: 0 auto; }
.task-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 80px 80px; gap: 12px; align-items: center; min-height: 58px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.task-row:first-child { border-top: 1px solid var(--line); }
.task-title { display: flex; min-width: 0; flex-direction: column; }
.task-title strong { overflow: hidden; color: #c7c7cb; font-size: 10px; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.task-title small { margin-top: 3px; color: #66666c; font-size: 8px; }
.task-model, .task-time { color: #7d7d83; font-size: 9px; }
.task-progress { display: flex; align-items: center; gap: 7px; color: #929298; font-size: 9px; }
.task-progress i { display: block; width: 52px; height: 3px; overflow: hidden; border-radius: 3px; background: #303034; }
.task-progress i::after { display: block; width: var(--progress); height: 100%; border-radius: inherit; background: var(--purple); content: ""; }
.empty-state { display: grid; min-height: 330px; place-items: center; color: #65656b; font-size: 10px; }

.api-dialog { width: min(640px, calc(100vw - 28px)); padding: 0; border: 1px solid #404045; border-radius: 12px; background: #1a1a1c; color: var(--text); box-shadow: 0 25px 70px rgba(0,0,0,.55); }
.api-dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.api-card { display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border-bottom: 1px solid var(--line); }
.dialog-head > div { display: flex; flex-direction: column; gap: 2px; }
.dialog-head strong { font-size: 13px; }
.dialog-head span { color: #717177; font-size: 9px; }
.dialog-head .icon-button { font-size: 20px; line-height: 1; }
.dialog-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-height: 66vh; overflow-y: auto; padding: 16px; }
.dialog-body label { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.dialog-body label > span { color: #909096; font-size: 9px; }
.dialog-body input { width: 100%; height: 35px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #141415; color: #d0d0d3; font-size: 10px; }
.dialog-body input:focus { border-color: rgba(123,92,255,.75); }
.two-columns { display: contents; }
.live-toggle { flex-direction: row !important; align-items: center; justify-content: space-between; grid-column: span 2; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: #171719; }
.live-toggle > span { display: flex; flex-direction: column; }
.live-toggle b { color: #c1c1c5; font-size: 10px; font-weight: 560; }
.live-toggle small { margin-top: 2px; color: #68686e; font-size: 8px; }
.live-toggle input { width: 17px; height: 17px; accent-color: var(--purple); }
.code-preview { grid-column: span 2; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #111112; }
.code-preview > div { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid #27272a; color: #717177; font-size: 9px; }
.code-preview button { border: 0; background: transparent; color: #9d89ff; font-size: 9px; }
.code-preview pre { max-height: 130px; margin: 0; overflow: auto; padding: 10px; color: #9c9ca2; font: 9px/1.6 Consolas, monospace; white-space: pre-wrap; }
.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); }
.dialog-foot > span { color: #8d8d93; font-size: 9px; }
.dialog-foot > div { display: flex; gap: 7px; }
.secondary-button, .primary-button { height: 32px; padding: 0 12px; border-radius: 7px; font-size: 10px; }
.secondary-button { border: 1px solid var(--line); background: #202023; color: #b5b5ba; }
.primary-button { border: 1px solid #6c52dc; background: #7658e8; color: white; }
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: flex; width: min(320px,calc(100vw - 32px)); flex-direction: column; gap: 7px; }
.toast { padding: 10px 11px; border: 1px solid #3c3c41; border-radius: 8px; background: #202023; color: #c7c7cb; font-size: 10px; box-shadow: 0 12px 28px rgba(0,0,0,.35); animation: toast-in .2s ease; }
.toast.error { border-color: rgba(255,107,120,.35); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-header { flex-wrap: wrap; height: auto; min-height: 54px; padding: 9px 12px; }
  .brand, .header-actions { min-width: 0; }
  .mode-tabs { order: 3; width: 100%; height: 38px; justify-content: center; overflow-x: auto; }
  .mode-tabs button { min-width: 95px; }
  .workspace { height: auto; min-height: calc(100vh - 100px); grid-template-columns: 1fr; }
  .control-panel { position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .control-scroll { overflow: visible; padding-bottom: 24px; }
  .create-bar { position: static; width: auto; height: auto; margin: 0; }
  .output-panel { min-height: 620px; }
  .output-scroll { overflow: visible; }
}
@media (max-width: 540px) {
  .header-actions .service-state, .header-button { display: none; }
  .results-list { width: 100%; }
  .media-stage, .media-art { min-height: 230px; }
  .result-head h3 { max-width: 220px; }
  .task-row { grid-template-columns: minmax(0,1fr) 70px; }
  .task-model, .task-time { display: none; }
  .dialog-body { grid-template-columns: 1fr; }
  .two-columns { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .live-toggle, .code-preview { grid-column: auto; }
}

/* Authentication and permissions */
body.auth-pending .app-header, body.auth-pending .workspace,
body.login-required .app-header, body.login-required .workspace { visibility: hidden; }
body:not(.is-admin) .admin-only { display: none !important; }
.quota-chip { margin-top: 2px; color: #79797f; font-size: 8px; white-space: nowrap; }
.quota-chip.low { color: #ef9b62; }
.quota-chip.empty { color: var(--red); }
.login-screen { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 18px; background: #0d0d0e; }
.login-screen[hidden] { display: none; }
.login-card { width: min(390px, 100%); padding: 26px; border: 1px solid #303034; border-radius: 14px; background: #18181a; box-shadow: 0 28px 80px rgba(0,0,0,.45); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-brand > span:last-child { display: flex; flex-direction: column; }
.login-brand strong { font-size: 14px; }
.login-brand small { color: #68686e; font-size: 8px; letter-spacing: .14em; }
.login-loading { padding: 38px 0; color: #77777d; font-size: 10px; text-align: center; }
.login-form h1 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.03em; }
.login-form > p { margin: 0 0 20px; color: #79797f; font-size: 10px; line-height: 1.6; }
.login-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.login-form label span { color: #99999f; font-size: 9px; }
.login-form input { width: 100%; height: 39px; padding: 0 11px; border: 1px solid #313135; border-radius: 8px; outline: 0; background: #121214; color: #e2e2e5; font-size: 11px; }
.login-form input:focus { border-color: #6b53d9; box-shadow: 0 0 0 3px rgba(123,92,255,.08); }
.login-form .primary-button { width: 100%; height: 40px; margin-top: 5px; }
.login-error { min-height: 18px; color: #ff727f; font-size: 9px; }
.login-footer { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 21px; color: #55555a; font-size: 8px; }
.login-footer i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.team-dialog { width: min(780px, calc(100vw - 28px)); padding: 0; border: 1px solid #414146; border-radius: 12px; background: #1a1a1c; color: var(--text); box-shadow: 0 25px 70px rgba(0,0,0,.55); }
.team-dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.team-card { display: flex; flex-direction: column; }
.team-summary { display: flex; gap: 20px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: #74747a; font-size: 9px; }
.team-summary b { color: #c6c6ca; font-weight: 600; }
.team-list { max-height: 56vh; overflow-y: auto; }
.team-row { display: grid; grid-template-columns: minmax(150px,1fr) 70px 90px 120px 82px; gap: 10px; align-items: center; min-height: 60px; padding: 0 16px; border-bottom: 1px solid #29292c; }
.team-row:last-child { border-bottom: 0; }
.team-user { display: flex; min-width: 0; flex-direction: column; }
.team-user strong { color: #d0d0d3; font-size: 10px; font-weight: 570; }
.team-user small { margin-top: 2px; color: #66666c; font-size: 8px; }
.team-role { color: #87878d; font-size: 9px; }
.team-used { color: #74747a; font-size: 9px; }
.team-quota { display: flex; align-items: center; gap: 6px; }
.team-quota input { width: 74px; height: 30px; padding: 0 7px; border: 1px solid #35353a; border-radius: 6px; outline: 0; background: #131315; color: #d3d3d6; font-size: 10px; }
.team-row button { height: 29px; padding: 0 9px; border: 1px solid #3a3a3f; border-radius: 6px; background: #232326; color: #a8a8ae; font-size: 9px; }
.team-row button:hover { color: white; background: #2b2b2f; }
.team-row.admin-row { background: rgba(123,92,255,.035); }
@media (max-width: 680px) {
  .team-row { grid-template-columns: minmax(120px,1fr) 80px 80px; }
  .team-role, .team-used { display: none; }
  .team-summary { flex-wrap: wrap; gap: 8px 16px; }
}

/* Reference image queue */
.reference-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 9px; }
.reference-grid:empty { display: none; }
.reference-card { position: relative; overflow: hidden; aspect-ratio: 1 / 1; border: 1px solid #333338; border-radius: 9px; background: #121214; cursor: grab; transition: border-color .16s ease, transform .16s ease, opacity .16s ease; }
.reference-card:active { cursor: grabbing; }
.reference-card.dragging { opacity: .38; transform: scale(.96); }
.reference-card.drag-over { border-color: var(--purple); box-shadow: inset 0 0 0 1px var(--purple); }
.reference-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reference-card::after { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.22), transparent 42%, rgba(0,0,0,.42)); content: ""; pointer-events: none; }
.reference-order { position: absolute; z-index: 2; top: 6px; left: 6px; display: grid; width: 19px; height: 19px; place-items: center; border-radius: 6px; background: rgba(0,0,0,.62); color: #fff; font-size: 8px; backdrop-filter: blur(5px); }
.reference-delete { position: absolute; z-index: 3; top: 5px; right: 5px; display: grid; width: 21px; height: 21px; place-items: center; padding: 0; border: 0; border-radius: 6px; background: rgba(0,0,0,.62); color: #fff; font-size: 15px; line-height: 1; opacity: 0; transition: opacity .16s ease; }
.reference-card:hover .reference-delete { opacity: 1; }
.reference-delete:hover { background: var(--red); }
.reference-name { position: absolute; z-index: 2; right: 5px; bottom: 5px; left: 5px; overflow: hidden; color: rgba(255,255,255,.82); font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.single-control button { cursor: default; }
.preview-dialog { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: hidden; border: 1px solid #414146; border-radius: 12px; background: #151517; color: var(--text); box-shadow: 0 25px 70px rgba(0,0,0,.6); }
.preview-dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(4px); }
.preview-dialog-head { display: flex; height: 52px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.preview-dialog-head > div { display: flex; min-width: 0; flex-direction: column; }
.preview-dialog-head strong { color: #d6d6d9; font-size: 11px; font-weight: 600; }
.preview-dialog-head span { color: #6f6f75; font-size: 8px; }
.preview-dialog-body { display: grid; min-height: 300px; max-height: calc(100vh - 82px); place-items: center; overflow: auto; padding: 14px; background: #0d0d0f; }
.preview-dialog-body img { display: block; max-width: 100%; max-height: calc(100vh - 130px); border-radius: 8px; object-fit: contain; }
.preview-empty { color: #6e6e74; font-size: 10px; }

/* Scrollable controls and compact result gallery */
.control-scroll {
  min-height: 0;
  padding-bottom: 78px !important;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.output-scroll { overscroll-behavior: contain; }
.results-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; width: 100%; max-width: none; margin: 0; }
.result-card { min-width: 0; margin: 0; }
.result-head { height: 46px; }
.result-title { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.result-title h3 { max-width: 100%; }
.result-title small { overflow: hidden; color: #5f5f65; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.result-card .media-stage { min-height: 0; cursor: zoom-in; }
.result-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.result-foot { min-height: 38px; padding: 6px 9px; }
.result-meta { min-width: 0; gap: 4px; }
.result-spec { overflow: hidden; color: #66666c; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.result-meta button.icon-button { width: 25px; height: 25px; padding: 0; }
.result-meta button.icon-button svg { width: 13px; height: 13px; }
.play-overlay svg { fill: none; stroke: currentColor; stroke-width: 1.7; }
.result-preview-dialog { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: hidden; border: 1px solid #414146; border-radius: 12px; background: #151517; color: var(--text); box-shadow: 0 25px 70px rgba(0,0,0,.6); }
.result-preview-dialog::backdrop { background: rgba(0,0,0,.82); backdrop-filter: blur(5px); }
.result-preview-body { display: grid; min-height: 420px; max-height: calc(100vh - 82px); place-items: center; overflow: auto; padding: 14px; background: #09090a; }
.result-preview-body video { display: block; width: min(100%, 460px); max-height: calc(100vh - 120px); border-radius: 8px; background: #000; }
.result-preview-art { width: min(430px, 72vw); aspect-ratio: 9 / 16; min-height: 0; border-radius: 10px; box-shadow: 0 18px 45px rgba(0,0,0,.4); }
@media (max-width: 700px) {
  .results-list { grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 10px; }
  .result-title small, .result-spec { display: none; }
  .result-foot { padding: 5px 7px; }
}
@media (max-width: 420px) {
  .results-list { grid-template-columns: 1fr; }
}

@media (min-width: 901px) {
  .control-scroll { max-height: calc(100vh - 117px); }
}

.reference-status { position: absolute; z-index: 3; right: 5px; bottom: 20px; padding: 3px 5px; border-radius: 4px; background: rgba(0,0,0,.7); color: #d6cfff; font-size: 7px; }
.reference-status.error { color: #ff8995; }

/* Minimal generation progress */
.media-stage.generating { background: radial-gradient(circle at 50% 38%, rgba(93,119,199,.16), transparent 38%), linear-gradient(180deg, #121722, #090b10 72%); }
.media-stage.generating .media-art { opacity: .13; filter: blur(24px) saturate(.65); transform: scale(1.12); }
.media-stage.generating .ai-badge { opacity: .65; }
.generation-state { position: absolute; z-index: 4; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 26px; text-align: center; }
.generation-ring { position: relative; display: grid; width: 78px; height: 78px; place-items: center; border-radius: 50%; background: conic-gradient(#9b87ff calc(var(--progress) * 1%), rgba(255,255,255,.08) 0); box-shadow: 0 0 30px rgba(112,93,255,.12); }
.generation-ring::before { position: absolute; inset: 3px; border-radius: 50%; background: #0d0f15; box-shadow: inset 0 0 18px rgba(126,105,255,.08); content: ""; }
.generation-ring::after { position: absolute; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: #b3a3ff; box-shadow: 0 0 10px rgba(155,135,255,.9); content: ""; }
.generation-ring span { position: relative; z-index: 1; color: #e3deff; font-size: 13px; font-weight: 650; letter-spacing: -.02em; }
.generation-state strong { margin-top: 17px; color: #d8d8dc; font-size: 10px; font-weight: 580; letter-spacing: .02em; }
.generation-state p { margin: 5px 0 0; color: #6f7584; font-size: 8px; }
.generation-dots { display: flex; gap: 4px; margin-top: 14px; }
.generation-dots i { width: 3px; height: 3px; border-radius: 50%; background: #777d91; animation: generation-dot 1.3s ease-in-out infinite; }
.generation-dots i:nth-child(2) { animation-delay: .18s; }
.generation-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes generation-dot { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
.generation-scan { position: absolute; right: 12%; left: 12%; height: 1px; background: linear-gradient(90deg, transparent, rgba(162,145,255,.75), transparent); box-shadow: 0 0 12px rgba(162,145,255,.45); animation: generation-scan 2.8s ease-in-out infinite; }
@keyframes generation-scan { 0% { top: 20%; opacity: 0; } 18% { opacity: .8; } 78% { opacity: .5; } 100% { top: 82%; opacity: 0; } }

.team-row { grid-template-columns: minmax(140px, 1fr) 64px 84px 170px 72px !important; }
.team-quota { flex-wrap: nowrap; }
.quota-label { color: #66666c; font-size: 8px; }
.team-quota input.changed { border-color: #7658e8; background: rgba(118,88,232,.08); color: #e4e0ff; }
#poolRemaining.negative { color: #ff727f; }
@media (max-width: 680px) {
  .team-row { grid-template-columns: minmax(110px, 1fr) 145px 65px !important; }
  .quota-label { display: none; }
}

.header-balance { display: flex; height: 32px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid rgba(123,92,255,.22); border-radius: 8px; background: rgba(123,92,255,.08); color: #a99aff; font-size: 9px; white-space: nowrap; }
.header-balance i { width: 6px; height: 6px; border-radius: 50%; background: #8d78ff; box-shadow: 0 0 8px rgba(141,120,255,.7); }
.header-balance b { color: #e5e1ff; font-size: 11px; font-weight: 650; }
.header-balance.empty { border-color: rgba(255,107,120,.25); background: rgba(255,107,120,.07); color: #ff8995; }
.header-balance.empty i { background: #ff727f; box-shadow: 0 0 8px rgba(255,114,127,.6); }
.quota-chip { color: #a99aff !important; font-size: 9px !important; }
.quota-chip.empty { color: #ff8995 !important; }
@media (max-width: 720px) { .header-balance span { display: none; } }

.balance-card { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; margin-bottom: 18px; padding: 14px; border: 1px solid #303034; border-radius: 10px; background: linear-gradient(145deg, #1d1d20, #18181a); }
.balance-card[hidden] { display: none; }
.balance-icon { display: grid; width: 28px; height: 28px; place-items: center; color: #ffa928; }
.balance-icon svg { width: 24px; height: 24px; stroke-width: 1.9; }
.balance-label { margin-top: 5px; color: #9a9aa0; font-size: 10px; }
.balance-value { color: #f2f2f4; font-size: 22px; line-height: 1.1; letter-spacing: -.04em; }
.balance-value b { font-weight: 760; }
.balance-card.empty { border-color: rgba(255,107,120,.25); }
.balance-card.empty .balance-icon, .balance-card.empty .balance-value { color: #ff7b87; }

.header-credit { display: inline-flex; height: 32px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid rgba(255,169,40,.18); border-radius: 8px; background: rgba(255,169,40,.055); color: #8d8d93; font-size: 9px; white-space: nowrap; }
.header-credit svg { width: 15px; height: 15px; color: #ffa928; stroke-width: 1.9; }
.header-credit b { color: #f0f0f2; font-size: 12px; font-weight: 680; }
.header-credit.empty { border-color: rgba(255,107,120,.25); background: rgba(255,107,120,.055); }
.header-credit.empty svg, .header-credit.empty b { color: #ff7b87; }
@media (max-width: 1080px) { .header-credit span { display: none; } }
@media (max-width: 720px) { .header-credit { padding: 0 8px; } }
