:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #fffdf8;
  --surface-soft: #f8f5ee;
  --surface-strong: #ebe6dc;
  --line: #ded7ca;
  --line-strong: #bfb5a6;
  --text: #24211d;
  --muted: #756d62;
  --muted-2: #a69b8b;
  --accent: #24211d;
  --accent-soft: #ece6dc;
  --danger: #9f1d1d;
  --success: #246b42;
  --shadow-lg: 0 18px 42px rgba(36, 33, 29, 0.08);
  --shadow-md: 0 10px 24px rgba(36, 33, 29, 0.07);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #151412;
  --surface: #1d1b18;
  --surface-soft: #24211d;
  --surface-strong: #302b25;
  --line: #403a32;
  --line-strong: #615749;
  --text: #f2ece2;
  --muted: #b8ad9d;
  --muted-2: #83786b;
  --accent: #f2ece2;
  --accent-soft: #302b25;
  --danger: #f2a0a0;
  --success: #93d5a8;
  --shadow-lg: 0 18px 42px rgba(0, 0, 0, .28);
  --shadow-md: 0 10px 24px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }

[v-cloak] { display: none; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(36, 33, 29, .025) 1px, transparent 1px),
    linear-gradient(180deg, var(--bg), #ebe6dc 100%);
  background-size: 32px 32px, auto;
  overflow-x: hidden;
  transition: background-color .18s ease, color .18s ease;
}

body.theme-dark {
  background:
    linear-gradient(90deg, rgba(242, 236, 226, .035) 1px, transparent 1px),
    linear-gradient(180deg, var(--bg), #0f0e0d 100%);
  background-size: 32px 32px, auto;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  min-height: 100vh;
  padding: 18px;
}

.glass-panel {
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.control-panel {
  position: sticky;
  top: 20px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.generation-panel {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.generation-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.privacy-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 74px;
  height: 30px;
  margin-left: auto;
  padding: 0 9px 0 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  transition: border-color .18s ease, background .18s ease, color .18s ease, padding .18s ease;
}

.privacy-toggle::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 4px 10px rgba(36, 33, 29, .12);
  transform: translateY(-50%);
  transition: left .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.privacy-toggle span {
  position: relative;
  z-index: 1;
  color: inherit;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.privacy-toggle.private {
  justify-content: flex-end;
  padding: 0 34px 0 9px;
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background: var(--accent-soft);
  color: var(--text);
}

.privacy-toggle.private::before {
  left: calc(100% - 26px);
  border-color: var(--line-strong);
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(36, 33, 29, .18);
}

.privacy-toggle:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.generation-panel-head span {
  align-self: flex-end;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .12em;
}

.generation-panel-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -.03em;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.brand-copy p {
  overflow: visible;
  white-space: nowrap;
}

.brand-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  color: var(--accent);
  font-size: 48px;
  line-height: 1;
}

.header-token-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.brand-header h1, .gallery-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -.03em;
  color: var(--text);
}

.brand-header p, .gallery-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: .18s ease;
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--surface-soft);
}

.form-stack, .field {
  display: flex;
  flex-direction: column;
}

.form-stack { gap: 16px; }

.field-help {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  transition: .18s ease;
}

.text-btn:hover:not(:disabled) {
  color: var(--text);
}

.prompt-examples,
.empty-example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  transition: .18s ease;
}

.example-chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.status-line {
  margin: -4px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.status-success {
  border-color: color-mix(in srgb, var(--success) 35%, var(--line));
  color: var(--success);
}

.status-error {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  color: var(--danger);
}
.field { gap: 8px; }
.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.glass-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.glass-input:hover {
  border-color: var(--line-strong);
}

.glass-input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 9%, transparent);
  background: var(--surface);
}

body.theme-dark .glass-input:focus {
  box-shadow: 0 0 0 3px rgba(242, 236, 226, .10);
}

.glass-input::placeholder { color: var(--muted-2); }
.prompt-area { min-height: 132px; resize: vertical; line-height: 1.65; }

.token-field {
  margin-bottom: 0;
}

.key-input-wrap { position: relative; }
.key-input-wrap .glass-input { padding-right: 48px; }
.ghost-icon {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  transition: .18s ease;
}

.ghost-icon:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--surface-strong);
}

.mobile-collapsible {
  display: grid;
  gap: 10px;
}

.mobile-section-toggle {
  display: none;
}

.mobile-collapsible-body {
  display: block;
}

.unified-controls-body {
  display: grid;
  gap: 14px;
}

.unified-control-block {
  display: grid;
  gap: 8px;
}

.control-block-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ref-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  padding: 4px 0 2px;
}

.ref-square-btn {
  position: relative;
  width: 96px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.ref-square-btn:hover {
  border-color: #9ca3af;
  background: var(--surface-soft);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.ref-square-plus {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  border: 1px solid var(--line);
}

.ref-square-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.ref-strip .ref-card {
  width: 96px;
  flex: 0 0 auto;
  box-shadow: var(--shadow-md);
}

.quick-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  width: 100%;
}

.compact-field { min-width: 0; }
.compact-field .glass-input {
  width: 100%;
  min-height: 40px;
  padding-right: 34px;
}
.compact-field select.glass-input {
  appearance: none;
  font-size: 13px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.compact-field select.glass-input option {
  font-size: 13px;
}
.style-field,
.ratio-field { min-width: 0; }

.ref-card small {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 8px 7px;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255,255,255,.84);
}

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  transition: .18s ease;
}

.soft-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.local-choice-btn {
  width: 100%;
  margin-bottom: 12px;
}

.hidden-input { display: none; }

.ref-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.ref-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.ref-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.ref-card button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, .92);
  transition: .18s ease;
}

body.theme-dark .ref-card button {
  background: rgba(21, 24, 33, .92);
}

.ref-card button:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

body.theme-dark .ref-card button:hover {
  background: rgba(127, 29, 29, .86);
  border-color: rgba(248, 113, 113, .55);
  color: #fecaca;
}

.ref-card small {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 8px 7px;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255,255,255,.84);
}

body.theme-dark .ref-card small {
  color: #fff;
  background: rgba(17, 24, 39, .74);
}

body.theme-dark .image-card time {
  background: #22c55e;
  color: #052e16;
}

body.theme-dark .task-badge {
  background: #111827;
  color: #fff;
}

.prompt-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.token-mini-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  transition: .18s ease;
}

.token-mini-btn:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--surface-soft);
}

.token-mini-btn.header-token-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.token-panel {
  display: grid;
  gap: 8px;
}

.token-panel-inline {
  margin-top: 0;
}

.ref-card.selected {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 1px rgba(17, 24, 39, .04), var(--shadow-md);
}

.generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  border: 1px solid var(--text);
  border-radius: 10px;
  padding: 0 20px;
  color: var(--surface);
  background: var(--text);
  font-weight: 800;
  letter-spacing: .01em;
  transition: opacity .18s ease, background .18s ease;
}

.generate-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text) 88%, var(--surface));
}

.generate-btn.small { min-height: 40px; border-radius: 12px; }

.shine-btn { position: relative; overflow: hidden; }
.shine-btn::after { content: none; }

.spinner, .large-spinner {
  border-radius: 999px;
  border-style: solid;
  animation: spin .72s linear infinite;
}

.spinner {
  width: 17px;
  height: 17px;
  border-width: 2px;
  border-color: rgba(255,255,255,.35);
  border-top-color: #fff;
}

.large-spinner {
  width: 46px;
  height: 46px;
  border-width: 3px;
  border-color: rgba(17,24,39,.12);
  border-top-color: var(--text);
}

.gallery-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 540px;
  border-radius: var(--radius-xl);
  padding: 18px;
  background: var(--surface);
}

.gallery-head > div {
  width: 100%;
  min-width: 0;
}

.token-mini-btn.header-token-btn.gallery-clear-btn {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  min-height: 26px;
  margin-left: auto;
  font-size: 11px;
}

.gallery-clear-btn:hover:not(:disabled) {
  color: var(--danger);
}

.gallery-clear-btn:disabled {
  opacity: .42;
}

.gallery-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 0;
}

.gallery-title-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.gallery-title-row h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -.03em;
}

.gallery-title-row .gallery-clear-btn {
  align-self: center;
}

.gallery-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.compact { min-height: 36px; }

.task-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.task-item {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  min-height: 164px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: default;
  box-shadow: 0 12px 28px rgba(36, 33, 29, .10);
  animation: fade-in .28s ease both;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background .18s ease;
}

.task-item.has-images {
  cursor: zoom-in;
}

.task-visual {
  width: 140px;
  height: 140px;
  min-width: 0;
}

.task-content {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 9px;
}

body.theme-dark .task-item {
  box-shadow: 0 16px 34px rgba(0, 0, 0, .28);
}

.task-item.active,
.task-item:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: 0 14px 30px rgba(36, 33, 29, 0.12);
}

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

.task-item-top strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted-2);
}

.task-running .task-status-dot,
.task-submitting .task-status-dot {
  background: #d97706;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, .12);
}

.task-success .task-status-dot { background: var(--success); }
.task-failed .task-status-dot { background: var(--danger); }

.task-item-top button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
}

.task-item p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 36px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.task-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-meta-row span {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.task-item small {
  min-width: 0;
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.4;
}

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

.task-retry-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  transition: .18s ease;
}

.task-retry-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.task-result-grid {
  width: 140px;
  height: 140px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.task-result-image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.task-result-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .2s ease;
}

.task-result-image:hover img {
  transform: scale(1.04);
}

.task-result-pending {
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-soft);
  text-align: center;
}

.task-result-pending p {
  min-height: 0;
  font-size: 11px;
}

.task-result-error {
  color: var(--danger);
}

.task-board-empty {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.task-example-empty {
  min-height: 220px;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.task-example-empty > i {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 2px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  box-shadow: 0 14px 32px rgba(36, 33, 29, .10);
}

.task-empty-copy {
  display: grid;
  gap: 6px;
}

.task-empty-copy strong {
  color: var(--text);
  font-size: 17px;
  letter-spacing: -.02em;
}

.task-empty-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-empty-examples {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 520px;
  margin: 4px auto 0;
}

.images-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--columns, 3), minmax(0, 1fr));
  align-content: center;
  justify-items: center;
  gap: 18px;
  min-height: 360px;
}

.image-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 280px);
  aspect-ratio: 1 / 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(36, 33, 29, .10);
  animation: fade-in .28s ease both;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

body.theme-dark .image-card {
  border-color: var(--line);
  box-shadow: 0 16px 34px rgba(0, 0, 0, .28);
}

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

  .image-hit-area {
    position: relative;
    inset: auto;
  }

  .image-card img {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }
}

.image-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 14px 30px rgba(36, 33, 29, 0.12);
}

.placeholder-card {
  display: grid;
  place-items: center;
  align-content: center;
  justify-self: center;
  width: min(100%, 220px);
  min-height: 120px;
  aspect-ratio: auto;
  gap: 10px;
  padding: 14px;
  text-align: center;
}

.error-placeholder-card {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--danger) 10%, var(--surface-soft)));
}

.error-placeholder-card .task-badge {
  background: var(--danger);
}

.error-placeholder-card .loading-progress-text {
  color: var(--danger);
}

.error-spinner {
  color: var(--danger);
}

.loading-progress-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.task-badge, .image-card time {
  position: absolute;
  z-index: 2;
  right: 10px;
  top: 10px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  background: var(--text);
  color: #fff;
}

.image-card time {
  background: #16a34a;
  color: #fff;
}

.image-hit-area {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  cursor: zoom-in;
  background: var(--surface-soft);
}

.image-hit-area:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.image-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  transition: transform .24s ease;
}

.image-card:hover img {
  transform: scale(1.02);
}

.card-prompt-marquee {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  overflow: hidden;
  padding: 8px 10px;
  color: #fff;
  background: rgba(15, 23, 42, .52);
  backdrop-filter: blur(8px);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

.card-prompt-marquee span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.image-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  padding: 10px;
  background: rgba(17, 24, 39, .34);
  transition: opacity .18s ease;
}

.image-card:hover .image-overlay,
.image-card:focus-within .image-overlay {
  opacity: 1;
  pointer-events: auto;
}

.image-actions,
.image-prompt-panel {
  pointer-events: auto;
}

.image-card:hover .image-overlay { opacity: 1; }

.image-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(17, 24, 39, .38);
  backdrop-filter: blur(10px);
  transform: translateY(-20px);
}

.lightbox-actions {
  flex-wrap: wrap;
  border-radius: 18px;
  padding: 8px;
}

.image-prompt-panel {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 14px;
  color: #fff;
  background: rgba(17, 24, 39, .72);
  backdrop-filter: blur(10px);
}

.prompt-text {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.45;
}

.image-meta-lines {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  white-space: normal;
  font-size: 11px;
  line-height: 1.2;
  color: rgba(255, 255, 255, .88);
  scrollbar-width: none;
}

.image-meta-lines::-webkit-scrollbar {
  display: none;
}

.image-meta-lines span {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .10);
  color: rgba(255, 255, 255, .90);
  white-space: nowrap;
  animation: none;
}

.image-meta-lines span b {
  color: rgba(255, 255, 255, .62);
  font-size: 10px;
  font-weight: 900;
}

.image-meta-lines:hover span {
  animation-play-state: paused;
}

.reference-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.image-overlay button, .lightbox-actions button, .lightbox-close {
  min-width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow-md);
  transition: .18s ease;
}

.lightbox-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  padding: 0 12px;
  color: #1f2937;
  font-size: 12px;
  font-weight: 900;
}

.lightbox-actions button span {
  line-height: 1;
  white-space: nowrap;
}

.download-spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
  border-color: rgba(31, 41, 55, .22);
  border-top-color: #1f2937;
}

body.theme-dark .image-overlay button,
body.theme-dark .lightbox-actions button,
body.theme-dark .lightbox-close {
  color: var(--text);
  background: rgba(21, 24, 33, .92);
  border-color: var(--line-strong);
}

.image-overlay button:hover, .lightbox-actions button:hover, .lightbox-close:hover {
  transform: translateY(-1px);
  background: #fff;
}

body.theme-dark .image-overlay button:hover,
body.theme-dark .lightbox-actions button:hover,
body.theme-dark .lightbox-close:hover {
  background: var(--surface-strong);
}

.image-overlay .image-delete-btn:hover, .lightbox-actions .image-delete-btn:hover {
  border-color: #fecaca;
  color: #991b1b;
  background: #fee2e2;
}

body.theme-dark .image-overlay .image-delete-btn:hover,
body.theme-dark .lightbox-actions .image-delete-btn:hover {
  border-color: rgba(248, 113, 113, .55);
  color: #fecaca;
  background: rgba(127, 29, 29, .86);
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  grid-column: 1 / -1;
  padding: 42px 18px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 64%, transparent);
}

.empty-state i { color: var(--muted); font-size: 42px; }
.empty-state h3 { margin: 0; color: var(--text); font-size: 20px; }
.empty-state p { margin: 0; max-width: 390px; line-height: 1.65; color: var(--muted); }
.empty-example-row { justify-content: center; margin-top: 4px; }
.empty-state.error-state {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--danger) 8%, var(--surface-soft)));
}
.empty-state.error-state i,
.empty-state.error-state h3,
.empty-state.error-state p {
  color: var(--danger);
}

.friend-cases-section,
.recommendation-section {
  margin-top: 0;
  padding-top: 0;
}

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

.friend-case-card {
  position: relative;
  overflow: hidden;
  display: grid;
  min-height: 148px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: none;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.friend-case-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.friend-case-card img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
  background: var(--surface-soft);
}

.friend-case-copy {
  display: grid;
  gap: 4px;
  padding: 9px 10px 10px;
}

.friend-case-copy strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.friend-case-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-cases-state {
  min-height: 92px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--muted);
  text-align: center;
}

.friend-cases-state p {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
}

.friend-cases-state .large-spinner {
  width: 28px;
  height: 28px;
}

.recommendation-head {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.recommendation-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -.03em;
}

.recommendation-head span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.recommendation-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--surface);
  box-shadow: none;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  overflow: hidden;
  transition: border-color .18s ease, background .18s ease;
}

.recommendation-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.recommendation-card:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.section-pulse {
  animation: section-pulse 1.45s ease;
}

.recommendation-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.recommendation-icon {
  flex: 0 0 auto;
  font-size: 18px;
  color: var(--accent);
}

.recommendation-card h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recommendation-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-dark .recommendation-card {
  background-color: var(--surface);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .56);
}

.modal.active, .lightbox.active { display: flex; }

.modal-card {
  width: min(440px, 100%);
  border-radius: 20px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal-card h3 { margin: 0 0 8px; }
.modal-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.modal-actions { margin-top: 16px; }

.lightbox {
  z-index: 70;
  flex-direction: column;
  gap: 16px;
  background: rgba(18, 17, 15, .88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.lightbox-media {
  position: relative;
  width: min(92vw, 1180px);
  max-height: 78vh;
  display: grid;
  place-items: center;
}

.lightbox-placeholder,
.lightbox-full-image {
  grid-area: 1 / 1;
  max-width: 100%;
  max-height: 78vh;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 24px 80px rgba(15, 23, 42, .40);
  object-fit: contain;
}

.lightbox-placeholder {
  filter: blur(18px) saturate(115%);
  transform: scale(1.03);
  opacity: .84;
}

.lightbox-full-image {
  position: relative;
  z-index: 1;
  opacity: 1;
}

.lightbox-full-image.loading {
  opacity: 1;
}

.lightbox-progress-layer {
  position: absolute;
  inset: auto 20px 18px;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.lightbox-progress-track {
  width: min(56vw, 420px);
  height: 8px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.lightbox-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: rgba(255, 253, 248, .86);
  transition: width .18s ease;
}

.lightbox-close { position: fixed; top: 18px; right: 18px; }

.lightbox-bottom-panel {
  display: grid;
  gap: 12px;
  width: min(92vw, 1180px);
  margin-top: 4px;
}

.lightbox-actions {
  justify-self: center;
}

.lightbox-prompt-panel {
  background: rgba(8, 15, 28, .74);
  backdrop-filter: blur(16px) saturate(150%);
}

.download-float {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes meta-scroll { from { transform: translateX(0); } to { transform: translateX(-42%); } }
@keyframes prompt-marquee { from { transform: translateX(0); } to { transform: translateX(-42%); } }
@keyframes section-pulse {
  0%, 100% { box-shadow: none; }
  18%, 72% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 12%, transparent), 0 18px 38px rgba(31, 35, 40, .10); }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .control-panel { position: static; }
  .gallery-panel { min-height: auto; }
  .friend-cases-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recommendation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { padding: 12px; gap: 12px; }
  .control-panel { gap: 12px; }
  .brand-header,
  .generation-panel,
  .gallery-panel { border-radius: 18px; padding: 16px; }
  .gallery-panel { min-height: 420px; }
  .brand-header { align-items: flex-start; }
  .theme-toggle { min-height: 32px; padding: 0 10px; }
  .brand-header h1, .gallery-head h2 { font-size: 20px; }
  .mobile-collapsible {
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
  }
  .mobile-section-toggle {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 12px;
    border: 0;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    text-align: left;
  }
  .mobile-section-toggle i {
    color: var(--muted);
    font-size: 11px;
    transition: transform .18s ease;
  }
  .mobile-collapsible.expanded .mobile-section-toggle i {
    transform: rotate(180deg);
  }
  .mobile-collapsible-body {
    display: none;
    padding: 0 12px 12px;
  }
  .mobile-collapsible.expanded .mobile-collapsible-body {
    display: grid;
  }
  .unified-controls-body {
    gap: 12px;
  }
  .quick-controls { grid-template-columns: minmax(64px, .8fr) minmax(0, 1.2fr) minmax(64px, .8fr); gap: 8px; }
  .task-board { grid-template-columns: minmax(0, 1fr); }
  .task-item { grid-template-columns: 140px minmax(0, 1fr); }
  .task-result-grid { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
  .prompt-examples { max-height: 78px; overflow-y: auto; }
  .ref-strip { gap: 8px; }
  .ref-actions { justify-content: stretch; }
  .soft-btn { flex: 1; }
  .gallery-head { align-items: flex-start; flex-direction: column; }
  .image-card { width: min(100%, 320px); }
  .empty-state { min-height: 360px; }
  .friend-cases-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recommendation-grid { grid-template-columns: 1fr; }
  .recommendation-card { min-height: 64px; }
  .image-overlay { opacity: 1; align-items: stretch; justify-content: flex-end; background: rgba(17, 24, 39, .18); }
  .image-actions { gap: 6px; }
  .image-overlay button, .lightbox-close { width: 36px; height: 36px; }
  .lightbox-actions button { min-height: 36px; height: 36px; padding: 0 10px; font-size: 11px; }
  .lightbox img { max-width: 94vw; max-height: 72vh; border-radius: 16px; }
}