@import url("fonts/fonts.css?v=34860ca0f75820dc");
@import url("theme-tokens.css?v=34860ca0f75820dc");

:root {
  color-scheme: light;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(203, 213, 225, 0.7);
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --shadow: 0 22px 55px rgba(15, 23, 42, 0.1);
  font-family: var(--ui-font-sans);
  line-height: 1.5;
  color: var(--ink);
  background: #eef7f6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #eef7f6 0%, #f8fafc 44%, #e8f6f3 100%);
}

button,
input,
textarea {
  margin: 0;
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
  vertical-align: middle;
}

p,
h2,
h3 {
  margin: 0;
}

::selection {
  color: #134e4a;
  background: rgba(20, 184, 166, 0.2);
}

::-webkit-scrollbar {
  width: 0.5rem;
  height: 0.5rem;
}

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

::-webkit-scrollbar-thumb {
  border-radius: 9999px;
  background: transparent;
  transition: background-color 0.2s ease;
}

*:hover::-webkit-scrollbar-thumb {
  background: rgba(209, 213, 219, 0.5);
}

*:hover::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-x: hidden;
}

#app::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18% 16%, rgba(20, 184, 166, 0.16) 0 18%, transparent 42%),
    radial-gradient(circle at 84% 8%, rgba(14, 165, 233, 0.13) 0 16%, transparent 40%),
    linear-gradient(120deg, rgba(15, 118, 110, 0.05), transparent 42%, rgba(245, 158, 11, 0.05));
}

.page-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 0;
}

.image-experience {
  width: 100%;
  min-height: 0;
  height: 100%;
}

.image-shell {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.88));
  box-shadow: none;
  backdrop-filter: none;
}

.image-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  align-items: center;
  border-bottom: 1px solid rgba(226, 232, 240, 0.68);
  padding: 0 clamp(12px, 1.4vw, 18px);
  background: rgba(255, 255, 255, 0.58);
}

.image-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid transparent;
  padding: clamp(9px, 1.5vh, 14px) 10px clamp(8px, 1.3vh, 12px);
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.image-tab:hover {
  color: #111827;
}

.image-tab-active {
  border-color: #14b8a6;
  color: #0d9488;
}

.mode-panel[hidden] {
  display: none !important;
}

.mode-panel {
  min-height: 0;
}

.image-workbench {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(380px, 0.65fr) minmax(360px, 1.35fr);
  gap: clamp(10px, 1.4vw, 18px);
  min-height: 0;
  height: auto;
  overflow: hidden;
  padding: clamp(10px, 1.4vw, 18px);
}

.image-controls {
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: clamp(8px, 1.15vh, 12px);
  overflow-y: auto;
  overflow-x: hidden;
  scroll-padding-block: 12px 76px;
  border: 1px solid rgba(226, 232, 240, 0.75);
  border-radius: 18px;
  padding: clamp(10px, 1.4vw, 14px);
  padding-bottom: clamp(20px, 3vh, 30px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.76)),
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.1), transparent 42%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.field-span {
  grid-column: 1 / -1;
}

.field-ratio {
  grid-column: 1 / -1;
}

.field-reference {
  grid-column: 1 / -1;
}

.field-prompt {
  grid-column: 1 / -1;
}

.image-field {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.75vh, 8px);
}

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

.input-label {
  display: block;
  margin-bottom: 0;
  color: #334155;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.25rem;
}

.input-hint {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1rem;
}

.image-muted,
.image-active-value,
.char-count {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.select-trigger {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.625rem 1rem;
  background: #ffffff;
  color: #111827;
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select-trigger:hover {
  border-color: #d1d5db;
}

.select-trigger:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: #14b8a6;
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.3);
}

.select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-icon {
  flex-shrink: 0;
  color: #94a3b8;
}

.input {
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 0.75rem;
  padding: 0.5rem 0.875rem;
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.25rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input::placeholder {
  color: #9ca3af;
}

.input:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

.prompt-textarea {
  width: 100% !important;
  min-height: 80px;
  height: clamp(120px, 20dvh, 200px);
  max-height: 80dvh;
  resize: vertical;
  box-sizing: border-box;
  display: block;
}

.resolution-tier {
  display: flex;
  gap: 6px;
  padding: 2px;
  background: rgba(241, 245, 249, 0.8);
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.6);
}

.tier-btn {
  flex: 1;
  padding: 6px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tier-btn:hover {
  color: #334155;
  background: rgba(255, 255, 255, 0.6);
}

.tier-btn-active {
  background: #ffffff;
  color: #0f766e;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  font-weight: 700;
}

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

.ratio-card {
  position: relative;
  display: flex;
  min-height: 64px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.ratio-card-active {
  border-color: #14b8a6;
  background: #ccfbf1;
  color: #0f766e;
}

.ratio-shape {
  display: block;
  border-radius: 6px;
  background: transparent;
  border: 2.5px solid #cbd5e1;
}

.ratio-shape-auto {
  border: 2.5px dashed #cbd5e1;
}

.ratio-card-active .ratio-shape {
  border-color: #2dd4bf;
}

.ratio-card-active .ratio-shape-auto {
  border-color: #2dd4bf;
  border-style: dashed;
}

.image-range {
  width: 100%;
  accent-color: var(--accent);
}

.image-count, .image-concurrency { width:86px; min-width:0; min-height:38px; text-align:center; }
.concurrency-row { margin-top:10px; }
.batch-error { color:var(--action-danger, #dc2626); }
.batch-warning { padding:8px 10px; border-radius:8px; color:var(--action-warning, #a16207); background:color-mix(in srgb, var(--action-warning, #a16207) 10%, var(--ui-surface-solid)); }
.image-count[aria-invalid="true"], .image-concurrency[aria-invalid="true"] { border-color:var(--action-danger, #dc2626); }
.page-drop-overlay { position:fixed; inset:12px; z-index:10000; display:grid; place-items:center; pointer-events:none; border:3px dashed var(--accent); border-radius:20px; color:var(--ui-text); background:color-mix(in srgb, var(--ui-surface-solid) 90%, transparent); font-size:clamp(20px,4vw,32px); font-weight:600; }
.page-drop-overlay[hidden] { display:none; }





.advanced-panel {
  grid-column: 1 / -1;
  min-height: min-content;
  overflow: hidden;
  border: 1px solid rgba(203, 213, 225, 0.78);
  border-radius: 14px;
  padding: 0;
  background: rgba(255, 255, 255, 0.78);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.advanced-panel[open] {
  border-color: rgba(20, 184, 166, 0.45);
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.advanced-panel summary {
  display: flex;
  cursor: pointer;
  list-style: none;
  align-items: center;
  justify-content: space-between;
  padding: clamp(9px, 1.35vh, 12px);
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}

.advanced-panel summary::-webkit-details-marker {
  display: none;
}

.advanced-panel summary svg {
  transition: transform 0.24s ease;
}

.advanced-panel[open] summary > svg:last-child {
  transform: rotate(180deg);
}

.advanced-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(8px, 1vh, 12px);
  height: 0;
  overflow: hidden;
  padding: 0 clamp(9px, 1.35vh, 12px) 0;
  opacity: 0;
  transform: translateY(-6px);
  transition: height 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), padding 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.advanced-panel[open] .advanced-body {
  height: auto;
  padding-bottom: clamp(9px, 1.35vh, 12px);
  opacity: 1;
  transform: translateY(0);
}

.cost-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-radius: 14px;
  padding: clamp(9px, 1.35vh, 12px);
  background: linear-gradient(135deg, rgba(240, 253, 250, 0.98), rgba(255, 255, 255, 0.86));
  min-width: 0;
  overflow-x: auto;
}

.cost-card > div {
  flex: 1;
  min-width: 0;
}

.cost-label {
  color: #0f766e;
  font-size: 13px;
  font-weight: 700;
}

.cost-hint {
  margin-top: 3px;
  color: #94a3b8;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.cost-value {
  color: var(--accent);
  font-weight: 800;
  font-size: clamp(14px, 1.2rem, 20px);
  flex: 0 0 auto;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.5);
}

.btn:disabled {
  transform: none;
  opacity: 0.5;
}

.btn-primary {
  background: linear-gradient(to right, #14b8a6, #0d9488);
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(20, 184, 166, 0.25), 0 2px 4px -2px rgba(20, 184, 166, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(to right, #0d9488, #0f766e);
  box-shadow: 0 10px 15px -3px rgba(20, 184, 166, 0.3), 0 4px 6px -4px rgba(20, 184, 166, 0.3);
}

.image-submit {
  grid-column: 1 / -1;
  width: 100%;
  justify-content: center;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: linear-gradient(to right, #14b8a6, #0d9488);
  box-shadow: 0 -4px 12px rgba(255, 255, 255, 0.8);
  margin-top: 4px;
}

.image-canvas {
  display: flex;
  min-height: 0;
  height: 100%;
  align-items: stretch;
  justify-content: center;
  border: 1px solid rgba(203, 213, 225, 0.72);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.035) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(135deg, transparent 75%, rgba(15, 23, 42, 0.035) 75%) 0 0 / 22px 22px,
    radial-gradient(circle at 50% 44%, rgba(20, 184, 166, 0.12), transparent 34%),
    rgba(248, 250, 252, 0.72);
  padding: clamp(10px, 1.4vw, 16px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.image-empty {
  display: flex;
  max-width: 360px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 22px;
  padding: clamp(18px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.08);
}

.image-empty-icon {
  display: flex;
  width: 62px;
  height: 62px;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #ccfbf1, #f8fafc);
  color: var(--accent);
  box-shadow: 0 12px 24px rgba(13, 148, 136, 0.12);
}

.image-empty h3,
.history-empty h3 {
  margin-top: 14px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.image-empty p,
.history-empty p {
  margin-top: 6px;
  color: #64748b;
  font-size: 14px;
}

.mock-results {
  display: flex;
  width: 100%;
  min-height: 0;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 14px);
}

.mock-result-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 16px;
  padding: clamp(10px, 1.4vh, 14px);
  background: rgba(255, 255, 255, 0.78);
}

.mock-result-head h3 {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.mock-result-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.mock-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(20, 184, 166, 0.12);
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
}

.mock-grid {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: clamp(10px, 1.4vw, 14px);
}

.mock-grid-compact {
  grid-auto-rows: 1fr;
}

.mock-card,
.history-card {
  min-width: 0;
  border: 1px solid rgba(226, 232, 240, 0.82);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}

.mock-card {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
}

.mock-art {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  align-items: flex-start;
  justify-content: flex-end;
  overflow: hidden;
  padding: 10px;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.72), transparent 14%),
    linear-gradient(135deg, #0f172a, #0f766e);
}

.mock-art::before {
  position: absolute;
  inset: 14% 18% 18% 16%;
  content: "";
  border-radius: 38% 44% 34% 42%;
  background: radial-gradient(circle at 45% 32%, #f8d38d, #d97706 45%, rgba(15, 23, 42, 0.55) 72%);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
}

.mock-art::after {
  position: absolute;
  inset: auto 10% 10% 10%;
  height: 20%;
  content: "";
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  filter: blur(14px);
}

.mock-art span {
  position: relative;
  z-index: 1;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(15, 23, 42, 0.52);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.mock-art-1 {
  background: radial-gradient(circle at 28% 28%, #facc15, transparent 16%), linear-gradient(135deg, #0f172a, #0e7490 48%, #ec4899);
}

.mock-art-2 {
  background: radial-gradient(circle at 72% 22%, #22d3ee, transparent 18%), linear-gradient(145deg, #111827, #0f766e 52%, #f97316);
}

.mock-art-3 {
  background: radial-gradient(circle at 36% 20%, #fef3c7, transparent 15%), linear-gradient(145deg, #172554, #155e75 58%, #fb7185);
}

.mock-art-4 {
  background: radial-gradient(circle at 68% 30%, #f0abfc, transparent 18%), linear-gradient(145deg, #020617, #164e63 48%, #14b8a6);
}

.mock-art-5 {
  background: radial-gradient(circle at 26% 24%, #fde68a, transparent 16%), linear-gradient(135deg, #0f172a, #0369a1 48%, #14b8a6);
}

.mock-art-6 {
  background: radial-gradient(circle at 72% 26%, #67e8f9, transparent 18%), linear-gradient(145deg, #111827, #7c2d12 48%, #0f766e);
}

.mock-art-7 {
  background: radial-gradient(circle at 42% 36%, #fed7aa, transparent 20%), linear-gradient(135deg, #f8fafc, #fb923c 46%, #2563eb);
}

.mock-art-8 {
  background: radial-gradient(circle at 44% 38%, #fef3c7, transparent 22%), linear-gradient(135deg, #14532d, #ca8a04 52%, #f9a8d4);
}

.mock-meta {
  flex: 0 0 auto;
  padding: 9px 10px 10px;
}

.mock-meta strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mock-meta span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.reference-upload {
  display: flex;
  width: 100%;
  height: clamp(52px, 8.5vh, 72px);
  cursor: pointer;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed rgba(20, 184, 166, 0.55);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(240, 253, 250, 0.72), rgba(255, 255, 255, 0.5));
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.reference-upload:hover {
  border-color: #14b8a6;
  background: linear-gradient(135deg, rgba(204, 251, 241, 0.6), rgba(240, 253, 250, 0.4));
  color: #0f766e;
}

.mock-reference-list {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.mock-reference-list span {
  max-width: 100%;
  overflow: hidden;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(241, 245, 249, 0.92);
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-list {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: clamp(12px, 1.4vw, 16px);
  align-content: start;
  overflow-y: auto;
  padding-right: 4px;
}

.history-card {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  padding: 0;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  cursor: default;
}

.history-card:hover {
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
  transform: translateY(-2px);
}

.history-thumb {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 75%;
  border-radius: 0;
  overflow: hidden;
}

.history-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.18), transparent 40%);
  pointer-events: none;
}

.history-card h3 {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.history-card p,
.history-card > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card p {
  margin-top: 4px;
  color: #475569;
  font-size: 12px;
}

.history-card > span {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
}

.history-panel {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  flex-direction: column;
  padding: clamp(12px, 1.4vw, 18px);
}

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

.history-head h2 {
  color: #1e293b;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.history-head p {
  color: #64748b;
  font-size: 13px;
  width: 100%;
  order: 3;
}

.history-empty {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  text-align: center;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 20px;
  background: rgba(248, 250, 252, 0.72);
}

.relative {
  position: relative;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 0.5rem;
}

.block {
  display: block;
}

.w-full {
  width: 100%;
}

.h-4,
.w-4 {
  width: 1rem;
  height: 1rem;
}

.h-5,
.w-5 {
  width: 1.25rem;
  height: 1.25rem;
}

.h-6,
.w-6 {
  width: 1.5rem;
  height: 1.5rem;
}

.h-8,
.w-8 {
  width: 2rem;
  height: 2rem;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1.5 {
  margin-bottom: 0.375rem;
}

.min-h-[80px] {
  min-height: 80px;
}

.resize-y {
  resize: vertical;
}

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

.gen-progress-text {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

@media (min-width: 768px) {
  .page-layout {
    padding: 0;
  }
}

@media (min-width: 1024px) {
  .page-layout {
    padding: 0;
  }
}

@media (max-width: 1180px) {
  .image-workbench {
    grid-template-columns: minmax(360px, 0.7fr) minmax(0, 1.3fr);
  }
}

@media (max-width: 960px) {
  .image-workbench {
    grid-template-columns: minmax(340px, 1fr) minmax(0, 1fr);
  }

  .image-canvas {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .page-layout {
    padding: 0;
  }

  .image-shell {
    border-radius: 0;
  }

  .image-tabs {
    overflow-x: auto;
    padding: 6px 12px;
  }

  .image-workbench {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(120px, 1fr);
  }

  .image-controls {
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-workbench,
  .history-panel {
    padding: 10px;
  }

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

  .history-head {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .image-controls {
    grid-template-columns: 1fr;
  }

  .field-ratio,
  .field-reference,
  .field-prompt,
  .advanced-panel,
  .cost-card,
  .image-submit {
    grid-column: 1;
  }

  .image-controls {
    gap: 7px;
  }

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

}

@media (max-height: 760px) {
  .page-layout {
    padding: 0;
  }

  .image-workbench,
  .history-panel {
    padding: 8px;
  }

  .image-controls {
    gap: 7px;
    padding: 8px;
  }

  .input-hint:not(.batch-error):not(.batch-warning):not(.reference-help):not(.reference-status) {
    display: none;
  }


  .image-empty-icon {
    width: 52px;
    height: 52px;
  }

  .image-empty h3,
  .history-empty h3 {
    margin-top: 10px;
    font-size: 16px;
  }

  .image-empty p,
  .history-empty p {
    font-size: 12px;
  }
}

#toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  padding: 14px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  color: #1e293b;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(226, 232, 240, 0.6);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(-16px) scale(0.96);
  transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1), transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
}

.toast::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-success { 
  background: linear-gradient(135deg, rgba(240, 253, 250, 0.98), rgba(255, 255, 255, 0.95));
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(20, 184, 166, 0.3);
}
.toast-success::before { background: #14b8a6; }

.toast-error { 
  background: linear-gradient(135deg, rgba(254, 242, 242, 0.98), rgba(255, 255, 255, 0.95));
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(239, 68, 68, 0.3);
}
.toast-error::before { background: #ef4444; }

.toast-warning { 
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.98), rgba(255, 255, 255, 0.95));
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(245, 158, 11, 0.3);
}
.toast-warning::before { background: #f59e0b; }

.toast-info { 
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.95));
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(59, 130, 246, 0.3);
}
.toast-info::before { background: #3b82f6; }

.select-open .select-trigger {
  border-color: #14b8a6;
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.3);
}

.select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 4px;
  animation: selectFadeIn 0.18s ease;
}

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

.select-option {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.select-option:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.select-option-active {
  background: rgba(20, 184, 166, 0.1);
  color: #0d9488;
  font-weight: 700;
}

.select-option-active:hover {
  background: rgba(20, 184, 166, 0.18);
}

.gen-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 16px;
  text-align: center;
}

.gen-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(20, 184, 166, 0.2);
  border-top-color: #14b8a6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.gen-loading-text {
  color: #334155;
  font-size: 16px;
  font-weight: 700;
}

.gen-loading-hint {
  color: #94a3b8;
  font-size: 13px;
}

.gen-btn-spin {
  animation: spin 1s linear infinite;
}

.gen-results {
  display: flex;
  width: 100%;
  min-height: 0;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 14px);
}

.gen-result-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 16px;
  padding: clamp(10px, 1.4vh, 14px);
  background: rgba(255, 255, 255, 0.78);
}

.gen-result-head h3 {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.gen-result-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.gen-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(20, 184, 166, 0.12);
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.gen-single-preview {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}

.gen-single-preview .result-image-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #f1f5f9;
}

.gen-single-preview .result-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gen-single-preview .result-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(15, 23, 42, 0.55);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(4px);
  z-index: 2;
}

.gen-single-preview .result-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.gen-single-preview:hover .result-actions {
  opacity: 1;
  transform: translateY(0);
}

.gen-single-preview .result-action-btn {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
  transition: background 0.15s ease, color 0.15s ease;
}

.gen-single-preview .result-action-btn:hover {
  background: #14b8a6;
  color: #ffffff;
}

.gen-single-preview .result-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 9px 12px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
  color: #ffffff;
  z-index: 2;
}

.gen-single-preview .result-meta strong {
  display: block;
  overflow: hidden;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gen-single-preview .result-meta span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  font-weight: 700;
}

.gen-multi-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px;
}

.gen-multi-preview .result-image-wrap {
  position: relative;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 14px;
  overflow: hidden;
  background: #f1f5f9;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gen-multi-preview .result-image-wrap:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.gen-multi-preview .result-image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  cursor: pointer;
}

.gen-multi-preview .result-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(15, 23, 42, 0.55);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  backdrop-filter: blur(4px);
  z-index: 2;
}

.gen-multi-preview .result-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.gen-multi-preview .result-image-wrap:hover .result-actions {
  opacity: 1;
  transform: translateY(0);
}

.gen-multi-preview .result-action-btn {
  display: flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
  transition: background 0.15s ease, color 0.15s ease;
}

.gen-multi-preview .result-action-btn:hover {
  background: #14b8a6;
  color: #ffffff;
}

.gen-grid {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  gap: clamp(10px, 1.4vw, 14px);
  overflow-y: auto;
  padding-right: 4px;
}

.gen-grid-large {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

.gen-grid-small {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(180px, 1fr);
}

.result-card {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.result-card:hover {
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
  transform: translateY(-2px);
}

.result-image-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #f1f5f9;
}

.result-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(15, 23, 42, 0.55);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(4px);
}

.result-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.result-card:hover .result-actions {
  opacity: 1;
  transform: translateY(0);
}

.result-action-btn {
  display: flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
  transition: background 0.15s ease, color 0.15s ease;
}

.result-action-btn:hover {
  background: #14b8a6;
  color: #ffffff;
}

.result-meta {
  flex: 0 0 auto;
  padding: 9px 10px 10px;
}

.result-meta strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.reference-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(241, 245, 249, 0.92);
  transition: background 0.15s ease;
}

.reference-item:hover {
  background: rgba(226, 232, 240, 0.92);
}
.reference-drag { display:grid; place-items:center; flex-shrink:0; width:24px; min-height:36px; padding:0; border:0; border-radius:6px; background:transparent; color:var(--ui-muted); cursor:grab; touch-action:none; font-size:22px; line-height:1; }
.reference-drag:hover { background:var(--ui-glow); color:var(--ui-text); }
.reference-drag:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.reference-open { touch-action:none; }
.reference-dragging { position:relative; z-index:2; opacity:0.85; box-shadow:0 8px 20px rgba(0,0,0,0.2); cursor:grabbing; user-select:none; }
.reference-dragging .reference-drag { cursor:grabbing; }
.reference-drop-target { outline:2px solid var(--accent); outline-offset:-2px; }
.reference-dragging { pointer-events:none; }
.reference-group-head, .reference-candidate { touch-action:none; cursor:grab; user-select:none; }
.reference-merge-target .reference-name, .reference-merge-target .reference-number { outline:2px solid var(--accent); background:var(--ui-glow); }
.reference-group.reference-merge-target, .reference-pending.reference-merge-target { position:relative; z-index:3; outline:3px solid #0d9488; outline-offset:1px; box-shadow:0 0 0 5px rgba(13,148,136,0.2); }
.reference-group.reference-merge-target > .reference-group-head { background:#ccfbf1; }
[data-theme="dark"] .reference-group.reference-merge-target { outline-color:#5eead4; box-shadow:0 0 0 5px rgba(94,234,212,0.22); }
[data-theme="dark"] .reference-group.reference-merge-target > .reference-group-head { background:#134e4a; }
.reference-drag-hint { position:fixed; z-index:10000; width:max-content; max-width:calc(100vw - 24px); padding:9px 13px; border:1px solid #cbd5e1; border-radius:10px; background:#0f172a; color:#fff; box-shadow:0 6px 22px rgba(0,0,0,0.28); font-size:13px; font-weight:700; line-height:1.5; pointer-events:none; }
.reference-drag-hint.is-merge { background:#065f46; border:2px solid #5eead4; font-size:14px; }
.reference-drag-hint.is-insert { background:#1e40af; border:2px solid #93c5fd; font-size:14px; }
.reference-drag-hint[hidden] { display:none; }
.reference-group { width:100%; min-width:0; border:1px solid var(--ui-border); border-radius:10px; background:var(--ui-bg); }
.reference-group-head { display:grid; grid-template-columns:24px 40px auto minmax(0,1fr) auto; gap:6px; }
.reference-group-head .reference-move { grid-column:3 / -1; justify-self:end; }
.reference-stack { position:relative; width:40px; height:40px; display:flex; align-items:center; }
.reference-stack .reference-open { position:relative; z-index:1; }
.reference-stack-back { position:absolute; top:4px; left:0; transform:translate(6px,6px); border:1px solid var(--ui-border); pointer-events:none; }
.reference-stack-back + .reference-stack-back { transform:translate(3px,3px); }
.reference-candidates { display:grid; gap:5px; padding:6px; border-top:1px solid var(--ui-border); }
.reference-candidate { display:grid; grid-template-columns:24px 36px minmax(0,1fr) auto; gap:6px; }
.reference-candidate .reference-move { grid-column:3 / -1; justify-self:end; }
.reference-move.input { width:110px; min-width:0; height:28px; padding:2px 6px; font-size:11px; }
.reference-expand { padding:5px 7px; font-size:11px; }
.reference-pending { display:grid; gap:6px; margin-top:8px; padding:8px; border:1px dashed var(--ui-border-strong); border-radius:10px; }
.reference-pending-title { margin:0 0 2px; font-size:12px; font-weight:600; color:var(--ui-muted); }
.reference-pending-empty { margin:0; min-height:34px; display:flex; align-items:center; justify-content:center; color:var(--ui-muted); font-size:12px; }
.reference-new-group { margin-top:8px; padding:12px; min-height:48px; border:2px dashed var(--ui-border-strong); border-radius:8px; color:var(--ui-text); font-size:12px; text-align:center; }
.reference-insert-before, .reference-insert-after { position:relative; }
.reference-insert-before::before, .reference-insert-after::after { content:""; position:absolute; left:0; right:0; height:4px; border-radius:2px; background:#2563eb; box-shadow:0 0 0 2px rgba(147,197,253,0.45); z-index:4; pointer-events:none; }
.reference-insert-before::before { top:-5px; }
.reference-insert-after::after { bottom:-5px; }
.reference-status { margin-top:8px; }
.reference-error { color:#dc2626; }
[data-theme="dark"] .reference-error { color:#fca5a5; }
.reference-pending[hidden], .reference-status[hidden], .reference-new-group[hidden] { display:none; }

.reference-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.reference-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-number {
  flex-shrink: 0;
  padding: 2px 6px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 5px;
  color: var(--ui-text);
  background: var(--ui-glow);
  font-size: 11px;
  font-weight: 600;
}

.reference-remove {
  display: flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.reference-remove:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.reference-upload-hover {
  border-color: #14b8a6 !important;
  background: linear-gradient(135deg, rgba(204, 251, 241, 0.6), rgba(240, 253, 250, 0.4)) !important;
}

.history-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #94a3b8;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.2s ease;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}

.history-card:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.history-info {
  min-width: 0;
  flex: 0 0 auto;
  padding: 10px 12px 12px;
}

.history-info h3 {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-info p {
  margin-top: 4px;
  color: #475569;
  font-size: 12px;
}

.history-info > span {
  display: block;
  margin-top: 6px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
}

.history-clear-btn {
  border-radius: 8px;
  padding: 6px 14px;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.history-clear-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

.history-head {
  flex-wrap: wrap;
  gap: 8px 16px;
}

@media (max-width: 760px) {
  .history-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .history-clear-btn {
    align-self: flex-start;
  }

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox-overlay.lightbox-active {
  opacity: 1;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.lightbox-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.lightbox-overlay.lightbox-active .lightbox-image {
  transform: scale(1);
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 24px;
  font-weight: 400;
  backdrop-filter: blur(8px);
  transition: background 0.15s ease;
  z-index: 10;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-download {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #14b8a6;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
  transition: background 0.15s ease, transform 0.15s ease;
  z-index: 10;
}

.lightbox-download:hover {
  background: #0d9488;
  transform: scale(1.05);
}

[data-theme="dark"] {
  color-scheme: dark;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-soft: rgba(45, 212, 191, 0.15);
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: rgba(71, 85, 105, 0.5);
  --panel: rgba(30, 41, 59, 0.9);
  --panel-strong: rgba(30, 41, 59, 0.98);
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.3);
  background: #0f172a;
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 14% 0%, rgba(8, 145, 178, 0.18), transparent 38rem),
    radial-gradient(circle at 90% 10%, rgba(124, 58, 237, 0.16), transparent 34rem),
    var(--ui-bg);
}

[data-theme="dark"] .image-shell,
[data-theme="dark"] .image-controls,
[data-theme="dark"] .image-canvas,
[data-theme="dark"] .history-card,
[data-theme="dark"] .result-card,
[data-theme="dark"] .mock-card,
[data-theme="dark"] .advanced-panel {
  background: rgba(19, 27, 52, 0.78);
  border-color: rgba(103, 232, 249, 0.18);
}

@supports not (backdrop-filter: blur(1px)) {
  .image-shell,
  .image-controls,
  .image-canvas,
  .history-card,
  .result-card,
  .mock-card,
  .advanced-panel {
    background: var(--ui-surface-solid);
  }
}

[data-theme="dark"] body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 44%, #0f172a 100%);
}

[data-theme="dark"] ::selection {
  color: #ccfbf1;
  background: rgba(45, 212, 191, 0.25);
}

[data-theme="dark"] *:hover::-webkit-scrollbar-thumb {
  background: rgba(71, 85, 105, 0.5);
}

[data-theme="dark"] *:hover::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

[data-theme="dark"] #app::before {
  background-image:
    radial-gradient(circle at 18% 16%, rgba(45, 212, 191, 0.08) 0 18%, transparent 42%),
    radial-gradient(circle at 84% 8%, rgba(56, 189, 248, 0.06) 0 16%, transparent 40%),
    linear-gradient(120deg, rgba(20, 184, 166, 0.03), transparent 42%, rgba(245, 158, 11, 0.03));
}

[data-theme="dark"] .image-shell {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.94), rgba(15, 23, 42, 0.88));
}

[data-theme="dark"] .image-tabs {
  border-bottom-color: rgba(51, 65, 85, 0.68);
  background: rgba(30, 41, 59, 0.58);
}

[data-theme="dark"] .image-tab {
  color: #94a3b8;
}

[data-theme="dark"] .image-tab:hover {
  color: #e2e8f0;
}

[data-theme="dark"] .image-tab-active {
  border-color: #2dd4bf;
  color: #2dd4bf;
}

[data-theme="dark"] .image-controls {
  border-color: rgba(51, 65, 85, 0.75);
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.76)),
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.05), transparent 42%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .input-label {
  color: #cbd5e1;
}

[data-theme="dark"] .image-muted,
[data-theme="dark"] .image-active-value,
[data-theme="dark"] .char-count {
  color: #94a3b8;
}

[data-theme="dark"] .select-trigger {
  border-color: #334155;
  background: #1e293b;
  color: #e2e8f0;
}

[data-theme="dark"] .select-trigger:hover {
  border-color: #475569;
}

[data-theme="dark"] .select-trigger:focus {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.3);
}

[data-theme="dark"] .select-icon {
  color: #64748b;
}

[data-theme="dark"] .input {
  border-color: rgba(51, 65, 85, 0.9);
  background: var(--panel-strong);
  color: var(--ink);
}

[data-theme="dark"] .input::placeholder {
  color: #64748b;
}

[data-theme="dark"] .input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2);
}

[data-theme="dark"] .resolution-tier {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(51, 65, 85, 0.6);
}

[data-theme="dark"] .tier-btn {
  color: #94a3b8;
}

[data-theme="dark"] .tier-btn:hover {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .tier-btn-active {
  background: #1e293b;
  color: #2dd4bf;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .ratio-card {
  border-color: #334155;
  background: #1e293b;
  color: #94a3b8;
}

[data-theme="dark"] .ratio-card-active {
  border-color: #2dd4bf;
  background: rgba(45, 212, 191, 0.1);
  color: #2dd4bf;
}

[data-theme="dark"] .ratio-shape {
  border-color: #475569;
}

[data-theme="dark"] .ratio-shape-auto {
  border-color: #475569;
}

[data-theme="dark"] .ratio-card-active .ratio-shape {
  border-color: #2dd4bf;
}

[data-theme="dark"] .ratio-card-active .ratio-shape-auto {
  border-color: #2dd4bf;
}

[data-theme="dark"] .advanced-panel {
  border-color: rgba(51, 65, 85, 0.78);
  background: rgba(30, 41, 59, 0.78);
}

[data-theme="dark"] .advanced-panel[open] {
  border-color: rgba(45, 212, 191, 0.3);
  background: #1e293b;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .advanced-panel summary {
  color: #cbd5e1;
}

[data-theme="dark"] .cost-card {
  border-color: rgba(45, 212, 191, 0.15);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.86));
}

[data-theme="dark"] .cost-label {
  color: #2dd4bf;
}

[data-theme="dark"] .cost-hint {
  color: #64748b;
}

[data-theme="dark"] .btn-primary {
  background: linear-gradient(to right, #2dd4bf, #14b8a6);
  box-shadow: 0 4px 6px -1px rgba(45, 212, 191, 0.2), 0 2px 4px -2px rgba(45, 212, 191, 0.2);
}

[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: linear-gradient(to right, #14b8a6, #0d9488);
  box-shadow: 0 10px 15px -3px rgba(45, 212, 191, 0.25), 0 4px 6px -4px rgba(45, 212, 191, 0.25);
}

[data-theme="dark"] .image-submit {
  background: linear-gradient(to right, #2dd4bf, #14b8a6);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .image-canvas {
  border-color: rgba(51, 65, 85, 0.72);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.02) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(135deg, transparent 75%, rgba(255, 255, 255, 0.02) 75%) 0 0 / 22px 22px,
    radial-gradient(circle at 50% 44%, rgba(45, 212, 191, 0.06), transparent 34%),
    rgba(15, 23, 42, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .image-empty {
  border-color: rgba(51, 65, 85, 0.82);
  background: rgba(30, 41, 59, 0.72);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .image-empty-icon {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.15), rgba(30, 41, 59, 0.8));
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .mock-results,
[data-theme="dark"] .gen-results {
  color: var(--ink);
}

[data-theme="dark"] .mock-result-head,
[data-theme="dark"] .gen-result-head {
  border-color: rgba(51, 65, 85, 0.82);
  background: rgba(30, 41, 59, 0.78);
}

[data-theme="dark"] .mock-status,
[data-theme="dark"] .gen-status {
  background: rgba(45, 212, 191, 0.12);
  color: #2dd4bf;
}

[data-theme="dark"] .mock-card,
[data-theme="dark"] .history-card,
[data-theme="dark"] .result-card {
  border-color: rgba(51, 65, 85, 0.82);
  background: rgba(30, 41, 59, 0.82);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .mock-card:hover,
[data-theme="dark"] .history-card:hover,
[data-theme="dark"] .result-card:hover {
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .mock-meta span,
[data-theme="dark"] .history-card > span {
  color: #64748b;
}

[data-theme="dark"] .reference-upload {
  border-color: rgba(45, 212, 191, 0.4);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.72), rgba(15, 23, 42, 0.5));
  color: #94a3b8;
}

[data-theme="dark"] .reference-upload:hover {
  border-color: #2dd4bf;
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.1), rgba(30, 41, 59, 0.4));
  color: #2dd4bf;
}

[data-theme="dark"] .mock-reference-list span {
  background: rgba(51, 65, 85, 0.92);
  color: #94a3b8;
}

[data-theme="dark"] .history-empty {
  border-color: rgba(51, 65, 85, 0.85);
  background: rgba(15, 23, 42, 0.72);
}

[data-theme="dark"] .history-card p {
  color: #94a3b8;
}

[data-theme="dark"] .history-head h2 {
  color: #e2e8f0;
}

[data-theme="dark"] .gen-loading-text {
  color: #cbd5e1;
}

[data-theme="dark"] .gen-loading-hint {
  color: #64748b;
}

[data-theme="dark"] .gen-spinner {
  border-color: rgba(45, 212, 191, 0.2);
  border-top-color: #2dd4bf;
}

[data-theme="dark"] .gen-single-preview {
  border-color: rgba(51, 65, 85, 0.82);
  background: rgba(30, 41, 59, 0.82);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .gen-single-preview .result-image-wrap,
[data-theme="dark"] .result-image-wrap {
  background: #1e293b;
}

[data-theme="dark"] .gen-multi-preview .result-image-wrap {
  border-color: rgba(51, 65, 85, 0.82);
  background: #1e293b;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .gen-multi-preview .result-image-wrap:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

[data-theme="dark"] .gen-single-preview .result-action-btn,
[data-theme="dark"] .gen-multi-preview .result-action-btn,
[data-theme="dark"] .result-action-btn {
  background: rgba(30, 41, 59, 0.9);
  color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .gen-single-preview .result-action-btn:hover,
[data-theme="dark"] .gen-multi-preview .result-action-btn:hover,
[data-theme="dark"] .result-action-btn:hover {
  background: #2dd4bf;
  color: #0f172a;
}

[data-theme="dark"] .reference-item {
  background: rgba(51, 65, 85, 0.92);
}

[data-theme="dark"] .reference-item:hover {
  background: rgba(71, 85, 105, 0.92);
}

[data-theme="dark"] .reference-name {
  color: #94a3b8;
}

[data-theme="dark"] .reference-remove {
  color: #64748b;
}

[data-theme="dark"] .reference-remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

[data-theme="dark"] .history-delete {
  background: rgba(30, 41, 59, 0.9);
  color: #64748b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .history-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

[data-theme="dark"] .history-info p {
  color: #94a3b8;
}

[data-theme="dark"] .history-info > span {
  color: #64748b;
}

[data-theme="dark"] .history-clear-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
}

[data-theme="dark"] .history-clear-btn:hover {
  background: rgba(239, 68, 68, 0.18);
}

[data-theme="dark"] .toast {
  background: rgba(30, 41, 59, 0.95);
  color: #e2e8f0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(51, 65, 85, 0.6);
}

[data-theme="dark"] .toast-success {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.95));
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(45, 212, 191, 0.25);
}

[data-theme="dark"] .toast-error {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.95));
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .toast-warning {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.95));
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .toast-info {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.95));
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .select-menu {
  border-color: #334155;
  background: #1e293b;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .select-option {
  color: #cbd5e1;
}

[data-theme="dark"] .select-option:hover {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .select-option-active {
  background: rgba(45, 212, 191, 0.12);
  color: #2dd4bf;
}

[data-theme="dark"] .select-option-active:hover {
  background: rgba(45, 212, 191, 0.2);
}

[data-theme="dark"] .select-open .select-trigger {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.3);
}

[data-theme="dark"] .gen-progress-text {
  color: #94a3b8;
}

[data-theme="dark"] .history-thumb::after {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.3), transparent 40%);
}

.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.confirm-overlay.confirm-active {
  opacity: 1;
}

.confirm-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.confirm-dialog {
  position: relative;
  width: 90%;
  max-width: 380px;
  padding: 24px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s ease;
}

.confirm-overlay.confirm-active .confirm-dialog {
  transform: scale(1) translateY(0);
}

.confirm-icon {
  display: flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.confirm-title {
  margin: 0 0 8px;
  color: #1e293b;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.confirm-message {
  margin: 0 0 20px;
  color: #64748b;
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.confirm-btn:active {
  transform: scale(0.98);
}

.confirm-btn-cancel {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

.confirm-btn-cancel:hover {
  background: #f1f5f9;
  color: #334155;
}

.confirm-btn-confirm {
  border: 0;
  background: linear-gradient(to right, #ef4444, #dc2626);
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.25);
}

.confirm-btn-confirm:hover {
  background: linear-gradient(to right, #dc2626, #b91c1c);
  box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .confirm-dialog {
  background: #1e293b;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .confirm-title {
  color: #e2e8f0;
}

[data-theme="dark"] .confirm-message {
  color: #94a3b8;
}

[data-theme="dark"] .confirm-btn-cancel {
  border-color: #334155;
  background: #0f172a;
  color: #94a3b8;
}

[data-theme="dark"] .confirm-btn-cancel:hover {
  background: #334155;
  color: #e2e8f0;
}

/* Shared Sub2API glass surface language. Keep extension-specific selectors
   below the legacy rules so existing controls retain their behavior. */
body {
  color: var(--ui-text);
  background:
    radial-gradient(circle at 8% 0%, var(--ui-glow), transparent 32rem),
    radial-gradient(circle at 95% 8%, rgba(56, 189, 248, 0.08), transparent 28rem),
    var(--ui-bg);
}

.image-shell,
.image-controls,
.image-canvas,
.history-card,
.result-card,
.mock-card,
.advanced-panel {
  border-color: var(--ui-border);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
  backdrop-filter: blur(22px) saturate(135%);
}

.image-tabs {
  border-color: var(--ui-border);
  background: color-mix(in srgb, var(--ui-surface-solid) 62%, transparent);
  backdrop-filter: blur(18px);
}

.image-tab-active,
.tier-btn-active,
.ratio-card-active {
  border-color: var(--ui-border-strong);
  color: var(--accent-strong);
  background: linear-gradient(110deg, rgba(20, 184, 166, 0.14), rgba(34, 211, 238, 0.08));
}

.select-trigger,
.input,
.prompt-input,
.reference-upload {
  border-color: var(--ui-border);
  background: var(--ui-surface-solid);
  color: var(--ui-text);
}

.btn-primary,
.image-submit {
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}


/* Cloud records and gallery use the existing light/dark theme tokens. */
.cloud-select { width:100%; min-height:42px; color:inherit; background:transparent; }
.history-list { grid-auto-rows: max-content; align-items: start; }
.cloud-card { overflow:hidden; display:flex; flex-direction:column; align-self:start; }
.cloud-thumb { display:block; flex:0 0 auto; border:0; padding:0; background:var(--ui-bg); cursor:zoom-in; width:100%; aspect-ratio:4 / 3; overflow:hidden; }
.cloud-thumb img { display:block; width:100%; height:100%; object-fit:contain; }
.cloud-thumb:focus-visible { outline:2px solid var(--accent); outline-offset:-3px; }
.history-info { container: card-actions / inline-size; }
.cloud-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:14px; }
.cloud-actions > :only-child { grid-column:1 / -1; }
@container card-actions (min-width:360px) {
  .cloud-actions:has(> :nth-child(4):last-child) { grid-template-columns:repeat(4,minmax(0,1fr)); }
}
.pagination { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-top:14px; }
.pagination { justify-content:center; }
.cloud-actions button { width:100%; min-width:0; margin:0; }
.history-head { display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center; gap:8px; }
.history-head > h2 { grid-column:1; grid-row:1; }
.history-head > p { grid-column:1 / -1; grid-row:2; }
.history-head > .history-description { grid-column:1 / -1; grid-row:2; display:flex; align-items:center; gap:8px; width:100%; }
.history-description > p { flex:0 1 auto; min-width:0; width:auto; order:0; margin:0; }
.history-help { display:inline-flex; align-items:center; justify-content:center; flex:0 0 30px; width:30px; height:30px; padding:0; border:1px solid var(--ui-border); border-radius:50%; color:var(--ui-muted); background:var(--ui-surface-solid); font-size:15px; line-height:1; font-weight:600; }
.history-help:hover { color:var(--ui-text); border-color:var(--ui-border-strong); }
.history-help:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.history-help:disabled { opacity:0.5; cursor:wait; }
.maintenance-help { display:grid; gap:16px; }
.maintenance-help h4 { margin:0 0 5px; font-size:14px; color:var(--ui-text); }
.maintenance-help p { margin:0; font-size:13px; line-height:1.75; color:var(--ui-muted); overflow-wrap:anywhere; }
.history-head > .history-clear-btn { grid-column:2; grid-row:1; align-self:center; }
.history-head > .list-refresh { grid-column:3; }
.list-refresh { position:relative; display:inline-grid; place-items:center; min-height:32px; border-radius:10px; }
.list-refresh[aria-busy="true"] > span { visibility:hidden; }
.list-refresh[aria-busy="true"]::before { content:""; position:absolute; inset:0; margin:auto; width:14px; height:14px; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; animation:spin 0.8s linear infinite; }
.history-clear-btn.list-refresh[aria-busy="true"]:disabled { opacity:1; cursor:progress; }
@media (prefers-reduced-motion:reduce) {
  .list-refresh[aria-busy="true"]::before { animation:none; }
}
.cloud-dialog { width:min(760px,94vw); max-height:90vh; overflow:auto; text-align:left; }
.cloud-dialog > * { margin-bottom:12px; }
.cloud-dialog-header { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:12px; }
.cloud-dialog-header > h3 { min-width:0; margin:0; }
.cloud-dialog-header > button { align-self:center; margin:0; }
.cloud-preview { display:block; width:100%; height:100%; min-height:0; object-fit:contain; }
.cloud-prompt { white-space:pre-wrap; overflow-wrap:anywhere; }
.share-option { display:flex; gap:12px; align-items:center; }
.image-canvas .history-list { grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); }
.gen-results > h3 { flex-shrink:0; }
@media (max-width:760px) {
  .history-panel { overflow-y:auto; overscroll-behavior:contain; }
  .history-panel > .history-list { flex:none; overflow:visible; }
  .image-workbench { display:flex; flex-direction:column; overflow-y:auto; overscroll-behavior:contain; scroll-padding-block:12px 76px; }
  .image-controls { flex-shrink:0; height:auto; overflow:visible; }
  .image-canvas { flex-shrink:0; height:auto; min-height:220px; }
  .image-canvas .history-list { overflow:visible; flex:none; }
  .history-list, .image-canvas .history-list { grid-template-columns:minmax(0,1fr); }
  .history-head, .pagination { flex-shrink:0; }
}
@media(max-width:600px) { .image-tab { flex:1; justify-content:center; padding:12px 8px; } .image-tabs { gap:2px; } }

/* Full-size viewer shared by private records and the gallery. */
.viewer-overlay .confirm-backdrop {
  background: rgba(8, 15, 28, 0.6);
  -webkit-backdrop-filter: blur(14px) saturate(80%);
  backdrop-filter: blur(14px) saturate(80%);
}
.cloud-dialog.cloud-viewer {
  display: flex;
  flex-direction: column;
  width: min(1500px, calc(100vw - 64px));
  height: min(960px, calc(100vh - 64px));
  height: min(960px, calc(100dvh - 64px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: 20px;
  color: var(--ui-text);
  background: var(--ui-surface-solid);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.35);
}
.cloud-viewer > * { margin: 0; }
.viewer-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--ui-border);
}
.viewer-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.viewer-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-left: auto; min-width: 0; max-width: 100%; }
.viewer-actions:not(:has(> .viewer-image-actions)):has(> :nth-child(4 of :not([hidden]))):not(:has(> :nth-child(5 of :not([hidden])))) {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  width:min(100%,480px);
}
.viewer-action[hidden] { display: none; }
.reuse-action:disabled { opacity: 0.5; cursor: not-allowed; }
.viewer-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  color: var(--ui-text);
  background: var(--ui-surface-solid);
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.viewer-action svg { width: 17px; height: 17px; flex-shrink: 0; }
.viewer-action:hover { background: var(--ui-glow); border-color: var(--ui-border-strong); }
.viewer-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.viewer-content { display: grid; grid-template-columns: minmax(0, 1fr) 360px; flex: 1; min-height: 0; }
.viewer-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 28px;
  background: var(--ui-bg);
}
.viewer-details {
  min-width: 0;
  padding: 28px;
  overflow: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--ui-border);
}
.viewer-label { margin: 0 0 14px; font-size: 14px; font-weight: 600; }
.viewer-details .cloud-prompt { font-size: 14px; line-height: 1.85; }
.viewer-muted { color: var(--ui-muted); font-size: 14px; }
.viewer-metadata { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0; color: var(--ui-muted); font-size: 12px; }
.viewer-metadata span { padding: 4px 9px; border: 1px solid var(--ui-border); border-radius: 6px; }
.viewer-references { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.viewer-reference { min-width: 0; margin: 0; }
.viewer-reference-button { display: block; width: 100%; padding: 0; border-radius: 10px; cursor: zoom-in; }
.reference-open { display: block; flex-shrink: 0; padding: 0; border-radius: 6px; cursor: zoom-in; }
.viewer-reference-button:hover, .reference-open:hover { outline: 1px solid var(--ui-border-strong); outline-offset: 2px; }
.viewer-reference-button:focus-visible, .viewer-reference-button[aria-pressed="true"], .reference-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.viewer-reference figcaption { margin-top: 6px; color: var(--ui-muted); font-size: 12px; }
.viewer-references .reference-thumb { width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; object-fit: contain; background: var(--ui-bg); }
@media (max-width: 1000px) {
  .viewer-content { grid-template-columns: minmax(0, 1fr) 300px; }
  .viewer-stage, .viewer-details { padding: 20px; }
}
@media (max-width: 700px) {
  .cloud-dialog.cloud-viewer { width: calc(100vw - 20px); height: calc(100vh - 24px); height: calc(100dvh - 24px); border-radius: 14px; }
  .viewer-header { padding: 12px; gap: 8px; flex-wrap: wrap; }
  .viewer-header h3 { font-size: 14px; }
  .viewer-actions { gap: 5px; }
  .viewer-actions:not(:has(> .viewer-image-actions)):has(> :nth-child(4 of :not([hidden]))):not(:has(> :nth-child(5 of :not([hidden])))) { grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
  .viewer-action { padding: 8px; font-size: 12px; gap: 5px; }
  .viewer-action svg { width: 15px; height: 15px; }
  .viewer-content { display: flex; flex-direction: column; overflow: auto; overscroll-behavior: contain; }
  .viewer-stage { flex: 0 0 48vh; flex-basis: 48dvh; padding: 14px; }
  .viewer-details { flex-shrink: 0; overflow: visible; border-left: 0; border-top: 1px solid var(--ui-border); padding: 20px; }
  .viewer-references { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.viewer-content.viewer-image-only { display: flex; }
.viewer-image-only .viewer-stage { flex: 1; width: 100%; }

/* Action colors are shared by cards, preview tools, and dialogs. */
:root {
  --action-neutral: #475569;
  --action-download: #1d4ed8;
  --action-share: #7e22ce;
  --action-reuse: #166534;
  --action-danger: #b91c1c;
  --action-warning: #854d0e;
  --action-refresh: #155e75;
  --action-favorite: #a16207;
  --action-like: #be185d;
}
:root.dark, :root[data-theme="dark"] {
  --action-neutral: #cbd5e1;
  --action-download: #93c5fd;
  --action-share: #d8b4fe;
  --action-reuse: #86efac;
  --action-danger: #fca5a5;
  --action-warning: #fde047;
  --action-refresh: #67e8f9;
  --action-favorite: #fcd34d;
  --action-like: #f9a8d4;
}
[data-tone="neutral"] { --action-color: var(--action-neutral); }
[data-tone="download"] { --action-color: var(--action-download); }
[data-tone="share"] { --action-color: var(--action-share); }
[data-tone="reuse"] { --action-color: var(--action-reuse); }
[data-tone="danger"] { --action-color: var(--action-danger); }
[data-tone="warning"] { --action-color: var(--action-warning); }
[data-tone="refresh"] { --action-color: var(--action-refresh); }
[data-tone="favorite"] { --action-color: var(--action-favorite); }
[data-tone="like"] { --action-color: var(--action-like); }
.history-clear-btn[data-tone], .viewer-action[data-tone],
[data-theme="dark"] .history-clear-btn[data-tone], [data-theme="dark"] .viewer-action[data-tone] {
  color: var(--action-color);
  border: 1px solid color-mix(in srgb, var(--action-color) 25%, transparent);
  background: color-mix(in srgb, var(--action-color) 9%, var(--ui-surface-solid));
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.history-clear-btn[data-tone]:hover:not(:disabled), .viewer-action[data-tone]:hover:not(:disabled),
[data-theme="dark"] .history-clear-btn[data-tone]:hover:not(:disabled), [data-theme="dark"] .viewer-action[data-tone]:hover:not(:disabled) {
  color: var(--action-color);
  border-color: color-mix(in srgb, var(--action-color) 45%, transparent);
  background: color-mix(in srgb, var(--action-color) 16%, var(--ui-surface-solid));
}
.history-clear-btn[data-tone]:focus-visible, .viewer-action[data-tone]:focus-visible {
  outline: 2px solid var(--action-color);
  outline-offset: 2px;
}
.history-clear-btn[data-tone]:disabled, .viewer-action[data-tone]:disabled { opacity: 0.5; cursor: not-allowed; }

/* Library controls and per-image interactions. */
.cloud-thumb-wrap { position:relative; flex:0 0 auto; width:100%; }
.favorite-overlay { position:absolute; top:8px; right:8px; width:30px; height:30px; padding:0; border-radius:50%; font-size:23px; line-height:1; background:var(--ui-bg); color:var(--ui-text); box-shadow:0 1px 6px #0003; opacity:0; pointer-events:none; }
@media (hover:hover) and (pointer:fine) {
  .cloud-thumb-wrap:hover .favorite-overlay, .cloud-thumb-wrap:focus-within .favorite-overlay { opacity:1; pointer-events:auto; }
}
@media (hover:none), (pointer:coarse) { .favorite-overlay { display:none; } }
.library-toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; flex-shrink:0; margin:0 0 16px; }
.library-search { flex:1 1 180px; min-width:120px; width:auto; }
.library-sort, .library-filter-dropdown { flex:0 1 170px; width:auto; min-width:0; }
.library-sort, .library-filter-trigger { min-height:38px; }
.library-filter-dropdown { position:relative; }
.library-filter-trigger { display:flex; align-items:center; justify-content:space-between; gap:8px; cursor:pointer; list-style:none; }
.library-filter-trigger::-webkit-details-marker { display:none; }
.library-filter-trigger > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.library-filter-trigger::after { content:""; flex:0 0 6px; width:6px; height:6px; margin-right:1px; border-right:2px solid currentColor; border-bottom:2px solid currentColor; transform:translateY(-2px) rotate(45deg); }
.library-filter-dropdown[open] > .library-filter-trigger::after { transform:translateY(2px) rotate(225deg); }
.library-filters { position:absolute; top:calc(100% + 6px); left:0; z-index:10; display:grid; width:max(100%, 210px); max-width:calc(100vw - 24px); max-height:min(260px, 45dvh); overflow-y:auto; padding:6px; border:1px solid var(--ui-border); border-radius:12px; background:var(--ui-surface-solid); color:var(--ui-text); box-shadow:var(--ui-shadow); }
.library-filter-hint { margin:4px 8px 6px; font-size:12px; line-height:1.5; color:var(--ui-muted); }
.library-filters label { display:flex; align-items:center; gap:8px; min-height:38px; padding:8px; border-radius:8px; font-size:14px; cursor:pointer; white-space:nowrap; }
.library-filters label:hover, .library-filters label:focus-within { background:color-mix(in srgb, var(--accent) 10%, var(--ui-surface-solid)); }
.library-filters input { width:16px; height:16px; margin:0; accent-color:var(--accent); }
.library-filters .filter-suspended { color:var(--ui-muted); opacity:0.55; }
.library-filters .filter-suspended input { accent-color:var(--ui-muted); }
.viewer-image-actions { display:inline-flex; align-items:center; gap:8px; max-width:100%; }
.viewer-social { display:flex; align-items:center; gap:6px; }
.social-card-action { display:inline-flex; align-items:center; justify-content:center; gap:6px; }
.social-card-action svg { width:17px; height:17px; flex-shrink:0; }
@media(max-width:600px) {
  .viewer-image-actions { gap:5px; }
  .library-toolbar { gap:8px; }
  .library-search { flex-basis:100%; }
  .library-filter-dropdown, .library-sort { flex-basis:100%; }
}

/* Gestures stay inside the preview so zoom never covers the prompt or toolbar. */
.viewer-zoom-stage { position:relative; overflow:hidden; touch-action:none; user-select:none; cursor:zoom-in; }
.viewer-zoom-stage .cloud-preview { transform-origin:center; will-change:transform; user-select:none; -webkit-user-drag:none; }
.viewer-zoom-stage.viewer-zoomed { cursor:grab; }
.viewer-zoom-stage.viewer-panning { cursor:grabbing; }
.viewer-zoom-stage:focus-visible { outline:2px solid var(--accent); outline-offset:-3px; }
.viewer-zoom-reset { position:absolute; right:12px; bottom:12px; z-index:1; box-shadow:0 2px 8px #0002; }

/* Compact generation settings and the advanced prompt editor. */
.compact-setting-buttons { display:grid; grid-template-columns:minmax(0,1.8fr) repeat(2,minmax(0,1fr)); gap:6px; }
.setting-toggle { min-width:0; padding:9px 4px; border:1px solid var(--ui-border,#cbd5e1); border-radius:10px; background:var(--ui-surface-solid,#fff); color:var(--ui-text,#334155); font-size:12px; font-weight:600; cursor:pointer; }
.setting-toggle[aria-expanded="true"] { border-color:var(--primary,#14b8a6); background:color-mix(in srgb,var(--primary,#14b8a6) 10%,var(--ui-surface-solid,#fff)); }
.compact-setting-body { padding:12px 0 2px; }
.compact-setting-body > * + * { margin-top:8px; }
.compact-setting-body .concurrency-row { margin-top:0; }
.batch-feedback:has(> :not([hidden])) { display:grid; gap:6px; }
.batch-feedback:not(:has(> :not([hidden]))) { display:none; }
.advanced-prompt-entry { align-self:flex-start; }
.prompt-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.prompt-heading > label { margin:0; }
.prompt-heading .prompt-expand { flex:none; min-height:36px; margin:0; padding:4px 10px; font-size:12px; }
:root .image-shell:has(.prompt-expanded-dialog) { backdrop-filter:none; }
.cloud-dialog.prompt-expanded-dialog {
  display:flex; flex-direction:column; gap:12px; width:min(1100px,calc(100vw - 24px)); max-width:none;
  height:min(820px,82dvh); max-height:calc(100dvh - 24px); padding:clamp(12px,2vw,24px); overflow:hidden;
}
.prompt-expanded-dialog > * { margin:0; }
.prompt-expanded-dialog .prompt-expanded-close { display:grid; place-items:center; width:44px; height:44px; padding:0; }
.prompt-expanded-dialog .prompt-editor { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:3px; }
.prompt-expanded-dialog .prompt-expand, .prompt-expanded-actions .prompt-profile-name { display:none; }
.prompt-expanded-dialog .prompt-textarea { font-size:16px; line-height:1.65; }
.prompt-expanded-dialog .plain-prompt-group { flex:1; min-height:0; grid-template-rows:auto minmax(0,1fr); }
.prompt-expanded-dialog .plain-prompt-group .prompt-textarea { height:100% !important; max-height:none; min-height:80px; resize:none; }
.prompt-expanded-dialog .prompt-input-block .prompt-textarea { height:clamp(160px,30dvh,360px); max-height:60dvh; }
.prompt-expanded-actions { display:flex; align-items:center; gap:clamp(6px,1vw,12px); flex:none; min-width:0; }
.prompt-expanded-actions > button { flex:none; align-self:center; min-height:44px; width:auto; margin:0; padding:8px clamp(8px,1vw,14px); font-size:clamp(12px,1.2vw,14px); white-space:nowrap; position:static; }
.prompt-expanded-actions .cost-card { margin-left:auto; min-height:44px; padding:8px; gap:6px; }
.prompt-expanded-actions .cost-card > div { flex:none; }
.prompt-expanded-actions .cost-hint { display:none; }
.prompt-expanded-actions .cost-label, .prompt-expanded-actions .cost-value { font-size:clamp(12px,1.2vw,16px); }
.plain-prompt-group, .advanced-prompt-inputs, .prompt-input-block { display:grid; gap:7px; }
.plain-prompt-group[hidden], .advanced-prompt-inputs[hidden], .compact-setting-body[hidden] { display:none; }
.prompt-input-block textarea { width:100%; min-height:80px; resize:vertical; }
.prompt-save-feedback { display:flex; align-items:center; flex-wrap:wrap; gap:6px; font-size:11px; color:var(--muted,#64748b); }
.prompt-save-status[data-error="true"] { color:var(--action-delete,#dc2626); }
.prompt-save-feedback button { padding:3px 7px; font-size:11px; }
.prompt-save-feedback button[hidden] { display:none; }
.cloud-dialog.advanced-prompt-dialog { max-width:820px; width:min(820px,94vw); }
.prompt-header-actions { display:flex; align-items:center; gap:6px; }
.prompt-header-actions > button { margin:0; white-space:nowrap; }
.cloud-dialog.prompt-preview-dialog { max-width:820px; width:min(820px,94vw); }
.prompt-merged-preview { display:block; width:100%; min-height:120px; height:45vh; max-height:60vh; resize:vertical; line-height:1.7; }
.prompt-profile-toolbar { display:grid; gap:10px; }
.prompt-profile-toolbar .share-option { margin:0; }
.prompt-profile-actions { display:flex; flex-wrap:wrap; gap:8px; }
.prompt-profile-actions > button { flex:1 1 auto; }
.prompt-profile-hint,.prompt-empty { font-size:12px; line-height:1.6; color:var(--muted,#64748b); }
.prompt-block-list { max-height:46vh; overflow:auto; overscroll-behavior:contain; padding:3px; }
.prompt-block-row { display:grid; grid-template-columns:28px 20px minmax(70px,1fr) 72px minmax(0,1.2fr) auto; align-items:center; gap:8px; border:1px solid var(--ui-border,#cbd5e1); border-radius:10px; padding:10px 8px; margin-bottom:8px; min-height:48px; color:var(--ui-text,#334155); background:var(--ui-surface-solid,#fff); touch-action:pan-y; }
.prompt-block-label { border:0; color:inherit; background:none; text-align:left; font-weight:600; overflow-wrap:anywhere; cursor:pointer; min-width:0; }
.prompt-block-type { font-size:12px; white-space:nowrap; }
.prompt-block-preview { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; color:var(--muted,#64748b); font-size:12px; }
.prompt-block-delete { padding:6px 8px; min-height:32px; margin:0; white-space:nowrap; font-size:12px; }
.prompt-drag-handle { border:0; background:none; color:inherit; font-size:22px; cursor:grab; touch-action:none; padding:0; min-height:28px; }
.prompt-block-disabled { opacity:.6; }
.prompt-dragging { opacity:.7; }
.prompt-drop-target { outline:2px solid var(--primary,#14b8a6); outline-offset:0; }
.prompt-block-content { display:block; width:100%; min-height:150px; resize:vertical; }
.prompt-snapshot-details { margin-top:14px; overflow-wrap:anywhere; }
.prompt-snapshot-details summary { cursor:pointer; font-weight:600; }
@media (max-width:520px) {
  .advanced-prompt-dialog .cloud-dialog-header { gap:6px; }
  .advanced-prompt-dialog .cloud-dialog-header > h3 { font-size:16px; }
  .prompt-header-actions > button { padding:6px; font-size:12px; }
  .prompt-block-row { grid-template-columns:24px 20px minmax(55px,1fr) 62px auto; gap:5px; padding:8px 5px; }
  .prompt-block-preview { grid-column:3 / 5; }
  .prompt-block-delete { grid-column:5; grid-row:1 / span 2; }
  .prompt-block-list { max-height:42dvh; }
}

.prompt-save-feedback[hidden] { display:none; }

.gemini-options-note { margin: .4rem 0 0; font-size: .75rem; line-height: 1.5; color: var(--muted); }
.generation-description { margin-top: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.share-option input[type="text"] { min-width: 0; flex: 1; padding: .45rem .65rem; border: 1px solid var(--ui-border); border-radius: 6px; background: var(--ui-bg); color: inherit; }

/* Refresh floats over the list: changing status never changes its geometry. */
.library-toolbar { position:relative; }
.library-sync-notice {
  position:absolute; top:calc(100% + 6px); left:0; right:0; z-index:5;
  box-sizing:border-box; display:flex; align-items:center; gap:12px;
  padding:10px 14px; border-radius:10px; color:var(--ui-text);
  background:var(--ui-surface-solid); box-shadow:0 4px 18px #0002;
  font-size:13px; line-height:1.5; pointer-events:none;
  opacity:1; visibility:visible; transform:translateY(0);
  transition:opacity 160ms ease-out, transform 160ms ease-out, visibility 0s;
}
.library-sync-notice[hidden] {
  display:flex; opacity:0; visibility:hidden; transform:translateY(-4px);
  transition:opacity 160ms ease-out, transform 160ms ease-out, visibility 0s 160ms;
}
.library-sync-notice[hidden] button { pointer-events:none; }
.library-sync-notice > span { flex:1; min-width:0; }
.library-sync-notice[data-state="loading"]::before, .loading-spinner {
  content:""; display:inline-block; width:16px; height:16px; flex:0 0 16px;
  border:2px solid currentColor; border-right-color:transparent; border-radius:50%;
  animation:library-spin 800ms linear infinite;
}
.library-sync-notice button { pointer-events:auto; flex-shrink:0; min-height:44px; }
@keyframes library-spin { to { transform:rotate(360deg); } }
.cloud-thumb img { max-width:100%; }
.image-select {
  position:absolute; top:4px; left:4px; z-index:1; width:44px; height:44px;
  display:grid; place-items:center; cursor:pointer;
  opacity:0; pointer-events:none; transition:opacity 120ms ease-out;
}
@media (any-hover:hover) and (any-pointer:fine) {
  .cloud-thumb-wrap:hover .image-select { opacity:1; pointer-events:auto; }
}
.cloud-thumb-wrap:has(:focus-visible) .image-select,
.cloud-card.is-selecting .image-select { opacity:1; pointer-events:auto; }
.cloud-thumb-wrap:has(.image-select) .cloud-thumb {
  -webkit-touch-callout:none; -webkit-user-select:none; user-select:none;
}
.image-select input {
  appearance:none; width:24px; height:24px; margin:0; border:2px solid var(--ui-border-strong);
  border-radius:6px; background:var(--ui-surface-solid); cursor:pointer; display:grid; place-items:center;
  box-shadow:0 1px 5px #0003;
}
.image-select input:checked { background:var(--accent); border-color:var(--accent); }
.image-select input:checked::after {
  content:""; width:6px; height:11px; border:solid white; border-width:0 2px 2px 0; transform:translateY(-1px) rotate(45deg);
}
.image-select input:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.image-select input:disabled { cursor:progress; opacity:0.6; }
.cloud-card[data-selected="true"] { outline:2px solid var(--accent); outline-offset:-2px; }
.cloud-card.is-selecting .cloud-thumb { cursor:pointer; }
.library-bulk-actions, .library-delete-notice {
  flex:1 0 100%; min-width:0; display:flex; align-items:center; flex-wrap:wrap; gap:8px 12px;
  padding:10px 12px; background:var(--ui-primary-soft); border-radius:10px; font-size:13px; line-height:1.5;
}
.library-bulk-actions[hidden], .library-delete-notice[hidden] { display:none; }
.library-bulk-actions button, .library-delete-notice button { min-height:44px; margin:0; }
.bulk-count { font-weight:600; font-variant-numeric:tabular-nums; }
.bulk-help, .bulk-status { flex-basis:100%; color:var(--ui-muted); overflow-wrap:anywhere; }
.bulk-status:empty { display:none; }
.library-delete-notice > span { flex:1 1 180px; min-width:0; overflow-wrap:anywhere; }
.viewer-stage { position:relative; }
.content-loading { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:12px; padding:16px; color:var(--ui-muted); font-size:14px; line-height:1.6; }
.content-loading[data-state="error"] .loading-spinner { display:none; }
.content-loading[hidden] { display:none; }
.viewer-image-status { position:absolute; inset:auto 20px 20px; border-radius:10px; background:var(--ui-surface-solid); box-shadow:0 3px 14px #0002; }
.viewer-stage .cloud-preview:not([src]) { visibility:hidden; }
.image-controls[aria-busy="true"] { opacity:0.65; }
@media (prefers-reduced-motion:reduce) {
  .library-sync-notice, .library-sync-notice::before, .loading-spinner { transition:none; animation:none; }
}
html[data-ui-motion="off"] .library-sync-notice,
html[data-ui-motion="off"] .library-sync-notice::before,
html[data-ui-motion="off"] .loading-spinner { transition:none; animation:none; }

.resolution-controls {display:flex; flex-wrap:wrap; align-items:end; gap:12px; margin-top:12px}
.resolution-label {flex:1; min-width:160px; font-size:12px; display:grid; gap:6px}
.resolution-custom {display:flex; flex:1; min-width:200px; gap:10px}
.resolution-custom[hidden] {display:none}
.resolution-custom label {flex:1; min-width:0; display:grid; gap:6px; font-size:12px}
.resolution-custom input {width:100%; min-width:0}
.ratio-card:disabled {opacity:.45;cursor:default}
.resolution-error {color:var(--danger, #b91c1c)}
/* Native image options reuse the advanced form grid and remain compact on mobile. */
.native-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; min-width:0; }
.native-options[hidden], .native-field[hidden], .markup-remove[hidden] { display:none; }
.native-field { min-width:0; }
.native-field .input { width:100%; min-width:0; }
.native-hint { margin:4px 0 0; color:var(--ui-muted, #64748b); font-size:12px; line-height:1.5; }
.markup-status { display:flex; gap:8px; align-items:center; font-size:12px; }
.markup-name { overflow-wrap:anywhere; min-width:0; }
@media (max-width:600px) { .native-options { grid-template-columns:minmax(0,1fr); } }
