:root {
  color-scheme: light;
  --paper: #f7f7f8;
  --surface: #ffffff;
  --surface-soft: #f2f2f3;
  --ink: #202123;
  --muted: #6e6e80;
  --line: #e5e5e5;
  --line-strong: #d1d5db;
  --accent: #10a37f;
  --accent-dark: #0d8f70;
  --green: #10a37f;
  --amber: #f4ac36;
  --red: #ef4146;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.brand strong { font-size: 16px; line-height: 1; font-weight: 650; }
.brand-title { display: inline-block; color: transparent; background: linear-gradient(110deg, #ff3d81, #ff8a00, #ffd400, #22c55e, #06b6d4, #6366f1, #d946ef, #ff3d81); background-size: 260% 100%; background-clip: text; -webkit-background-clip: text; animation: brand-spectrum 6s linear infinite; }
.brand small, .eyebrow, .section-title small { font-size: 9px; color: var(--muted); font-weight: 600; }

.brand-mark {
  width: 34px;
  height: 34px;
  display: block;
  flex: 0 0 34px;
  object-fit: cover;
  padding: 0;
  border-radius: 8px;
  background: #111;
}

.topbar-meta { display: flex; align-items: center; gap: 18px; }
.topbar-meta a { color: var(--text); text-decoration: none; font-size: 12px; }
.topbar-meta a:hover { color: var(--blue); }
#studioAdmin[hidden] { display: none !important; }
.api-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.api-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.api-state.ready i { background: var(--green); box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.1); }
.api-state.missing i { background: var(--red); box-shadow: 0 0 0 4px rgba(239, 65, 70, 0.1); }

.workspace { display: grid; grid-template-columns: 292px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.model-rail { padding: 24px 16px; border-right: 1px solid var(--line); background: #f9f9fa; }
.rail-heading, .studio-heading, .history-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.rail-heading h1, .studio-heading h2, .history-heading h2 { margin: 5px 0 0; font-size: 21px; line-height: 1.2; font-weight: 650; }
.model-count { min-width: 34px; padding: 5px 8px; border-radius: 999px; text-align: center; background: #ececf1; color: var(--ink); font-size: 11px; }

.search-box { height: 42px; display: flex; align-items: center; gap: 8px; margin: 20px 0 14px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; transition: border-color 160ms, box-shadow 160ms; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.12); }
.search-box span { color: var(--muted); font-size: 20px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }

.model-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 194px); overflow-y: auto; padding: 1px 7px 10px 1px; scrollbar-width: thin; scrollbar-color: #c7c7d0 transparent; }
.model-list::-webkit-scrollbar { width: 7px; }
.model-list::-webkit-scrollbar-thumb { border-radius: 8px; background: #c7c7d0; }
.model-item { width: 100%; height: 176px; min-height: 176px; display: flex; flex-direction: column; gap: 7px; overflow: hidden; padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; color: var(--ink); transition: border-color 160ms, box-shadow 160ms, background 160ms; }
.model-item:hover { border-color: #b8bcc5; background: #fff; }
.model-item.active { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.model-item-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.model-item strong { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.model-item .price { flex: 0 0 auto; padding: 3px 6px; border-radius: 5px; background: #eaf7f3; font-size: 11px; font-weight: 700; color: var(--accent-dark); }
.model-capability { color: var(--ink); font-size: 10px; font-weight: 600; line-height: 1.55; }
.model-description { flex: 1; min-height: 0; overflow-y: scroll; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 7px 7px 7px 8px; border-left: 2px solid #e5e7eb; border-radius: 0 5px 5px 0; background: #f7f7f8; color: var(--muted); font-size: 10px; line-height: 1.55; white-space: normal; overflow-wrap: anywhere; scrollbar-width: thin; scrollbar-color: #b9bdc6 transparent; }
.model-description::-webkit-scrollbar { width: 6px; }
.model-description::-webkit-scrollbar-track { background: transparent; }
.model-description::-webkit-scrollbar-thumb { border-radius: 6px; background: #b9bdc6; }
.model-health { margin-top: auto; padding-top: 2px; color: var(--green); font-size: 9px; font-weight: 700; }
.model-empty { padding: 24px 8px; color: var(--muted); text-align: center; }

.studio { min-width: 0; padding: 28px 32px 50px; }
.studio-heading { margin-bottom: 22px; }
.studio-heading h2 { font-size: 27px; }
.heading-stats { display: flex; align-items: center; gap: 8px; }
.stat-chip { display: flex; flex-direction: column; min-width: 80px; padding: 7px 10px; border-left: 1px solid var(--line); }
.stat-chip span { color: var(--muted); font-size: 9px; font-weight: 700; }
.stat-chip strong { margin-top: 3px; font-size: 12px; }

.studio-grid { display: grid; grid-template-columns: minmax(440px, 1.04fr) minmax(360px, 0.96fr); overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.composer { min-width: 0; padding: 26px; border-right: 1px solid var(--line); }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.section-title > span:first-child { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: #eaf7f3; color: var(--accent-dark); font-size: 10px; font-weight: 700; }
.section-title > div { display: flex; flex-direction: column; gap: 1px; }
.section-title strong { font-size: 14px; }
.control-title { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.material-total { margin-left: auto; color: var(--muted); font-size: 11px; }

.prompt-field { position: relative; display: block; }
.prompt-editor { width: 100%; min-height: 132px; max-height: 260px; overflow-y: auto; padding: 15px; border: 1px solid var(--line-strong); border-radius: 8px; outline: none; background: #fff; color: var(--ink); line-height: 1.7; white-space: pre-wrap; transition: border-color 160ms, box-shadow 160ms; }
.prompt-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.12); }
.prompt-editor:empty::before { content: attr(data-placeholder); color: #9a9da3; pointer-events: none; }
.prompt-token { display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; margin: 0 2px; padding: 2px 5px 2px 3px; border: 1px solid #b9e5d8; border-radius: 5px; background: #effaf7; color: var(--accent-dark); font-size: 11px; font-weight: 700; line-height: 1.35; }
.prompt-token img { width: 18px; height: 18px; border-radius: 3px; object-fit: cover; }
.prompt-token button { width: 15px; height: 15px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; }
.prompt-token button:hover { background: #d7eee8; color: var(--ink); }
.prompt-field > span { position: absolute; right: 11px; bottom: 9px; color: var(--muted); font-size: 10px; }
.prompt-expand {
  position: absolute;
  z-index: 3;
  right: 9px;
  bottom: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 8px;
  background: rgba(255,255,255,.54);
  box-shadow: inset 0 1px rgba(255,255,255,.88), 0 2px 6px rgba(66,90,120,.08);
  color: #52708c;
  font-size: 15px;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.prompt-expand:hover { background: rgba(226,243,255,.86); color: #176bc5; transform: translateY(-1px); }
.prompt-field > #promptCount { right: 44px; }
.prompt-field.expanded .prompt-editor { min-height: min(500px, 58vh); max-height: 58vh; }
.prompt-field.expanded .prompt-expand { background: rgba(213,239,255,.84); color: #176bc5; }
.mention-menu { position: absolute; z-index: 15; left: 10px; right: 10px; bottom: 38px; max-height: 220px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 10px 28px rgba(0,0,0,0.13); }
.mention-menu button { width: 100%; display: grid; grid-template-columns: 34px minmax(0,1fr); align-items: center; gap: 9px; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.mention-menu button:hover, .mention-menu button.active { background: #f0faf7; }
.mention-thumb { width: 32px; height: 32px; display: grid; place-items: center; overflow: hidden; border-radius: 5px; background: #eef0f1; color: var(--accent-dark); }
.mention-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mention-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mention-menu button strong { color: var(--accent-dark); font-size: 11px; }
.mention-menu button small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.mention-empty { padding: 18px 10px; color: var(--muted); text-align: center; font-size: 11px; }
.prompt-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.prompt-presets button, .material-tabs button, .history-heading button { border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.prompt-presets button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: #f7f7f8; }
.prompt-presets button:hover { color: var(--accent-dark); border-color: #9bd7c7; background: #f0faf7; }

.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.control-block { min-width: 0; }
.control-block > label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.control-block:first-child { grid-column: 1 / -1; }
/* Liquid-glass controls: keep the existing native behavior while adding a frosted, lifted surface. */
.segmented {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--ratio-count, 3), minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(232, 239, 247, 0.8), rgba(214, 225, 237, 0.58));
  box-shadow: inset 0 1px 1px rgba(255,255,255,.92), inset 0 -1px 2px rgba(139,157,180,.16), 0 7px 18px rgba(83,104,132,.09);
  backdrop-filter: blur(16px) saturate(145%);
  touch-action: none;
  cursor: grab;
}
.segmented::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,.56), transparent 30%, transparent 72%, rgba(255,255,255,.22));
}
.segmented.dragging { cursor: grabbing; }
.ratio-glider {
  position: absolute;
  z-index: 1;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--ratio-count, 3));
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.96);
  border-radius: 11px;
  background: linear-gradient(140deg, rgba(255,255,255,.97), rgba(236,246,255,.68));
  box-shadow: 0 8px 17px rgba(67,100,141,.2), inset 0 1px 2px rgba(255,255,255,1), inset 0 -2px 3px rgba(114,148,188,.14);
  will-change: transform;
}
.ratio-glider::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  right: 10px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,.86), rgba(255,255,255,.08));
}
.ratio-glider::after {
  content: "";
  position: absolute;
  right: 9px;
  bottom: 5px;
  width: 18px;
  height: 9px;
  border-radius: 50%;
  background: rgba(61,159,255,.15);
  filter: blur(5px);
}
.ratio-glider-shine {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,.55), transparent 30%, transparent 72%, rgba(255,255,255,.22));
}
.segmented button {
  position: relative;
  z-index: 2;
  min-width: 0;
  height: 38px;
  padding: 0 4px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #65758a;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 160ms ease, transform 160ms ease;
}
.segmented button:hover { color: #2f73c5; }
.segmented button.active {
  color: #1672d2;
  transform: scale(1.03);
}

.duration-control {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr) 58px;
  align-items: center;
  min-height: 46px;
  gap: 12px;
  padding: 0 12px 0 14px;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(255,255,255,.72), rgba(226,236,246,.56));
  box-shadow: inset 0 1px 1px rgba(255,255,255,.92), inset 0 -1px 2px rgba(139,157,180,.14), 0 7px 18px rgba(83,104,132,.08);
  backdrop-filter: blur(16px) saturate(145%);
}
.duration-control::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 13px;
  pointer-events: none;
  background: linear-gradient(110deg, rgba(255,255,255,.45), transparent 34%, transparent 78%, rgba(255,255,255,.18));
}
.duration-control input[type="range"] {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 7px;
  margin: 0;
  border: 1px solid rgba(255,255,255,.7);
  background: linear-gradient(to right, #4a9eff 0 var(--range-progress, 0%), rgba(157,177,200,.42) var(--range-progress, 0%) 100%);
  box-shadow: inset 0 1px 2px rgba(76,101,130,.18), 0 1px rgba(255,255,255,.7);
  outline: 0;
  appearance: none;
}
.duration-control input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  appearance: none;
  border: 3px solid rgba(255,255,255,.94);
  background: linear-gradient(145deg, #7dc2ff, #3287ed);
  box-shadow: 0 4px 10px rgba(40,112,204,.28), 0 0 0 1px rgba(54,133,223,.5), inset 0 1px 2px rgba(255,255,255,.72);
}
.duration-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255,255,255,.94);
  background: linear-gradient(145deg, #7dc2ff, #3287ed);
  box-shadow: 0 4px 10px rgba(40,112,204,.28), 0 0 0 1px rgba(54,133,223,.5), inset 0 1px 2px rgba(255,255,255,.72);
}
.duration-control output { position: relative; z-index: 1; color: #315f91; text-align: right; font-size: 12px; font-weight: 750; }
.split-control select { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px; outline: 0; background: #fff; color: var(--ink); }

.switch-control { min-height: 50px; grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch-control > span { display: flex; flex-direction: column; gap: 2px; }
.switch-control small { color: var(--muted); }
.switch-control input { position: absolute; opacity: 0; }
.switch-control i { position: relative; width: 42px; height: 22px; border: 1px solid var(--line-strong); border-radius: 11px; background: #e4e7e3; transition: background 160ms; }
.switch-control i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 160ms; }
.switch-control input:checked + i { background: var(--green); border-color: var(--green); }
.switch-control input:checked + i::after { transform: translateX(20px); }

.material-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.material-tabs button { padding: 8px 11px; border-bottom: 2px solid transparent; }
.material-tabs button.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 700; }
.material-tabs span { margin-left: 4px; color: var(--muted); }
.material-panel { padding-top: 11px; }
.file-entry { display: block; }
.file-picker { min-height: 54px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px dashed #b6c2bd; border-radius: 8px; background: #fafcfb; color: var(--ink); cursor: pointer; }
.file-picker:hover { border-color: var(--accent); background: #f0faf7; }
.file-picker-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: #eaf7f3; color: var(--accent-dark); font-size: 17px; }
.file-picker span:last-child { display: flex; flex-direction: column; gap: 2px; }
.file-picker small { color: var(--muted); font-size: 10px; }
.material-list { display: flex; flex-direction: column; gap: 6px; margin-top: 9px; }
.material-row { position: relative; min-width: 0; display: grid; grid-template-columns: 38px minmax(0,1fr) 30px; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; background: #f7f7f8; }
.material-thumb { width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden; padding: 0; border: 0; border-radius: 5px; background: #e7ebea; color: var(--accent-dark); cursor: zoom-in; }
.material-thumb img { width: 100%; height: 100%; object-fit: cover; }
.material-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.material-info strong { color: var(--accent-dark); font-size: 10px; }
.material-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.material-upload-status { display: block; margin-top: 1px; font-size: 9px; font-style: normal; }
.material-upload-status.uploading { color: #2e85d3; }
.material-upload-status.ready { color: var(--green); }
.material-upload-status.error { color: var(--red); }
.material-row button { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); font-size: 16px; }
.material-row > button[data-remove-material] { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; display: grid; place-items: center; opacity: 0; border-radius: 4px; background: rgba(32,33,35,.78); color: #fff; font-size: 14px; transition: opacity 140ms; }
.material-row:hover > button[data-remove-material], .material-row:focus-within > button[data-remove-material] { opacity: 1; }
.material-row .material-thumb { width: 38px; }
.material-popover { position: absolute; z-index: 12; left: 48px; bottom: calc(100% + 8px); display: none; width: 230px; max-height: 190px; padding: 5px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 10px 28px rgba(0,0,0,.18); }
.material-preview-wrap:hover .material-popover { display: block; }
.material-popover img, .material-popover video { display: block; width: 100%; max-height: 180px; object-fit: contain; background: #101211; }
.popover-file { min-height: 120px; display: grid; place-items: center; gap: 8px; color: var(--accent-dark); font-size: 26px; }
.popover-file span { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.material-empty { padding: 10px 2px; color: var(--muted); font-size: 11px; }
.frame-slots { display: flex; flex-direction: column; gap: 8px; }
.frame-slot { display: grid; grid-template-columns: 72px minmax(0,1fr) 52px auto; align-items: center; gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: #f7f7f8; }
.frame-slot.disabled { opacity: 0.48; }
.frame-slot-label { display: flex; flex-direction: column; gap: 2px; }
.frame-slot-label strong { font-size: 11px; }
.frame-slot-label span { color: var(--accent-dark); font-size: 9px; }
.frame-slot input[type=file] { display: none; }
.frame-file-picker { min-width: 0; height: 42px; display: flex; align-items: center; gap: 7px; overflow: hidden; padding: 4px 7px; border: 1px dashed var(--line-strong); border-radius: 6px; background: #fff; color: var(--muted); font-size: 10px; cursor: pointer; }
.frame-file-picker img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; }
.frame-file-picker span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame-slot > .frame-remove { width: 30px; padding: 0; background: #ececf1; color: var(--muted); font-size: 15px; }
.frame-hint { margin: 7px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

.submit-band { display: flex; align-items: stretch; justify-content: space-between; gap: 18px; margin: 28px -26px -26px; padding: 18px 26px; border-top: 1px solid var(--line); background: #f7f7f8; }
.submit-band > div { display: flex; flex-direction: column; justify-content: center; }
.submit-band > div span { color: var(--muted); font-size: 10px; }
.submit-band > div strong { margin-top: 3px; font-size: 17px; }
.generate-button { min-width: 184px; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 20px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.generate-button:hover { background: var(--accent-dark); }
.generate-button:active { transform: translateY(1px); }
.button-icon { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,0.55); border-radius: 50%; font-size: 9px; }
.button-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.button-copy strong { font-size: 13px; }
.button-copy small { font-size: 8px; opacity: 0.75; }
.generate-button.loading .button-icon { color: transparent; border-style: dashed; animation: spin 800ms linear infinite; }

.preview { min-width: 0; display: flex; flex-direction: column; background: #202123; color: #fff; }
.preview-stage { position: relative; min-height: 460px; flex: 1; overflow: hidden; background: #111; }
.empty-preview { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; background-image: linear-gradient(180deg, rgba(5,8,6,0.08), rgba(5,8,6,0.74)), url("https://images.unsplash.com/photo-1485846234645-a62644f84728?auto=format&fit=crop&w=1600&q=82"); background-size: cover; background-position: center; }
.preview-index { align-self: flex-end; padding: 4px 7px; border: 1px solid rgba(255,255,255,0.55); font-size: 9px; }
.empty-copy { display: flex; flex-direction: column; gap: 7px; }
.empty-copy span { font-size: 9px; opacity: 0.7; }
.empty-copy strong { max-width: 360px; font-size: 30px; line-height: 1.15; }
.processing-preview { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 13px; background: #202123; }
.processing-orbit { position: relative; width: 112px; height: 112px; display: grid; place-items: center; border: 1px solid #4b514d; border-radius: 50%; }
.processing-orbit::before, .processing-orbit::after { content: ""; position: absolute; inset: 11px; border: 1px dashed #5d645f; border-radius: 50%; animation: spin 8s linear infinite; }
.processing-orbit::after { inset: 25px; border-style: solid; border-color: var(--accent) transparent var(--accent) transparent; animation-duration: 2.2s; animation-direction: reverse; }
.processing-orbit i { position: absolute; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 15px var(--accent); }
.processing-orbit span { font-size: 22px; font-weight: 800; }
.processing-orbit span::after { content: "%"; margin-left: 2px; font-size: 9px; color: #969c98; }
.processing-preview > strong { font-size: 14px; }
.processing-preview > span { color: #929894; font-size: 10px; }
#videoPlayer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #050605; }
.hidden { display: none !important; }

.preview-toolbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-top: 1px solid #323733; }
.preview-toolbar > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.status-label { color: #9da39f; font-size: 9px; }
.preview-toolbar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.preview-actions { display: flex; gap: 7px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #4a504c; background: transparent; color: #fff; text-decoration: none; font-size: 16px; }
.icon-button:hover { border-color: #fff; }
.icon-button.disabled { pointer-events: none; opacity: 0.35; }
.preview-details { display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid #323733; }
.preview-details div { min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 13px 15px; border-right: 1px solid #323733; }
.preview-details div:last-child { border-right: 0; }
.preview-details span { color: #858b87; font-size: 9px; }
.preview-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }

.history-section { margin-top: 34px; }
.history-heading { padding-bottom: 14px; border-bottom: 1px solid var(--line-strong); }
.history-heading h2 { font-size: 20px; }
.history-heading button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #fff; }
.history-table { min-width: 0; }
.history-row { display: grid; grid-template-columns: 112px minmax(150px,1.5fr) minmax(170px,2fr) 90px 90px 72px; align-items: center; gap: 12px; min-height: 62px; padding: 9px 5px; border-bottom: 1px solid var(--line); }
.history-row:hover { background: #f7f7f8; }
.history-row > * { min-width: 0; }
.history-model, .history-time, .history-meta { color: var(--muted); font-size: 10px; }
.history-prompt { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-status { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; }
.history-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.history-status.completed i { background: var(--green); }
.history-status.failed i { background: var(--red); }
.history-actions { display: flex; justify-content: flex-end; gap: 3px; }
.history-actions button { width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); }
.history-empty { padding: 34px 5px; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { width: min(360px, calc(100vw - 40px)); padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,0.12); animation: toast-in 180ms ease-out; }
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes brand-spectrum { from { background-position: 0% 50%; } to { background-position: 260% 50%; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 250px minmax(0,1fr); }
  .studio { padding: 26px 24px 44px; }
  .studio-grid { grid-template-columns: 1fr; }
  .composer { border-right: 0; }
  .preview-stage { min-height: 420px; }
  .history-row { grid-template-columns: 90px minmax(130px,1fr) minmax(160px,1.7fr) 82px 62px; }
  .history-time { display: none; }
}

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 16px; }
  .brand small { display: none; }
  .topbar-meta { gap: 8px; }
  .api-state span { display: none; }
  .workspace { display: block; }
  .model-rail { padding: 18px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-heading { align-items: center; }
  .rail-heading h1 { font-size: 19px; }
  .search-box { margin: 14px 0 10px; }
  .model-list { max-height: none; flex-direction: row; overflow-x: auto; padding: 0 0 7px; }
  .model-item { min-width: 276px; width: 276px; height: 170px; min-height: 170px; }
  .studio { padding: 20px 14px 36px; }
  .studio-heading { align-items: flex-start; flex-direction: column; }
  .studio-heading h2 { font-size: 24px; }
  .heading-stats { width: 100%; overflow-x: auto; }
  .stat-chip { flex: 1 0 78px; }
  .composer { padding: 20px 16px; }
  .prompt-editor { min-height: 150px; }
  .control-grid { grid-template-columns: 1fr; }
  .control-block:first-child, .switch-control { grid-column: auto; }
  .frame-slot { grid-template-columns: 64px minmax(0,1fr) 48px auto; }
  .submit-band { margin: 24px -16px -20px; padding: 14px 16px 20px; flex-direction: column; }
  .generate-button { width: 100%; }
  .preview-stage { min-height: 390px; }
  .empty-copy strong { font-size: 26px; }
  .history-row { grid-template-columns: 82px minmax(0,1fr) 76px 62px; gap: 7px; }
  .history-model { display: none; }
  .history-meta { font-size: 9px; }
}

@media (max-width: 430px) {
  .frame-slot { grid-template-columns: 1fr 48px auto; }
  .frame-slot-label { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .material-tabs { overflow-x: auto; }
  .material-tabs button { flex: 0 0 auto; }
}

.theme-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 50%;
  background: rgba(255,255,255,.43);
  box-shadow: inset 0 1px rgba(255,255,255,.88), 0 3px 10px rgba(65,91,121,.08);
  color: #38546f;
  font-size: 15px;
  line-height: 1;
  transition: transform 180ms ease, background 220ms ease, color 220ms ease, border-color 220ms ease;
}
.theme-toggle:hover { transform: translateY(-1px); background: rgba(255,255,255,.7); }
.theme-toggle:active { transform: translateY(0); }
.theme-toggle span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #fff, #d5e8fb); box-shadow: 0 2px 5px rgba(52,83,118,.18), inset 0 1px #fff; }

html[data-theme="dark"] {
  --paper: #101a28;
  --surface: rgba(29, 46, 69, .58);
  --surface-soft: rgba(17, 33, 52, .46);
  --ink: #edf5ff;
  --muted: #a9bfd4;
  --line: rgba(204, 232, 255, .14);
  --line-strong: rgba(204, 232, 255, .2);
  --accent: #64bcff;
  --accent-dark: #a8ddff;
  --shadow: 0 20px 48px rgba(0, 4, 12, .32), inset 0 1px rgba(255, 255, 255, .1);
  background: #101a28;
}
html[data-theme="dark"] body {
  color: #edf5ff;
  background: linear-gradient(135deg, #101a28 0%, #1c2940 54%, #142b2c 100%);
}
html[data-theme="dark"] .app-shell::before { opacity: .2; }
html[data-theme="dark"] .topbar {
  border-color: rgba(190,224,255,.18);
  background: rgba(27,43,64,.68);
  box-shadow: 0 12px 34px rgba(0,5,14,.36), inset 0 1px rgba(230,246,255,.13), inset 0 -1px rgba(0,0,0,.16);
}
html[data-theme="dark"] .topbar::before { background: linear-gradient(112deg, rgba(187,227,255,.12), rgba(255,255,255,.01) 50%, rgba(171,238,219,.06)); }
html[data-theme="dark"] .brand small,
html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .section-title small { color: #9db4cc; }
html[data-theme="dark"] .api-state,
html[data-theme="dark"] .theme-toggle {
  border-color: rgba(204,232,255,.21);
  background: rgba(73,103,136,.42);
  box-shadow: inset 0 1px rgba(255,255,255,.14), 0 4px 12px rgba(0,0,0,.18);
  color: #dcecff;
}
html[data-theme="dark"] .theme-toggle:hover { background: rgba(90,127,164,.56); }
html[data-theme="dark"] .theme-toggle span { background: linear-gradient(145deg, #6589b0, #2b425e); box-shadow: 0 2px 6px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.22); }
html[data-theme="dark"] .model-rail {
  border-color: rgba(193,225,255,.15);
  background: rgba(27,44,65,.56);
  box-shadow: 0 18px 40px rgba(0,4,12,.3), inset 0 1px rgba(235,248,255,.11);
}
html[data-theme="dark"] .model-rail::before,
html[data-theme="dark"] .studio-grid::before { background: linear-gradient(112deg, rgba(190,230,255,.11), rgba(255,255,255,.01) 52%, rgba(170,230,212,.06)); }
html[data-theme="dark"] .model-count,
html[data-theme="dark"] .search-box {
  border-color: rgba(204,232,255,.18);
  background: rgba(13,28,46,.42);
  box-shadow: inset 0 1px rgba(255,255,255,.09);
  color: #c8d9eb;
}
html[data-theme="dark"] .search-box input { color: #edf5ff; }
html[data-theme="dark"] .search-box:focus-within { border-color: rgba(103,187,255,.66); box-shadow: 0 0 0 3px rgba(53,151,244,.15), inset 0 1px rgba(255,255,255,.12); }
html[data-theme="dark"] .model-item {
  border-color: rgba(205,234,255,.14);
  background: rgba(55,79,106,.34);
  box-shadow: inset 0 1px rgba(255,255,255,.09), 0 6px 15px rgba(0,0,0,.14);
  color: #eaf4ff;
}
html[data-theme="dark"] .model-item:hover { border-color: rgba(194,228,255,.3); background: rgba(65,94,124,.47); box-shadow: inset 0 1px rgba(255,255,255,.13), 0 10px 20px rgba(0,0,0,.2); }
html[data-theme="dark"] .model-item.active { border-color: rgba(100,190,255,.56); background: linear-gradient(135deg, rgba(72,114,153,.54), rgba(37,70,99,.64)); box-shadow: 0 8px 20px rgba(0,6,17,.3), inset 0 1px rgba(255,255,255,.15); }
html[data-theme="dark"] .model-item .price { border-color: rgba(157,215,255,.2); background: rgba(61,145,204,.25); color: #9bdbff; }
html[data-theme="dark"] .model-capability { color: #dce9f7; }
html[data-theme="dark"] .model-description { border-left-color: rgba(121,183,236,.27); background: rgba(13,29,46,.29); color: #b3c5d7; }
html[data-theme="dark"] .model-health { color: #70ddb3; }
html[data-theme="dark"] .studio-grid {
  border-color: rgba(197,228,255,.16);
  background: rgba(29,46,69,.58);
  box-shadow: 0 25px 62px rgba(0,4,12,.34), inset 0 1px rgba(237,249,255,.11), inset 0 -1px rgba(0,0,0,.14);
}
html[data-theme="dark"] .composer { border-right-color: rgba(187,218,246,.14); background: rgba(13,27,44,.22); }
html[data-theme="dark"] .heading-stats { border-color: rgba(204,232,255,.17); background: rgba(10,25,42,.26); box-shadow: inset 0 1px rgba(255,255,255,.1); }
html[data-theme="dark"] .stat-chip { background: rgba(91,124,156,.18); }
html[data-theme="dark"] .stat-chip:nth-child(2) { border-color: rgba(200,230,255,.12); }
html[data-theme="dark"] .stat-chip span,
html[data-theme="dark"] .material-total,
html[data-theme="dark"] .control-block > label,
html[data-theme="dark"] .switch-control small,
html[data-theme="dark"] .frame-hint,
html[data-theme="dark"] .material-empty { color: #a9bfd4; }
html[data-theme="dark"] .section-title > span:first-child { border-color: rgba(198,232,255,.18); background: rgba(62,140,196,.27); color: #9ddcff; box-shadow: inset 0 1px rgba(255,255,255,.16), 0 4px 10px rgba(0,0,0,.14); }
html[data-theme="dark"] .control-title,
html[data-theme="dark"] .switch-control { border-top-color: rgba(190,221,248,.13); }
html[data-theme="dark"] .prompt-editor,
html[data-theme="dark"] .split-control select,
html[data-theme="dark"] .frame-file-picker {
  border-color: rgba(205,234,255,.17);
  background: rgba(10,25,42,.4);
  box-shadow: inset 0 1px rgba(255,255,255,.08), inset 0 -2px 6px rgba(0,0,0,.12);
  color: #edf5ff;
}
html[data-theme="dark"] .prompt-editor:focus { border-color: rgba(95,185,255,.72); box-shadow: 0 0 0 3px rgba(53,151,244,.16), inset 0 1px rgba(255,255,255,.1); }
html[data-theme="dark"] .prompt-editor:empty::before { color: #8ea5bd; }
html[data-theme="dark"] .prompt-token { border-color: rgba(116,198,255,.4); background: rgba(49,130,187,.29); color: #b0e1ff; box-shadow: inset 0 1px rgba(255,255,255,.13); }
html[data-theme="dark"] .prompt-token button { color: #c3d7e9; }
html[data-theme="dark"] .prompt-expand {
  border-color: rgba(204,232,255,.2);
  background: rgba(58,87,116,.52);
  box-shadow: inset 0 1px rgba(255,255,255,.13), 0 2px 7px rgba(0,0,0,.2);
  color: #c8dcef;
}
html[data-theme="dark"] .prompt-expand:hover,
html[data-theme="dark"] .prompt-field.expanded .prompt-expand { background: rgba(68,143,198,.46); color: #e2f3ff; }
html[data-theme="dark"] .mention-menu,
html[data-theme="dark"] .material-popover {
  border-color: rgba(204,232,255,.2);
  background: rgba(27,45,67,.84);
  box-shadow: 0 18px 40px rgba(0,0,0,.35), inset 0 1px rgba(255,255,255,.13);
}
html[data-theme="dark"] .mention-menu button:hover,
html[data-theme="dark"] .mention-menu button.active { background: rgba(65,135,187,.35); }
html[data-theme="dark"] .mention-thumb { border-color: rgba(205,234,255,.18); background: rgba(53,130,183,.28); color: #a8ddff; }
html[data-theme="dark"] .mention-menu button strong,
html[data-theme="dark"] .material-info strong,
html[data-theme="dark"] .frame-slot-label span { color: #a8ddff; }
html[data-theme="dark"] .mention-menu button small,
html[data-theme="dark"] .material-info span { color: #adc0d3; }
html[data-theme="dark"] .material-upload-status.uploading { color: #9bd4ff; }
html[data-theme="dark"] .material-upload-status.ready { color: #70ddb3; }
html[data-theme="dark"] .material-upload-status.error { color: #ff9da0; }
html[data-theme="dark"] .prompt-presets button,
html[data-theme="dark"] .history-heading button {
  border-color: rgba(204,232,255,.17);
  background: rgba(77,108,140,.23);
  box-shadow: inset 0 1px rgba(255,255,255,.1);
  color: #c3d5e6;
}
html[data-theme="dark"] .prompt-presets button:hover { border-color: rgba(95,185,255,.5); background: rgba(55,133,190,.34); color: #b8e2ff; }
html[data-theme="dark"] .segmented,
html[data-theme="dark"] .duration-control {
  border-color: rgba(204,232,255,.18);
  background: linear-gradient(135deg, rgba(57,86,116,.58), rgba(26,48,73,.68));
  box-shadow: inset 0 1px rgba(255,255,255,.12), inset 0 -1px 2px rgba(0,0,0,.16), 0 7px 18px rgba(0,0,0,.16);
}
html[data-theme="dark"] .segmented::before,
html[data-theme="dark"] .duration-control::before { background: linear-gradient(115deg, rgba(210,239,255,.16), transparent 34%, transparent 72%, rgba(158,229,255,.09)); }
html[data-theme="dark"] .ratio-glider { border-color: rgba(233,248,255,.3); background: linear-gradient(140deg, rgba(157,207,245,.65), rgba(77,131,183,.48)); box-shadow: 0 8px 17px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.34), inset 0 -2px 3px rgba(0,0,0,.15); }
html[data-theme="dark"] .ratio-glider::before { background: linear-gradient(90deg, rgba(255,255,255,.42), rgba(255,255,255,.04)); }
html[data-theme="dark"] .segmented button { color: #adc2d6; }
html[data-theme="dark"] .segmented button.active,
html[data-theme="dark"] .segmented button:hover { color: #f0f8ff; }
html[data-theme="dark"] .duration-control input[type="range"] { border-color: rgba(255,255,255,.18); background: linear-gradient(to right, #67bdff 0 var(--range-progress, 0%), rgba(117,151,183,.43) var(--range-progress, 0%) 100%); box-shadow: inset 0 1px 2px rgba(0,0,0,.25); }
html[data-theme="dark"] .duration-control output { color: #b9e0ff; }
html[data-theme="dark"] .switch-control i { border-color: rgba(204,232,255,.18); background: rgba(115,142,169,.42); box-shadow: inset 0 1px rgba(255,255,255,.16), inset 0 -1px rgba(0,0,0,.16); }
html[data-theme="dark"] .switch-control i::after { border-color: rgba(255,255,255,.26); background: linear-gradient(145deg, #d9ebfa, #7e9ab7); box-shadow: 0 3px 6px rgba(0,0,0,.28), inset 0 1px #fff; }
html[data-theme="dark"] .material-tabs { border-color: rgba(204,232,255,.16); background: rgba(11,27,45,.34); box-shadow: inset 0 1px rgba(255,255,255,.08); }
html[data-theme="dark"] .material-tabs button { color: #a9bfd2; }
html[data-theme="dark"] .material-tabs button.active { background: rgba(90,145,190,.4); color: #e5f4ff; box-shadow: inset 0 1px rgba(255,255,255,.17), 0 4px 10px rgba(0,0,0,.17); }
html[data-theme="dark"] .file-picker,
html[data-theme="dark"] .frame-slot,
html[data-theme="dark"] .material-row {
  border-color: rgba(204,232,255,.16);
  background: rgba(61,88,116,.24);
  box-shadow: inset 0 1px rgba(255,255,255,.1), 0 6px 15px rgba(0,0,0,.11);
}
html[data-theme="dark"] .file-picker:hover { border-color: rgba(100,190,255,.55); background: rgba(52,122,173,.33); }
html[data-theme="dark"] .file-picker-icon,
html[data-theme="dark"] .material-thumb { border-color: rgba(204,232,255,.2); background: rgba(54,135,191,.28); color: #a9ddff; box-shadow: inset 0 1px rgba(255,255,255,.16); }
html[data-theme="dark"] .submit-band { border-top-color: rgba(190,221,248,.13); background: rgba(7,19,33,.18); }
html[data-theme="dark"] .submit-band > div span { color: #a9bfd4; }
html[data-theme="dark"] .generate-button { box-shadow: 0 12px 25px rgba(0,52,123,.34), inset 0 1px rgba(255,255,255,.56), inset 0 -2px rgba(0,36,95,.25); }
html[data-theme="dark"] .preview { border-left-color: rgba(205,234,255,.12); background: rgba(14,29,46,.76); }
html[data-theme="dark"] .preview-toolbar { background: rgba(86,117,149,.12); }
html[data-theme="dark"] .history-heading { border-color: rgba(204,232,255,.16); background: rgba(27,45,67,.42); box-shadow: inset 0 1px rgba(255,255,255,.1); }
html[data-theme="dark"] .history-row,
html[data-theme="dark"] .history-empty { border-color: rgba(204,232,255,.13); background: rgba(50,75,101,.25); box-shadow: inset 0 1px rgba(255,255,255,.08); }
html[data-theme="dark"] .history-row:hover { background: rgba(65,94,124,.38); }
html[data-theme="dark"] .history-model,
html[data-theme="dark"] .history-time,
html[data-theme="dark"] .history-meta { color: #a8bed3; }
html[data-theme="dark"] .toast { border-color: rgba(204,232,255,.2); background: rgba(27,45,67,.86); color: #edf5ff; box-shadow: 0 18px 40px rgba(0,0,0,.34), inset 0 1px rgba(255,255,255,.13); }

/* The active editor and selected model share the animated spectrum used by the brand. */
.app-shell .prompt-editor:focus {
  border: 2px solid transparent;
  background:
    linear-gradient(#f9fbfd, #f9fbfd) padding-box,
    linear-gradient(105deg, #ff4f91, #ff9d38, #f3cc3c, #33bf83, #39b8e8, #6c78ef, #dc63d9, #ff4f91) border-box;
  background-size: auto, 260% 100%;
  background-position: 0 0, 0% 50%;
  background-clip: padding-box, border-box;
  box-shadow: 0 8px 18px rgba(67,91,120,.06), inset 0 1px rgba(255,255,255,.92);
  animation: spectrum-border 6s linear infinite;
}
.app-shell .model-item.active {
  border: 2px solid transparent;
  background:
    linear-gradient(#f9fbfd, #f9fbfd) padding-box,
    linear-gradient(105deg, #ff4f91, #ff9d38, #f3cc3c, #33bf83, #39b8e8, #6c78ef, #dc63d9, #ff4f91) border-box;
  background-size: auto, 260% 100%;
  background-position: 0 0, 0% 50%;
  background-clip: padding-box, border-box;
  box-shadow: 0 7px 16px rgba(65,90,122,.07), inset 0 1px rgba(255,255,255,.82);
  animation: spectrum-border 6s linear infinite;
}
html[data-theme="dark"] .prompt-editor:focus {
  background:
    linear-gradient(#13243a, #13243a) padding-box,
    linear-gradient(105deg, #ff4f91, #ff9d38, #f3cc3c, #33bf83, #39b8e8, #6c78ef, #dc63d9, #ff4f91) border-box;
  background-size: auto, 260% 100%;
  background-position: 0 0, 0% 50%;
  box-shadow: 0 8px 18px rgba(0,0,0,.16), inset 0 1px rgba(255,255,255,.08);
}
html[data-theme="dark"] .model-item.active {
  background:
    linear-gradient(#243a53, #243a53) padding-box,
    linear-gradient(105deg, #ff4f91, #ff9d38, #f3cc3c, #33bf83, #39b8e8, #6c78ef, #dc63d9, #ff4f91) border-box;
  background-size: auto, 260% 100%;
  background-position: 0 0, 0% 50%;
  box-shadow: inset 0 1px rgba(255,255,255,.09), 0 6px 15px rgba(0,0,0,.14);
}
@keyframes spectrum-border {
  from { background-position: 0 0, 0% 50%; }
  to { background-position: 0 0, 260% 50%; }
}

/* App-wide liquid glass treatment. Interaction structure remains unchanged. */
:root {
  --paper: #e9eef4;
  --surface: rgba(255, 255, 255, 0.58);
  --surface-soft: rgba(247, 250, 253, 0.48);
  --ink: #17212f;
  --muted: #66758a;
  --line: rgba(255, 255, 255, 0.68);
  --line-strong: rgba(142, 165, 189, 0.4);
  --accent: #1687f7;
  --accent-dark: #176bc5;
  --green: #1aaf83;
  --shadow: 0 18px 48px rgba(50, 74, 105, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

html { background: #e9eef4; }
body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(224, 235, 245, 0.18) 46%, rgba(235, 244, 239, 0.42)),
    #e9eef4;
}
.app-shell { position: relative; isolation: isolate; }
.app-shell::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: .56;
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.25) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.22) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

.topbar {
  height: 68px;
  margin: 10px 14px 0;
  padding: 0 18px;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 19px;
  background: rgba(247, 251, 255, .54);
  box-shadow: 0 12px 36px rgba(64, 91, 124, .12), inset 0 1px rgba(255,255,255,.98), inset 0 -1px rgba(107,136,168,.08);
  backdrop-filter: blur(24px) saturate(155%);
}
.topbar::before, .studio-grid::before, .model-rail::before {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 1px 1px auto;
  height: 38%;
  border-radius: inherit;
  background: linear-gradient(112deg, rgba(255,255,255,.72), rgba(255,255,255,.12) 45%, rgba(255,255,255,.34));
}
.topbar > * { position: relative; z-index: 1; }
.brand-mark { border-radius: 12px; box-shadow: 0 5px 13px rgba(48,72,100,.2), inset 0 1px rgba(255,255,255,.6); }
.brand small, .eyebrow, .section-title small { color: #77899d; letter-spacing: .04em; }
.api-state {
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 999px;
  background: rgba(255,255,255,.34);
  box-shadow: inset 0 1px rgba(255,255,255,.8);
}

.workspace { grid-template-columns: 304px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.model-rail {
  position: relative;
  margin: 14px 0 14px 14px;
  padding: 22px 15px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 20px;
  background: rgba(243, 248, 253, .42);
  box-shadow: 0 15px 36px rgba(67, 91, 122, .1), inset 0 1px rgba(255,255,255,.85);
  backdrop-filter: blur(22px) saturate(145%);
}
.model-rail > * { position: relative; z-index: 1; }
.model-count {
  border: 1px solid rgba(255,255,255,.84);
  background: rgba(255,255,255,.48);
  box-shadow: inset 0 1px rgba(255,255,255,.9), 0 3px 9px rgba(73,98,127,.08);
}
.search-box {
  border-color: rgba(255,255,255,.76);
  border-radius: 14px;
  background: rgba(255,255,255,.44);
  box-shadow: inset 0 1px rgba(255,255,255,.86), inset 0 -1px rgba(109,137,166,.08);
  backdrop-filter: blur(14px);
}
.search-box:focus-within { border-color: rgba(51,142,240,.62); box-shadow: 0 0 0 3px rgba(22,135,247,.13), inset 0 1px rgba(255,255,255,.9); }
.model-list { scrollbar-color: rgba(104,130,161,.44) transparent; }
.model-list::-webkit-scrollbar-thumb, .model-description::-webkit-scrollbar-thumb { background: rgba(104,130,161,.44); }
.model-item {
  border-color: rgba(255,255,255,.74);
  border-radius: 16px;
  background: rgba(255,255,255,.42);
  box-shadow: 0 7px 16px rgba(65,90,122,.07), inset 0 1px rgba(255,255,255,.82);
  backdrop-filter: blur(14px) saturate(140%);
}
.model-item:hover { border-color: rgba(255,255,255,.95); background: rgba(255,255,255,.62); box-shadow: 0 11px 24px rgba(65,90,122,.12), inset 0 1px rgba(255,255,255,.96); transform: translateY(-1px); }
.model-item.active { border-color: rgba(88,169,255,.7); background: linear-gradient(135deg, rgba(255,255,255,.72), rgba(220,239,255,.5)); box-shadow: 0 0 0 1px rgba(98,177,255,.34), 0 11px 26px rgba(38,120,215,.14), inset 0 1px rgba(255,255,255,.98); }
.model-item .price { border: 1px solid rgba(255,255,255,.78); border-radius: 999px; background: rgba(232,246,255,.68); color: #176bc5; box-shadow: inset 0 1px rgba(255,255,255,.9); }
.model-description { border-left-color: rgba(117,160,206,.34); border-radius: 0 9px 9px 0; background: rgba(233,241,249,.42); }

.studio { padding: 30px 28px 50px; }
.studio-heading { padding: 0 8px; }
.heading-stats { gap: 7px; padding: 4px; border: 1px solid rgba(255,255,255,.68); border-radius: 16px; background: rgba(255,255,255,.28); box-shadow: inset 0 1px rgba(255,255,255,.75); backdrop-filter: blur(14px); }
.stat-chip { min-width: 88px; padding: 7px 11px; border: 0; border-radius: 12px; background: rgba(255,255,255,.3); }
.stat-chip:nth-child(2) { border-left: 1px solid rgba(129,153,180,.17); border-right: 1px solid rgba(129,153,180,.17); }
.studio-grid {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-color: rgba(255,255,255,.8);
  border-radius: 24px;
  background: rgba(250,253,255,.4);
  box-shadow: 0 24px 60px rgba(58,84,117,.15), inset 0 1px rgba(255,255,255,.9), inset 0 -1px rgba(99,130,160,.08);
  backdrop-filter: blur(25px) saturate(150%);
}
.studio-grid > * { position: relative; z-index: 1; }
.composer { border-right-color: rgba(140,164,190,.22); background: rgba(255,255,255,.2); }
.section-title > span:first-child { border: 1px solid rgba(255,255,255,.8); border-radius: 10px; background: rgba(225,242,255,.7); color: #176bc5; box-shadow: inset 0 1px rgba(255,255,255,.95), 0 4px 10px rgba(73,127,182,.1); }
.control-title { border-top-color: rgba(137,163,190,.2); }
.prompt-editor {
  border-color: rgba(255,255,255,.78);
  border-radius: 17px;
  background: rgba(255,255,255,.42);
  box-shadow: inset 0 1px rgba(255,255,255,.92), inset 0 -2px 6px rgba(108,141,177,.08), 0 8px 18px rgba(67,91,120,.06);
  backdrop-filter: blur(16px);
}
.prompt-editor:focus { border-color: rgba(76,157,245,.72); box-shadow: 0 0 0 3px rgba(22,135,247,.13), inset 0 1px rgba(255,255,255,.96); }
.prompt-token { border-color: rgba(126,194,255,.58); border-radius: 8px; background: rgba(224,244,255,.7); color: #176bc5; box-shadow: inset 0 1px rgba(255,255,255,.88); }
.mention-menu { border-color: rgba(255,255,255,.8); border-radius: 15px; background: rgba(250,253,255,.74); box-shadow: 0 17px 36px rgba(59,82,110,.18), inset 0 1px rgba(255,255,255,.95); backdrop-filter: blur(22px) saturate(150%); }
.mention-menu button:hover, .mention-menu button.active { background: rgba(214,237,255,.62); }
.mention-thumb { border: 1px solid rgba(255,255,255,.78); border-radius: 8px; background: rgba(226,241,254,.72); color: #176bc5; }
.mention-menu button strong { color: #176bc5; }
.prompt-presets button {
  border-color: rgba(255,255,255,.7);
  border-radius: 999px;
  background: rgba(255,255,255,.38);
  box-shadow: inset 0 1px rgba(255,255,255,.86), 0 3px 8px rgba(66,90,120,.05);
}
.prompt-presets button:hover { border-color: rgba(93,171,248,.5); background: rgba(224,243,255,.64); color: #176bc5; }

.split-control select {
  border-color: rgba(255,255,255,.78);
  border-radius: 14px;
  background: rgba(255,255,255,.48);
  box-shadow: inset 0 1px rgba(255,255,255,.92), inset 0 -1px rgba(111,142,174,.08);
  color: #31506d;
}
.switch-control { border-top-color: rgba(137,163,190,.2); }
.switch-control i { border-color: rgba(255,255,255,.82); background: rgba(173,191,209,.55); box-shadow: inset 0 1px rgba(255,255,255,.84), inset 0 -1px rgba(88,116,145,.13); }
.switch-control i::after { top: 2px; left: 2px; width: 16px; height: 16px; border: 1px solid rgba(255,255,255,.84); background: linear-gradient(145deg, #fff, #dbe8f4); box-shadow: 0 3px 6px rgba(57,81,111,.24), inset 0 1px #fff; }
.switch-control input:checked + i { border-color: rgba(255,255,255,.82); background: linear-gradient(135deg, #48b4ff, #2681ed); }
.switch-control input:checked + i::after { transform: translateX(20px); }

.material-tabs { gap: 5px; padding: 4px; border: 1px solid rgba(255,255,255,.68); border-radius: 14px; background: rgba(224,235,246,.42); box-shadow: inset 0 1px rgba(255,255,255,.75); }
.material-tabs button { flex: 1; min-width: 0; padding: 7px 5px; border: 0; border-radius: 10px; transition: background 160ms, box-shadow 160ms, color 160ms; }
.material-tabs button.active { border-bottom: 0; background: rgba(255,255,255,.76); color: #176bc5; box-shadow: 0 4px 10px rgba(63,96,132,.12), inset 0 1px rgba(255,255,255,.96); }
.file-picker, .frame-slot {
  border-color: rgba(255,255,255,.75);
  border-style: solid;
  border-radius: 15px;
  background: rgba(255,255,255,.35);
  box-shadow: inset 0 1px rgba(255,255,255,.85), 0 6px 15px rgba(70,95,124,.06);
  backdrop-filter: blur(14px);
}
.file-picker:hover { border-color: rgba(89,168,244,.55); background: rgba(229,244,255,.62); }
.file-picker-icon { border: 1px solid rgba(255,255,255,.86); border-radius: 9px; background: rgba(218,240,255,.72); color: #176bc5; box-shadow: inset 0 1px #fff; }
.material-row { border: 1px solid rgba(255,255,255,.64); border-radius: 12px; background: rgba(255,255,255,.34); box-shadow: inset 0 1px rgba(255,255,255,.75); }
.material-thumb { border: 1px solid rgba(255,255,255,.8); border-radius: 9px; background: rgba(220,239,255,.66); color: #176bc5; box-shadow: inset 0 1px #fff; }
.material-info strong, .frame-slot-label span { color: #176bc5; }
.material-row > button[data-remove-material] { border: 1px solid rgba(255,255,255,.42); border-radius: 8px; background: rgba(39,57,77,.72); backdrop-filter: blur(8px); }
.material-popover { border-color: rgba(255,255,255,.8); border-radius: 15px; background: rgba(247,252,255,.72); box-shadow: 0 17px 36px rgba(59,82,110,.2), inset 0 1px #fff; backdrop-filter: blur(20px); }
.frame-file-picker { border-color: rgba(150,181,214,.5); border-radius: 10px; background: rgba(255,255,255,.44); }
.frame-slot > .frame-remove { border: 1px solid rgba(255,255,255,.7); border-radius: 9px; background: rgba(226,237,247,.6); }

.submit-band {
  border-top-color: rgba(137,163,190,.2);
  background: rgba(229,239,248,.36);
}
.generate-button {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 17px;
  background: linear-gradient(135deg, rgba(54,160,255,.96), rgba(24,111,224,.95));
  box-shadow: 0 12px 24px rgba(20,110,215,.26), inset 0 1px rgba(255,255,255,.55), inset 0 -2px rgba(5,72,155,.18);
}
.generate-button::before { content: ""; position: absolute; inset: 1px 1px auto; height: 46%; border-radius: inherit; background: linear-gradient(100deg, rgba(255,255,255,.4), transparent 55%); }
.generate-button > * { position: relative; z-index: 1; }
.generate-button:hover { background: linear-gradient(135deg, #54b1ff, #207ce8); box-shadow: 0 15px 28px rgba(20,110,215,.32), inset 0 1px rgba(255,255,255,.65); transform: translateY(-1px); }

.preview { background: rgba(19, 33, 49, .72); }
.preview-stage { background: #17263a; }
.empty-preview { background-image: linear-gradient(180deg, rgba(16,29,45,.12), rgba(12,25,39,.72)), url("https://images.unsplash.com/photo-1485846234645-a62644f84728?auto=format&fit=crop&w=1600&q=82"); }
.preview-index { border-color: rgba(255,255,255,.7); border-radius: 999px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.preview-toolbar { border-top-color: rgba(255,255,255,.14); background: rgba(255,255,255,.08); backdrop-filter: blur(18px); }
.icon-button { border-color: rgba(255,255,255,.27); border-radius: 11px; background: rgba(255,255,255,.1); box-shadow: inset 0 1px rgba(255,255,255,.24); }
.icon-button:hover { border-color: rgba(255,255,255,.8); background: rgba(255,255,255,.18); }
.preview-details { border-top-color: rgba(255,255,255,.13); background: rgba(3,15,28,.13); }
.preview-details div { border-right-color: rgba(255,255,255,.13); }
.processing-preview { background: rgba(18,35,54,.9); backdrop-filter: blur(18px); }
.processing-orbit { border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.06); box-shadow: inset 0 1px rgba(255,255,255,.2), 0 14px 30px rgba(0,0,0,.2); }

.history-heading { padding: 15px 16px; border: 1px solid rgba(255,255,255,.72); border-radius: 18px; background: rgba(255,255,255,.3); box-shadow: inset 0 1px rgba(255,255,255,.85); backdrop-filter: blur(16px); }
.history-heading button { border-color: rgba(255,255,255,.78); border-radius: 11px; background: rgba(255,255,255,.45); box-shadow: inset 0 1px rgba(255,255,255,.88); }
.history-row { margin-top: 7px; padding: 9px 12px; border: 1px solid rgba(255,255,255,.52); border-radius: 14px; background: rgba(255,255,255,.25); box-shadow: inset 0 1px rgba(255,255,255,.68); }
.history-row:hover { background: rgba(255,255,255,.5); }
.history-empty { margin-top: 7px; border: 1px solid rgba(255,255,255,.52); border-radius: 14px; background: rgba(255,255,255,.25); }
.toast { border-color: rgba(255,255,255,.8); border-left: 3px solid var(--accent); border-radius: 15px; background: rgba(250,253,255,.78); box-shadow: 0 18px 40px rgba(50,74,105,.18), inset 0 1px rgba(255,255,255,.92); backdrop-filter: blur(20px); }

@media (max-width: 1100px) {
  .model-rail { margin-right: 0; }
  .composer { border-right: 0; border-bottom: 1px solid rgba(140,164,190,.2); }
}
@media (max-width: 760px) {
  .topbar { height: 62px; margin: 8px 8px 0; border-radius: 16px; }
  .model-rail { margin: 10px 8px; border-radius: 18px; }
  .studio { padding: 12px 8px 34px; }
  .studio-heading { padding: 6px 8px; }
  .studio-grid { border-radius: 20px; }
  .heading-stats { width: 100%; }
  .material-tabs button { flex: 0 0 auto; }
}

/* ------------------------------------------------------------------
   创作模式：视频 / 图片
------------------------------------------------------------------ */
.mode-panel { display: none; }
body[data-mode="video"] .mode-panel[data-panel="video"],
body[data-mode="image"] .mode-panel[data-panel="image"] { display: block; }

.mode-block, .mode-inline { display: none; }
body[data-mode="video"] .mode-block[data-panel="video"],
body[data-mode="image"] .mode-block[data-panel="image"] { display: block; }
body[data-mode="video"] .mode-inline[data-panel="video"],
body[data-mode="image"] .mode-inline[data-panel="image"] { display: inline; }

.model-list[data-panel] { display: none; }
body[data-mode="video"] .model-list[data-panel="video"],
body[data-mode="image"] .model-list[data-panel="image"] { display: flex; }

.mode-switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(232, 239, 247, .78), rgba(214, 225, 237, .54));
  box-shadow: inset 0 1px 1px rgba(255,255,255,.94), inset 0 -1px 2px rgba(139,157,180,.16), 0 8px 20px rgba(83,104,132,.1);
  backdrop-filter: blur(16px) saturate(145%);
}
.mode-switch::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,.5), transparent 34%, transparent 74%, rgba(255,255,255,.2));
}
.mode-glider {
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 2);
  border: 1px solid rgba(255,255,255,.96);
  border-radius: 999px;
  background: linear-gradient(140deg, rgba(255,255,255,.98), rgba(233,245,255,.7));
  box-shadow: 0 8px 17px rgba(67,100,141,.2), inset 0 1px 2px rgba(255,255,255,1), inset 0 -2px 3px rgba(114,148,188,.14);
  transition: transform 320ms cubic-bezier(.16, 1.25, .35, 1);
}
body[data-mode="image"] .mode-glider { transform: translateX(100%); }
.mode-switch button {
  position: relative;
  z-index: 1;
  min-width: 78px;
  height: 32px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #65758a;
  font-size: 12px;
  font-weight: 650;
  transition: color 180ms ease;
}
.mode-switch button:hover { color: #2f73c5; }
.mode-switch button.active { color: #1672d2; }

/* 参考图缩略图 */
.asset-strip { position: relative; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.asset-cell { position: relative; flex: 0 0 auto; }
.asset-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 14px;
  background: rgba(255,255,255,.42);
  box-shadow: inset 0 1px rgba(255,255,255,.88), 0 7px 16px rgba(65,90,122,.09);
  backdrop-filter: blur(14px);
}
.asset-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .25s ease; }
.asset-thumb:hover img { transform: scale(1.07); }
.asset-name {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  overflow: hidden;
  padding: 3px 6px;
  border-radius: 8px;
  background: rgba(10, 25, 40, .6);
  color: #fff;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}
.asset-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  padding: 2px 6px;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 999px;
  background: rgba(10,25,40,.55);
  color: #eaf6ff;
  font-size: 8px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}
.asset-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 50%;
  background: rgba(25, 39, 54, .68);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  transform: scale(.82);
  transition: opacity .18s ease, transform .18s ease;
  backdrop-filter: blur(8px);
}
.asset-thumb:hover .asset-remove,
.asset-thumb:focus-within .asset-remove { opacity: 1; transform: scale(1); }
.asset-remove:hover { background: rgba(214, 55, 62, .88); }
.asset-zoom {
  position: absolute;
  z-index: 14;
  left: calc(100% + 8px);
  bottom: 0;
  display: none;
  width: 240px;
  max-height: 240px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 15px;
  background: rgba(247,252,255,.74);
  box-shadow: 0 17px 36px rgba(59,82,110,.2), inset 0 1px #fff;
  backdrop-filter: blur(20px);
}
.asset-cell.flip .asset-zoom { left: auto; right: calc(100% + 8px); }
.asset-cell:hover .asset-zoom { display: block; }
.asset-zoom img { display: block; width: 100%; max-height: 228px; object-fit: contain; border-radius: 10px; background: rgba(12,25,39,.6); }
.asset-progress {
  position: absolute;
  inset: auto 0 0;
  padding: 3px 6px;
  background: rgba(10,25,40,.72);
  color: #9bd4ff;
  font-size: 8px;
  font-weight: 700;
  text-align: center;
}
.asset-progress.error { color: #ffb4b6; }
.asset-add {
  width: 84px;
  height: 84px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px dashed rgba(108, 158, 200, .55);
  border-radius: 14px;
  background: rgba(255,255,255,.32);
  color: #2b76b5;
  box-shadow: inset 0 1px rgba(255,255,255,.8);
  text-align: center;
}
.asset-add:hover { border-color: rgba(89,168,244,.8); background: rgba(229,244,255,.62); }
.asset-add b { display: block; font-size: 20px; font-weight: 400; line-height: 1; }
.asset-add span { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.asset-hint { margin: 8px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

/* 图片参数 */
.ratio-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin-top: 5px; }
.ratio-option {
  min-width: 0;
  padding: 9px 3px 8px;
  border: 1px solid rgba(255,255,255,.74);
  border-radius: 14px;
  background: rgba(255,255,255,.4);
  color: #6b7c90;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  box-shadow: inset 0 1px rgba(255,255,255,.85), 0 5px 12px rgba(70,95,124,.06);
  backdrop-filter: blur(14px);
  transition: color 160ms ease, transform 160ms ease;
}
.ratio-option i { display: block; width: 18px; height: 18px; margin: 0 auto 5px; border: 1.5px solid currentColor; border-radius: 3px; opacity: .8; }
.ratio-option:hover { color: #2f73c5; }
.ratio-option.active {
  border-color: transparent;
  color: #1d73b8;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(105deg, #ff4f91, #ff9d38, #f3cc3c, #33bf83, #39b8e8, #6c78ef, #dc63d9, #ff4f91) border-box;
  background-clip: padding-box, border-box;
  background-size: auto, 260% 100%;
  box-shadow: 0 8px 18px rgba(65,90,122,.1), inset 0 1px rgba(255,255,255,.9);
  animation: spectrum-border 6s linear infinite;
}
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 46px;
  padding: 0 8px;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 15px;
  background: rgba(255,255,255,.42);
  box-shadow: inset 0 1px rgba(255,255,255,.9), inset 0 -1px 2px rgba(139,157,180,.12), 0 7px 18px rgba(83,104,132,.07);
  backdrop-filter: blur(16px);
}
.stepper button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 10px;
  background: rgba(255,255,255,.6);
  color: #2674b1;
  font-size: 15px;
  line-height: 1;
  box-shadow: inset 0 1px rgba(255,255,255,.9);
}
.stepper button:hover { background: rgba(224,243,255,.85); }
.stepper button:disabled { opacity: .4; }
.stepper strong { min-width: 46px; color: #276fa8; font-size: 12px; font-weight: 750; text-align: center; }
.control-block + .control-block { margin-top: 0; }
.control-grid .control-block > label { display: block; margin-bottom: 6px; }
body[data-mode="image"] .control-grid .control-block:first-child { grid-column: auto; }
.prompt-field > #imagePromptCount { right: 44px; }
.model-item.pending { border-style: dashed; }

/* 图片结果 */
.image-canvas {
  min-height: 430px;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  background: linear-gradient(145deg, #173049, #0a1724);
}
.result-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.02));
  box-shadow: 0 14px 26px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.14);
}
.result-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.result-card.placeholder { display: grid; place-items: center; padding: 10px; color: rgba(218,237,249,.48); font-size: 10px; text-align: center; }
.result-card.placeholder::before {
  content: "";
  width: 42px;
  height: 42px;
  margin: 0 auto 8px;
  border: 1px dashed rgba(198,226,243,.28);
  border-radius: 13px;
  background: rgba(255,255,255,.045);
}
.result-card.placeholder span { display: block; }
.result-card.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.16) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: image-shimmer 1.6s linear infinite;
}
.result-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  opacity: 0;
  transition: opacity .2s ease;
}
.result-card:hover .result-actions { opacity: 1; }
.result-actions button, .result-actions a {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 10px;
  background: rgba(9,22,35,.66);
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  backdrop-filter: blur(8px);
}
.result-actions button:hover, .result-actions a:hover { border-color: rgba(255,255,255,.85); background: rgba(9,22,35,.86); }
@keyframes image-shimmer { from { background-position: 140% 0; } to { background-position: -40% 0; } }

html[data-theme="dark"] .mode-switch { border-color: rgba(204,232,255,.2); background: linear-gradient(135deg, rgba(38,58,84,.7), rgba(20,36,56,.6)); box-shadow: inset 0 1px rgba(255,255,255,.1), 0 10px 24px rgba(0,4,12,.3); }
html[data-theme="dark"] .mode-switch::before { background: linear-gradient(115deg, rgba(190,230,255,.12), transparent 40%, rgba(190,230,255,.06)); }
html[data-theme="dark"] .mode-glider { border-color: rgba(233,248,255,.24); background: linear-gradient(140deg, rgba(126,178,226,.44), rgba(52,88,126,.5)); box-shadow: 0 8px 18px rgba(0,8,20,.34), inset 0 1px rgba(255,255,255,.18); }
html[data-theme="dark"] .mode-switch button { color: #adc2d6; }
html[data-theme="dark"] .mode-switch button.active { color: #eaf6ff; }
html[data-theme="dark"] .asset-thumb,
html[data-theme="dark"] .asset-add,
html[data-theme="dark"] .ratio-option,
html[data-theme="dark"] .stepper { border-color: rgba(204,232,255,.18); background: rgba(9,24,40,.46); color: #dbe9f8; box-shadow: inset 0 1px rgba(255,255,255,.08); }
html[data-theme="dark"] .ratio-option.active {
  color: #cdeaff;
  background:
    linear-gradient(rgba(23,42,64,.94), rgba(23,42,64,.94)) padding-box,
    linear-gradient(105deg, #ff4f91, #ff9d38, #f3cc3c, #33bf83, #39b8e8, #6c78ef, #dc63d9, #ff4f91) border-box;
  background-clip: padding-box, border-box;
  background-size: auto, 260% 100%;
}
html[data-theme="dark"] .stepper button { border-color: rgba(204,232,255,.2); background: rgba(60,102,146,.4); color: #cfeaff; }
html[data-theme="dark"] .stepper strong { color: #b9e0ff; }
html[data-theme="dark"] .asset-zoom { border-color: rgba(204,232,255,.2); background: rgba(14,28,45,.82); box-shadow: 0 18px 38px rgba(0,6,16,.45); }
html[data-theme="dark"] .image-canvas { background: linear-gradient(145deg, #12263c, #071320); }

@media (max-width: 1100px) {
  .ratio-grid { gap: 5px; }
  .ratio-option { padding: 8px 2px 7px; font-size: 9px; }
}
@media (max-width: 760px) {
  .mode-switch button { min-width: 62px; padding: 0 10px; }
  .image-canvas { min-height: 340px; }
  .asset-zoom { display: none !important; }
}
