:root {
  color-scheme: dark;
  --page: #0a0a13;
  --panel: #11111d;
  --field: #0d0d18;
  --border: #252439;
  --strong-border: #32304a;
  --foreground: #f1effa;
  --muted: #a7a3ba;
  --quiet: #858198;
  --violet: #aa8bff;
  --violet-dark: #7a4dee;
  --green: #65d6ad;
  --amber: #fed092;
  --red: #ff9aab;
  --radius: 20px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse 55% 21rem at 58% 0%, #201733 0%, transparent 100%), var(--page);
  color: var(--foreground);
}
button, input, textarea { color: inherit; font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button, textarea, input:not([type="range"]) { outline-offset: 3px; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 4px; }
button:disabled { opacity: .52; cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
a, button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
p { line-height: 1.55; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; display: inline-block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.quiet { color: var(--quiet); font-size: 12px; }

.topbar { border-bottom: 1px solid #ffffff0c; background: #0b0a15b9; }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1240px;
  min-height: 67px;
  margin-inline: auto;
  padding: 0 34px;
}
.brand, .topbar-actions, .history-link, .connection { display: inline-flex; align-items: center; }
.brand { gap: 11px; text-wrap: nowrap; }
.brand-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #d9c4ff45;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #a27eff, #6436d4);
  box-shadow: 0 5px 15px #734cce46;
}
.brand-icon .icon { width: 21px; height: 21px; }
.brand-name { font-size: 20px; font-weight: 750; letter-spacing: .04em; }
.brand-kind {
  padding-inline-start: 12px;
  border-inline-start: 1px solid #ffffff18;
  color: var(--muted);
  font-size: 12px;
}
.topbar-actions { gap: 23px; }
.public-account { display: inline-flex; align-items: center; min-width: 0; gap: 8px; }
.account-name { max-width: 112px; overflow: hidden; color: var(--foreground); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.history-link { gap: 7px; color: var(--muted); font-size: 13px; }
.history-link:hover { color: var(--foreground); }
.history-link .icon { width: 15px; height: 15px; }
.connection {
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid #ffffff12;
  border-radius: 100px;
  color: var(--muted);
  background: #ffffff06;
  font-size: 12px;
  white-space: nowrap;
}
.status-dot, .job-dot { display: inline-block; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--quiet); }
.connection[data-state="connected"] .status-dot { background: var(--green); box-shadow: 0 0 9px #65d6ad50; }
.connection[data-state="offline"] .status-dot { background: var(--amber); }

.workspace { max-width: 1240px; margin-inline: auto; padding: 45px 34px 52px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 0 0 27px; }
.intro h1 { font-size: clamp(31px, 5vw, 49px); line-height: 1.13; letter-spacing: -.045em; font-weight: 780; }
.headline-dot { margin-left: .07em; color: var(--violet); }
.intro p { margin-top: 10px; color: var(--muted); font-size: 14px; }
.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(280px, 100%);
  padding: 7px 12px;
  border: 1px solid #b793ff36;
  border-radius: 100px;
  background: #a47afa13;
  color: #dac9ff;
  font-size: 12px;
  line-height: 1.45;
}
.engine-badge .icon { width: 14px; height: 14px; }
.engine-badge[data-mode="preview"] { border-color: #dba16e39; background: #d89b5810; color: #ffce99; }
.connection-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 17px;
  padding: 12px 15px;
  border: 1px solid #dc9e6150;
  border-radius: 12px;
  background: #35251e;
  color: #ffe1bc;
  font-size: 13px;
}
.text-button { padding: 3px 0; border: 0; background: transparent; color: inherit; text-decoration: underline; white-space: nowrap; }

.studio-grid { display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr); align-items: start; gap: 22px; }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); box-shadow: 0 18px 35px #0000001b; }
.panel-heading { display: flex; align-items: center; gap: 10px; min-height: 65px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { font-size: 16px; font-weight: 720; letter-spacing: .02em; }
.panel-symbol { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #ad85ff16; color: #bf9aff; }
.panel-symbol .icon { width: 16px; height: 16px; }
#history-count, .format-label { margin-inline-start: auto; }
.format-label { text-wrap: nowrap; color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .055em; }
.format-label span { padding: 0 2px; color: var(--violet); }

#generation-form { display: grid; gap: 21px; padding: 20px 22px 22px; }
.field { min-width: 0; }
.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 25px; margin-bottom: 8px; }
.field-heading label, .field-heading h3 { color: #e6e2f2; font-size: 14px; font-weight: 650; }
.selection-count {
  padding: 4px 8px;
  border: 1px solid #a982ff2b;
  border-radius: 6px;
  background: #ae8bff12;
  color: #ceb9ff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.drop-zone {
  padding: 16px;
  border: 1px dashed #504368;
  border-radius: 13px;
  background: linear-gradient(100deg, #af84ff07, #af84ff03);
  text-align: center;
  transition: background .18s, border-color .18s;
}
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--violet); background: #a579ff13; }
.drop-zone p { margin-top: 8px; }
.upload-button { display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; text-align: left; }
.upload-button strong { display: block; color: #e8dfff; font-size: 13px; font-weight: 670; }
.upload-detail { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.upload-icon { display: grid; width: 37px; height: 37px; place-items: center; border: 1px solid #aa86fd37; border-radius: 11px; background: #ad83ff17; color: #c09eff; }
.upload-status { display: grid; gap: 4px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.upload-status p[data-state="error"], .form-error, .job-warning { color: var(--red); }
.image-hint { margin: 11px 0 7px; color: var(--muted); font-size: 11px; }
#image-error { margin: 8px 0; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(108px, 100%), 1fr)); gap: 8px; }
.image-grid:empty { display: none; }
.asset { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: #0d0c16; }
.asset[data-selected="true"] { border-color: #a585fa; }
.asset-select { position: relative; display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; margin: 0; padding: 0; border: 0; background: #222035; }
.asset-select:focus-visible { z-index: 1; outline-offset: -4px; }
.asset-image { display: block; width: 100%; height: 100%; object-fit: cover; }
.asset-number, .asset-check { position: absolute; inset-block-start: 5px; display: grid; align-content: center; min-width: 19px; height: 19px; padding: 0 4px; border: 1px solid #ffffff3a; border-radius: 5px; background: #0f0a19de; color: #fff; font-size: 10px; line-height: 1; }
.asset-number { inset-inline-start: 5px; }
.asset-check { inset-inline-end: 5px; opacity: .7; }
.asset-check .icon { width: 10px; height: 10px; opacity: 0; stroke-width: 2.5; }
.asset[data-selected="true"] .asset-check { opacity: 1; background: #8a5cf5; }
.asset[data-selected="true"] .asset-check .icon { opacity: 1; }
.asset-footer { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 4px; padding: 4px 3px 4px 6px; }
.asset-name { overflow: hidden; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.asset-actions { display: flex; gap: 2px; }
.icon-button { display: inline-grid; width: 28px; height: 28px; flex: none; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); }
.icon-button .icon { width: 15px; height: 15px; }
.icon-button:hover { border-color: #b68dfc42; background: #b486ff14; color: #e9ddff; }
.asset-actions .icon-button { width: 23px; height: 23px; }
.asset-delete:hover { border-color: #ff9aab47; background: #ff9aab11; color: var(--red); }

textarea {
  width: 100%;
  min-height: 91px;
  padding: 11px 13px;
  border: 1px solid var(--strong-border);
  border-radius: 11px;
  resize: vertical;
  background: var(--field);
  color: var(--foreground);
  font-size: 13px;
  line-height: 1.65;
}
textarea::placeholder { color: #9189aa; opacity: 1; }
textarea:focus-visible { outline-offset: 2px; }
.duration-input { display: flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--strong-border); border-radius: 7px; background: var(--field); color: var(--muted); font-size: 12px; }
.duration-input input { width: 55px; padding: 2px 0; border: 0; background: transparent; color: var(--foreground); font-size: 13px; font-variant-numeric: tabular-nums; }
input[type="range"] {
  --position: 30%;
  width: 100%;
  height: 17px;
  margin: 2px 0 0;
  padding: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 20px; background: linear-gradient(to right, #a387ff 0 var(--position), #312b46 var(--position) 100%); }
input[type="range"]::-moz-range-track { height: 5px; border-radius: 20px; background: linear-gradient(to right, #a387ff 0 var(--position), #312b46 var(--position) 100%); }
input[type="range"]::-webkit-slider-thumb { width: 15px; height: 15px; appearance: none; margin-top: -5px; border: 2px solid #e1d3ff; border-radius: 50%; background: #a77fff; box-shadow: 0 0 0 3px #9f74ff27; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 2px solid #e1d3ff; border-radius: 50%; background: #a77fff; box-shadow: 0 0 0 3px #9f74ff27; }
.range-labels { display: flex; justify-content: space-between; margin-top: 5px; color: var(--quiet); font-size: 11px; }
.composer-footer { display: grid; gap: 9px; padding-top: 1px; }
.generate-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.generate-actions button { flex: 1 1 135px; min-height: 43px; }
.generate-notes :not(:empty) + :not(:empty) { margin-top: 4px; }
.engine-note, .form-error { font-size: 12px; }
.engine-note { color: var(--muted); }
.engine-note[data-mode="preview"] { color: #f4c995; }
.worker-status { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--field); font-size: 12px; }
.worker-status .status-dot { margin-top: .35em; background: var(--amber); }
.worker-status[data-state="ready"] .status-dot { background: var(--green); }
.worker-status[data-state="preparing"] .status-dot { background: var(--violet); }
.worker-status p { color: var(--muted); overflow-wrap: anywhere; }
.worker-status p:not(:empty) { margin-top: 3px; }
.colab-pairing { margin: 10px 0; font-size: 12px; }
.colab-pairing-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.colab-pairing-actions a { color: #d6baff; }
.colab-pairing [readonly] { width: 100%; margin: 6px 0; padding: 7px 9px; font: inherit; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 675; }
.primary-button {
  min-height: 43px;
  padding: 8px 16px;
  color: white;
  border-color: #bb9bff68;
  background: linear-gradient(110deg, #8760f2 0%, #7445de 68%, #8353f0 100%);
  box-shadow: 0 8px 19px #7647e341;
}
.primary-button:hover:not(:disabled) { background: linear-gradient(110deg, #9672ff, #8753ef); }
.primary-button .icon { width: 16px; height: 16px; }
.secondary-button { min-height: 34px; padding: 4px 10px; border-color: #9b78f254; background: #946bfa16; color: #e0cdff; white-space: nowrap; }
.secondary-button:hover:not(:disabled) { background: #946bfa2b; }
.secondary-button .icon { width: 15px; height: 15px; }

.login-shell { display: grid; min-height: 100vh; min-height: 100svh; place-items: center; padding: 26px 18px; }
.login-card { width: min(100%, 420px); padding: clamp(20px, 6vw, 34px); }
.login-heading { display: grid; justify-items: start; gap: 8px; }
.login-heading h1 { font-size: clamp(24px, 6vw, 31px); line-height: 1.2; }
.login-heading p { color: var(--muted); font-size: 13px; }
.login-form { display: grid; gap: 15px; margin-top: 25px; }
.login-field { display: grid; gap: 6px; }
.login-field label { color: #e6e2f2; font-size: 13px; font-weight: 650; }
.login-field input { width: 100%; min-height: 43px; padding: 8px 11px; border: 1px solid var(--strong-border); border-radius: 9px; background: var(--field); }
.login-form button { margin-top: 3px; }
.login-feedback { color: var(--muted); font-size: 13px; }
.login-feedback:not(:empty) { margin-top: 12px; }
.login-feedback.form-error { color: var(--red); }

.output { overflow: hidden; }
.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 409px;
  padding: 23px 18px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 66% 68% at 50% 48%, #28203e 0%, #161327 54%, transparent 100%),
    linear-gradient(145deg, #10101c, #0c0c16);
}
.preview-stage::before {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#bda4e547 1px, transparent 1px);
  background-size: 21px 21px;
  mask-image: radial-gradient(ellipse 75% 60% at 50% 48%, #000 0, transparent 93%);
  opacity: .34;
  content: "";
  pointer-events: none;
}
.preview-frame {
  position: relative;
  display: grid;
  overflow: hidden;
  width: min(100%, 202px);
  aspect-ratio: 9 / 16;
  place-items: center;
  border: 1px solid #9d7be152;
  border-radius: 20px;
  background: radial-gradient(ellipse at 52% 40%, #282042 0%, #17142a 54%, #0e0e1c 100%);
  box-shadow: 0 16px 40px #090611a6, 0 0 0 5px #7f59c411;
}
.preview-placeholder { padding: 12px; text-align: center; }
.preview-icon { display: grid; width: 49px; height: 49px; margin: 0 auto 13px; place-items: center; border: 1px solid #ae89ff5e; border-radius: 50%; color: #c49dff; background: #b685ff13; }
.preview-icon .icon { width: 22px; height: 22px; }
.preview-placeholder strong { display: block; color: #eae0fb; font-size: 14px; font-weight: 650; }
.preview-placeholder p { margin-top: 5px; color: #ada2c2; font-size: 11px; }
#video-player { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #08080d; }
.output-footer { display: grid; gap: 9px; min-height: 71px; padding: 14px 22px 17px; border-top: 1px solid var(--border); }
.progress-heading, .progress-state, .output-actions { display: flex; align-items: center; }
.progress-heading, .output-actions { justify-content: space-between; gap: 9px; }
.progress-state { gap: 7px; color: var(--muted); font-size: 12px; }
#job-phase { overflow-wrap: anywhere; }
.job-dot[data-state="active"] { background: var(--violet); box-shadow: 0 0 8px #b087ff68; }
.job-dot[data-state="success"] { background: var(--green); }
.job-dot[data-state="failure"] { background: var(--red); }
.progress-value { color: #cbb4ff; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.progress-track { height: 5px; overflow: hidden; border-radius: 99px; background: #2d263d; }
#progress-fill { width: 0; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #7e54e9, #c397ff); transition: width .24s ease; }
.job-warning { font-size: 12px; }
.output-actions { flex-wrap: wrap; padding-top: 2px; }
 
.history { margin-top: 22px; scroll-margin-top: 16px; }
.history-empty { display: flex; gap: 9px; align-items: center; justify-content: center; min-height: 95px; padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }
.history-empty .icon { color: var(--violet); opacity: .68; }
.history-list { padding: 2px 15px 7px; }
.history-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto; align-items: center; gap: 13px; padding: 12px 7px; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }
.history-symbol { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #a783f02a; border-radius: 8px; background: #aa83ff12; color: var(--violet); }
.history-description { display: grid; gap: 4px; min-width: 0; }
.history-prompt { overflow: hidden; color: #e9e3f5; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.history-meta { overflow: hidden; color: var(--quiet); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.history-status { padding: 4px 7px; border: 1px solid var(--border); border-radius: 99px; background: #ffffff0a; color: var(--muted); font-size: 11px; white-space: nowrap; }
.history-status[data-state="succeeded"] { border-color: #69cfaa36; background: #5aca9d13; color: #98e4c6; }
.history-status[data-state="failed"] { border-color: #ff9aab39; background: #ff9aab12; color: var(--red); }
.history-status[data-state="running"], .history-status[data-state="queued"] { border-color: #a680f941; background: #a680f914; color: #d8c0ff; }
.history-actions { display: flex; gap: 5px; }
.history-actions .icon-button { border-color: var(--border); }
.history-row[data-current="true"] .history-view { border-color: #aa83ff80; background: #aa83ff1a; color: #dbc7ff; }

.image-dialog { width: min(calc(100% - 30px), 690px); max-height: calc(100dvh - 30px); margin: auto; padding: 0; overflow: auto; border: 1px solid var(--strong-border); border-radius: 15px; color: var(--foreground); background: #10101a; }
.image-dialog::backdrop { background: #050409cd; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.dialog-heading h2 { overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.image-dialog img { display: block; max-width: 100%; max-height: calc(100dvh - 105px); margin: 0 auto; object-fit: contain; }

@media (max-width: 790px) {
  .workspace, .topbar-inner { padding-inline: 19px; }
  .studio-grid { gap: 14px; }
  .panel-heading { padding-inline: 16px; }
  #generation-form, .output-footer { padding-inline: 16px; }
  .preview-stage { min-height: 392px; }
}
@media (max-width: 620px) {
  .topbar-inner { min-height: 61px; }
  .topbar-actions { gap: 12px; }
  .brand-kind, .history-link .icon { display: none; }
  .workspace { padding-top: 29px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 20px; }
  .intro p { font-size: 13px; }
  .studio-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-stage { min-height: 380px; }
  .preview-frame { width: 180px; }
  .history { margin-top: 14px; }
  .history-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; padding-inline: 0; }
  .history-symbol { display: none; }
  .history-list { padding-inline: 10px; }
}
@media (max-width: 520px) {
  body[data-mode="server"] .topbar-inner { flex-wrap: wrap; gap: 9px; padding-block: 10px; }
  body[data-mode="server"] .topbar-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  body[data-mode="server"] .public-account { margin-inline-start: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0s !important; }
}
