:root {
  color-scheme: dark;
  --bg: #0b1117;
  --workspace: #0f1720;
  --sidebar: #111922;
  --panel: #151f2a;
  --panel-2: #101922;
  --panel-3: #1b2834;
  --line: rgba(155, 184, 205, 0.18);
  --line-strong: rgba(155, 184, 205, 0.34);
  --text: #eef5f8;
  --muted: #91a4b3;
  --muted-2: #627786;
  --accent: #ffb447;
  --accent-deep: #e68c22;
  --cyan: #33c2d7;
  --green: #5bd6a1;
  --danger: #ff6b7a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  --thumb-size: 230px;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #eef5f8;
  --workspace: #f7fbfd;
  --sidebar: #edf5f8;
  --panel: #ffffff;
  --panel-2: #f3f8fb;
  --panel-3: #e8f1f6;
  --line: rgba(52, 76, 95, 0.17);
  --line-strong: rgba(52, 76, 95, 0.28);
  --text: #132333;
  --muted: #5d7182;
  --muted-2: #8799a8;
  --accent: #ffae3d;
  --accent-deep: #d87316;
  --cyan: #087f98;
  --green: #20996d;
  --danger: #d94c5c;
  --shadow: 0 22px 58px rgba(41, 67, 86, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  background:
    radial-gradient(circle at 22% 12%, rgba(51, 194, 215, 0.12), transparent 28%),
    linear-gradient(135deg, #0b1117 0%, #101821 52%, #111416 100%);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "微软雅黑", "PingFang SC", Arial, sans-serif;
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at 22% 12%, rgba(8, 127, 152, 0.13), transparent 30%),
    linear-gradient(135deg, #eaf4f8 0%, #fbfdff 52%, #eef3f6 100%);
}

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

button,
select,
.image-upload {
  cursor: pointer;
}

.sidebar {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 20px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 22%),
    var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px 22px;
}

.brand > div:last-child {
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffd38a 0%, #ffb447 48%, #ee7044 100%);
  color: #17120b;
  font-weight: 950;
  font-size: 24px;
  box-shadow: 0 12px 28px rgba(255, 180, 71, 0.22);
}

.brand h1,
.brand span,
.topbar h2,
.topbar .eyebrow,
.modal-header h2,
.empty-state h3,
.empty-state p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand span,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 800;
  margin: 8px 2px 10px;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  font-weight: 800;
}

.ghost-btn:hover {
  border-color: rgba(255, 180, 71, 0.45);
  background: rgba(255, 180, 71, 0.08);
}

.project-list {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.project-item {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 4px 6px 4px 10px;
}

.project-name {
  min-width: 0;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.project-rename {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.project-rename svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-rename:hover {
  color: #15110b;
  border-color: transparent;
  background: var(--accent);
}

.project-item:hover,
.project-item.active {
  background: linear-gradient(90deg, rgba(255, 180, 71, 0.16), rgba(51, 194, 215, 0.07));
  border-color: rgba(255, 180, 71, 0.34);
}

.theme-toggle-btn {
  width: 42px;
  height: 42px;
  justify-self: end;
  align-self: end;
  display: grid;
  place-items: center;
  border: 3px solid #ff6570;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.2), transparent 34%),
    rgba(255, 101, 112, 0.08);
  color: var(--accent);
  padding: 0;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 12px 30px rgba(255, 101, 112, 0.16);
}

.theme-toggle-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.28), transparent 34%),
    rgba(255, 180, 71, 0.16);
}

body[data-theme="light"] .theme-toggle-btn {
  color: #25384a;
  border-color: #ffb447;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.92), transparent 36%),
    #fff4cf;
  box-shadow: 0 12px 28px rgba(255, 180, 71, 0.28);
}

.workspace {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 32%),
    var(--workspace);
}

body[data-theme="light"] .workspace {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), transparent 34%),
    var(--workspace);
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.balance-badge {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(91, 214, 161, 0.32);
  border-radius: 8px;
  background: rgba(20, 118, 67, 0.16);
  color: #b9f7d0;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

body[data-theme="light"] .balance-badge {
  border-color: rgba(17, 116, 82, 0.4);
  background: rgba(17, 116, 82, 0.12);
  color: #075f42;
}

.balance-badge.error {
  border-color: rgba(255, 107, 122, 0.45);
  background: rgba(95, 17, 30, 0.28);
  color: #ffd4da;
}

body[data-theme="light"] .balance-badge.error {
  border-color: rgba(185, 43, 63, 0.36);
  background: rgba(185, 43, 63, 0.1);
  color: #9b1c32;
}

.topbar h2 {
  font-size: 25px;
  margin-top: 5px;
  letter-spacing: 0;
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  padding: 0 14px;
  font-weight: 900;
}

.settings-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-btn:hover {
  border-color: rgba(51, 194, 215, 0.5);
  background: rgba(51, 194, 215, 0.1);
}

.gallery-shell {
  position: relative;
  min-height: 0;
  display: grid;
  margin: 0 28px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel-2);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.thumb-size-control {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  width: 132px;
  height: 34px;
  display: grid;
  grid-template-columns: 16px 1fr 16px;
  align-items: center;
  gap: 7px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 18, 0.76);
  color: var(--text);
  padding: 0 9px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body[data-theme="light"] .thumb-size-control {
  background: rgba(255, 255, 255, 0.84);
}

.thumb-size-control.hidden {
  display: none;
}

.thumb-size-control span {
  color: var(--muted);
  font-weight: 950;
  text-align: center;
}

.thumb-size-control input {
  min-height: 0;
  height: 4px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(155, 184, 205, 0.32);
  accent-color: var(--text);
}

.empty-state {
  grid-area: 1 / 1;
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  padding: 42px 20px;
  text-align: center;
}

.empty-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.empty-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state h3 {
  color: var(--text);
  font-size: 20px;
}

.result-grid {
  grid-area: 1 / 1;
  min-height: 0;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-size), var(--thumb-size)));
  align-items: start;
  justify-content: start;
  gap: 16px;
  padding: 18px 18px 64px;
}

.result-grid.chat-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1040px;
  margin: 0 auto;
  width: 100%;
  min-height: 100%;
  padding-bottom: 84px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
}

.result-grid:not(.chat-results) .result-card {
  width: var(--thumb-size);
  border: 0;
  background: #05080b;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

.image-loading-card {
  min-height: calc(var(--thumb-size) * 1.24);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #2a2d33;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

.image-loading-glass {
  width: 100%;
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #eef1f5;
  text-align: center;
}

.image-loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #ffb340;
  border-radius: 50%;
  animation: imageLoadingSpin 0.9s linear infinite;
}

.image-loading-glass strong {
  font-size: 16px;
  font-weight: 900;
}

@keyframes imageLoadingSpin {
  to { transform: rotate(360deg); }
}

body[data-theme="light"] .image-loading-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #2f343c;
  box-shadow: 0 18px 38px rgba(20, 30, 45, 0.14);
}

body[data-theme="light"] .image-loading-glass {
  color: #eef1f5;
}

.result-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--panel-2);
}

.image-thumb-button {
  position: relative;
  width: 100%;
  display: block;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}

.image-thumb-button:focus-visible {
  outline: 3px solid rgba(51, 194, 215, 0.55);
  outline-offset: -3px;
}

.image-thumb-button img {
  width: 100%;
  max-height: calc(var(--thumb-size) * 1.85);
  aspect-ratio: auto;
  object-fit: contain;
  display: block;
  background: #0a1016;
}

.image-hover-tools {
  position: absolute;
  inset: 0 0 auto;
  min-height: clamp(28px, calc(var(--thumb-size) * 0.16), 46px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(5px, calc(var(--thumb-size) * 0.03), 10px);
  padding: clamp(5px, calc(var(--thumb-size) * 0.032), 10px);
  color: #fff;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.56), transparent);
  opacity: 0;
  transform: translateY(-8px);
  transition: 160ms ease;
  pointer-events: none;
}

.image-thumb-button:hover .image-hover-tools {
  opacity: 1;
  transform: translateY(0);
}

.image-resolution {
  font-size: clamp(9px, calc(var(--thumb-size) * 0.07), 18px);
  font-weight: 950;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.image-download-btn {
  min-height: clamp(18px, calc(var(--thumb-size) * 0.115), 30px);
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #1b2530;
  padding: 0 clamp(5px, calc(var(--thumb-size) * 0.04), 12px);
  text-decoration: none;
  font-size: clamp(8px, calc(var(--thumb-size) * 0.052), 13px);
  font-weight: 950;
  pointer-events: auto;
  cursor: pointer;
}

.prompt-copy-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: clamp(42px, calc(var(--thumb-size) * 0.28), 84px);
  display: grid;
  place-items: end center;
  padding: 0 8px clamp(9px, calc(var(--thumb-size) * 0.06), 18px);
  border: 0;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.34));
  color: #fff;
  font-size: clamp(11px, calc(var(--thumb-size) * 0.078), 20px);
  font-weight: 950;
  line-height: 1;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.34);
  cursor: pointer;
}

.image-thumb-button:hover .prompt-copy-overlay {
  opacity: 1;
  transform: translateY(0);
}

.image-card-caption {
  min-height: clamp(30px, calc(var(--thumb-size) * 0.18), 40px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: clamp(4px, calc(var(--thumb-size) * 0.03), 7px);
  padding: clamp(4px, calc(var(--thumb-size) * 0.03), 6px) clamp(5px, calc(var(--thumb-size) * 0.035), 8px);
  color: #10141a;
  background: #ffffff;
  border-top: 1px solid rgba(10, 14, 20, 0.1);
}

body[data-theme="light"] .image-card-caption {
  color: #10141a;
  background: #ffffff;
  border-top: 1px solid var(--line);
}

.image-card-caption span {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  font-size: clamp(9px, calc(var(--thumb-size) * 0.052), 12px);
  font-weight: 800;
  word-break: break-word;
}

.caption-copy-btn {
  display: none;
  width: clamp(24px, calc(var(--thumb-size) * 0.15), 32px);
  min-height: clamp(24px, calc(var(--thumb-size) * 0.15), 32px);
  border: 1px solid rgba(51, 194, 215, 0.34);
  border-radius: 999px;
  background: rgba(10, 132, 255, 0.1);
  color: #0759a8;
  padding: 0;
  font-size: clamp(8px, calc(var(--thumb-size) * 0.048), 11px);
  font-weight: 900;
}

body[data-theme="light"] .caption-copy-btn {
  border-color: rgba(10, 132, 255, 0.24);
  background: rgba(10, 132, 255, 0.09);
  color: #0759a8;
}

.caption-copy-btn:hover {
  border-color: rgba(51, 194, 215, 0.58);
  background: rgba(51, 194, 215, 0.24);
}

.text-result-card {
  width: 100%;
  display: grid;
  gap: 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.chat-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.user-message {
  justify-content: flex-end;
}

.assistant-message {
  justify-content: flex-start;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  border-radius: 50%;
  background: #202632;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e8edf5;
  font-size: 12px;
  font-weight: 950;
}

.chat-stack {
  max-width: min(76%, 760px);
  display: grid;
  gap: 6px;
}

.chat-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-bubble {
  max-width: min(76%, 760px);
  padding: 11px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-size: 14px;
  border: 1px solid var(--line);
}

.user-message .chat-bubble {
  color: #111827;
  background: #f2f4f7;
  border-color: rgba(255, 255, 255, 0.16);
  border-bottom-right-radius: 5px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.assistant-message .chat-bubble {
  max-width: 100%;
  color: #eef1f5;
  background: #151922;
  border-color: rgba(255, 255, 255, 0.12);
  border-bottom-left-radius: 5px;
}

.loading-bubble {
  color: #b8c0cc;
}

.loading-bubble::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: loadingDots 1.2s steps(4, end) infinite;
}

@keyframes loadingDots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

.text-result-card.is-error .assistant-message .chat-bubble {
  color: #ffccd2;
  border-color: rgba(255, 94, 111, 0.38);
}

.text-result-card.is-loading .result-meta {
  display: none;
}

body[data-theme="light"] .chat-avatar {
  background: #eef1f5;
  border-color: #d7dde6;
  color: #354052;
}

body[data-theme="light"] .user-message .chat-bubble {
  color: #111827;
  background: #f2f4f7;
  border-color: #d7dde6;
  box-shadow: 0 10px 22px rgba(20, 30, 45, 0.08);
}

body[data-theme="light"] .assistant-message .chat-bubble {
  color: #111827;
  background: #ffffff;
  border-color: #d7dde6;
}

body[data-theme="light"] .loading-bubble {
  color: #657083;
}

.chat-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 220px));
  gap: 10px;
  align-items: start;
}

.chat-image-card {
  display: grid;
  gap: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.chat-image-preview {
  display: block;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.chat-image-preview:focus-visible {
  outline: 3px solid rgba(51, 194, 215, 0.55);
  outline-offset: 2px;
  border-radius: 8px;
}

.chat-download-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  text-align: left;
  font-size: 12px;
  font-weight: 900;
}

.chat-image-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
}

.text-result {
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  padding: 16px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(51, 194, 215, 0.06), transparent 44%),
    var(--panel-2);
  border-bottom: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.72;
  font-size: 14px;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  color: var(--muted);
  font-size: 12px;
}

.download-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 900;
}

.text-copy-btn {
  border: 0;
  background: transparent;
  padding: 0;
}

.text-result-card .result-meta {
  justify-content: flex-start;
  gap: 10px;
  padding: 0 44px 8px;
}

.composer {
  margin: 0 28px 22px;
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 48%),
    var(--panel);
  box-shadow: var(--shadow);
}

.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 14px 0;
}

.mode-tab {
  min-height: 34px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 900;
}

.mode-tab.active {
  background: linear-gradient(135deg, var(--accent), #ffd28a);
  border-color: transparent;
  color: #15110b;
}

.prompt-row {
  display: grid;
  gap: 10px;
  padding: 14px 14px 8px;
}

.image-upload {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border: 1px dashed rgba(158, 186, 205, 0.42);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 180, 71, 0.08), rgba(51, 194, 215, 0.08)),
    rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.image-upload:hover {
  border-color: rgba(255, 180, 71, 0.66);
}

.image-upload input {
  display: none;
}

.plus {
  position: relative;
  color: var(--muted);
  display: block;
  width: 24px;
  height: 24px;
  font-size: 0;
  line-height: 0;
}

.plus::before,
.plus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.plus::after {
  width: 2px;
  height: 18px;
}

.reference-strip {
  min-width: 168px;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding: 0;
  flex: 1 1 260px;
}

.reference-list {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.reference-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--panel-2);
  padding: 0;
  overflow: hidden;
}

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

.reference-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 180, 71, 0.18);
}

.reference-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(7, 12, 18, 0.82);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}

.reference-remove:hover {
  background: var(--danger);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  outline: 0;
}

textarea {
  min-height: 106px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.2 1.2 6 6l4.8-4.8' fill='none' stroke='%239aa6b5' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: calc(100% - 14px) 50%;
  background-size: 12px 8px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(51, 194, 215, 0.7);
  box-shadow: 0 0 0 3px rgba(51, 194, 215, 0.14);
}

.controls-row {
  display: flex;
  gap: 10px;
  align-items: end;
  padding: 0 14px 14px;
}

.control-field,
.custom-size-group label {
  display: grid;
  gap: 6px;
}

.control-field {
  flex: 0 0 142px;
}

.control-field span,
.custom-size-group span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.custom-size-group {
  display: none;
  grid-template-columns: 92px 92px;
  gap: 8px;
  align-items: end;
  flex: 0 0 auto;
}

.custom-size-group input[type="number"] {
  min-width: 92px;
  padding-left: 12px;
  padding-right: 6px;
  font-variant-numeric: tabular-nums;
}

.custom-size-group.show {
  display: grid;
}

.control-field.compact {
  flex-basis: 86px;
  min-width: 86px;
}

.count-field {
  flex: 0 0 126px;
}

.count-stepper {
  min-height: 42px;
  display: grid;
  grid-template-columns: 34px minmax(42px, 1fr) 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}

.count-stepper button,
.count-stepper input {
  min-height: 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.count-stepper button {
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.count-stepper button:hover {
  color: var(--accent);
  background: rgba(255, 180, 71, 0.08);
}

.count-stepper input {
  padding: 0;
  text-align: center;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.count-stepper input::-webkit-outer-spin-button,
.count-stepper input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.count-stepper:focus-within {
  border-color: rgba(255, 180, 71, 0.68);
  box-shadow: 0 0 0 3px rgba(255, 180, 71, 0.14);
}

.generate-btn,
.primary-btn,
.secondary-btn {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 950;
}

.generate-btn,
.primary-btn {
  background: linear-gradient(135deg, var(--accent), #ffd28a);
  color: #15110b;
  box-shadow: 0 12px 28px rgba(255, 180, 71, 0.22);
}

.generate-btn {
  min-width: 118px;
  flex: 0 0 auto;
}

.generate-btn:hover,
.primary-btn:hover {
  filter: brightness(1.06);
}

.generate-btn:disabled {
  opacity: 0.62;
  cursor: wait;
}

.secondary-btn {
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
}

.secondary-btn:hover {
  background: rgba(51, 194, 215, 0.13);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 20;
}

.modal.open {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 12, 0.68);
  backdrop-filter: blur(10px);
}

.modal-panel {
  position: relative;
  width: min(780px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 40%),
    var(--panel);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 18px;
}

.close-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 24px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 16px 14px;
}

.settings-grid label {
  display: grid;
  gap: 6px;
}

.settings-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.settings-grid .full {
  grid-column: 1 / -1;
}

.settings-note {
  margin: 0;
  border: 1px solid rgba(82, 158, 190, 0.32);
  border-radius: 8px;
  background: rgba(21, 55, 72, 0.22);
  color: var(--text);
  padding: 10px 12px;
  line-height: 1.55;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px 16px;
}

.error-panel {
  width: min(760px, calc(100vw - 28px));
}

.model-picker-panel {
  width: min(1120px, calc(100vw - 28px));
}

.usage-panel {
  width: min(900px, calc(100vw - 28px));
}

.notice-panel {
  width: min(620px, calc(100vw - 28px));
}

.notice-content {
  display: grid;
  gap: 14px;
  padding: 16px;
  color: var(--text);
}

.notice-lead {
  margin: 0;
  border: 1px solid rgba(255, 180, 71, 0.35);
  border-radius: 8px;
  background: rgba(255, 180, 71, 0.12);
  padding: 12px;
  line-height: 1.65;
  font-weight: 900;
}

.notice-content ol {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 9px;
  line-height: 1.65;
  font-weight: 800;
}

.notice-link-card {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
}

.notice-link-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.notice-link-card a,
.notice-open-link {
  color: var(--accent);
  word-break: break-all;
}

.usage-content {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.usage-summary {
  border: 1px solid rgba(82, 158, 190, 0.36);
  border-radius: 8px;
  background: rgba(21, 55, 72, 0.26);
  color: var(--text);
  padding: 12px;
  font-weight: 800;
}

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

.usage-stat {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px;
}

.usage-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.usage-stat b {
  color: var(--text);
  font-size: 15px;
  word-break: break-word;
}

.usage-log-wrap {
  max-height: min(420px, calc(100vh - 330px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.usage-log-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.usage-log-table th,
.usage-log-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(155, 184, 205, 0.14);
  color: var(--text);
  text-align: left;
  font-size: 12px;
}

.usage-log-table th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-weight: 900;
}

.model-picker-body {
  padding: 14px;
  overflow: hidden;
}

.model-picker-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px 150px 150px 150px;
  gap: 8px;
  align-items: center;
}

.model-target-select {
  border-color: rgba(255, 180, 71, 0.72);
  background-color: rgba(255, 180, 71, 0.15);
  color: #ffdca1;
  font-weight: 950;
  box-shadow:
    0 0 0 1px rgba(255, 180, 71, 0.22),
    0 10px 24px rgba(255, 180, 71, 0.12);
}

body[data-theme="light"] .model-target-select {
  color: #8a4300;
  background-color: #fff1d3;
  border-color: rgba(217, 116, 20, 0.62);
}

.model-target-select:focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(255, 180, 71, 0.22),
    0 12px 28px rgba(255, 180, 71, 0.16);
}

.model-picker-hint {
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.model-picker-list {
  height: min(474px, calc(100vh - 290px));
  min-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.model-row {
  width: 100%;
  min-height: 47px;
  display: grid;
  grid-template-columns: 28px 128px minmax(360px, 1fr) 250px;
  gap: 10px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid rgba(155, 184, 205, 0.14);
  background: transparent;
  color: var(--text);
  padding: 7px 10px;
  text-align: left;
}

.model-row:hover,
.model-row.active {
  background: rgba(51, 194, 215, 0.13);
}

.model-row.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.model-check {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(155, 184, 205, 0.42);
  border-radius: 6px;
  color: #17120b;
  background: transparent;
  font-weight: 950;
}

.model-row.active .model-check {
  border-color: transparent;
  background: var(--accent);
}

.model-vendor {
  min-width: 0;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(155, 184, 205, 0.3);
  border-radius: 999px;
  color: var(--text);
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.model-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.model-tags {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.model-tag {
  min-width: 72px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(155, 184, 205, 0.3);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.model-tag.text {
  color: #adffcc;
  border-color: rgba(91, 214, 161, 0.42);
  background: rgba(20, 118, 67, 0.24);
}

.model-tag.image {
  color: #ffe0a7;
  border-color: rgba(255, 180, 71, 0.5);
  background: rgba(255, 180, 71, 0.14);
}

.model-empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.error-content {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.error-tip {
  border: 1px solid rgba(82, 158, 190, 0.46);
  border-radius: 8px;
  background: rgba(21, 55, 72, 0.36);
  color: var(--text);
  padding: 12px;
  line-height: 1.55;
  font-size: 14px;
  font-weight: 800;
}

.error-summary {
  border: 1px solid rgba(255, 107, 122, 0.55);
  border-radius: 8px;
  background: rgba(95, 17, 30, 0.42);
  color: #ffd4da;
  padding: 13px 12px;
  line-height: 1.5;
  font-weight: 900;
}

.error-details {
  min-height: 120px;
  max-height: 260px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.45 Consolas, "Microsoft YaHei UI", monospace;
}

.image-preview-modal {
  place-items: center;
}

.image-preview-panel {
  position: relative;
  width: min(96vw, 1380px);
  height: min(94vh, 900px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.image-preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  background: rgba(8, 13, 18, 0.72);
}

body[data-theme="light"] .image-preview-close {
  background: rgba(255, 255, 255, 0.82);
}

.image-preview-canvas {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #1b1b1d;
  cursor: zoom-in;
}

.image-preview-canvas img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 80ms linear;
  will-change: transform;
}

.image-preview-info {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 22px 18px 18px;
}

.image-preview-info h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.preview-info-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.preview-info-list div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 9px 10px;
}

.preview-info-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.preview-info-list dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  word-break: break-word;
}

.preview-prompt-block {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.preview-prompt-block span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.preview-prompt-block p {
  min-height: 0;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-size: 13px;
}

.preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preview-actions .primary-btn,
.preview-actions .secondary-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

@media (max-width: 860px) {
  .image-preview-panel {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(240px, 42vh);
  }

  .image-preview-info {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 5;
  width: max-content;
  max-width: min(520px, calc(100% - 360px));
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px);
  transition: 160ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  border-color: rgba(255, 107, 122, 0.62);
  color: #ffd6db;
}

body[data-mode="text"] .image-only {
  display: none !important;
}

body[data-mode="text"] .controls-row {
  justify-content: flex-end;
}

body[data-mode="text"] .control-field:not(.image-only) {
  flex: 0 1 320px;
}

.model-field {
  flex: 0 1 280px;
}

/* Polished visual refresh */
:root {
  --bg: #090b10;
  --workspace: #0c0f14;
  --sidebar: rgba(18, 22, 29, 0.92);
  --panel: rgba(24, 28, 36, 0.92);
  --panel-2: rgba(16, 20, 27, 0.92);
  --panel-3: rgba(34, 39, 49, 0.92);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f7fb;
  --muted: #a3adba;
  --muted-2: #707b89;
  --accent: #4da3ff;
  --accent-deep: #1473e6;
  --cyan: #64d2ff;
  --green: #30d158;
  --danger: #ff453a;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.28);
}

body[data-theme="light"] {
  --bg: #f5f5f7;
  --workspace: #f5f5f7;
  --sidebar: rgba(255, 255, 255, 0.82);
  --panel: rgba(255, 255, 255, 0.86);
  --panel-2: rgba(255, 255, 255, 0.7);
  --panel-3: rgba(232, 236, 242, 0.9);
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --muted: #666f7a;
  --muted-2: #8c949f;
  --accent: #0071e3;
  --accent-deep: #005bbf;
  --cyan: #06a4cf;
  --green: #087a4c;
  --danger: #d70015;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.12);
}

body {
  background:
    radial-gradient(circle at 72% 10%, rgba(77, 163, 255, 0.13), transparent 30%),
    linear-gradient(135deg, #090b10 0%, #0d1118 58%, #111317 100%);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "微软雅黑", "PingFang SC", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at 70% 8%, rgba(0, 113, 227, 0.12), transparent 30%),
    linear-gradient(135deg, #f5f5f7 0%, #fbfbfd 52%, #eef1f5 100%);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(128, 137, 148, 0.48) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(128, 137, 148, 0.52);
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar,
.composer,
.gallery-shell,
.modal-panel,
.usage-stat,
.notice-link-card,
.preview-info-list div,
.preview-prompt-block p,
.settings-note,
.usage-summary,
.model-picker-list,
.usage-log-wrap,
.error-details,
.toast {
  backdrop-filter: blur(22px) saturate(145%);
}

.sidebar {
  padding: 22px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 30%),
    var(--sidebar);
}

.brand {
  gap: 10px;
  padding: 8px 2px 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(145deg, #ffd76c 0%, #ff9f0a 58%, #ff6b35 100%);
  box-shadow: 0 14px 34px rgba(255, 159, 10, 0.24);
}

.brand h1 {
  font-size: 19px;
  font-weight: 850;
}

.project-item {
  min-height: 42px;
  border-radius: 8px;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.project-item:hover,
.project-item.active {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line-strong);
}

body[data-theme="light"] .project-item:hover,
body[data-theme="light"] .project-item.active {
  background: rgba(0, 113, 227, 0.08);
  border-color: rgba(0, 113, 227, 0.18);
}

.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-width: 1px;
  border-color: var(--line-strong);
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

body[data-theme="light"] .theme-toggle-btn {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: #ff9f0a;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.1);
}

.topbar {
  min-height: 86px;
  padding: 23px 28px 14px;
}

.topbar h2 {
  font-size: 26px;
  font-weight: 850;
}

.settings-btn,
.ghost-btn,
.secondary-btn {
  background: rgba(255, 255, 255, 0.065);
  border-color: var(--line);
  font-weight: 750;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

body[data-theme="light"] .settings-btn,
body[data-theme="light"] .ghost-btn,
body[data-theme="light"] .secondary-btn {
  background: rgba(255, 255, 255, 0.76);
}

.settings-btn:hover,
.ghost-btn:hover,
.secondary-btn:hover {
  border-color: rgba(77, 163, 255, 0.48);
  background: rgba(77, 163, 255, 0.12);
  transform: translateY(-1px);
}

.balance-badge {
  border-color: rgba(48, 209, 88, 0.24);
  background: rgba(48, 209, 88, 0.1);
  color: #b8f7c5;
  font-weight: 800;
}

body[data-theme="light"] .balance-badge {
  border-color: rgba(8, 122, 76, 0.18);
  background: rgba(8, 122, 76, 0.08);
  color: #075f42;
}

.gallery-shell,
.composer,
.modal-panel {
  border-color: var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent),
    var(--panel);
  box-shadow: var(--shadow);
}

.gallery-shell {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--panel-2);
}

.mode-tabs {
  gap: 8px;
}

.mode-tab {
  min-height: 36px;
  background: rgba(255, 255, 255, 0.055);
  font-weight: 800;
}

.mode-tab.active {
  background: linear-gradient(135deg, #0a84ff, #64d2ff);
  color: #fff;
  box-shadow: 0 10px 28px rgba(10, 132, 255, 0.26);
}

textarea,
input,
select {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.045);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

body[data-theme="light"] textarea,
body[data-theme="light"] input,
body[data-theme="light"] select {
  background: rgba(255, 255, 255, 0.78);
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(0, 113, 227, 0.62);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

.generate-btn,
.primary-btn {
  background: linear-gradient(135deg, #0a84ff, #64d2ff);
  color: #fff;
  box-shadow: 0 12px 30px rgba(10, 132, 255, 0.26);
}

.generate-btn:hover,
.primary-btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.result-grid:not(.chat-results) .result-card {
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

body[data-theme="light"] .result-grid:not(.chat-results) .result-card {
  background: #fff;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.12);
}

.caption-copy-btn,
.chat-download-btn {
  color: var(--accent);
}

.model-target-select {
  border-color: rgba(10, 132, 255, 0.58);
  background-color: rgba(10, 132, 255, 0.14);
  color: #d8ebff;
  box-shadow:
    0 0 0 1px rgba(10, 132, 255, 0.14),
    0 10px 24px rgba(10, 132, 255, 0.12);
}

body[data-theme="light"] .model-target-select {
  color: #005bbf;
  background-color: rgba(0, 113, 227, 0.1);
  border-color: rgba(0, 113, 227, 0.38);
}

.model-target-select:focus {
  border-color: rgba(10, 132, 255, 0.76);
  box-shadow:
    0 0 0 4px rgba(10, 132, 255, 0.16),
    0 12px 28px rgba(10, 132, 255, 0.16);
}

.model-row:hover,
.model-row.active {
  background: rgba(10, 132, 255, 0.12);
}

.model-row.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.46);
}

body[data-theme="light"] .modal-backdrop {
  background: rgba(245, 245, 247, 0.56);
}

/* Compact header and sidebar polish */
.brand {
  gap: 9px;
  padding: 7px 2px 18px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  font-size: 21px;
  box-shadow: 0 10px 24px rgba(255, 159, 10, 0.2);
}

.brand h1 {
  font-size: 17px;
  line-height: 1.12;
  font-weight: 820;
}

.brand span {
  margin-top: 3px;
  display: block;
  font-size: 11px;
}

.project-head {
  margin: 4px 2px 8px;
  font-size: 13px;
  font-weight: 760;
}

.ghost-btn {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 760;
}

.project-list {
  gap: 6px;
}

.project-item {
  min-height: 38px;
  grid-template-columns: minmax(0, 1fr) 26px;
  padding: 3px 6px 3px 10px;
}

.project-name {
  min-height: 30px;
  font-size: 13px;
  font-weight: 760;
}

.project-rename {
  width: 26px;
  height: 26px;
}

.project-rename svg {
  width: 13px;
  height: 13px;
}

.topbar {
  min-height: 76px;
  padding-top: 18px;
  padding-bottom: 10px;
}

.topbar .eyebrow {
  font-size: 11px;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.12;
  font-weight: 820;
}

.topbar-actions {
  gap: 6px;
}

.balance-badge,
.settings-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 760;
}

.settings-btn svg {
  width: 15px;
  height: 15px;
}

.balance-badge {
  padding-inline: 11px;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.12;
  font-weight: 880;
}

.brand-mark {
  width: 42px;
  height: 42px;
  font-size: 23px;
}

.topbar-actions {
  gap: 8px;
}

.balance-badge,
.settings-btn {
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 820;
}

.settings-btn svg {
  width: 16px;
  height: 16px;
}

.balance-badge {
  padding-inline: 14px;
}

/* Night composer refinement */
body:not([data-theme="light"]) .composer {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 44%),
    #1d2128;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

body:not([data-theme="light"]) .mode-tab {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.1);
  color: #aeb6c2;
}

body:not([data-theme="light"]) .mode-tab.active {
  background: linear-gradient(135deg, #f6b94b, #ffd37a);
  color: #241707;
  border-color: rgba(255, 211, 122, 0.78);
  box-shadow: 0 10px 26px rgba(246, 185, 75, 0.2);
}

body:not([data-theme="light"]) textarea,
body:not([data-theme="light"]) input,
body:not([data-theme="light"]) select {
  background-color: #242933;
  border-color: rgba(255, 255, 255, 0.1);
  color: #eef1f5;
}

body:not([data-theme="light"]) textarea::placeholder,
body:not([data-theme="light"]) input::placeholder {
  color: #7f8792;
}

body:not([data-theme="light"]) textarea:focus,
body:not([data-theme="light"]) input:focus,
body:not([data-theme="light"]) select:focus {
  border-color: rgba(246, 185, 75, 0.58);
  box-shadow: 0 0 0 4px rgba(246, 185, 75, 0.12);
}

body:not([data-theme="light"]) .generate-btn {
  background: linear-gradient(135deg, #ffb340, #ffd47a);
  color: #201407;
  box-shadow: 0 12px 28px rgba(255, 179, 64, 0.25);
}

body:not([data-theme="light"]) .generate-btn:hover {
  filter: brightness(1.04);
  box-shadow: 0 14px 32px rgba(255, 179, 64, 0.3);
}

.mode-tab.active,
body[data-theme="light"] .mode-tab.active {
  background: linear-gradient(135deg, #f6b94b, #ffd37a);
  color: #241707;
  border-color: rgba(255, 211, 122, 0.78);
  box-shadow: 0 10px 26px rgba(246, 185, 75, 0.2);
}

.generate-btn,
.primary-btn,
body[data-theme="light"] .generate-btn,
body[data-theme="light"] .primary-btn {
  background: linear-gradient(135deg, #ffb340, #ffd47a);
  color: #201407;
  box-shadow: 0 12px 28px rgba(255, 179, 64, 0.25);
}

.generate-btn:hover,
.primary-btn:hover,
body[data-theme="light"] .generate-btn:hover,
body[data-theme="light"] .primary-btn:hover {
  filter: brightness(1.04);
  box-shadow: 0 14px 32px rgba(255, 179, 64, 0.3);
}

body:not([data-theme="light"]) .image-upload {
  background:
    linear-gradient(135deg, rgba(255, 179, 64, 0.08), rgba(255, 255, 255, 0.025)),
    #242933;
  border-color: rgba(255, 255, 255, 0.14);
}

body:not([data-theme="light"]) .image-upload:hover {
  border-color: rgba(255, 179, 64, 0.62);
}

/* Night tone hierarchy: lighter shell, darker work areas */
body:not([data-theme="light"]) {
  background:
    radial-gradient(circle at 72% 10%, rgba(255, 179, 64, 0.08), transparent 30%),
    linear-gradient(135deg, #12161d 0%, #171b22 54%, #11141a 100%);
}

body:not([data-theme="light"]) .sidebar,
body:not([data-theme="light"]) .workspace {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 34%),
    #171b22;
}

body:not([data-theme="light"]) .topbar,
body:not([data-theme="light"]) .composer {
  background: transparent;
}

body:not([data-theme="light"]) .composer {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 42%),
    #252a33;
  border-color: rgba(255, 255, 255, 0.13);
}

body:not([data-theme="light"]) .gallery-shell {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 34%),
    #0f1218;
  border-color: rgba(255, 255, 255, 0.12);
}

body:not([data-theme="light"]) textarea,
body:not([data-theme="light"]) input,
body:not([data-theme="light"]) select {
  background-color: #151922;
  border-color: rgba(255, 255, 255, 0.12);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.2 1.2 6 6l4.8-4.8' fill='none' stroke='%239aa6b5' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: calc(100% - 14px) 50%;
  background-size: 12px 8px;
  background-repeat: no-repeat;
}

body:not([data-theme="light"]) select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.2 1.2 6 6l4.8-4.8' fill='none' stroke='%23b7c0cc' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

body:not([data-theme="light"]) .count-stepper {
  background-color: #151922;
  border-color: rgba(255, 255, 255, 0.12);
}

body:not([data-theme="light"]) .count-stepper input,
body[data-theme="light"] .count-stepper input {
  background: transparent;
}

.model-target-select,
body:not([data-theme="light"]) .model-target-select {
  border-color: rgba(10, 132, 255, 0.68);
  background-color: rgba(10, 132, 255, 0.16);
  color: #d8ebff;
  box-shadow:
    0 0 0 1px rgba(10, 132, 255, 0.16),
    0 10px 24px rgba(10, 132, 255, 0.12);
}

body[data-theme="light"] .model-target-select {
  color: #005bbf;
  background-color: rgba(0, 113, 227, 0.1);
  border-color: rgba(0, 113, 227, 0.42);
}

body:not([data-theme="light"]) select option {
  background: #151922;
  color: #eef1f5;
}

body:not([data-theme="light"]) .model-target-select option {
  background: #151922;
  color: #d8ebff;
}

#applyModelPickerBtn {
  background: linear-gradient(135deg, #ffb340, #ffd47a);
  color: #201407;
  box-shadow: 0 12px 28px rgba(255, 179, 64, 0.25);
}

#applyModelPickerBtn:hover {
  filter: brightness(1.04);
  box-shadow: 0 14px 32px rgba(255, 179, 64, 0.3);
}

body:not([data-theme="light"]) .image-upload,
body:not([data-theme="light"]) .reference-thumb {
  background-color: #151922;
}

body:not([data-theme="light"]) .result-grid:not(.chat-results) .result-card {
  background: #07090d;
}

body:not([data-theme="light"]) .result-grid:not(.chat-results) .image-loading-card {
  background: #2f343c;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

body[data-theme="light"] .gallery-shell {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: none;
}

body[data-theme="light"] .composer {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: none;
}

body[data-theme="light"] .result-grid {
  background: #e3e6ea;
}

body[data-theme="light"] textarea {
  background: #eef0f3;
  border-color: rgba(0, 0, 0, 0.1);
}

@media (max-width: 1040px) {
  .controls-row {
    flex-wrap: wrap;
  }

  .custom-size-group,
  .custom-size-group.show {
    grid-template-columns: 100px 100px;
  }

  .generate-btn {
    margin-left: auto;
  }
}

@media (max-width: 780px) {
  .usage-stats {
    grid-template-columns: 1fr 1fr;
  }

  .model-picker-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .model-target-select {
    grid-column: 1 / -1;
  }

  .model-row {
    grid-template-columns: 28px 92px minmax(0, 1fr);
  }

  .model-tags {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (min-width: 781px) and (max-width: 1040px) {
  .model-picker-toolbar {
    grid-template-columns: minmax(220px, 1fr) 145px 145px;
  }

  .model-target-select {
    grid-column: auto;
  }

  .model-row {
    grid-template-columns: 28px 112px minmax(260px, 1fr) 220px;
  }
}

@media (max-width: 860px) {
  body {
    height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    height: auto;
    max-height: 178px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    height: auto;
    min-height: 0;
  }

  .project-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar,
  .gallery-shell,
  .composer {
    margin-left: 14px;
    margin-right: 14px;
  }

  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .toast {
    top: 54px;
    left: 14px;
    right: 14px;
    width: auto;
    max-width: none;
    justify-content: center;
    transform: translateY(-6px);
  }

  .toast.show {
    transform: translateY(0);
  }

  .settings-grid,
  .prompt-row {
    grid-template-columns: 1fr;
  }

  .image-upload,
  .reference-thumb {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
  }

  .controls-row {
    align-items: stretch;
  }

  .reference-strip,
  .control-field,
  .control-field.compact,
  .count-field,
  .generate-btn {
    flex: 1 1 100%;
  }

  .text-result-card {
    grid-column: span 1;
  }

  .modal-actions {
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

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

  .topbar-actions .settings-btn {
    flex: 1;
    justify-content: center;
  }

  .balance-badge {
    width: 100%;
    justify-content: center;
  }

  .usage-stats {
    grid-template-columns: 1fr;
  }
}
