:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: rgba(10, 22, 32, 0.78);
  --panel-strong: rgba(15, 30, 43, 0.94);
  --panel-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(180, 219, 230, 0.14);
  --line-strong: rgba(180, 219, 230, 0.24);
  --text: #eef8f8;
  --soft: #c8dcde;
  --muted: #86a0a6;
  --accent: #33d6b2;
  --accent-2: #68a7ff;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius: 14px;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 12%, rgba(51, 214, 178, 0.26), transparent 25%),
    radial-gradient(circle at 82% 8%, rgba(104, 167, 255, 0.22), transparent 24%),
    radial-gradient(circle at 48% 112%, rgba(27, 138, 118, 0.22), transparent 34%),
    linear-gradient(145deg, #061018 0%, #0d1d28 42%, #071019 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(118deg, transparent 0 18%, rgba(88, 241, 210, 0.075) 18% 19%, transparent 19% 100%),
    linear-gradient(138deg, transparent 0 58%, rgba(110, 170, 255, 0.07) 58% 59%, transparent 59% 100%),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 52px 52px, 52px 52px;
  mask-image: radial-gradient(circle at center, black 0%, transparent 78%);
  opacity: 0.72;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.04), transparent 46%),
    radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.34));
}

button, input, textarea, select { font: inherit; outline: none; }
button { border: 0; cursor: pointer; }
h1, h2, p { margin: 0; }
.hidden { display: none !important; }

body.dragging-image::before {
  z-index: 50;
  background:
    radial-gradient(circle at center, rgba(51, 214, 178, 0.18), transparent 42%),
    rgba(3, 12, 18, 0.72);
  border: 2px dashed rgba(51, 214, 178, 0.72);
  box-shadow: inset 0 0 0 9999px rgba(3, 12, 18, 0.42);
}
body.dragging-image::after {
  content: "松开即可上传参考图";
  z-index: 51;
  display: grid;
  place-items: center;
  color: #eafffb;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: transparent;
  text-shadow: 0 10px 34px rgba(0, 0, 0, 0.42);
}


::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(159, 195, 202, 0.28);
  border-radius: 999px;
}

.app-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 0;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 36px rgba(51, 214, 178, 0.12);
}
.brand-mark img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
}
h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
}
.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.status-pill {
  max-width: 520px;
  min-height: 34px;
  display: flex;
  align-items: center;
  color: var(--soft);
  font-size: 13px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(7, 16, 24, 0.54);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  gap: 14px;
}

.control-panel {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: visible;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 8px 2px 2px;
}
.presets-card {
  position: relative;
  z-index: 9;
}
.panel-card,
.studio {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 32, 45, 0.84), rgba(8, 19, 28, 0.76));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.panel-card {
  border-radius: var(--radius);
  padding: 14px;
}
.card-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
}
.card-title small,
.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.hint { margin-top: 10px; line-height: 1.5; }

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}
.field:last-child { margin-bottom: 0; }
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.field-grid .field { margin-bottom: 0; }
label {
  color: var(--soft);
  font-size: 12px;
  font-weight: 600;
}
input,
select {
  width: 100%;
  height: 38px;
  color: var(--text);
  background: rgba(3, 10, 16, 0.56);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 11px;
  font-size: 13px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  padding: 0;
}
input:focus,
select:focus {
  border-color: rgba(51, 214, 178, 0.72);
  box-shadow: 0 0 0 3px rgba(51, 214, 178, 0.12);
  background: rgba(3, 10, 16, 0.74);
}
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  user-select: none;
}
select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.button,
.send {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.button:hover,
.send:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.11);
  border-color: var(--line-strong);
}
.button.primary,
.send {
  color: #031310;
  border-color: transparent;
  background: linear-gradient(135deg, #75ffe1, #63b2ff);
  box-shadow: 0 12px 30px rgba(51, 214, 178, 0.16);
}
.button.subtle {
  min-height: 34px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.045);
}
.button.danger {
  color: #ffd6d6;
  border-color: rgba(255, 107, 107, 0.28);
  background: rgba(255, 107, 107, 0.08);
}
.button.full { width: 100%; margin-top: 10px; }
.send:disabled {
  opacity: 0.64;
  cursor: not-allowed;
  transform: none;
}

.preset-picker {
  position: relative;
}
.preset-trigger {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  border: 1px solid rgba(51, 214, 178, 0.22);
  border-radius: 13px;
  background:
    linear-gradient(135deg, rgba(51, 214, 178, 0.11), rgba(104, 167, 255, 0.06)),
    rgba(255, 255, 255, 0.045);
  padding: 11px 12px;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.preset-trigger:hover {
  transform: translateY(-1px);
  border-color: rgba(51, 214, 178, 0.42);
  background:
    linear-gradient(135deg, rgba(51, 214, 178, 0.16), rgba(104, 167, 255, 0.09)),
    rgba(255, 255, 255, 0.065);
}
.preset-trigger strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}
.preset-trigger small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}
.preset-trigger i {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  color: var(--soft);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  font-style: normal;
  transition: transform 0.18s ease;
}
.preset-trigger[aria-expanded="true"] i {
  transform: rotate(180deg);
}
.preset-list {
  position: static;
  margin-top: 10px;
  max-height: min(420px, 46vh);
  overflow-y: auto;
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgba(20, 42, 55, 0.98), rgba(8, 20, 30, 0.98));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.30);
}
.preset {
  width: 100%;
  text-align: left;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  padding: 9px 10px;
  line-height: 1.35;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.preset:hover {
  transform: translateY(-1px);
  background: rgba(51, 214, 178, 0.09);
  border-color: rgba(51, 214, 178, 0.3);
}
.preset strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}
.preset span {
  color: var(--muted);
  font-size: 11px;
}
.stats-card .stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.stats-card .stat strong {
  color: var(--text);
}

.studio {
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.hero-strip {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(110deg, rgba(51, 214, 178, 0.12), transparent 42%),
    rgba(255, 255, 255, 0.025);
}
.hero-strip h2 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
}
.hero-strip p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}
.hero-badges span {
  color: var(--soft);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.empty {
  margin: auto;
  width: min(460px, 100%);
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.035);
}
.empty strong {
  color: var(--text);
  font-size: 18px;
}
.empty span {
  font-size: 13px;
  line-height: 1.6;
}
.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.message.user {
  justify-content: flex-end;
}
.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  color: #061018;
  background: linear-gradient(135deg, #77ffe1, #7bb9ff);
  border-radius: 11px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(51, 214, 178, 0.12);
}
.logo-avatar {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.logo-avatar img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  display: block;
}
.message.user .avatar {
  order: 2;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  box-shadow: none;
}
.bubble {
  max-width: min(760px, calc(100% - 48px));
  color: var(--soft);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 5px;
  background: rgba(255, 255, 255, 0.055);
  padding: 12px 13px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}
.message.user .bubble {
  color: var(--text);
  border-color: rgba(51, 214, 178, 0.26);
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(135deg, rgba(51, 214, 178, 0.18), rgba(104, 167, 255, 0.12));
}
.bubble p {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.65;
}
.meta {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.meta .button {
  min-height: 30px;
}

.loading-line {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--soft);
  font-size: 14px;
}
.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(51, 214, 178, 0.58);
  animation: pulse 1.2s infinite;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
  gap: 12px;
  margin-top: 11px;
}
.image-tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
}
.image-preview {
  display: block;
  height: clamp(180px, 24vh, 310px);
}
.image-tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: rgba(2, 8, 12, 0.5);
}
.export-inline {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 0.8fr) minmax(0, 0.9fr);
  gap: 7px;
  padding: 8px 9px 0;
}
.export-inline select {
  height: 32px;
  padding-left: 8px;
  padding-right: 24px;
  font-size: 12px;
  border-radius: 8px;
}
.tile-actions {
  display: grid;
  grid-template-columns: 0.9fr 1fr 0.8fr;
  gap: 8px;
  padding: 9px;
  border-top: 1px solid var(--line);
  background: rgba(4, 13, 20, 0.82);
}
.tile-actions .button {
  min-height: 34px;
  background: rgba(255, 255, 255, 0.07);
  text-decoration: none;
}
.tile-actions .button.primary {
  color: #031310;
  border-color: transparent;
  background: linear-gradient(135deg, #75ffe1, #63b2ff);
}
.image-info {
  padding: 8px 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.composer {
  border-top: 1px solid var(--line);
  background: rgba(6, 15, 23, 0.9);
  padding: 12px 14px 14px;
  display: grid;
  gap: 9px;
}
.refs {
  min-height: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.refs:empty { display: none; }
.ref {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
}
.ref img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ref button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: white;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
}
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}
.attach {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  color: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.065);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.attach:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
}
.attach input { display: none; }
textarea {
  flex: 1;
  min-height: 42px;
  max-height: 128px;
  resize: none;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(2, 9, 14, 0.58);
  padding: 10px 12px;
  line-height: 1.55;
  font-size: 14px;
}
textarea:focus {
  border-color: rgba(51, 214, 178, 0.55);
  box-shadow: 0 0 0 3px rgba(51, 214, 178, 0.1);
}
textarea::placeholder { color: #789099; }
.send {
  min-width: 76px;
  height: 42px;
  flex: 0 0 auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(5, 15, 22, 0.92);
  box-shadow: var(--shadow);
  padding: 10px 16px;
  font-size: 13px;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 11px rgba(51, 214, 178, 0); }
  100% { box-shadow: 0 0 0 0 rgba(51, 214, 178, 0); }
}

@media (max-width: 1120px) {
  html, body { overflow: auto; height: auto; min-height: 100%; }
  .app-shell {
    min-height: 100vh;
    height: auto;
    width: min(100% - 22px, 900px);
    grid-template-rows: auto auto;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .control-panel {
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .presets-card,
  .stats-card { grid-column: 1 / -1; }
  .preset-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .studio { height: min(780px, calc(100vh - 24px)); }
}

@media (max-width: 680px) {
  .app-shell {
    width: 100%;
    padding: 0;
    gap: 0;
  }
  .topbar {
    min-height: 62px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(6, 15, 23, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .brand p,
  .top-actions .button,
  .hero-badges { display: none; }
  h1 { font-size: 18px; }
  .status-pill {
    max-width: 42vw;
    font-size: 12px;
    min-height: 30px;
  }
  .workspace {
    padding: 12px;
    gap: 12px;
  }
  .control-panel,
  .preset-list {
    grid-template-columns: 1fr;
  }
  .panel-card { padding: 12px; }
  .studio {
    height: calc(100vh - 86px);
    border-radius: 16px;
  }
  .hero-strip {
    min-height: 58px;
    padding: 12px;
  }
  .hero-strip h2 { font-size: 15px; }
  .hero-strip p { display: none; }
  .messages {
    padding: 13px 11px;
    gap: 13px;
  }
  .avatar {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    border-radius: 9px;
    font-size: 12px;
  }
  .bubble {
    max-width: calc(100% - 40px);
    padding: 10px 11px;
  }
  .image-grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }
  .image-preview {
    height: clamp(145px, 24vh, 240px);
  }
  .export-inline,
  .tile-actions {
    grid-template-columns: 1fr;
  }
  .composer {
    padding: 10px;
  }
  .composer-box {
    gap: 7px;
  }
  .attach,
  .send {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
  }
  .send {
    font-size: 0;
  }
  .send::after {
    content: "发";
    font-size: 14px;
  }
  textarea {
    min-height: 40px;
    max-height: 108px;
  }
}
