/* ===== Design Tokens ===== */
:root {
  --bg: #f4f7fa;
  --bg-surface: rgba(255, 255, 255, 0.55);
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --border: rgba(148, 163, 184, 0.24);
  --border-strong: rgba(148, 163, 184, 0.4);
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --accent: #2563eb;
  --accent-soft: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.12);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius-sm: 14px;
  --radius: 20px;
  --radius-lg: 28px;
  --radius-full: 9999px;
  --font-heading: "Songti SC", "STSong", "Kaiti SC", "STKaiti", "Hiragino Mincho ProN", "Noto Serif CJK SC", serif;
  --font-body: "Inter", "SF Pro Text", "PingFang SC", "HarmonyOS Sans SC", "MiSans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "SF Mono", "Cascadia Code", "Fira Code", monospace;
  --shadow-sm: 0 4px 16px rgba(148, 163, 184, 0.08);
  --shadow: 0 12px 40px rgba(148, 163, 184, 0.1);
  --shadow-lg: 0 24px 64px rgba(148, 163, 184, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  background: #010204;
  background-attachment: fixed;
  overflow-x: hidden;
}

.static-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-image:
    linear-gradient(180deg, rgba(2, 6, 14, 0.50) 0%, rgba(2, 6, 14, 0.26) 34%, rgba(2, 6, 14, 0.50) 68%, rgba(1, 3, 8, 0.78) 100%),
    linear-gradient(90deg, rgba(2, 6, 14, 0.24) 0%, transparent 46%, rgba(2, 6, 14, 0.14) 100%),
    url("mountain-road-sunrise.jpg");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.055;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at 50% 42%, black 0%, transparent 72%);
}

/* ===== Shell ===== */
.app-shell {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 0 auto;
  padding: 124px 32px 80px;
}

.canvas-entry {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 20;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #0f172a;
  text-decoration: none;
  transition: transform 150ms cubic-bezier(0.23, 1, 0.32, 1), background 150ms ease, box-shadow 180ms ease;
}

.canvas-entry-icon {
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 10px;
  background: #111827;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.canvas-entry-copy {
  display: grid;
  gap: 1px;
  line-height: 1.15;
}

.canvas-entry-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.canvas-entry-copy small {
  color: #64748b;
  font-size: 10px;
}

.canvas-entry-arrow {
  margin-left: 2px;
  color: #64748b;
  font-size: 13px;
}

@media (hover: hover) and (pointer: fine) {
  .canvas-entry:hover {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
    transform: translateY(-1px);
  }
}

.canvas-entry:active {
  transform: scale(0.97);
}

/* ===== Hero ===== */
.hero {
  margin-bottom: 44px;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: 40px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.16;
  color: rgba(255, 253, 247, 0.96);
  -webkit-text-stroke: 0.25px rgba(255, 255, 255, 0.18);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18),
    0 12px 34px rgba(0, 0, 0, 0.45),
    0 0 28px rgba(245, 158, 11, 0.16);
}

/* ===== Panel ===== */
.workspace { display: flex; justify-content: center; }

.panel {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    var(--shadow);
}

.composer-panel {
  width: 100%;
  padding: 0;
}

.composer-card {
  width: min(100%, 1080px);
  min-height: 210px;
  margin: 0 auto;
  padding: 30px 34px 28px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05), 0 24px 64px rgba(15, 23, 42, 0.18);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer-card:focus-within {
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.08),
    0 24px 64px rgba(15, 23, 42, 0.2);
}

.composer-body {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-height: 110px;
}

.composer-body.no-reference {
  grid-template-columns: minmax(0, 1fr);
}

.reference-picker {
  position: relative;
  margin: 0;
}

.reference-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.reference-tile {
  width: 72px;
  min-height: 92px;
  margin: 0 auto;
  padding: 14px 8px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text-dim);
  text-align: center;
  cursor: pointer;
  transform: rotate(-8deg);
  box-shadow: 0 8px 20px rgba(148, 163, 184, 0.12);
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.reference-tile:hover {
  border-color: rgba(37, 99, 235, 0.32);
  color: var(--accent);
  transform: rotate(-5deg) translateY(-1px);
}

.reference-plus {
  font-size: 30px;
  line-height: 1;
  font-weight: 300;
}

.reference-label-text {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.reference-picker .hint {
  display: none;
}

.prompt-area {
  min-width: 0;
  width: 100%;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.upload-status {
  min-height: 0;
  margin-top: 4px;
}

.upload-status:empty {
  display: none;
  margin: 0;
}

.hidden-field {
  display: none;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 16px;
  padding-top: 8px;
}

#klingModelPill {
  width: 156px;
  min-width: 0;
  flex: 0 1 156px;
}

#klingModelPill .dropdown-control,
#klingModelTrigger {
  width: 100%;
  min-width: 0;
}

#klingModelTrigger {
  display: flex;
  align-items: center;
}

#klingModelCurrent {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-toolbar .clear-inline,
.composer-toolbar .send-button {
  flex-shrink: 0;
}

.control-pill {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.control-pill.field {
  margin-bottom: 0;
}

.control-caption {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: #1f2937;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
}

.control-caption::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 7px;
  border-right: 1.5px solid #64748b;
  border-bottom: 1.5px solid #64748b;
  transform: rotate(45deg) translateY(-2px);
}

.control-separator {
  width: 1px;
  height: 18px;
  background: rgba(203, 213, 225, 0.9);
}

.control-pill select {
  width: auto;
  min-width: 0;
  height: 28px;
  padding: 0 22px 0 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  color: #1f2937;
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.spec-pill select {
  max-width: 86px;
}

.model3d-model-name {
  color: #1f2937;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.model3d-spec-pill select:first-of-type {
  max-width: 132px;
}

.model3d-spec-pill select:last-of-type {
  max-width: 68px;
}

.duration-pill select {
  max-width: 58px;
}

.image-spec-pill #imgSize {
  width: var(--selected-option-width, auto);
}

.image-size-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.image-size-trigger {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 4px 11px;
  background: transparent;
  color: #111827;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.image-size-trigger:hover,
.image-size-trigger[aria-expanded="true"] {
  background: #eff6ff;
  color: #1d4ed8;
}

.image-size-trigger .image-size-icon {
  width: 14px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.image-size-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  width: min(78vw, 470px);
  padding: 16px;
  border: 1px solid rgba(226, 232, 240, 0.86);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 52px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.image-size-section + .image-size-section {
  margin-top: 16px;
}

.image-size-label {
  margin-bottom: 8px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
}

.image-ratio-grid {
  display: grid;
  grid-template-columns: repeat(var(--image-ratio-columns, 9), minmax(0, 1fr));
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: #f4f4f5;
}

.image-ratio-option,
.image-resolution-option {
  appearance: none;
  border: 0;
  color: #111827;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.image-ratio-option {
  min-width: 0;
  min-height: 54px;
  border-radius: 10px;
  background: transparent;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 5px;
  padding: 5px 2px;
  font-size: 12px;
  white-space: nowrap;
}

.image-ratio-option:hover,
.image-resolution-option:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.image-ratio-option.is-active,
.image-resolution-option.is-active {
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.image-resolution-option:disabled {
  color: #94a3b8;
  cursor: not-allowed;
}

.image-resolution-option:disabled:hover {
  background: transparent;
}

.ratio-icon {
  display: block;
  width: 24px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.image-ratio-option[data-ratio="21:9"] .ratio-icon { width: 30px; height: 13px; }
.image-ratio-option[data-ratio="16:9"] .ratio-icon { width: 28px; height: 16px; }
.image-ratio-option[data-ratio="3:2"] .ratio-icon { width: 26px; height: 17px; }
.image-ratio-option[data-ratio="4:3"] .ratio-icon { width: 24px; height: 18px; }
.image-ratio-option[data-ratio="1:1"] .ratio-icon { width: 22px; height: 22px; }
.image-ratio-option[data-ratio="3:4"] .ratio-icon { width: 18px; height: 24px; }
.image-ratio-option[data-ratio="2:3"] .ratio-icon { width: 17px; height: 26px; }
.image-ratio-option[data-ratio="9:16"] .ratio-icon { width: 16px; height: 28px; }

.image-ratio-option[data-ratio="auto"] .ratio-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  position: relative;
}

.image-ratio-option[data-ratio="auto"] .ratio-icon::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.image-resolution-grid {
  display: grid;
  grid-template-columns: repeat(var(--image-resolution-columns, 3), minmax(0, 1fr));
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: #f4f4f5;
}

.image-resolution-option {
  min-height: 38px;
  border-radius: 10px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

.control-pill select:focus {
  box-shadow: none;
  border-color: transparent;
}

.dropdown-control,
.wheel-control {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.mode-pill,
.channel-pill,
.model-pill,
.capability-pill,
.image-provider-pill {
  padding: 6px 5px;
}

.dropdown-trigger,
.wheel-trigger {
  min-height: 30px;
  padding: 4px 26px 4px 10px;
  border: 0;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
}

.dropdown-trigger:hover,
.wheel-trigger:hover {
  background: #f8fafc;
  color: #1f2937;
}

.mode-pill .dropdown-trigger,
.channel-pill .dropdown-trigger,
.model-pill .dropdown-trigger,
.capability-pill .dropdown-trigger,
.image-provider-pill .dropdown-trigger {
  background: transparent;
  color: #1f2937;
  font-size: 14px;
  padding-left: 8px;
  padding-right: 28px;
}

.mode-pill .dropdown-trigger:hover,
.channel-pill .dropdown-trigger:hover,
.model-pill .dropdown-trigger:hover,
.capability-pill .dropdown-trigger:hover,
.image-provider-pill .dropdown-trigger:hover {
  background: #f8fafc;
}

.dropdown-prefix {
  margin-right: 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.model-pill .dropdown-menu,
.image-provider-pill .dropdown-menu {
  min-width: 190px;
}

#seedanceModelMenu {
  min-width: 226px;
}

.dropdown-trigger::after,
.wheel-trigger::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-65%) rotate(45deg);
  opacity: 0.8;
}

.dropdown-menu,
.wheel-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 30;
  min-width: 178px;
  padding: 6px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.dropdown-option,
.wheel-option {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
}

.dropdown-option {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
}

.dropdown-option span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.dropdown-option small {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.35;
}

.dropdown-option:hover,
.wheel-option:hover {
  background: #f1f5f9;
}

.dropdown-option.is-active,
.wheel-option.is-active {
  background: #eff6ff;
  color: #1d4ed8;
}

.dropdown-option.is-active span,
.dropdown-option.is-active small {
  color: #1d4ed8;
}

.dropdown-option.is-active small {
  color: #64748b;
}

.image-provider-pill .dropdown-option.is-active {
  background: #eff6ff;
  color: #1d4ed8;
}

.image-provider-pill .dropdown-option.is-active span {
  color: #1d4ed8;
}

.image-provider-pill .dropdown-option.is-active small {
  color: #64748b;
}

.native-duration-select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
}

.wheel-menu {
  min-width: 92px;
  max-height: 176px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
}

.wheel-menu::before,
.wheel-menu::after {
  content: "";
  position: sticky;
  display: block;
  height: 18px;
  pointer-events: none;
}

.wheel-menu::before {
  top: 0;
  background: linear-gradient(#fff, rgba(255, 255, 255, 0));
}

.wheel-menu::after {
  bottom: 0;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff);
}

.wheel-option {
  display: flex;
  justify-content: center;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  scroll-snap-align: center;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.compact-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.compact-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.clear-inline {
  min-height: 42px;
  border-radius: 11px;
  padding: 8px 12px;
}

button.send-button {
  width: 46px;
  height: 46px;
  min-width: 46px;
  margin-left: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #d9dee5;
  color: #fff;
  font-size: 0;
  line-height: 0;
  box-shadow: none;
  overflow: hidden;
}

button.send-button:hover {
  transform: translateY(-1px);
  background: #94a3b8;
  box-shadow: none;
}

.send-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.capability-hint {
  margin-top: 8px;
  color: var(--text-dim);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 32px;
}

.panel-head h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text);
}

.model-picker {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 4px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.4);
}

.composer-toolbar .segmented {
  width: auto;
  min-width: 0;
  display: inline-flex;
  gap: 2px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.composer-toolbar .seg-item {
  min-width: 0;
  padding: 4px 7px;
  border-radius: 7px;
}

.composer-toolbar .seg-item.is-active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.composer-toolbar .seg-title {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.composer-toolbar .seg-sub {
  display: none;
}

.segmented.seg-mini {
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  grid-template-columns: unset;
}

.segmented.seg-mini .seg-item {
  padding: 8px 10px;
}

.segmented.seg-mini .seg-title {
  font-size: 13px;
}

.segmented.seg-mini .seg-sub {
  font-size: 9px;
}

.seg-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-body);
  color: var(--text-muted);
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.seg-item:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
}

.seg-item:active {
  transform: scale(0.985);
}

.seg-item.is-active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.seg-item.is-active .seg-sub {
  color: rgba(255, 255, 255, 0.65);
}

.seg-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
}

.seg-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.mini-chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.5);
}

/* ===== Fields ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

textarea, select, input[type="file"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.7;
}

select {
  height: 44px;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 120ms ease;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hint {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
  line-height: 1.6;
}

/* ===== Grid ===== */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.check-grid { margin-bottom: 24px; }

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.check-item:hover { border-color: var(--accent); background: rgba(255, 255, 255, 0.6); }

.check-item input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ===== Buttons ===== */
.actions { margin-top: 4px; }

.primary-button {
  border: 1px solid var(--accent);
  border-radius: var(--radius-full);
  padding: 14px 32px;
  background: var(--text);
  color: #fff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 180ms ease, transform 120ms ease;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.primary-button:hover {
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.2);
  transform: translateY(-1px);
}

.primary-button:active { transform: scale(0.98); }

.primary-button:disabled {
  opacity: 0.35;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.secondary-button,
.ghost-button,
.history-button {
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.secondary-button:hover,
.ghost-button:hover,
.history-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.75);
}

.history-button.danger:hover {
  border-color: rgba(220, 38, 38, 0.45);
  color: var(--danger);
  background: rgba(254, 242, 242, 0.8);
}

.history-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.secondary-button:active,
.ghost-button:active,
.history-button:active { transform: scale(0.97); }

/* ===== Preview Grid ===== */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.composer-card .preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.composer-card .preview-grid:empty {
  display: none;
  margin-bottom: 0;
}

.composer-card .preview-card {
  width: 54px;
  border-radius: 8px;
}

.composer-card .preview-card p {
  padding: 3px 4px;
}

.preview-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  overflow: visible;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.preview-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(148, 163, 184, 0.1);
}

.preview-card.is-missing {
  border-color: rgba(220, 38, 38, 0.72);
  background: rgba(254, 242, 242, 0.9);
}

.preview-missing-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: rgba(254, 226, 226, 0.9);
  color: #b91c1c;
  font-size: 9px;
  font-weight: 700;
  text-align: center;
}

.preview-card-clickable {
  cursor: pointer;
}
.preview-card-clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.18);
  transform: translateY(-1px);
}
.preview-card-clickable:active {
  transform: translateY(0);
}

.preview-card img,
.preview-card video,
.preview-media-icon {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.preview-media-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  color: #cbd5e1;
  font-size: 22px;
  font-weight: 600;
}

.preview-file-icon {
  background: linear-gradient(145deg, #312e81, #1e3a8a);
  color: #eef2ff;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.preview-card p {
  margin: 0;
  padding: 4px 6px 2px;
  font-size: 9px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.preview-card .caption-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 9px;
  color: var(--text);
}

.preview-card .caption-tag {
  display: inline-block;
  font-size: 8px;
  font-weight: 600;
  color: var(--accent, #6366f1);
  letter-spacing: 0.04em;
}

.preview-remove {
  position: absolute;
  top: -11px;
  right: -11px;
  z-index: 3;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.82);
  transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.preview-card:hover .preview-remove,
.preview-card:focus-within .preview-remove,
.preview-card.show-remove .preview-remove {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.preview-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff;
}

@media (hover: none) {
  .preview-card:hover .preview-remove {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.82);
  }

  .preview-card.show-remove .preview-remove,
  .preview-card:focus-within .preview-remove {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
  }
}

.tool-output {
  width: min(100%, 1080px);
  margin: 14px auto 0;
}

/* ===== Tools Divider ===== */
.tools-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 36px 0 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.tools-divider::before,
.tools-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== Analyze Card ===== */
.analyze-card {
  margin-bottom: 32px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, var(--shadow-sm);
}

.analyze-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  list-style: none;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.analyze-header:hover { color: var(--text); }

.analyze-header::-webkit-details-marker { display: none; }

.analyze-header::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(-45deg);
  transition: transform 0.25s ease;
}

details[open] .analyze-header::after { transform: rotate(45deg); }

.analyze-hint { font-size: 11px; font-weight: 400; color: var(--text-dim); }

.analyze-body { padding: 0 22px 22px; }

.analyze-drop-zone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.3);
  padding: 32px 20px;
  text-align: center;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
  margin-bottom: 20px;
}

.analyze-drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.04);
  box-shadow: 0 0 32px var(--accent-glow);
}

.analyze-drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  box-shadow: none;
  border-radius: var(--radius);
  z-index: 10;
}

.analyze-drop-zone .drop-hint { position: relative; z-index: 1; pointer-events: none; }
.analyze-drop-zone .video-preview-wrap { position: relative; z-index: 1; pointer-events: all; }

.drop-hint { display: grid; gap: 6px; color: var(--text-dim); font-size: 13px; }

.drop-icon { font-size: 28px; line-height: 1; }

.drop-link { color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }

.drop-tip { font-size: 11px; color: var(--text-dim); }

.video-preview-wrap { display: grid; gap: 10px; justify-items: center; }

.video-preview-wrap video {
  width: 100%;
  max-height: 180px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.video-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-size: 12px;
  color: var(--text-dim);
}

.video-meta #videoFileSize { font-weight: 500; color: var(--text-muted); }

.remove-video-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  pointer-events: all;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 120ms ease;
}

.remove-video-btn:hover { border-color: var(--danger); color: var(--danger); }

.analyze-output { margin-bottom: 20px; }

.analyze-output-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 8px;
}

.analyze-result {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
  max-height: 400px;
  overflow-y: auto;
}

.analyze-actions { display: flex; justify-content: flex-end; }

.analyze-btn {
  border: 1px solid var(--accent);
  border-radius: var(--radius-full);
  padding: 10px 28px;
  background: var(--text);
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 180ms ease, transform 120ms ease;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
}

.analyze-btn:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  transform: translateY(-1px);
}

.analyze-btn:active:not(:disabled) { transform: scale(0.98); }
.analyze-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===== Image Gallery (生成结果) ===== */
.img-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.img-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
  display: grid;
  gap: 0;
}

.img-card img {
  width: 100%;
  display: block;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f1f5f9;
  cursor: zoom-in;
  transition: opacity 0.2s ease;
}

.img-card img:hover { opacity: 0.92; }

.img-meta {
  min-height: 92px;
  padding: 8px 10px 0;
  display: grid;
  grid-template-rows: 34px 36px;
  gap: 4px;
}

.img-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(42px, auto);
  align-items: start;
  column-gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.3;
  color: var(--text-dim);
}

.img-meta-row span {
  min-width: 0;
}

.img-meta-row span:last-child {
  max-width: 76px;
  text-align: right;
}

.img-meta-prompt {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.prompt-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 5px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.prompt-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.95);
}

.prompt-chip-thumb {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 50%;
  background: #e2e8f0;
  pointer-events: none;
}

.prompt-chip-preview {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 160px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff center / cover no-repeat;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.prompt-chip:hover .prompt-chip-preview { opacity: 1; }

.prompt-echo {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--font-mono);
}

.prompt-echo-label {
  letter-spacing: 0.06em;
}

.prompt-echo-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.prompt-echo-tag.warn {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.img-history-wrap { margin-top: 16px; }

.result-panel .analyze-output,
.result-panel .img-history-wrap {
  margin-top: 14px;
}

.result-panel .img-gallery {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.img-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-head-actions .ghost-button {
  padding: 7px 11px;
}

.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.78);
  display: grid;
  place-items: center;
  cursor: zoom-out;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.img-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.img-card .img-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.img-card .img-actions a,
.img-card .img-actions button {
  min-width: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.img-card-pending {
  border-style: dashed;
}

.img-pending-visual {
  aspect-ratio: 1 / 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(217, 189, 128, 0.14));
  color: var(--text-muted);
  font-size: 12px;
}

.img-pending-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(146, 113, 46, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: image-pending-spin 0.8s linear infinite;
}

.img-pending-note {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.45;
}

@keyframes image-pending-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .img-pending-spinner { animation: none; }
}

.img-card .img-actions a:hover,
.img-card .img-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.img-card.failed {
  display: grid;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--danger);
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.3);
  word-break: break-word;
}

/* ===== Drawer ===== */
.drawer-hotspot {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1002;
  width: 56px;
  height: 100vh;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: width 160ms ease, opacity 160ms ease;
}

.drawer-hotspot::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 38px;
  height: 104px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-right: 0;
  border-radius: 18px 0 0 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: -8px 10px 28px rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transform: translateY(-50%);
  transition: width 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drawer-hotspot::after {
  content: "历史";
  position: absolute;
  top: 50%;
  right: 11px;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1;
  writing-mode: vertical-rl;
  transform: translateY(-50%);
  transition: color 160ms ease, transform 160ms ease;
}

.drawer-hotspot:hover,
.drawer-hotspot:focus-visible {
  width: 64px;
  outline: none;
}

.drawer-hotspot:hover::before,
.drawer-hotspot:focus-visible::before {
  width: 46px;
  background: rgba(239, 246, 255, 0.94);
  box-shadow: -10px 12px 32px rgba(15, 23, 42, 0.24);
}

.drawer-hotspot:hover::after,
.drawer-hotspot:focus-visible::after {
  color: #1d4ed8;
  transform: translate(-3px, -50%);
}

.drawer-hotspot.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(15, 23, 42, 0.36);
}

.result-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 470px;
  height: 100vh;
  z-index: 1000;
  padding: 22px 20px 24px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  box-shadow: -20px 0 56px rgba(15, 23, 42, 0.18);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.result-panel.open { transform: translateX(0); }

.drawer-head {
  align-items: center;
  margin-bottom: 12px;
}

.drawer-head h2 {
  font-size: 20px;
}

.drawer-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.drawer-close {
  min-width: 0;
  padding: 5px 10px;
}

/* ===== Status Badge ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-dim);
}

.status-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-badge.processing { border-color: var(--warning); color: var(--warning); }
.status-badge.processing::before { background: var(--warning); }
.status-badge.success { border-color: var(--success); color: var(--success); }
.status-badge.success::before { background: var(--success); }
.status-badge.error { border-color: var(--danger); color: var(--danger); }
.status-badge.error::before { background: var(--danger); }

.status-text,
.task-id {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.drawer-head .status-text {
  margin-top: 4px;
  max-width: 240px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-id {
  margin: 0 0 10px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--border);
}

.task-id:empty {
  display: none;
}

.result-wrap {
  display: grid;
  gap: 9px;
  pointer-events: none;
}

.result-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.result-wrap video {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
  pointer-events: auto;
}

.video-preview-error {
  position: relative;
  z-index: 2;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  border: 1px solid rgba(245, 158, 11, 0.34);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(9, 12, 18, 0.96), rgba(24, 18, 8, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: rgba(255, 247, 222, 0.88);
  font-size: 11px;
  line-height: 1.35;
  pointer-events: auto;
}

.video-preview-error span {
  min-width: 0;
}

.video-preview-error,
.video-preview-error * {
  pointer-events: auto;
}

.video-preview-retry-button {
  flex: 0 0 auto;
  min-height: 24px;
  appearance: none;
  border: 1px solid rgba(251, 191, 36, 0.54);
  border-radius: 7px;
  padding: 4px 8px;
  background: rgba(251, 191, 36, 0.08);
  color: #fbbf24;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.video-preview-retry-button:hover {
  border-color: rgba(252, 211, 77, 0.82);
  background: rgba(251, 191, 36, 0.14);
  color: #fde68a;
}

.video-preview-retry-button:focus-visible {
  outline: 2px solid rgba(251, 191, 36, 0.72);
  outline-offset: 2px;
}

.result-actions,
.result-actions * {
  pointer-events: auto;
}

.result-wrap a {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  text-decoration: none;
}

.model3d-pending,
.model3d-result-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.76);
}

.model3d-pending {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  color: var(--text-muted);
  font-size: 12px;
}

.model3d-spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 2px solid rgba(37, 99, 235, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: model3d-spin 0.8s linear infinite;
}

.model3d-result-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 13px;
  animation: model3d-card-in 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.model3d-result-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #eff6ff;
  color: #2563eb;
}

.model3d-result-icon svg {
  width: 25px;
  height: 25px;
}

.model3d-result-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.model3d-result-copy strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.model3d-result-copy span {
  overflow: hidden;
  color: var(--text-dim);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes model3d-spin {
  to { transform: rotate(360deg); }
}

@keyframes model3d-card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Error ===== */
.error-box {
  overflow: auto;
  margin: 16px 0 0;
  padding: 14px;
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.04);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

/* ===== History ===== */
.history-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-head h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-style: normal;
  font-weight: 600;
  color: var(--text);
}

.history-list { display: grid; gap: 8px; }
.history-empty { font-size: 12px; color: var(--text-dim); }
.img-history-empty { grid-column: 1 / -1; padding: 10px 0; }

.history-load-more,
.img-history-load-more {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.img-history-load-more {
  grid-column: 1 / -1;
}

.history-load-more:hover,
.img-history-load-more:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.history-item {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 180ms ease;
}

.history-item:hover { border-color: var(--accent); }

.history-item.is-selected {
  border-color: rgba(37, 99, 235, 0.88);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(239, 246, 255, 0.76));
  box-shadow:
    0 0 0 3px rgba(37, 99, 235, 0.12),
    0 14px 36px rgba(15, 23, 42, 0.12);
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-time { font-size: 11px; color: var(--text-dim); }
.history-task {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.history-meta-status {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.history-meta-status .status-badge {
  padding: 3px 8px;
  font-size: 9px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.history-prompt {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: help;
}

.history-prompt-box {
  margin: 8px 0 12px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  font-size: 12px;
}
.history-prompt-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.history-prompt-box pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  font-family: inherit;
  line-height: 1.55;
  max-height: 280px;
  overflow: auto;
}

.history-actions { display: flex; flex-wrap: wrap; gap: 8px; }

button:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.72);
  outline-offset: 2px;
}

button:not(:disabled):active {
  transform: scale(0.97);
}

.drawer-hotspot:active::before {
  transform: translateY(-50%) scale(0.97);
}

.hidden,
.control-pill.hidden,
.tool-output.hidden,
.mode-hidden { display: none !important; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.4); }

/* ===== Selection ===== */
::selection { background: rgba(59, 130, 246, 0.15); color: var(--text); }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .composer-toolbar { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .app-shell { min-height: 100svh; padding: 72px 14px 48px; }
  .canvas-entry { top: 12px; left: 12px; min-height: 44px; border-radius: 14px; }
  .canvas-entry-icon { width: 28px; height: 28px; }
  .canvas-entry-copy small, .canvas-entry-arrow { display: none; }
  .composer-panel { padding: 0; }
  .hero { margin-bottom: 26px; }
  .composer-card { padding: 18px 16px; border-radius: 24px; }
  .composer-body { grid-template-columns: 1fr; gap: 10px; }
  .reference-picker { position: static; display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
  .reference-tile { width: 92px; min-height: 44px; margin: 0; padding: 8px 10px; transform: none; display: inline-flex; }
  .reference-plus { font-size: 22px; }
  .composer-card .preview-grid { padding-left: 0; justify-content: center; min-height: 0; }
  .prompt-editor { min-height: 118px; padding: 14px 8px 10px; }
  .composer-toolbar { flex-wrap: wrap; gap: 6px; }
  .control-pill { min-height: 38px; padding: 5px 9px; }
  .control-caption, .composer-toolbar .seg-title, .control-pill select { font-size: 13px; }
  button.send-button { width: 42px; height: 42px; min-width: 42px; margin-left: 0; }
  .grid { grid-template-columns: 1fr; }
  .panel-head { align-items: center; }
  .hero h1 { font-size: 32px; }
  .drawer-hotspot {
    top: 38vh;
    width: 44px;
    height: 112px;
    background: transparent;
  }
  .drawer-hotspot::before {
    right: 0;
    width: 34px;
    height: 82px;
  }
  .drawer-hotspot::after {
    right: 9px;
  }
  .result-panel { right: 0; max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ===== 富文本提示词编辑器(contenteditable + 缩略图 chip) ===== */
.prompt-editor {
  width: 100%;
  min-height: 104px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.52;
  letter-spacing: 0;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  text-align: left;
}

.prompt-editor:focus {
  border-color: transparent;
  box-shadow: none;
}

.prompt-editor:empty::before {
  content: attr(data-placeholder);
  display: block;
  width: 100%;
  margin: 0;
  color: #667085;
  line-height: 1.52;
  text-align: left;
  pointer-events: none;
}

.prompt-editor:empty {
  display: block;
}

.prompt-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.map-references-button {
  padding: 4px 8px;
  font-size: 12px;
}
.map-references-status {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted, #999);
  overflow-wrap: anywhere;
}
.prompt-footer .prompt-counter { margin-left: auto; }
.prompt-counter {
  margin-top: 6px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

.prompt-counter.is-warning {
  color: #b45309;
}

.ph-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 3px 1px 3px;
  margin: 0;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.065);
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.12;
  /* height auto from content */
  vertical-align: middle;
  transform: translateY(-0.5px);
  cursor: default;
  user-select: all;
  white-space: nowrap;
}

.ph-chip.is-missing {
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.42);
  background: rgba(254, 226, 226, 0.82);
}

.ph-chip-thumb {
  width: 12px;
  height: 12px;
  object-fit: cover;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ph-chip-thumb-icon {
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1a1a1a;
  color: var(--accent, #6366f1);
}

/* 统一 SVG 图标:用 currentColor + viewBox 自动居中,跟 emoji 字形脱钩 */
.ph-chip-svg {
  width: 7.5px;
  height: 7.5px;
  display: block;
}

.ph-chip-label {
  font-size: 12px;
  line-height: 1.12;
  letter-spacing: 0;
}

@media (max-width: 720px) {
  .prompt-editor {
    min-height: 92px;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.drawer-head > div:first-child { flex: 1; min-width: 0; }
.video-task-progress { margin-top: 12px; min-width: 180px; }
.video-task-progress-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12px; color: #8a611c; }
.video-task-progress progress { display: block; width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; appearance: none; background: #e8e4dc; }
.video-task-progress progress::-webkit-progress-bar { background: #e8e4dc; border-radius: 999px; }
.video-task-progress progress::-webkit-progress-value { background: linear-gradient(90deg, #c89135, #edc775); border-radius: 999px; transition: width .4s ease; }
.video-task-progress progress::-moz-progress-bar { background: #c89135; border-radius: 999px; }
.video-task-progress.is-complete .video-task-progress-heading { color: #27806b; }
.video-task-progress.is-complete progress::-webkit-progress-value { background: #399b81; }
.video-task-progress.is-complete progress::-moz-progress-bar { background: #399b81; }
@media (prefers-reduced-motion: reduce) { .video-task-progress progress::-webkit-progress-value { transition: none; } }
