:root {
  --bg: #f7f9ff;
  --bg-clean: #ffffff;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-solid: #ffffff;
  --surface-soft: #f4f7ff;
  --surface-tint: #eef3ff;
  --ink: #172033;
  --ink-soft: #34405a;
  --muted: rgba(23, 32, 51, 0.62);
  --muted-strong: rgba(23, 32, 51, 0.78);
  --line: rgba(74, 108, 247, 0.12);
  --line-strong: rgba(88, 78, 214, 0.2);
  --accent: #4a6cf7;
  --accent-strong: #3152d4;
  --accent-soft: #eef3ff;
  --purple: #7c3aed;
  --purple-strong: #5b21b6;
  --purple-soft: #f3edff;
  --cyan-soft: #eaf8ff;
  --danger: #b42318;
  --success: #229744;
  --shadow: 0 22px 58px rgba(42, 58, 130, 0.12);
  --shadow-soft: 0 10px 28px rgba(42, 58, 130, 0.08);
  --inner-line: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  --creator-panel-height: auto;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.hidden,
.hidden-input {
  display: none !important;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  padding: clamp(14px, 2.1vw, 30px);
  background:
    linear-gradient(90deg, rgba(74, 108, 247, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(124, 58, 237, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 12% 12%, rgba(74, 108, 247, 0.16), transparent 32%),
    radial-gradient(circle at 88% 8%, rgba(124, 58, 237, 0.15), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #f6f8ff 45%, #f9fbff 100%);
  background-size:
    42px 42px,
    42px 42px,
    auto,
    auto,
    auto;
}

.app-shell::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(120deg, transparent 0 36%, rgba(255, 255, 255, 0.52) 48%, transparent 62%),
    radial-gradient(circle at 52% 0%, rgba(255, 255, 255, 0.78), transparent 36%);
}

.topbar,
.workspace {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1520px;
  min-width: 0;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  padding: 10px 12px 10px 10px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow-soft), var(--inner-line);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(74, 108, 247, 0.14);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(74, 108, 247, 0.1);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand small {
  display: block;
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  display: block;
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand strong,
h1,
h2,
h3,
p {
  margin-top: 0;
}

.brand strong {
  display: block;
  color: var(--ink);
  font-size: clamp(18px, 1.55vw, 23px);
  line-height: 1.16;
  font-weight: 800;
}

h1,
h2 {
  margin-bottom: 0;
  color: var(--ink);
  line-height: 1.18;
}

h1,
h2 {
  font-size: 22px;
}

.topbar-tools {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.endpoint-pill {
  display: flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  gap: 10px;
  padding: 9px 13px;
  border: 1px solid rgba(74, 108, 247, 0.14);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(238, 243, 255, 0.92), rgba(243, 237, 255, 0.86)),
    rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--inner-line);
}

.guide-button {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid rgba(74, 108, 247, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(238, 243, 255, 0.96), rgba(243, 237, 255, 0.9)),
    #fff;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--inner-line);
  transition:
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

.guide-button svg {
  width: 16px;
  height: 16px;
}

.guide-button:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 58, 237, 0.36);
  color: var(--purple-strong);
  box-shadow: 0 10px 22px rgba(74, 108, 247, 0.14), var(--inner-line);
}

.endpoint-pill strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(18px, 2vw, 28px);
}

.creator-panel,
.result-panel {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.86);
  background: var(--surface);
  box-shadow: var(--shadow), var(--inner-line);
  backdrop-filter: blur(24px);
}

.creator-panel {
  position: sticky;
  top: 18px;
  overflow: hidden;
  padding: 18px;
  border-radius: 28px;
}

.creator-panel::before {
  position: absolute;
  top: 0;
  left: -36%;
  width: 36%;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--accent), var(--purple), transparent);
  opacity: 0;
}

.creator-panel.is-generating {
  border-color: rgba(74, 108, 247, 0.34);
}

.creator-panel.is-generating::before {
  animation: loading-sweep 1.2s linear infinite;
  opacity: 1;
}

.result-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  height: var(--creator-panel-height);
  min-height: 0;
  overflow: hidden;
  padding: 20px;
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(250, 252, 255, 0.76)),
    radial-gradient(circle at 96% 0%, rgba(124, 58, 237, 0.11), transparent 28%),
    radial-gradient(circle at 12% 96%, rgba(74, 108, 247, 0.1), transparent 26%);
}

.result-panel::before {
  position: absolute;
  inset: 78px 18px 18px;
  z-index: -1;
  border: 1px solid rgba(74, 108, 247, 0.08);
  border-radius: 28px;
  content: "";
  background:
    linear-gradient(90deg, rgba(74, 108, 247, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(124, 58, 237, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
}

.panel-heading,
.field-topline,
.action-row,
.settings-title,
.image-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  align-items: flex-start;
  margin-bottom: 18px;
}

.result-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.secondary-button,
.image-card-footer button,
.reference-thumb button {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink-soft);
  box-shadow: var(--inner-line);
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

.icon-button,
.secondary-button {
  width: 42px;
  height: 42px;
}

.icon-button:hover,
.secondary-button:hover,
.image-card-footer button:hover,
.reference-thumb button:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 58, 237, 0.28);
  background: linear-gradient(135deg, var(--accent-soft), var(--purple-soft));
  color: var(--purple-strong);
  box-shadow: 0 10px 22px rgba(74, 108, 247, 0.12), var(--inner-line);
}

.field {
  display: grid;
  min-width: 0;
  gap: 9px;
  margin-bottom: 16px;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.field-hint a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.field-hint a:hover {
  color: var(--purple-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field-label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
}

.field-label svg,
.settings-title svg {
  color: var(--accent);
}

.field-link {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.field-link:hover {
  color: var(--purple-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-input,
.prompt-input,
.select-field select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(74, 108, 247, 0.13);
  outline: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(249, 251, 255, 0.88)),
    var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--inner-line);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.text-input,
.select-field select {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 15px;
}

.select-field select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%2334405a' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}

.prompt-input {
  min-height: 186px;
  padding: 15px 16px;
  border-radius: 20px;
  line-height: 1.62;
  resize: vertical;
}

.text-input:focus,
.prompt-input:focus,
.select-field select:focus {
  border-color: rgba(74, 108, 247, 0.72);
  background: #fff;
  box-shadow:
    0 0 0 4px rgba(74, 108, 247, 0.1),
    0 12px 24px rgba(74, 108, 247, 0.08),
    var(--inner-line);
}

.text-input::placeholder,
.prompt-input::placeholder {
  color: rgba(52, 64, 90, 0.52);
}

.password-field {
  position: relative;
  display: block;
}

.password-field .text-input {
  padding-right: 48px;
}

.field-icon-button {
  position: absolute;
  top: 50%;
  right: 10px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted-strong);
  transform: translateY(-50%);
  transition:
    border-color 0.16s ease,
    color 0.16s ease,
    background 0.16s ease;
}

.field-icon-button:hover,
.field-icon-button[aria-pressed="true"] {
  border-color: rgba(74, 108, 247, 0.28);
  background: #fff;
  color: var(--accent-strong);
}

.save-key-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 18px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.save-key-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.save-key-option small,
.counter {
  color: var(--muted);
  font-weight: 700;
}

.counter {
  flex: 0 0 auto;
  font-size: 13px;
}

.counter.warn {
  color: #d44728;
}

.action-row {
  margin-top: 16px;
}

.primary-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 52px;
  gap: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 16px 34px rgba(74, 108, 247, 0.22);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease;
}

.primary-button::after {
  position: absolute;
  inset: 1px 1px auto;
  height: 50%;
  border-radius: 15px 15px 10px 10px;
  pointer-events: none;
  content: "";
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 20px 42px rgba(74, 108, 247, 0.28);
}

.primary-button:disabled {
  opacity: 0.54;
  box-shadow: none;
}

.message {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.5;
}

.message.error {
  border: 1px solid rgba(180, 35, 24, 0.14);
  background: #fff4f2;
  color: var(--danger);
}

.message.success {
  border: 1px solid rgba(34, 151, 68, 0.14);
  background: #f0fbf4;
  color: var(--success);
}

.reference-zone {
  display: grid;
  min-width: 0;
  gap: 11px;
  margin: 20px 0 18px;
}

.reference-zone.is-dragging .upload-box {
  transform: translateY(-1px);
  border-color: rgba(34, 151, 68, 0.48);
  background:
    linear-gradient(135deg, rgba(240, 251, 244, 0.98), rgba(238, 243, 255, 0.86)),
    #fff;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.history-note {
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.upload-summary {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.reference-limit-popover {
  position: absolute;
  z-index: 40;
  display: grid;
  width: min(300px, calc(100vw - 24px));
  gap: 9px;
  padding: 11px;
  border: 1px solid rgba(74, 108, 247, 0.18);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 16px 34px rgba(42, 58, 130, 0.18), var(--inner-line);
}

.reference-limit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.reference-limit-actions button {
  padding: 6px 9px;
  border: 1px solid rgba(74, 108, 247, 0.18);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.upload-box {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 126px;
  place-items: center;
  gap: 4px;
  padding: 16px;
  border: 1px dashed rgba(74, 108, 247, 0.3);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(238, 243, 255, 0.72), rgba(243, 237, 255, 0.62)),
    rgba(255, 255, 255, 0.66);
  color: var(--accent-strong);
  text-align: center;
  box-shadow: var(--inner-line);
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    transform 0.16s ease;
}

.upload-box:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 58, 237, 0.48);
  background:
    linear-gradient(135deg, rgba(238, 243, 255, 0.98), rgba(243, 237, 255, 0.9)),
    #fff;
}

.upload-box span {
  color: var(--ink);
  font-weight: 800;
}

.upload-box small {
  color: var(--muted);
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.reference-thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  margin: 0;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 18px;
  background: var(--surface-tint);
  box-shadow: var(--inner-line);
}

.reference-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-thumb button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
}

.settings-block {
  display: grid;
  min-width: 0;
  gap: 16px;
  padding: 15px;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(246, 248, 255, 0.7)),
    rgba(255, 255, 255, 0.64);
  box-shadow: var(--inner-line);
}

.settings-title {
  justify-content: flex-start;
  color: var(--ink);
  font-weight: 780;
}

.settings-toggle {
  display: none;
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink-soft);
  place-items: center;
  transition: transform 0.2s ease;
}

.settings-block.is-collapsed .settings-toggle {
  transform: rotate(-90deg);
}

.settings-block.is-collapsed .control-grid,
.settings-block.is-collapsed .ratio-label,
.settings-block.is-collapsed .ratio-group,
.settings-block.is-collapsed .range-field {
  display: none;
}

@media (max-width: 720px) {
  .settings-toggle {
    display: grid;
  }
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  gap: 10px;
}

.select-field,
.range-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.select-field span,
.range-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.ratio-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  gap: 10px;
}

.ratio-label {
  margin: -2px 0 -6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.ratio-button {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 64px;
  gap: 4px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--inner-line);
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.ratio-button strong {
  font-size: 14px;
}

.prompt-tools {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
}

.ratio-button span {
  color: var(--muted);
  font-size: 12px;
}

.ratio-button:hover {
  transform: translateY(-1px);
  border-color: rgba(74, 108, 247, 0.28);
}

.ratio-button.active {
  border-color: rgba(124, 58, 237, 0.42);
  background:
    linear-gradient(135deg, rgba(238, 243, 255, 0.96), rgba(243, 237, 255, 0.92)),
    #fff;
  color: var(--purple-strong);
}

.ratio-button.active::after {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  content: "";
  background: linear-gradient(135deg, var(--accent), var(--purple));
}

.range-field input {
  accent-color: var(--accent);
}

.model-chip {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 999px;
  background:
    linear-gradient(135deg, var(--accent-soft), var(--purple-soft)),
    #fff;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--inner-line);
}

.generation-feed {
  display: grid;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  gap: 24px;
}

.generation-turn {
  display: grid;
  gap: 14px;
}

.user-message {
  justify-self: end;
  width: min(660px, 86%);
  padding: 13px 15px;
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 22px 22px 7px 22px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  box-shadow: 0 16px 32px rgba(74, 108, 247, 0.18);
}

.user-message span,
.assistant-message-head span {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.user-message span {
  color: rgba(255, 255, 255, 0.9);
}

.user-message p {
  margin: 5px 0 6px;
  color: #fff;
  line-height: 1.6;
  white-space: pre-wrap;
}

.user-message p.is-collapsed {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.prompt-toggle {
  display: inline-flex;
  padding: 0;
  margin: 0 0 7px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.user-message small,
.assistant-message-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.user-message small {
  color: rgba(255, 255, 255, 0.76);
}

.assistant-message {
  justify-self: start;
  width: min(100%, 940px);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 255, 0.78)),
    rgba(255, 255, 255, 0.78);
  box-shadow: 0 18px 42px rgba(42, 58, 130, 0.1), var(--inner-line);
}

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

.result-loading-grid,
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

.result-skeleton {
  display: grid;
  min-height: 224px;
  place-items: center;
  gap: 10px;
  overflow: hidden;
  border: 1px solid rgba(124, 58, 237, 0.16);
  border-radius: 22px;
  background:
    linear-gradient(110deg, transparent, rgba(255, 255, 255, 0.82) 45%, transparent 70%),
    linear-gradient(135deg, var(--accent-soft), var(--purple-soft));
  background-position:
    -240px 0,
    0 0;
  background-size:
    240px 100%,
    100% 100%;
  color: var(--accent-strong);
  font-size: 13px;
  animation: skeleton-shimmer 1.25s ease-in-out infinite;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(124, 58, 237, 0.2);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 1s linear infinite;
}

.image-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 42px rgba(42, 58, 130, 0.11), var(--inner-line);
}

.image-card img {
  display: block;
  width: 100%;
  height: auto;
  background:
    linear-gradient(90deg, rgba(74, 108, 247, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(124, 58, 237, 0.045) 1px, transparent 1px),
    linear-gradient(135deg, #fbfdff, #f0f4ff);
  background-size:
    24px 24px,
    24px 24px,
    auto;
  cursor: zoom-in;
  transition: filter 0.18s ease;
}

.image-card img:hover {
  filter: brightness(1.02);
}

.image-card.is-image-broken img {
  opacity: 0;
}

.image-load-error {
  position: absolute;
  top: 12px;
  right: 12px;
  left: 12px;
  z-index: 1;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(180, 35, 24, 0.14);
  border-radius: 16px;
  background: rgba(255, 244, 242, 0.96);
  color: var(--danger);
  box-shadow: var(--inner-line);
}

.image-load-error strong {
  font-size: 13px;
}

.image-load-error span {
  color: rgba(180, 35, 24, 0.76);
  font-size: 12px;
  line-height: 1.45;
}

.image-card-footer {
  padding: 12px 14px 14px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 800;
}

.image-card-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
  margin-top: -2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.image-card-actions::-webkit-scrollbar {
  display: none;
}

/* 右侧渐变遮罩,暗示可横滑 */
.image-card-actions::after {
  content: "";
  position: sticky;
  right: 0;
  flex-shrink: 0;
  width: 32px;
  height: 100%;
  margin-left: -32px;
  background: linear-gradient(to left, rgba(255,255,255,0.92), transparent);
  pointer-events: none;
  transition: opacity 0.2s;
}

.image-card-actions.scrolled-end::after {
  opacity: 0;
}

.image-card-footer button {
  display: inline-flex;
  width: auto;
  min-width: 58px;
  height: 34px;
  gap: 5px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.image-card-footer button svg {
  width: 15px;
  height: 15px;
}

.retry-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  margin-top: 10px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 14px;
  background: #fff;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--inner-line);
}

.retry-button:hover {
  border-color: rgba(180, 35, 24, 0.3);
  background: #fff7f5;
}

.empty-state {
  display: grid;
  min-height: 420px;
  place-items: center;
  padding: clamp(24px, 4vw, 46px);
  border: 1px solid rgba(74, 108, 247, 0.1);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 250, 255, 0.58)),
    rgba(255, 255, 255, 0.56);
  box-shadow: var(--inner-line);
  text-align: center;
}

.empty-state h3 {
  margin: 20px 0 8px;
  font-size: 20px;
}

.empty-state p {
  width: min(560px, 100%);
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.sample-frame {
  position: relative;
  overflow: hidden;
  width: min(500px, 100%);
  aspect-ratio: 16 / 11;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 30px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(135deg, #eff5ff 0%, #ede7ff 54%, #e7f8ff 100%);
  background-size:
    28px 28px,
    28px 28px,
    auto;
  box-shadow: 0 24px 62px rgba(74, 108, 247, 0.16);
}

.sample-frame::before {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 22px;
  content: "";
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
}

.sample-sun {
  position: absolute;
  top: 34px;
  right: 42px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  box-shadow: 0 16px 34px rgba(74, 108, 247, 0.28);
}

.sample-mountain {
  position: absolute;
  bottom: -18px;
  width: 76%;
  height: 58%;
  border-radius: 28px;
  transform: rotate(45deg);
}

.sample-mountain.first {
  left: -22%;
  background: linear-gradient(135deg, #446cf6, #7c3aed);
}

.sample-mountain.second {
  right: -24%;
  background: linear-gradient(135deg, #65b7ff, #4a6cf7);
}

.sample-card {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.36);
  box-shadow: var(--inner-line);
  backdrop-filter: blur(10px);
}

.sample-card.small {
  top: 46px;
  left: 38px;
  width: 70px;
  height: 46px;
}

.sample-card.large {
  right: 62px;
  bottom: 44px;
  width: 112px;
  height: 70px;
}

.image-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(247, 249, 255, 0.82);
  backdrop-filter: blur(18px);
}

.image-preview-modal {
  display: grid;
  width: min(1080px, 100%);
  max-height: calc(100vh - 40px);
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 28px 90px rgba(42, 58, 130, 0.22), var(--inner-line);
}

.image-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
}

.image-preview-heading h2 {
  font-size: 16px;
}

.image-preview-modal img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 128px);
  margin: 0 auto;
  border-radius: 18px;
  background: var(--surface-soft);
  object-fit: contain;
}

.guide-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(247, 249, 255, 0.82);
  backdrop-filter: blur(18px);
}

.guide-modal {
  display: grid;
  width: min(640px, 100%);
  max-height: calc(100vh - 40px);
  gap: 18px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 255, 0.92)),
    rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 90px rgba(42, 58, 130, 0.22), var(--inner-line);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.guide-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.guide-heading h2 {
  font-size: 22px;
}

.guide-steps {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  list-style: none;
}

.guide-step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 248, 255, 0.78)),
    rgba(255, 255, 255, 0.78);
  box-shadow: var(--inner-line);
}

.guide-step-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(74, 108, 247, 0.22);
}

.guide-step-body h3 {
  margin: 2px 0 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.guide-step-body p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.7;
}

.guide-step-body strong {
  color: var(--ink);
  font-weight: 800;
}

.guide-step-body a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.guide-step-body a:hover {
  color: var(--purple-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-step-body code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-tint);
  color: var(--accent-strong);
  font-size: 12.5px;
}

.guide-action-list {
  display: grid;
  gap: 6px;
  padding: 8px 0 0 18px;
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.guide-contact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: stretch;
  gap: 20px;
  padding: 18px;
  border: 1px solid rgba(74, 108, 247, 0.14);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(238, 243, 255, 0.9), rgba(247, 242, 255, 0.82)),
    rgba(255, 255, 255, 0.88);
  box-shadow: var(--inner-line);
}

.guide-contact-copy {
  min-width: 0;
}

.guide-contact h3 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.guide-contact p {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.65;
}

.guide-contact span {
  display: inline-flex;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.guide-contact img {
  display: block;
  width: 240px;
  max-width: 100%;
  justify-self: end;
  aspect-ratio: 930 / 880;
  object-fit: contain;
  object-position: center center;
  border: 1px solid rgba(74, 108, 247, 0.12);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(42, 58, 130, 0.12);
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes loading-sweep {
  to {
    left: 100%;
  }
}

@keyframes skeleton-shimmer {
  to {
    background-position:
      120% 0,
      0 0;
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .creator-panel {
    position: static;
  }

  .result-panel {
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
  }

  .generation-feed {
    overflow: visible;
  }

  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 10px;
    border-radius: 20px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand strong {
    font-size: 23px;
  }

  .topbar-tools {
    flex-wrap: wrap;
    width: 100%;
  }

  .endpoint-pill {
    align-items: flex-start;
    flex-direction: column;
    flex: 1 1 200px;
    gap: 5px;
    border-radius: 18px;
  }

  .guide-button {
    flex: 0 0 auto;
  }

  .guide-modal {
    padding: 18px;
    border-radius: 24px;
  }

  .guide-contact {
    grid-template-columns: 1fr;
  }

  .guide-contact img {
    width: min(280px, 100%);
    justify-self: center;
  }

  .guide-step {
    grid-template-columns: 28px 1fr;
    padding: 12px;
    gap: 10px;
  }

  .guide-step-index {
    width: 26px;
    height: 26px;
    font-size: 12.5px;
  }

  .creator-panel,
  .result-panel {
    padding: 14px;
    border-radius: 24px;
    box-shadow: 0 14px 38px rgba(42, 58, 130, 0.1), var(--inner-line);
  }

  .workspace {
    gap: 14px;
  }

  .prompt-input {
    min-height: 132px;
  }

  .control-grid,
  .ratio-group,
  .result-loading-grid,
  .reference-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-grid {
    grid-template-columns: 1fr;
  }

  .image-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
  }

  .image-card img {
    height: 100%;
    min-height: 180px;
    object-fit: cover;
  }

  .image-card-footer {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 76px;
    padding: 10px;
    gap: 8px;
  }

  .image-card-footer > span {
    text-align: center;
  }

  .image-card-actions {
    flex-direction: column;
    align-items: stretch;
    padding-top: 0;
    margin-top: 0;
    overflow: visible;
  }

  .image-card-actions::after {
    display: none;
  }

  .image-card-footer button {
    justify-content: center;
    min-width: 0;
    width: 100%;
    height: 36px;
    padding: 0 6px;
  }

  .user-message {
    width: 94%;
  }

  .assistant-message {
    padding: 12px;
    border-radius: 22px;
  }

  .result-skeleton {
    min-height: 190px;
  }

  .empty-state {
    min-height: 320px;
    padding: 22px 14px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 10px;
  }

  .creator-panel,
  .result-panel {
    padding: 12px;
  }

  .text-input,
  .select-field select {
    min-height: 44px;
  }

  .upload-box {
    min-height: 98px;
  }

  .primary-button {
    min-height: 46px;
  }

  .save-key-option {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: inherit;
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .creator-panel.is-generating::before { animation: none; opacity: 1; }
  .result-skeleton { animation: none; }
}
