*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --checkerboard: repeating-conic-gradient(#d1d5db 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.12);
  --success: #34d399;
  --success-light: rgba(52, 211, 153, 0.1);
  --danger: #f87171;
  --danger-light: rgba(248, 113, 113, 0.1);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  --checkerboard: repeating-conic-gradient(#475569 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===================================================================
   Header & Tabs
   =================================================================== */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.tab {
  padding: 6px 20px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.header-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.header-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.header-action-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.header-action-btn svg {
  flex-shrink: 0;
}

.theme-toggle {
  position: relative;
  width: 56px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  outline-offset: 3px;
}

.theme-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #7ec8e3, #54a0d0);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: background 0.5s ease;
  overflow: hidden;
}

[data-theme="dark"] .theme-toggle-track {
  background: linear-gradient(135deg, #1a1a40, #0f0f2d);
}

.theme-toggle-stars {
  position: absolute;
  inset: 0;
}

.theme-toggle-stars > span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.4s ease 0.15s, transform 0.4s ease 0.15s;
}

.theme-toggle-stars > span:nth-child(1) { top: 6px; left: 10px; }
.theme-toggle-stars > span:nth-child(2) { top: 14px; left: 18px; width: 2px; height: 2px; }
.theme-toggle-stars > span:nth-child(3) { top: 8px; left: 24px; width: 2px; height: 2px; }

[data-theme="dark"] .theme-toggle-stars > span {
  opacity: 1;
  transform: scale(1);
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s cubic-bezier(0.68, -0.15, 0.27, 1.15);
  z-index: 1;
}

[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(28px);
}

.theme-icon-sun,
.theme-icon-moon {
  position: absolute;
  transition: opacity 0.3s ease, transform 0.4s ease;
}

.theme-icon-sun {
  color: #e6940a;
  opacity: 1;
  transform: rotate(0deg);
}

.theme-icon-moon {
  color: #7c83ff;
  opacity: 0;
  transform: rotate(-90deg);
}

[data-theme="dark"] .theme-icon-sun {
  opacity: 0;
  transform: rotate(90deg);
}

[data-theme="dark"] .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

/* ===================================================================
   App Layout
   =================================================================== */

.app-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
}

.tab-content { display: none; }
.tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease;
}
.tab-content[hidden] { display: none; }

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

.panel-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  align-items: start;
}

/* ===================================================================
   Cards
   =================================================================== */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ===================================================================
   Forms
   =================================================================== */

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--text-secondary);
}

textarea,
select,
input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease;
  margin-bottom: 20px;
}

textarea:focus,
select:focus,
input[type="number"]:focus,
input[type="text"]:focus {
  outline: 2px solid transparent;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.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;
}

textarea { resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row .form-group { margin-bottom: 0; }

.form-group { margin-bottom: 20px; }
.form-group label { margin-bottom: 6px; }
.form-group select,
.form-group input[type="number"] { margin-bottom: 0; }

.hint {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 4px;
}

/* ===================================================================
   Label Row & Prompt Helpers
   =================================================================== */

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.label-row label { margin-bottom: 0; }

.try-example {
  font-size: 13px;
  text-decoration: none;
  color: var(--primary);
}

.try-example:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

.char-counter {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: -16px;
  margin-bottom: 20px;
  text-align: right;
}

.char-counter.hint-mode {
  text-align: left;
  font-style: italic;
  opacity: 0.7;
}

/* ===================================================================
   Prompt Actions Row
   =================================================================== */

.prompt-actions {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

/* ===================================================================
   Prompt Hint
   =================================================================== */

.prompt-hint {
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: -12px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.show-all-sizes {
  display: inline-block;
  font-size: 12px;
  margin-top: -14px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.show-all-sizes:hover { color: var(--primary); }

.aspect-ratio-extra { margin-top: -14px; }

/* ===================================================================
   Generate Form Sections
   =================================================================== */

.prompt-mode-switcher {
  display: flex;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--bg);
}

.prompt-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.prompt-mode-btn + .prompt-mode-btn {
  border-left: 1.5px solid var(--border);
}

.prompt-mode-btn:hover:not(.active) {
  background: var(--surface);
  color: var(--text);
}

.prompt-mode-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.prompt-mode-btn svg {
  flex-shrink: 0;
}

.prompt-mode-panel {
  padding-bottom: 20px;
}

.prompt-group {
  padding-bottom: 0;
}

.prompt-group .btn-enhance {
  margin-bottom: 16px;
}

.prompt-group .dropzone {
  margin-bottom: 0;
}

.gen-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin: 0 -28px -28px;
  padding: 16px 28px 20px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.gen-action-bar .form-group {
  margin-bottom: 12px;
}

.gen-action-bar .form-group:last-child {
  margin-bottom: 0;
}

.gen-action-bar .btn-primary {
  margin-top: 0;
}

.gen-action-bar .btn-link {
  display: inline-block;
  margin-bottom: 8px;
}


.btn-enhance {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 16px;
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-enhance:hover {
  background: var(--primary);
  color: white;
  border-style: solid;
}

.btn-enhance:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-enhance .spinner-sm {
  border-top-color: currentColor;
  border-color: rgba(37, 99, 235, 0.2);
  border-top-color: var(--primary);
}

.btn-enhance:hover .spinner-sm {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
}

/* ===================================================================
   Thinking Toggle
   =================================================================== */

.thinking-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 0;
}

.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.thinking-toggle-row .optional {
  font-size: 12px;
}

/* ===================================================================
   Pill Groups (Templates, Presets, Models)
   =================================================================== */

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.pill {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.pill:hover {
  border-color: var(--primary);
  color: var(--text);
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===================================================================
   Preset Summary
   =================================================================== */

.preset-summary {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.auto-compress-row {
  margin-bottom: 12px;
}

.auto-compress-row .toggle-label {
  font-size: 13px;
  color: var(--text-secondary);
}

#custom-settings {
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

#custom-settings .form-group:last-child { margin-bottom: 0; }
#custom-settings .form-row { margin-bottom: 0; }

/* ===================================================================
   Dropzone
   =================================================================== */

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  margin-bottom: 20px;
  overflow: hidden;
}

.dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  animation: dropzonePulse 1.2s ease-in-out infinite;
}

@keyframes dropzonePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.15); }
  50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--text-secondary);
}

.dropzone-content svg { opacity: 0.5; }
.dropzone-content p { font-size: 14px; }
.dropzone-content .link { color: var(--primary); font-weight: 500; }

.dropzone-hint {
  font-size: 12px !important;
  opacity: 0.6;
}

/* Multi-reference preview grid */
.dropzone-previews {
  padding: 12px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.preview-grid-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-grid-item .remove-ref {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.preview-grid-item:hover .remove-ref { opacity: 1; }

/* ===================================================================
   Range Slider
   =================================================================== */

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  margin: 8px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-md);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ===================================================================
   Buttons
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
  margin-top: 4px;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--text);
  color: var(--surface);
}

.btn-secondary:hover { opacity: 0.85; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 10px 16px;
  font-size: 13px;
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover { color: var(--danger); }

.result-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===================================================================
   Spinner & Loading
   =================================================================== */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Shimmer loading placeholder */
.shimmer-placeholder {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.shimmer-block {
  width: 100%;
  height: 300px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.shimmer-canvas {
  position: absolute;
  inset: 0;
}

.gen-paint-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.shimmer-orbs-fallback {
  display: none;
}

.shimmer-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  animation: shimmer-drift 6s ease-in-out infinite;
}

.shimmer-orb-1 {
  width: 180px;
  height: 180px;
  background: var(--primary);
  top: 20%;
  left: 15%;
  animation-delay: 0s;
}

.shimmer-orb-2 {
  width: 140px;
  height: 140px;
  background: #a78bfa;
  top: 40%;
  right: 20%;
  animation-delay: -2s;
  animation-duration: 7s;
}

.shimmer-orb-3 {
  width: 160px;
  height: 160px;
  background: #f472b6;
  bottom: 10%;
  left: 40%;
  animation-delay: -4s;
  animation-duration: 8s;
}

[data-theme="dark"] .shimmer-orb { opacity: 0.3; }

.shimmer-status {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.shimmer-status-exit {
  opacity: 0;
  transform: translateY(-4px);
}

.shimmer-text {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

@keyframes shimmer-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.1); }
  66% { transform: translate(-20px, 15px) scale(0.9); }
}

@media (prefers-reduced-motion: reduce) {
  .shimmer-orb { animation: none; }
  .shimmer-status { transition: none; }
  .gen-paint-canvas { display: none; }
  .shimmer-orbs-fallback { display: block; }
}

/* ===================================================================
   Preview Panel
   =================================================================== */

.preview-card {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

/* ===================================================================
   Template Chooser (Cards-First Landing)
   =================================================================== */

.template-chooser {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 32px;
  text-align: center;
}

.template-chooser-heading {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.template-chooser-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 420px;
}

.template-chooser .quick-start-grid {
  margin-bottom: 0;
}

.template-chooser-more {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 600px;
  margin-top: 12px;
}

.template-chooser-toggle {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.template-chooser-toggle:hover {
  color: var(--primary);
}

.template-chooser-hint {
  margin-top: 24px;
  text-align: center;
}

.quick-start-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 600px;
}

.quick-start-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  font-family: inherit;
  color: var(--text);
}

.quick-start-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quick-start-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
}

.quick-start-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.quick-start-hint {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Template Indicator (in form header) */

.template-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 8px 14px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
}

.template-indicator-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.template-indicator-change {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

.template-indicator-change:hover {
  color: var(--primary);
}

@media (max-width: 880px) {
  .quick-start-grid { grid-template-columns: repeat(2, 1fr); }
  .template-chooser-more { grid-template-columns: repeat(2, 1fr); }
  .template-chooser { padding: 24px 16px; }
  .template-chooser-heading { font-size: 20px; }
}

@media (max-width: 480px) {
  .quick-start-grid { grid-template-columns: 1fr 1fr; }
  .template-chooser-more { grid-template-columns: 1fr 1fr; }
}

.placeholder-tips {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.placeholder-tips .hint { margin-top: 0; }

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border);
}

.preview-result {
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.preview-result img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

.gen-result-img-wrapper {
  position: relative;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: zoom-in;
}

.img-expand-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  opacity: 0;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease, background 0.15s ease;
}

.gen-result-img-wrapper:hover .img-expand-btn {
  opacity: 1;
}

.img-expand-btn:hover {
  background: rgba(0, 0, 0, 0.75);
}

.result-lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 95vw;
  max-height: 95vh;
}

.result-lightbox-content img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  display: block;
}

.gen-result-img-wrapper.refining img {
  opacity: 0.45;
  transition: opacity 0.3s ease;
}

.gen-result-img-wrapper.refining .img-expand-btn {
  display: none;
}

.refine-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-overlay, rgba(0, 0, 0, 0.25));
  backdrop-filter: blur(2px);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.refine-overlay .spinner {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.result-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.result-text {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
}

/* Preview Grid */

.preview-grid-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.preview-grid-thumbnails {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.preview-thumbnail {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  aspect-ratio: 1;
}

.preview-thumbnail:hover {
  border-color: var(--text-secondary);
}

.preview-thumbnail.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

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

.preview-thumbnail-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.preview-thumbnail:hover .preview-thumbnail-actions {
  opacity: 1;
}

.preview-thumbnail-actions .icon-btn {
  width: 2rem;
  height: 2rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: var(--radius);
  backdrop-filter: blur(4px);
}

.preview-thumbnail.editing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.preview-thumbnail.editing::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  z-index: 3;
}

.preview-edit-bar {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.preview-edit-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.preview-edit-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  transition: border-color 0.15s ease;
}

.preview-edit-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.preview-edit-row input:disabled {
  opacity: 0.5;
}

.preview-edit-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.preview-edit-send:hover:not(:disabled) {
  background: var(--primary-hover);
}

.preview-edit-send:disabled {
  opacity: 0.4;
  cursor: default;
}

.back-to-previews {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.return-to-upscaled {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.return-to-upscaled:hover {
  background: var(--primary);
  color: #fff;
}

.history-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  width: fit-content;
}

.history-badge svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.history-badge-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  color: var(--text-secondary);
  opacity: 0.6;
  transition: opacity 0.15s ease;
  margin-left: 4px;
}

.history-badge-dismiss:hover {
  opacity: 1;
}

.history-item.has-image .history-info {
  color: var(--primary);
}

/* ===================================================================
   Chat Panel (Refine Conversation)
   =================================================================== */

.chat-panel {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 680px;
  margin-top: 4px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-icon {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.chat-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.chat-msg-count {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  line-height: 1.4;
}

.chat-msg-count:empty { display: none; }

.chat-clear-btn {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
  scrollbar-width: thin;
  scroll-behavior: smooth;
  min-height: 0;
  max-height: 480px;
}

/* Chat message */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: chatMsgIn 0.25s ease-out;
}

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

.chat-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-assistant {
  align-self: flex-start;
}

/* Avatars */
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-avatar-ai {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white;
}

.chat-avatar-user {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Message content bubble */
.chat-msg-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.chat-msg-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg-user .chat-msg-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Inline image in chat */
.chat-msg-image {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.2s;
  max-width: 280px;
}

.chat-msg-image:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.chat-msg-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* Reference images attached to user message */
.chat-msg-refs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chat-msg-ref-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Version badge on assistant image messages */
.chat-msg-version {
  font-size: 10px;
  color: var(--text-secondary);
  padding-top: 2px;
}

/* Hint shown after initial generation messages */
.chat-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0 4px;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.chat-hint svg {
  flex-shrink: 0;
  opacity: 0.6;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  opacity: 0.4;
  animation: typingDot 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.4; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* Chat input area */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 4px 4px 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 99, 102, 241), 0.1);
}

.chat-input-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-input-wrapper {
  flex: 1;
  min-width: 0;
}

.chat-input-wrapper textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  resize: none;
  padding: 6px 4px;
  margin: 0;
  max-height: 160px;
  overflow-y: auto;
  outline: none;
}

.chat-input-wrapper textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.65;
}

.chat-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  flex-shrink: 0;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  font-family: inherit;
}

.chat-attach-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.chat-attach-label {
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

@media (max-width: 480px) {
  .chat-attach-label { display: none; }
  .chat-attach-btn { padding: 0; width: 32px; }
}

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
}

.chat-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  background: var(--border);
  color: var(--text-secondary);
  cursor: default;
  opacity: 0.5;
}

/* Chat reference image strip (inline inside input row) */
.chat-ref-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 4px;
}

.chat-ref-grid {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.chat-ref-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.chat-ref-thumb:hover {
  border-color: var(--primary);
}

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

.chat-ref-remove {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
}

.chat-ref-thumb:hover .chat-ref-remove {
  opacity: 1;
}

.chat-ref-clear {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.chat-ref-clear:hover {
  color: var(--danger, #ef4444);
  background: rgba(239, 68, 68, 0.1);
}

.chat-panel.dragover .chat-input-row {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 99, 102, 241), 0.15);
}

/* ===================================================================
   Prompt Assist Panel (modernized to match chat aesthetic)
   =================================================================== */

.prompt-assist-panel {
  margin-top: 0;
  margin-bottom: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.assist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.assist-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.assist-header-icon {
  color: var(--primary);
}

.assist-header h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

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

.assist-close-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.assist-close-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.assist-messages {
  max-height: 480px;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  scroll-behavior: smooth;
}

.assist-messages::-webkit-scrollbar { width: 6px; }
.assist-messages::-webkit-scrollbar-track { background: transparent; }
.assist-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.assist-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.assist-typing {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 14px 8px;
}

.assist-final-prompt {
  align-self: stretch;
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  border-radius: 12px;
  padding: 12px;
  margin-top: 4px;
}

.assist-final-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin-bottom: 6px;
}

.assist-final-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 10px;
}

.assist-use-prompt {
  width: auto !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
  margin-top: 0 !important;
  border-radius: 20px !important;
}

.assist-input-area {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px;
}

.assist-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 4px 4px 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.assist-input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 99, 102, 241), 0.1);
}

.assist-input-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.assist-input-row textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  resize: none;
  padding: 8px 6px;
  margin: 0;
  min-height: 40px;
  max-height: 200px;
  overflow-y: auto;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.assist-input-row textarea::-webkit-scrollbar { width: 5px; }
.assist-input-row textarea::-webkit-scrollbar-track { background: transparent; }
.assist-input-row textarea::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.assist-input-row textarea::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.assist-input-row textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.65;
}

.assist-input-row .assist-send-btn {
  margin-top: 0 !important;
}

/* Assist reference image strip (inline inside input row) */
.assist-ref-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 4px;
}

.assist-ref-grid {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.assist-ref-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.assist-ref-thumb:hover {
  border-color: var(--primary);
}

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

.assist-ref-thumb .chat-ref-remove {
  opacity: 0;
}

.assist-ref-thumb:hover .chat-ref-remove {
  opacity: 1;
}

#assist-reset {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===================================================================
   Error States
   =================================================================== */

.preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 40px 24px;
  color: var(--text-secondary);
}

.preview-error svg { color: var(--danger); opacity: 0.6; }

.preview-error .error-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.preview-error .error-message {
  font-size: 14px;
  max-width: 360px;
  line-height: 1.5;
}

.preview-error .btn { width: auto; margin-top: 4px; }

/* ===================================================================
   File Queue
   =================================================================== */

.file-queue { margin-bottom: 20px; }

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.queue-header span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.15s ease;
}

.queue-item.compressing,
.queue-item.processing { background: var(--primary-light); }
.queue-item.done { background: var(--success-light); }
.queue-item.error { background: var(--danger-light); }

.queue-item-status {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.status-dot.queued { background: var(--text-secondary); opacity: 0.4; }
.status-icon.done { color: var(--success); }
.status-icon.error { color: var(--danger); }

.queue-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  align-items: center;
}

.queue-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.queue-item-size {
  color: var(--text-secondary);
  font-size: 12px;
  flex-shrink: 0;
}

.queue-item-error {
  color: var(--danger);
  font-size: 11px;
  margin-left: 6px;
}

.queue-item-remove {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.queue-item-retry {
  padding: 2px 10px;
  border-radius: 4px;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.queue-item-retry:hover {
  background: var(--primary);
  color: white;
}

.queue-item-remove:hover { background: rgba(0, 0, 0, 0.08); color: var(--danger); }
.queue-item-remove:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===================================================================
   Batch Results
   =================================================================== */

.batch-results {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.batch-progress { margin-bottom: 16px; }

.batch-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.batch-progress-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.batch-progress-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.batch-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.batch-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.batch-progress-fill.complete { background: var(--success); }

.aggregate-stats-simple {
  text-align: center;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.aggregate-headline {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.aggregate-saved-pct {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.aggregate-saved-pct.positive { color: var(--success); }
.aggregate-saved-pct.negative { color: var(--danger); }

.aggregate-saved-text {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

.aggregate-detail {
  font-size: 13px;
  color: var(--text-secondary);
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.result-item:hover {
  background: var(--primary-light);
}

.result-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.result-item-name {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-item-sizes {
  font-size: 12px;
  color: var(--text-secondary);
}

.result-item-saved {
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.result-item-saved.positive { color: var(--success); }
.result-item-saved.negative { color: var(--danger); }

.result-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.result-item-download {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
}

.result-item-copy {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.result-item-copy:hover,
.result-item-download:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ===================================================================
   Remove BG Results
   =================================================================== */

.rembg-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.rembg-result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.rembg-result-preview {
  position: relative;
  aspect-ratio: 1;
  background: var(--checkerboard);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rembg-result-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.rembg-result-footer {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.rembg-result-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rembg-result-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.rembg-result-copy,
.rembg-result-download {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  flex-shrink: 0;
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
}

.rembg-result-copy:hover,
.rembg-result-download:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ===================================================================
   Comparison Modal
   =================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.modal-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

/* ===================================================================
   Preview Lightbox
   =================================================================== */

.preview-lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 90vh;
}

.preview-lightbox-content img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  display: block;
}

.preview-lightbox-close {
  position: absolute;
  top: -48px;
  right: 0;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  font-size: 22px;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.preview-lightbox-close:hover {
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-color: transparent;
}

.preview-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease;
}

.preview-lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.75);
}

.preview-lightbox-nav.prev { left: -60px; }
.preview-lightbox-nav.next { right: -60px; }

.preview-lightbox-counter {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

@media (max-width: 880px) {
  .preview-lightbox-nav.prev { left: 8px; }
  .preview-lightbox-nav.next { right: 8px; }
  .preview-lightbox-close { top: 8px; right: 8px; }
  .preview-lightbox-counter { bottom: 12px; }
}

/* ===================================================================
   Shortcuts Modal
   =================================================================== */

.shortcuts-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  width: 420px;
  max-width: 90vw;
}

.shortcuts-body { padding: 20px 24px 24px; }

.shortcut-group { margin-bottom: 20px; }
.shortcut-group:last-child { margin-bottom: 0; }

.shortcut-group h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.shortcut-desc { color: var(--text); }

.shortcut-hint {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

/* ===================================================================
   History Panel
   =================================================================== */

.history-panel {
  width: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transition: width 0.25s ease;
  flex-shrink: 0;
}

.history-panel.open {
  width: 320px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.history-header h3 {
  font-size: 16px;
  font-weight: 600;
}

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

.history-close {
  width: 32px;
  height: 32px;
  font-size: 20px;
}

.history-list {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  scrollbar-width: thin;
}

.history-empty {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  padding: 40px 16px;
}

.history-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  margin-bottom: 8px;
}

.history-item:hover {
  background: var(--bg);
}

.history-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.history-thumb.checkerboard {
  background: var(--checkerboard);
}

.history-meta {
  flex: 1;
  min-width: 0;
}

.history-prompt {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-info {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.history-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
}

.history-type.generate { background: var(--primary-light); color: var(--primary); }
.history-type.compress { background: var(--success-light); color: var(--success); }
.history-type.rembg { background: #fef3c7; color: #d97706; }

[data-theme="dark"] .history-type.rembg { background: rgba(217, 119, 6, 0.15); }

/* ===================================================================
   Drop Overlay
   =================================================================== */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(37, 99, 235, 0.1);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--primary);
  font-size: 20px;
  font-weight: 600;
}

.drop-overlay-content svg {
  opacity: 0.6;
}

.drop-overlay-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.drop-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  pointer-events: auto;
}

.drop-action-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.02);
}

.drop-action-btn svg { opacity: 1; }

/* ===================================================================
   Toast Notifications
   =================================================================== */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  color: white;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  max-width: 420px;
  min-width: 280px;
  animation: slideUp 0.3s ease;
  overflow: hidden;
  pointer-events: none;
}

.toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  pointer-events: auto;
}

.toast-icon { flex-shrink: 0; display: flex; }

.toast-message { flex: 1; line-height: 1.4; }

.toast-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}

.toast-close:hover { color: white; }

.toast-timer {
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  animation: toastCountdown 5s linear forwards;
}

.toast-error { background: #dc2626; }
.toast-success { background: #059669; }

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes toastCountdown {
  from { width: 100%; }
  to { width: 0%; }
}

/* ===================================================================
   Focus & Reduced Motion
   =================================================================== */

.btn:focus-visible,
.pill:focus-visible,
.icon-btn:focus-visible,
.header-action-btn:focus-visible,
.theme-toggle:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===================================================================
   Responsive
   =================================================================== */

@media (max-width: 1100px) {
  .history-panel.open { width: 280px; }
}

@media (max-width: 880px) {
  .panel-layout { grid-template-columns: 1fr; }

  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  header h1 { font-size: 18px; }

  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; text-align: center; padding: 6px 12px; font-size: 13px; }

  .header-actions { order: 2; }

  .header-action-btn span { display: none; }
  .header-action-btn { padding: 0 10px; }

  main { padding: 16px; }

  .aggregate-stats { grid-template-columns: repeat(2, 1fr); }

  .history-panel.open {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }

  .result-buttons { flex-direction: column; }
  .result-buttons .btn { width: 100%; }

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

  .gen-action-bar {
    position: sticky;
    bottom: 0;
    margin: 0 -28px -28px;
    padding: 14px 28px 16px;
  }

  .feedback-popover {
    left: 12px;
    right: 12px;
    width: auto;
  }
}

/* ===================================================================
   Feedback Widget
   =================================================================== */

.feedback-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 400;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feedback-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.feedback-fab:active { transform: scale(0.96); }

.feedback-fab.open { background: var(--text-secondary); box-shadow: var(--shadow-md); }

.feedback-popover {
  position: fixed;
  bottom: 84px;
  left: 24px;
  z-index: 400;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.feedback-popover.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
}

.feedback-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.feedback-close {
  width: 32px;
  height: 32px;
  font-size: 20px;
}

.feedback-body {
  padding: 0 20px 20px;
}

.feedback-body .pill-group { margin-bottom: 12px; }

.feedback-body textarea {
  margin-bottom: 12px;
  resize: vertical;
  min-height: 80px;
}

.feedback-note {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
  opacity: 0.7;
}

.feedback-success-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 24px;
  text-align: center;
  color: var(--success);
}

.feedback-success-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.feedback-success-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.feedback-success-view .btn-link {
  margin-top: 8px;
  color: var(--primary);
}

/* ===================================================================
   Site Audit Tab
   =================================================================== */

.audit-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.mode-btn {
  flex: 1;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.mode-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.mode-btn:hover {
  background: var(--surface-hover);
}

.mode-btn.active {
  background: var(--primary);
  color: #fff;
}

.audit-steps {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.audit-step {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.audit-step.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.audit-step.completed {
  color: var(--success);
  background: var(--success-light);
}

.audit-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.audit-stats .stat {
  flex: 1;
}

.audit-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px 16px;
  font-size: 14px;
}

.audit-error {
  text-align: center;
  color: var(--danger);
  padding: 24px 16px;
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* Select bar */

#audit-select-bar {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.audit-select-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audit-select-all-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.audit-selected-count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Image list */

.audit-image-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.audit-image-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.audit-image-row:last-child {
  border-bottom: none;
}

.audit-image-check {
  flex-shrink: 0;
  cursor: pointer;
}

.audit-image-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.audit-image-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}

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

.audit-image-info {
  flex: 1;
  min-width: 0;
}

.audit-image-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audit-image-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.audit-image-pages {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  cursor: help;
}

.audit-image-alt {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-style: italic;
}

.audit-missing-alt {
  color: var(--danger);
  font-style: normal;
  font-weight: 500;
}

/* Compress results */

.audit-compress-summary {
  margin-bottom: 16px;
}

.audit-compressed-list {
  max-height: 350px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.audit-compress-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

.audit-compress-item:last-child {
  border-bottom: none;
}

.audit-compress-item.error {
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.audit-compress-thumb {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
}

.audit-compress-info {
  flex: 1;
  min-width: 0;
}

.audit-compress-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.audit-compress-sizes {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.audit-compress-saved {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
}

.audit-compress-saved.positive {
  color: var(--success);
}

.audit-compress-saved.negative {
  color: var(--danger);
}

.audit-compress-error {
  font-size: 12px;
  color: var(--danger);
}

/* Replace results */

.audit-replace-done {
  text-align: center;
  padding: 32px 16px;
}

.audit-replace-done svg {
  color: var(--success);
  margin-bottom: 12px;
}

.audit-replace-done h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.audit-replace-failures {
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 12px;
}

.audit-regen-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.audit-regen-status.success {
  color: var(--success);
}

.audit-regen-status.warning {
  color: var(--danger);
}

.audit-regen-status code {
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Replace section */

#audit-replace-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}

/* Server modal */

.server-modal-content {
  max-width: 560px;
}

.server-list {
  margin-bottom: 20px;
}

.server-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.server-item:last-child {
  border-bottom: none;
}

.server-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.server-item-info strong {
  font-size: 14px;
  color: var(--text);
}

.server-item-host {
  font-size: 12px;
  color: var(--text-secondary);
}

.server-add-form {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.server-add-form h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.btn-link.danger {
  color: var(--danger);
}

.btn-link.danger:hover {
  color: var(--danger);
  text-decoration: underline;
}
