/* Custom styles for imgen - separated from HTML for better maintainability */

:root {
  --accent: #b3123e;
  --accent-hover: #d41a52;
  --accent-active: #8a0e2f;
  --accent-text: #c41e4a;
  --accent-subtle: #b3123e;
  --adv-control-bg: rgba(255, 255, 255, 0.05);
}

.bg-zinc-950 {
  background-color: rgba(66, 66, 66, 0.66) !important;
}

.bg-zinc-900 {
  background: rgba(0, 0, 0, 0.40) !important;
}

body {
  background: #111113;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 18% 22%, rgba(196, 30, 74, 0.11), transparent 50%),
    radial-gradient(ellipse at 82% 18%, rgba(113, 113, 122, 0.16), transparent 50%),
    radial-gradient(ellipse at 72% 78%, rgba(196, 30, 74, 0.075), transparent 50%),
    radial-gradient(ellipse at 26% 82%, rgba(82, 82, 91, 0.15), transparent 50%),
    linear-gradient(180deg, rgba(63, 63, 70, 0.3), rgba(0, 0, 0, 0.3));
  background-size: 120% 120%, 115% 115%, 125% 125%, 110% 110%, 100% 100%;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("../assets/bg-waves.svg?v=20260605waveslow2");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    background-image: none;
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 80rem;
  margin-left: auto;
  margin-right: auto;
  padding-top: 3rem;
  overflow-x: clip;
}

.app-topbar {
  position: fixed !important;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 80rem);
  box-sizing: border-box;
  z-index: 200;
  background: #000;
  box-shadow: 0 1px 0 rgba(39, 39, 42, 0.95);
}

body.advanced-active #advanced-view,
body.advanced-active #gallery-section {
  box-sizing: border-box;
  width: 100%;
  max-width: 80rem;
  margin-left: auto;
  margin-right: auto;
}

body.advanced-active #gallery-section {
  padding-left: 1rem;
  padding-right: 1rem;
  position: relative;
  isolation: isolate;
}

body.advanced-active #civitai-daily-section {
  display: none !important;
}

@media (min-width: 768px) {
  body.advanced-active #gallery-section {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  touch-action: pan-y;
}

@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

#advanced-view,
#civitai-daily-section,
#civitai-daily-grid,
#gallery-section,
#gallery {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#civitai-daily-grid {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#civitai-daily-grid::-webkit-scrollbar {
  display: none;
}
#civitai-daily-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.civitai-card {
  cursor: zoom-in;
  border-radius: 0.5rem;
  overflow: hidden;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.35);
}


#civitai-daily-grid.civitai-expanded {
  max-height: 520px;
  overflow-y: auto;
  overflow-anchor: auto;
}

.civitai-prompt-box {
  max-height: 52vh;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid rgba(63, 63, 70, 0.8);
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.35);
}

@media (max-width: 1023px) {
  .civitai-prompt-box {
    max-height: 24vh;
  }
}

#advanced-view {
  position: relative;
  isolation: isolate;
}

#advanced-view::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: rgba(0, 0, 0, 0);
}

#advanced-view .section,
#advanced-control-groups > .node-card {
  background: rgba(0, 0, 0, 0.40) !important;
  opacity: 1;
  filter: none;
  mix-blend-mode: normal;
}

#advanced-view input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
#advanced-view select,
#advanced-view textarea {
  background-color: var(--adv-control-bg) !important;
  opacity: 1;
  filter: none;
  mix-blend-mode: normal;
}

#simple-view input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
#simple-view select,
#simple-view textarea {
  background-color: var(--adv-control-bg) !important;
  opacity: 1;
  filter: none;
  mix-blend-mode: normal;
}

@media (min-width: 768px) {
  body:not(.advanced-active) #simple-view {
    display: block !important;
    column-count: 2;
    column-gap: 1.25rem;
  }

  body:not(.advanced-active) #simple-view > .simple-card-stack {
    display: contents;
  }

  body:not(.advanced-active) #simple-view .sim-masonry-item {
    display: block;
    break-inside: avoid;
    min-height: 56px;
    margin-bottom: 1.25rem;
  }

  body:not(.advanced-active) #simple-view #simple-ai-assist-slot {
    display: flex;
    flex-direction: column;
  }

  body:not(.advanced-active) #simple-view #simple-ai-assist-slot #ai-assist-card {
    flex: 1;
    min-height: 56px;
  }

  body:not(.advanced-active) #simple-view .sim-masonry-item:empty {
    display: none;
  }

  body:not(.advanced-active) #simple-view .sim-masonry-full {
    column-span: all;
    break-inside: avoid;
  }
}

.gallery-toolbar {
  min-width: 0;
  max-width: 100%;
  flex-wrap: nowrap;
}

.gallery-actions {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  justify-content: flex-end;
}

.gallery-show-control {
  flex: 0 0 auto;
  text-align: left;
  white-space: nowrap;
}

body.advanced-active #gallery-section .gallery-toolbar,
body.advanced-active #gallery-section .gallery-toolbar * {
  opacity: 1;
  filter: none;
  mix-blend-mode: normal;
}

body.advanced-active #gallery-section .gallery-toolbar button,
body.advanced-active #gallery-section .gallery-toolbar a {
  color: #d4d4d8 !important;
}

body.advanced-active #gallery-more-control {
  background: rgba(39, 39, 42, 0.96) !important;
}

body.advanced-active #compare-btn {
  background: rgba(179, 18, 62, 1);
) !important;
  color: #f4c2ce !important;
}

body.advanced-active #download-all-btn,
body.advanced-active #gallery-section .gallery-actions button:not(#compare-btn) {
  background: rgba(0, 0, 0, 0.40) !important;
  border-radius: 0.375rem;
}

.download-spinner {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid rgba(196, 30, 74, 0.35);
  border-top-color: #c41e4a;
  border-radius: 9999px;
  animation: imgen-spin 0.75s linear infinite;
  vertical-align: -0.1em;
  margin-right: 0.35rem;
}

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

@media (max-width: 767px) {
  .gallery-toolbar {
    align-items: center;
  }

  .gallery-actions {
    gap: 0.375rem;
  }

  #gallery-section button {
    white-space: nowrap;
  }

  .gallery-actions button,
  .gallery-show-control {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  body.advanced-active #advanced-view > div,
  body.advanced-active #advanced-top-grid,
  body.advanced-active #advanced-control-groups {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.advanced-active #advanced-view .sticky {
    flex-wrap: wrap;
    overflow-x: hidden;
  }

  body.advanced-active #advanced-view .sticky > .flex-1 {
    flex-basis: 100%;
    min-width: 0;
  }

  #advanced-node-search {
    max-width: 100% !important;
  }

  .adv-workflow-row {
    min-width: 0;
    max-width: 100%;
  }

  .adv-workflow-action {
    min-width: 0;
  }
}

#login-btn {
  background: linear-gradient(135deg, #ffffff 0%, #e5e5e5 100%);
  color: black;
  transition: all 0.2s ease;
}

#login-btn:hover {
  background: linear-gradient(135deg, #e5e5e5 0%, #cccccc 100%);
}

.topbar-actions {
  column-gap: 0.5rem !important;
}

.topbar-actions > .flex.items-center.gap-0 {
  gap: 0 !important;
}

.topbar-actions a[href="https://derekxu.me"],
#debug-toggle-btn {
  width: 1.25rem !important;
  min-width: 1.25rem;
  height: 1.25rem !important;
  padding: 0 !important;
  line-height: 1;
}

.topbar-actions a[href="https://derekxu.me"] i,
#debug-toggle-btn i {
  font-size: 0.86rem;
  line-height: 1;
}

.debug-cat-icon {
  width: 0.98rem;
  height: 0.98rem;
  display: block;
  object-fit: contain;
  filter: grayscale(1) brightness(1.2);
  opacity: 0.82;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

#debug-toggle-btn:hover .debug-cat-icon {
  filter: none;
  opacity: 1;
}

.adv-mode-switch {
  margin-left: 0.3125rem;
}

#logout-btn {
  min-height: 1.25rem;
  height: 1.25rem;
  padding: 0 0.45rem !important;
  border-radius: 9999px !important;
  font-size: 9px !important;
  line-height: 1;
}

#logout-btn i {
  font-size: 10px;
}

.ref-status-pill {
  min-height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0 0.45rem;
  border: 1px solid #3f3f46;
  border-radius: 9999px;
  background: #09090b;
  color: #71717a;
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ref-status-dot {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 9999px;
  background: #52525b;
  box-shadow: 0 0 0 2px rgba(82, 82, 91, 0.18);
}

.ref-status-active {
  border-color: rgba(179, 18, 62, 0.72);
  background: rgba(74, 15, 33, 0.55);
  color: #f4c2ce;
}

.ref-status-active .ref-status-dot {
  background: #c41e4a;
  box-shadow: 0 0 0 2px rgba(196, 30, 74, 0.22), 0 0 8px rgba(196, 30, 74, 0.55);
}

.health-status-btn {
  border: 1px solid transparent;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.health-status-unknown {
  background: #27272a;
  color: #a1a1aa;
}

.health-status-ok {
  background: rgba(20, 83, 45, 0.72);
  border-color: rgba(34, 197, 94, 0.55);
  color: #bbf7d0;
}

.health-status-bad {
  background: rgba(127, 29, 29, 0.78);
  border-color: rgba(239, 68, 68, 0.65);
  color: #fecaca;
}

.health-status-btn:hover {
  filter: brightness(1.12);
}

@media (max-width: 380px) {
  .app-topbar {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .topbar-actions {
    column-gap: 0.375rem;
  }

  #logout-btn {
    padding-left: 0.375rem;
    padding-right: 0.375rem;
  }
}

/* Gradient accents using the brand color */
.gradient-accent {
  background: linear-gradient(135deg, #b3123e 0%, #8a0e2f 100%);
  color: white;
  transition: all 0.2s ease;
}

.gradient-accent:hover {
  background: linear-gradient(135deg, #d41a52 0%, #b3123e 100%);
}

.gradient-accent:active {
  background: linear-gradient(135deg, #8a0e2f 0%, #6b0c24 100%);
  transform: scale(0.985);
}

.generate-cancel-mode {
  background: linear-gradient(135deg, #7f1d1d 0%, #450a0a 100%) !important;
  color: #fecdd3 !important;
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.28);
}

.generate-cancel-mode:hover {
  background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%) !important;
  color: #ffffff !important;
}

/* Softer gradient for small buttons / overlays */
.gradient-accent-soft {
  background: linear-gradient(135deg, #b3123e 0%, #8a0e2f 100%);
  color: white;
  transition: all 0.2s ease;
}

/* === Advanced Mode: sim and adv are two completely separate systems ===
   Only one is visible at a time. 
   We fully hide the entire #simple-view container in adv mode so its padding 
   and grid structure do not add unwanted top space. 
   The gallery is moved out by JS *before* layout settles. */

body.advanced-active #simple-view {
  display: none !important;
}

/* (The gallery is moved out of #simple-view by JS, so it stays visible below adv content) */
body.advanced-active #simple-view #gallery {
  display: block !important;
  /* no margin-top per request (only bottom + left/right on the gallery container) */
}

/* The advanced-view itself becomes the main content area */
body.advanced-active #advanced-view {
  order: 1;
}

/* Generate slot spacing handled in HTML (mb-4) + injected label for clear separation from live preview below */

/* No extra bottom margin on the advanced cards container */
body.advanced-active #advanced-control-groups {
  margin-bottom: 0;
}

/* Gallery container box (the .md:col-span-12 wrapper holding header strip + #gallery grid)
   now gets mx + mb via Tailwind for left/right + bottom margins (responsive 16-24px).
   No top margin so the gallery header sits tight under preceding content (in adv or simple). */

/* Hide the secondary mini progress when the real live panel is at the top in Advanced */
body.advanced-active #adv-progress {
  display: none !important;
}

#adv-debug-wrapper:has(#adv-debug-card.hidden) {
  height: 0;
  padding-top: 0 !important;
  overflow: hidden;
}

#advanced-top-grid {
  padding: 1rem !important;
}

@media (min-width: 768px) {
  #advanced-top-grid {
    padding: 1rem 1.25rem 1.25rem !important;
  }
}

.adv-workflow-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  min-width: 0;
}

.adv-workflow-select {
  width: 100% !important;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.75rem;
  line-height: 1rem;
}

.adv-workflow-actions-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  justify-self: stretch;
}

.adv-workflow-action {
  width: 100%;
  min-width: 0;
}

#advanced-save-status {
  grid-column: 1 / -1;
  justify-self: end;
}

.adv-node-tools-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  min-width: 0;
}

.adv-node-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.adv-node-action {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.adv-node-search-wrap {
  min-width: 0;
}

.adv-node-count {
  justify-self: end;
}

@media (min-width: 768px) {
  .adv-workflow-row {
    grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem);
    align-items: center;
  }

  .adv-workflow-actions-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-self: end;
  }

  .adv-node-tools-row {
    grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr) auto;
    align-items: center;
  }

  .adv-node-count {
    min-width: 4rem;
    text-align: right;
  }
}

/* Make Advanced raw node cards more compact */
#advanced-control-groups .bg-zinc-900 {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0;
  font-size: 12px;
}

#advanced-control-groups .bg-zinc-900 input,
#advanced-control-groups .bg-zinc-900 select,
#advanced-control-groups .bg-zinc-900 textarea {
  padding: 3px 6px;
  font-size: 10.5px;
}

/* Nice slider inside advanced cards - with visible grip/thumb */
#advanced-control-groups input[type="range"] {
  accent-color: #b3123e;
  height: 5px;
  margin-top: 7px;
  margin-bottom: 7px;
  background: #27272a;
  border-radius: 9999px;
  cursor: pointer;
}

#advanced-control-groups input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #b3123e;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  border: 2px solid #18181b;
  margin-top: -3.5px; /* centers the smaller thumb on the track */
}

#advanced-control-groups input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #b3123e;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  border: 2px solid #18181b;
}

/* Node connector visual (for array links) */
.adv-connector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #18181b;
  border: 1px solid #3f3f46;
  border-radius: 9999px;
  padding: 1px 8px 1px 4px;
  font-family: ui-monospace, monospace;
  font-size: 10px;
}
.adv-connector::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #b3123e;
  box-shadow: 0 0 0 2px rgba(179,18,62,0.3);
}

/* Gallery "view more" */
#gallery-view-more {
  font-size: 11px;
  padding: 2px 10px;
}

/* Responsive Masonry for Advanced node cards using CSS Grid + JS span */
/* Full page scroll - no artificial inner scroll container */
#advanced-control-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  grid-auto-rows: 2px;
  gap: 8px;
  align-items: start;
  padding: 0;
  position: relative;
  z-index: 1;
  isolation: isolate;
}

/* Force 1 column on phones / narrow viewports so cards never overflow horizontally */
@media (max-width: 560px) {
  #advanced-control-groups {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* Extra safety at very small screens */
@media (max-width: 380px) {
  #advanced-control-groups {
    gap: 4px;
  }
}

/* Individual cards - height will be controlled by grid-row-end via JS */
#advanced-control-groups > div {
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  font-size: 11px;
  line-height: 1.15;
  margin: 0; /* Important: let grid gap handle all spacing for unified gaps */
  min-width: 0;
  overflow-x: hidden; /* Contain any internal content so narrow tracks never get pushed wider */
}

#advanced-control-groups > div:hover {
  border-color: #52525b;
}

/* Very tight header */
#advanced-control-groups > div > div:first-child {
  border-bottom: 1px solid #565656;
  margin-bottom: 0;
  min-height: 18px;
}

/* Compact inputs */
#advanced-control-groups input[type="text"],
#advanced-control-groups input[type="number"],
#advanced-control-groups select,
#advanced-control-groups textarea {
  font-size: 10.5px;
  padding-top: 2px;
  padding-bottom: 2px;
  line-height: 1.2;
  max-width: 100%;
}

/* Advanced node card rows: fixed label column + uniform full-width field edge */
#advanced-control-groups .adv-param-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  column-gap: 6px;
  align-items: start;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

#advanced-control-groups .adv-param-label {
  min-width: 0;
  padding-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #a1a1aa;
  font-size: 13px;
  line-height: 1.2;
}

#advanced-control-groups .adv-control-slot {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#advanced-control-groups .adv-field {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

#advanced-control-groups .adv-param-row > .adv-field,
#advanced-control-groups .adv-param-row > select.adv-field,
#advanced-control-groups .adv-param-row > textarea.adv-field,
#advanced-control-groups .adv-param-row > input.adv-field {
  width: 100%;
}

#advanced-control-groups .adv-control-slot.flex .adv-field {
  width: auto;
}

#advanced-control-groups .adv-connection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 6px;
  align-items: center;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

#advanced-control-groups .adv-connection-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #a1a1aa;
  font-size: 13px;
}

#advanced-control-groups .adv-connection-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 2px;
  min-width: 0;
}

#advanced-control-groups .adv-connection-controls input {
  flex: 0 0 auto;
  box-sizing: border-box;
}

/* Hide ugly up/down arrows on number fields (they poke out on tight inputs).
   Slider + direct typing is the intended UX; arrows just cause visual overflow. */
#advanced-control-groups input[type="number"] {
  -moz-appearance: textfield;
}
#advanced-control-groups input[type="number"]::-webkit-inner-spin-button,
#advanced-control-groups input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  display: none !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

/* Prevent very long model names from breaking card width */
#advanced-control-groups select {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#advanced-control-groups textarea {
  min-height: 68px !important;
  line-height: 1.2;
}

/* Explicit control for collapsible bodies */
.node-card-body {
  display: block;
}

#advanced-control-groups .node-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.node-card-body.hidden {
  display: none !important;
}

/* Hardened card to prevent internal flex/number fields from causing overflow at intermediate widths */
.node-card {
  background: rgba(0, 0, 0, 0.40) !important;
  min-width: 0;
  overflow-x: hidden;
  position: relative;
  z-index: 1;
  opacity: 1;
  filter: none;
  mix-blend-mode: normal;
}

#advanced-control-groups .adv-connection-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 6px;
  margin-top: 0;
}

#advanced-control-groups .node-card-connector-only .node-card-body {
  gap: 0;
}

#advanced-control-groups .node-card-connector-only .adv-connection-section {
  border-top: 0 !important;
  padding-top: 0;
}

/* Active state for the new 4-button seed mode controls in Advanced cards */
#advanced-control-groups .seed-mode-btn.active-seed-mode,
#advanced-control-groups .seed-mode-btn.\!bg-\[\#b3123e\] {
  background-color: #b3123e !important;
  color: white !important;
}

.sim-control-grid {
  align-items: end;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sim-param-field,
.sim-seed-field {
  min-width: 0;
}

.sim-seed-field {
  grid-column: 1 / -1;
}

.sim-param-row,
.sim-select-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  min-width: 0;
}

@media (min-width: 640px) {
  .sim-control-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.sim-seed-control {
  display: grid;
  grid-template-columns: minmax(8.5rem, 1fr) auto;
  gap: 0.375rem;
  align-items: stretch;
}

.sim-seed-input {
  width: 100%;
  min-width: 0;
  min-height: 2rem;
}

.sim-seed-modes {
  display: grid;
  grid-template-columns: repeat(4, 1.9rem);
  gap: 1px;
  padding: 2px;
  border: 1px solid #27272a;
  border-radius: 0.5rem;
  background: #09090b;
}

.simple-seed-mode-btn {
  min-width: 0;
  min-height: 1.48rem;
  margin: 0.085rem;
  border-radius: 0.375rem;
  background: #27272a;
  color: #a1a1aa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  line-height: 1;
}

.simple-seed-mode-btn i {
  font-size: 1.5em;
  line-height: 1;
  vertical-align: 0;
}

.simple-seed-mode-btn:hover {
  background: #3f3f46;
  color: #e4e4e7;
}

.simple-seed-mode-btn.active-seed-mode {
  background: #b3123e;
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(179, 18, 62, 0.6);
}

.sim-seed-set {
  margin-top: 0.375rem;
  border: 1px solid #27272a;
  border-radius: 0.5rem;
  background: rgba(9, 9, 11, 0.72);
  overflow: hidden;
}

.sim-seed-set-toggle {
  width: 100%;
  min-height: 1.8rem;
  padding: 0.25rem 0.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.375rem;
  align-items: center;
  color: #a1a1aa;
  font-size: 0.68rem;
  line-height: 1.1;
}

.sim-seed-set-toggle:hover {
  background: rgba(39, 39, 42, 0.7);
  color: #e4e4e7;
}

.sim-seed-set-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.sim-seed-set-list {
  max-height: 8.5rem;
  overflow-y: auto;
  border-top: 1px solid #27272a;
  padding: 0.375rem;
  display: grid;
  gap: 0.3125rem;
}

.sim-seed-set-list.hidden {
  display: none;
}

.sim-seed-row {
  display: grid;
  grid-template-columns: minmax(3.75rem, auto) minmax(0, 1fr);
  gap: 0.375rem;
  align-items: center;
}

.sim-seed-node-label {
  color: #71717a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.64rem;
  white-space: nowrap;
}

.sim-seed-node-input {
  width: 100%;
  min-width: 0;
  min-height: 1.75rem;
  border: 1px solid #27272a;
  border-radius: 0.375rem;
  background: #09090b;
  color: #e4e4e7;
  padding: 0.25rem 0.45rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.68rem;
  outline: none;
}

.sim-seed-node-input:focus {
  border-color: #b3123e;
}

@media (max-width: 420px) {
  .sim-seed-control {
    grid-template-columns: 1fr;
  }

  .sim-seed-modes {
    grid-template-columns: repeat(4, 1fr);
  }
}

.gradient-accent-soft:hover {
  background: linear-gradient(135deg, #d41a52 0%, #b3123e 100%);
}

.gradient-logo {
  background: linear-gradient(145deg, #b3123e 0%, #8a0e2f 100%);
}

body {
  font-family: 'Inter', system_ui, sans-serif;
}

.font-display {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 600;
}

.qq-logo-cat {
  width: 0.86em;
  height: 0.86em;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  transform: translateY(0);
}

.section {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0.5rem;
}

.prompt-textarea {
  font-size: 15px;
  line-height: 1.55;
  resize: vertical;
}

/* Hide textarea scrollbars; wheel/touch scrolling still works */
textarea {
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.prompt-history-panel {
  border: 1px solid #27272a;
  border-radius: 0.5rem;
  background: rgba(9, 9, 11, 0.68);
  overflow: hidden;
}

.prompt-history-toggle {
  width: 100%;
  min-height: 1.8rem;
  padding: 0.25rem 0.5rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.375rem;
  align-items: center;
  color: #a1a1aa;
  font-size: 0.68rem;
  line-height: 1.1;
}

.prompt-history-toggle:hover {
  background: rgba(39, 39, 42, 0.7);
  color: #e4e4e7;
}

.prompt-history-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.prompt-history-list {
  max-height: 12rem;
  overflow-y: auto;
  border-top: 1px solid #27272a;
  padding: 0.375rem;
  display: grid;
  gap: 0.3125rem;
}

.prompt-history-list.hidden {
  display: none;
}

.prompt-history-row {
  min-width: 0;
  min-height: 2.25rem;
  padding: 0.25rem 0.45rem 0.25rem 0.25rem;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.375rem;
  align-items: center;
  border-radius: 0.375rem;
  background: #18181b;
  color: #d4d4d8;
  text-align: left;
}

.prompt-history-row:hover {
  background: #27272a;
  color: #ffffff;
}

.prompt-history-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.64rem;
  line-height: 1.2;
}

.prompt-history-thumb {
  width: 2rem;
  height: 2rem;
  border-radius: 0.25rem;
  object-fit: cover;
  background: #09090b;
  border: 1px solid #27272a;
}

.prompt-history-thumb-empty {
  display: block;
  background:
    linear-gradient(135deg, rgba(196, 30, 74, 0.18), rgba(39, 39, 42, 0.6)),
    #09090b;
}

.prompt-history-clear-row {
  min-height: 1.65rem;
  border-radius: 0.375rem;
  background: #09090b;
  color: #71717a;
  font-size: 0.64rem;
  text-align: center;
}

.prompt-history-clear-row:hover {
  background: #27272a;
  color: #f87171;
}

.prompt-history-empty {
  padding: 0.4rem 0.5rem;
  color: #71717a;
  font-size: 0.7rem;
}

.control-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #b9b9b9;
}

.gen-image {
  transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1), box-shadow 0.2s ease;
}

.gen-image:hover {
  transform: scale(1.015);
}

.live-preview {
  animation: pulse-glow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

#live-img {
  height: 100%;
  width: auto;
  max-width: none;
  max-height: 100%;
  object-fit: contain;
}

.live-preview-window {
  min-height: 40px;
  height: 40px;
  transition: height 0.22s ease, min-height 0.22s ease;
}

.live-preview-window.live-preview-window-active {
  height: auto;
  min-height: 9rem;
  aspect-ratio: 16 / 10;
}

.live-preview-window-empty #live-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.live-preview-window-empty #live-placeholder i {
  margin-bottom: 0;
  font-size: 0.75rem;
}

.live-preview-window-empty #live-placeholder div {
  font-size: 0.65rem;
  line-height: 1;
}

#progress-text {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: space-between;
}

.progress-status-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-status-detail {
  flex-shrink: 0;
  margin-left: 0.5rem;
  color: #a1a1aa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(179, 18, 62, 0.25); }
  50% { box-shadow: 0 0 0 14px rgba(179, 18, 62, 0); }
}

.image-dropzone {
  transition: all 0.2s ease;
}

.image-dropzone.dragover {
  background-color: rgba(179, 18, 62, 0.1);
  border-color: #b3123e;
}

.result-card {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0.5rem;
}

.result-card:hover {
  transform: translateY(-1px);
}

.slider {
  accent-color: var(--accent);
}

.mini-btn {
  font-size: 12px;
  padding: 3px 9px;
}

.status-dot {
  animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* =======================
   Fullscreen Image Lightbox
======================= */
#lightbox {
  transition: opacity 0.15s ease;
  opacity: 0;
  pointer-events: none;
}

#lightbox.show {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  touch-action: none;
  overscroll-behavior: none;
}

#lightbox-img {
  touch-action: none;
}

#lightbox-img {
  transition: transform 0.2s ease;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5);
  cursor: zoom-out;
}

#lightbox-counter {
  max-width: min(96vw, 60rem);
  padding: 0.125rem 0.5rem;
  color: rgba(255, 255, 255, 0.58);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.625rem;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  white-space: nowrap;
}

#lightbox-counter button,
#lightbox-counter a {
  pointer-events: auto;
}
#lightbox-counter a {
  text-decoration: none;
}

/* ============================================
   VISUAL DENSITY & REDUCED ROUNDED CORNERS
   Better screen real estate, modern sharp look
============================================ */

/* Force smaller radii everywhere (less bubbly) */
.rounded-3xl { border-radius: 0.5rem !important; }
.rounded-2xl { border-radius: 0.375rem !important; }
.rounded-xl  { border-radius: 0.375rem !important; }

/* Tighter base spacing */
body { font-size: 14.5px; }

/* Section cards: smaller internal padding */
.section {
  padding: 0.875rem 1rem !important;
}
@media (min-width: 768px) {
  .section { padding: 1rem 1.125rem !important; }
}

/* Top bar tighter */
.border-b.border-zinc-800.px-6.py-4 {
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
}

/* Control labels slightly larger for readability */
.control-label {
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

/* Compact inputs + selects */
input[type="number"],
select {
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  font-size: 13px;
  border-radius: 0.375rem;
}

.prompt-textarea {
  font-size: 14px;
  padding: 0.625rem 0.75rem;
  border-radius: 0.375rem;
  line-height: 1.45;
}

/* Generate button less rounded + slightly shorter */
 #generate-btn {
   height: 40px;
   border-radius: 0.75rem;
 }

/* Gallery grid tighter gaps on all sizes */
#gallery {
  gap: 0.5rem;
}
@media (min-width: 768px) {
  #gallery { gap: 0.625rem; }
}

/* Result cards: slightly less inner chrome */
.result-card .absolute {
  padding: 0.375rem;
  /* Bottom action bar is invisible until hover. Make it non-interactive when invisible
     so clicks always reach the <img> (or the card container for compare mode). */
  pointer-events: none;
}

.result-card:hover .absolute {
  /* Only when the hover bar is visible do we let it receive clicks (for the buttons). */
  pointer-events: auto;
}

/* Restore previous gallery card style (compact thumbnails) - strong rules */
#gallery {
  display: grid !important;
}
#gallery .result-card,
#gallery > div.result-card {
  aspect-ratio: 4 / 3 !important;
  overflow: hidden;
  width: 100%;
  height: auto;
  background: #09090b;
}
#gallery .result-card img,
#gallery > div.result-card img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block;
  background: #09090b;
  opacity: 1;
  transform: translateZ(0);
}

/* Status bar + settings button */
#status-bar,
button[onclick*="showSettings"] {
  border-radius: 0.375rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

#status-bar {
  min-height: 1.25rem;
  height: 1.25rem;
  gap: 0.25rem;
  padding: 0 0.4rem !important;
  border-radius: 9999px;
  font-size: 10px;
}

#status-bar #status-dot {
  width: 0.375rem !important;
  height: 0.375rem !important;
}

#status-bar #status-text {
  font-size: 9px !important;
  line-height: 1;
  font-weight: 500;
  max-width: 5.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile top bar compaction */
@media (max-width: 640px) {
  .border-b.border-zinc-800 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
  /* Further squeeze right side items */
  .flex.items-center.gap-x-2 {
    gap: 0.25rem !important;
  }
}

.adv-mode-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.adv-mode-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 2.6rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: #3f3f46;
  box-shadow: inset 0 0 0 1px rgba(113, 113, 122, 0.5);
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.adv-mode-knob {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: #e4e4e7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease;
  z-index: 2;
}

.adv-mode-cat {
  position: absolute;
  right: 0.52rem;
  width: 0.82rem;
  height: 0.82rem;
  background: url("../vendor/icon-set-cat/IMGEN-Cat-45.svg") center / contain no-repeat;
  filter: grayscale(1) brightness(1.25);
  opacity: 0.76;
  transition: filter 0.18s ease, opacity 0.18s ease, left 0.18s ease, right 0.18s ease;
  z-index: 1;
}

.generate-btn-cat{
  width: 0.96rem;
  height: 0.96rem;
}

.ai-prompt-cat {
  width: 1rem;
  height: 1rem;
}
#advanced-mode-toggle:focus-visible + .adv-mode-track {
  box-shadow: inset 0 0 0 1px rgba(212, 26, 82, 0.7), 0 0 0 2px rgba(179, 18, 62, 0.32);
}

#advanced-mode-toggle:checked + .adv-mode-track {
  background: #4a0f21;
  box-shadow: inset 0 0 0 1px rgba(179, 18, 62, 0.72);
}

#advanced-mode-toggle:checked + .adv-mode-track .adv-mode-knob {
  transform: translateX(1.35rem);
}

#advanced-mode-toggle:checked + .adv-mode-track .adv-mode-cat {
  left: 0.52rem;
  right: auto;
  filter: none;
  opacity: 1;
}

/* === Advanced Mode: Clean contained Generate + Live Preview (same card style as Simple) === */

/* Ensure the moved Live Preview card keeps 100% identical styling to Simple mode */
body.advanced-active #live-panel {
  margin: 0 !important;
}

/* Keep the Advanced generate button the same prominent size */
body.advanced-active #advanced-generate-slot #generate-btn-advanced {
  height: 48px;
  font-size: 1rem;
}

/* Dropdowns / model select */
#main-checkpoint,
#sampler,
#scheduler {
  border-radius: 0.375rem;
  font-size: 13px;
  padding: 0.375rem 0.625rem;
}

/* Sliders track */
.slider {
  height: 4px;
}

/* Live preview area */
#live-panel .aspect-\\[16\\/10\\] {
  border-radius: 0.375rem;
}

/* Lightbox + compare modals: sharper */
#lightbox-img,
#compare-modal img {
  border-radius: 0.375rem;
}

.compare-modal {
  height: 100dvh;
  max-height: 100dvh;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.compare-modal.flex {
  display: block;
}

.compare-modal-panel {
  min-height: calc(100dvh - 1.5rem);
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.compare-modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
}

.compare-image-wrap {
  min-height: 0;
  touch-action: pan-y;
}

.compare-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  touch-action: pan-y;
  -webkit-user-drag: none;
}

body.compare-modal-open {
  overflow: hidden;
}

.imgen-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.imgen-dialog-panel {
  width: min(92vw, 560px);
  max-height: min(78vh, 620px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid rgba(179, 18, 62, 0.45);
  border-radius: 0.75rem;
  background: #18181b;
  color: #f4f4f5;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  padding: 1rem;
}

.imgen-dialog-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.imgen-dialog-body {
  max-height: 48vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #27272a;
  border-radius: 0.5rem;
  background: #09090b;
  color: #d4d4d8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  padding: 0.75rem;
}

.imgen-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.imgen-dialog-btn {
  min-width: 5.5rem;
  border-radius: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 700;
  transition: background 0.15s ease, transform 0.15s ease;
}

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

.imgen-dialog-btn-muted {
  background: #27272a;
  color: #e4e4e7;
}

.imgen-dialog-btn-muted:hover {
  background: #3f3f46;
}

.imgen-dialog-btn-primary,
.imgen-dialog-btn-danger {
  background: #b3123e;
  color: #ffffff;
}

.imgen-dialog-btn-primary:hover,
.imgen-dialog-btn-danger:hover {
  background: #c41e4a;
}

.compare-instructions {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid rgba(179, 18, 62, 0.35);
  border-radius: 0.5rem;
  background: rgba(24, 24, 27, 0.96);
  color: #f4f4f5;
  font-size: 0.75rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.compare-instructions button {
  flex: 0 0 auto;
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  background: rgba(127, 29, 29, 0.75);
  color: white;
  font-size: 0.75rem;
  line-height: 1.25;
}

.compare-instructions button:hover {
  background: rgb(127, 29, 29);
}

@media (min-width: 768px) {
  .compare-modal.flex {
    display: flex;
  }

  .compare-modal {
    height: auto;
    max-height: none;
    overflow-y: auto;
  }

  .compare-modal-panel {
    min-height: 0;
    padding-bottom: 0;
  }

  .compare-modal-header {
    position: static;
  }

  .compare-image-wrap {
    min-height: 300px;
  }

  .compare-img {
    width: auto;
    max-height: 70vh;
  }
}

/* Responsive improvements for params */
.param-grid {
  gap: 0.875rem 0.75rem;
}

/* Small numeric inputs (W/H) */
.sim-size-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
}

.sim-size-number-row,
.sim-size-button-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

@media (min-width: 768px) {
  .sim-size-button-row {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.25rem;
  }

  .sim-size-button-row .size-preset-btn {
    width: 100%;
    min-width: 0;
  }
}

.sim-size-separator {
  flex: 0 0 auto;
  color: #71717a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.input-num {
  width: 100%;
  max-width: 3.6rem;
  flex: 0 1 3.6rem;
  text-align: center;
  font-size: 13px;
  padding: 0.25rem 0.375rem;
  border-radius: 0.25rem;
}

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

.input-num[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.size-preset-btn {
  min-width: 2.1rem;
  min-height: 1.35rem;
  border-radius: 0.375rem;
  background: rgba(39, 39, 42, 0.92);
  color: #a1a1aa;
  font-size: 0.5625rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.25rem 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.size-preset-btn:hover {
  background: #3f3f46;
  color: #e4e4e7;
}

.size-swap-btn {
  font-size: 0.625rem;
}

@media (max-width: 767px) {
  .sim-size-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.45rem;
    overflow: visible;
  }

  .sim-size-number-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.375rem;
    width: 100%;
  }

  .sim-size-number-row .input-num {
    max-width: none;
    width: 100%;
    flex: none;
  }

  .sim-size-button-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.375rem;
    width: 100%;
  }

  .sim-size-button-row .size-preset-btn {
    min-width: 0;
    width: 100%;
  }
}

.ai-send-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.ai-send-actions button {
  min-width: 0;
  min-height: 2.125rem;
  white-space: nowrap;
}

#ai-assist-card select,
#ai-assist-card textarea,
#ai-assist-card input {
  font-size: 10px !important;
  line-height: 1.2 !important;
}

#ai-assist-card #ai-model-select,
#ai-assist-card #ai-mode-select,
#ai-assist-card #ai-target-select,
#ai-assist-card #ai-style-preset,
#ai-assist-card #ai-eroticness-select {
  min-height: 1.75rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  color: #d4d4d8;
  font-size: 10px !important;
  font-weight: 400;
}

#ai-assist-card #ai-model-select option,
#ai-assist-card #ai-mode-select option,
#ai-assist-card #ai-target-select option,
#ai-assist-card #ai-style-preset option,
#ai-assist-card #ai-eroticness-select option {
  font-size: 10px;
  font-weight: 400;
  background: #09090b;
  color: #d4d4d8;
}

#ai-assist-card #ai-custom-system {
  font-size: 10px !important;
  line-height: 1.3;
}

#ai-assist-body > .grid:first-child > div > div:first-child {
  font-size: 9px;
  line-height: 1.1;
  color: #8b8b94;
  letter-spacing: 0;
}

#prompt,
#negative,
#seed,
#batch-val,
#sampler,
#scheduler,
#width,
#height {
  font-size: 10px !important;
  line-height: 1.25 !important;
}

.ai-response-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.ai-response-actions button {
  min-width: 0;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.ai-response-actions button:nth-child(-n + 3) {
  background: rgba(179, 18, 62, 0.18) !important;
  border-color: rgba(196, 30, 74, 0.38) !important;
  color: #f4d6df !important;
}

.ai-response-actions button:nth-child(-n + 3):hover {
  background: rgba(196, 30, 74, 0.36) !important;
  border-color: rgba(212, 26, 82, 0.62) !important;
  color: #ffffff !important;
}

.ai-response-actions button:nth-child(n + 4) {
  background: rgba(39, 39, 42, 0.72) !important;
  border-color: rgba(82, 82, 91, 0.52) !important;
  color: #d4d4d8 !important;
}

.ai-response-actions button:nth-child(n + 4):hover {
  background: rgba(63, 63, 70, 0.92) !important;
  border-color: rgba(113, 113, 122, 0.72) !important;
  color: #ffffff !important;
}

.ai-response-actions button:disabled {
  background: #18181b !important;
  border-color: #27272a !important;
  color: #52525b !important;
  cursor: not-allowed;
  opacity: 0.72;
  filter: grayscale(1);
}

.ai-response-actions button:disabled:hover {
  background: #18181b !important;
  border-color: #27272a !important;
  color: #52525b !important;
}

.ai-payload-log {
  border: 1px solid #27272a;
  border-radius: 0.5rem;
  background: rgba(9, 9, 11, 0.68);
  overflow: hidden;
}

.ai-payload-log-toggle {
  width: 100%;
  min-height: 1.8rem;
  padding: 0.25rem 0.5rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.375rem;
  align-items: center;
  color: #a1a1aa;
  font-size: 0.68rem;
  line-height: 1.1;
  text-align: left;
}

.ai-payload-log-toggle:hover {
  background: rgba(39, 39, 42, 0.7);
  color: #e4e4e7;
}

#ai-payload-log-body {
  background: #09090b;
}

#ai-payload-log-text {
  display: block;
  border: 0;
  border-radius: 0;
  background: #09090b !important;
  color: #d4d4d8 !important;
  caret-color: #e4e4e7;
  -webkit-text-fill-color: #d4d4d8;
  box-shadow: inset 0 1px 0 rgba(39, 39, 42, 0.85);
}

#ai-payload-log-text:focus {
  background: #09090b !important;
  color: #e4e4e7 !important;
}

#ai-payload-log-text::selection {
  background: rgba(196, 30, 74, 0.42);
  color: #ffffff;
}

#ai-body-parts-panel {
  max-height: 14rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.625rem;
  border-top: 1px solid #27272a;
}

.ai-tags-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.5rem;
  min-width: 0;
}

.ai-tag-lang-group {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  justify-self: start;
  gap: 0.25rem;
  min-width: 0;
}

.ai-tag-lang-btn,
.ai-tags-edit-btn {
  width: 2.45rem;
  min-height: 1.35rem;
  padding: 0.15rem 0.25rem;
  border-radius: 0.375rem;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.ai-tag-lang-btn {
  background: #27272a;
  color: #71717a;
}

.ai-tag-lang-btn:hover {
  background: #3f3f46;
  color: #d4d4d8;
}

.ai-tag-lang-btn.ai-tag-lang-active {
  background: #b3123e;
  color: #ffffff;
}

.ai-tags-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #27272a;
  color: #a1a1aa;
  text-decoration: none;
}

.ai-tags-edit-btn:hover {
  background: #3f3f46;
  color: #ffffff;
}

.ai-tags-count {
  min-width: 0;
  justify-self: end;
  color: #71717a;
  font-size: 10px;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.ai-tag-category {
  margin-top: 0.25rem;
  padding-top: 0.375rem;
  border-top: 1px solid #27272a;
}

.ai-tag-category:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.ai-tags-panel {
  border: 1px solid #27272a;
  border-radius: 0.5rem;
  background: rgba(9, 9, 11, 0.68);
  overflow: hidden;
}

.ai-tags-toggle {
  width: 100%;
  min-height: 1.8rem;
  padding: 0.25rem 0.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.375rem;
  align-items: center;
  color: #a1a1aa;
  font-size: 10px;
  line-height: 1.1;
}

.ai-tags-toggle:hover {
  background: rgba(39, 39, 42, 0.7);
  color: #e4e4e7;
}

.ai-tags-summary {
  grid-column: 1;
  grid-row: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

#ai-tags-toggle-icon {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
}

#ai-body-parts-panel.hidden {
  display: none;
}

#ai-body-parts-panel > #ai-tags-list {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  column-gap: 0.875rem;
  row-gap: 0.375rem;
  align-items: start;
}

#ai-body-parts-panel > #ai-tags-list > div {
  grid-column: 1 / -1 !important;
  margin-top: 0.375rem;
  padding-top: 0.5rem;
  border-top: 1px solid #27272a;
  color: #71717a;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#ai-body-parts-panel label {
  display: grid !important;
  grid-template-columns: 0.875rem minmax(0, 1fr);
  align-items: start;
  gap: 0.375rem;
  min-width: 0;
  color: #d4d4d8;
  font-size: 12px;
  line-height: 1.2;
}

#ai-body-parts-panel input[type="checkbox"] {
  width: 0.75rem;
  height: 0.75rem;
  margin-top: 0.075rem;
}

.ai-user-input::placeholder,
.ai-soft-placeholder::placeholder {
  color: rgba(161, 161, 170, 0.48);
  font-size: 12px;
  font-weight: 400;
}

.ai-user-input.ai-input-needs-text::placeholder {
  color: rgba(248, 113, 113, 0.78);
}

.adv-debug-header {
  min-width: 0;
}

.adv-debug-title {
  white-space: nowrap;
}

.debug-title-cat {
  width: 0.86rem;
  height: 0.86rem;
  display: block;
  object-fit: contain;
}

.adv-debug-actions {
  flex-wrap: wrap;
}

.adv-debug-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.375rem;
  white-space: nowrap;
  line-height: 1.1;
  text-align: center;
}

/* Make dropzone less puffy */
.image-dropzone {
  padding: 0.75rem 0.875rem;
  border-radius: 0.5rem;
}

/* Better mobile stacking for left column */
@media (max-width: 767px) {
  .lg\:col-span-5.space-y-6 > .section {
    padding: 0.75rem !important;
  }
  .grid.grid-cols-2.sm\:grid-cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 0.625rem;
  }

  /* Fix long model/checkpoint filenames causing horizontal overflow in sim */
  #workflow,
  #advanced-workflow,
  #main-checkpoint {
    font-size: 10px !important;
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    max-width: 100%;
    min-width: 0;
  }

  /* Make refresh buttons next to selects more compact on mobile */
  #simple-view .flex.gap-1\\.5 button {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    font-size: 10px !important;
  }

  .adv-debug-header {
    align-items: flex-start !important;
    flex-direction: column;
  }

  .adv-debug-title {
    width: 100%;
    font-size: 10px;
  }

  .adv-debug-actions {
    width: 100%;
    justify-content: flex-start !important;
    gap: 0.375rem !important;
  }

  .adv-debug-action {
    flex: 0 1 auto;
    padding: 0.25rem 0.45rem !important;
    font-size: 9px !important;
    max-width: 100%;
  }
}

@media (max-width: 380px) {
  .adv-debug-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .adv-debug-action {
    width: 100%;
    text-align: center;
  }
}

/* Debug bug icon visibility - only show in Advanced mode */
body.advanced-active #debug-toggle-btn {
  display: flex !important;
}

@media (max-width: 767px) {
  #ai-assist-card #ai-user-input,
  #ai-assist-card #ai-response,
  #prompt,
  #negative,
  #seed,
  #batch-val,
  #width,
  #height,
  #ai-user-input,
  #ai-response,
  #ai-custom-system,
  #login-password,
  #advanced-node-search,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea {
    font-size: 16px !important;
  }

  body select,
  body #workflow,
  body #advanced-workflow,
  body #main-checkpoint,
  body #sampler,
  body #scheduler,
  body #ai-assist-card select,
  body #ai-assist-card #ai-model-select,
  body #ai-assist-card #ai-mode-select,
  body #ai-assist-card #ai-target-select,
  body #ai-assist-card #ai-style-preset,
  body #ai-assist-card #ai-eroticness-select,
  body #advanced-control-groups select {
    font-size: 13px !important;
  }
}
