/* Image Prompt Builder */

:root {
  --bg: #050914;
  --bg-elevated: rgba(12, 18, 31, 0.88);
  --surface: rgba(18, 27, 44, 0.92);
  --surface-tinted: rgba(17, 31, 53, 0.94);
  --border: rgba(124, 144, 170, 0.24);
  --text: #f7fbff;
  --text-muted: #a8b3c6;
  --accent: #48f5ee;
  --accent-dim: rgba(72, 245, 238, 0.12);
  --accent-border: rgba(72, 245, 238, 0.42);
  --indigo: #7a58ff;
  --indigo-dim: rgba(122, 88, 255, 0.2);
  --danger: #ff6b7a;
  --radius: 12px;
  --radius-pill: 9999px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.26);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 6.5rem;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(72, 245, 238, 0.2), transparent 26rem),
    radial-gradient(circle at 88% 8%, rgba(122, 88, 255, 0.28), transparent 28rem),
    linear-gradient(115deg, rgba(255, 255, 255, 0.05), transparent 35%),
    var(--bg);
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.35rem 1rem 2.5rem;
}

.site-header {
  display: grid;
  grid-template-columns: minmax(5.5rem, 8rem) 1fr auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.4rem;
  padding: 0.9rem 0.2rem 0.25rem;
}

.site-logo {
  width: 100%;
  max-width: 8rem;
  aspect-ratio: 1;
  border-radius: 26px;
  box-shadow:
    0 0 36px rgba(72, 245, 238, 0.16),
    0 18px 42px rgba(0, 0, 0, 0.42);
}

.site-header-copy {
  min-width: 0;
}

.site-kicker {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: clamp(0.78rem, 2.8vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.site-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.8rem, 6vw, 3.35rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.18);
}

.site-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 42em;
}

.site-header-actions {
  display: flex;
  justify-content: flex-end;
  align-self: start;
  padding-top: 0.2rem;
}

.btn-tip {
  color: var(--text);
  background: linear-gradient(135deg, rgba(72, 245, 238, 0.18), rgba(216, 78, 159, 0.28));
  border-color: rgba(72, 245, 238, 0.36);
  box-shadow: 0 0 24px rgba(72, 245, 238, 0.14);
  white-space: nowrap;
}

.btn-tip:hover:not(:disabled) {
  border-color: rgba(72, 245, 238, 0.58);
  box-shadow: 0 0 28px rgba(216, 78, 159, 0.2);
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel {
  padding: 1.15rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.panel-title {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b7c5dd;
}

.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-heading-row .panel-title {
  margin-bottom: 0;
}

.platform-panel .output-mode-toggle {
  margin-bottom: 0;
}

.platform-settings {
  margin-top: 1rem;
}

.platform-settings[hidden] {
  display: none;
}

.platform-settings-toggle::after {
  content: ">";
  margin-left: 0.35rem;
  font-weight: 700;
}

.platform-settings-toggle[aria-expanded="true"]::after {
  content: "v";
}

.tag-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.85rem;
}

.tag-card {
  min-width: 0;
  padding: 0.85rem;
  background:
    linear-gradient(180deg, rgba(19, 30, 50, 0.96), rgba(13, 22, 38, 0.96)),
    radial-gradient(circle at 0% 0%, rgba(72, 245, 238, 0.12), transparent 70%);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.tag-card:hover {
  border-color: rgba(72, 245, 238, 0.32);
  box-shadow:
    0 0 0 1px rgba(72, 245, 238, 0.08),
    var(--shadow-soft);
  transform: translateY(-1px);
}

.tag-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.category-label {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #b7c5dd;
}

.btn-mini {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.1;
}

.tag-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.tag-lock-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.65rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.tag-lock-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tag-lock-control span[aria-hidden="true"] {
  display: inline-grid;
  place-items: center;
  width: 0.9rem;
  height: 0.9rem;
  color: transparent;
  border: 1px solid rgba(168, 179, 198, 0.45);
  border-radius: 3px;
  font-size: 0.65rem;
  line-height: 1;
}

.tag-lock-control:has(input:checked) {
  color: var(--text);
  background: var(--indigo-dim);
  border-color: rgba(109, 93, 252, 0.5);
}

.tag-lock-control:has(input:checked) span[aria-hidden="true"] {
  color: #fff;
  background: var(--indigo);
  border-color: var(--indigo);
}

.tag-lock-control:has(input:focus-visible) {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

.tag-select {
  width: 100%;
  margin-bottom: 0.5rem;
}

#tags-randomize-btn,
.tags-randomize-btn {
  color: #08111f;
  background: linear-gradient(135deg, #48f5ee, #7a58ff 54%, #d84e9f);
  border-color: transparent;
  box-shadow: 0 0 26px rgba(72, 245, 238, 0.18);
}

#tags-randomize-btn:hover:not(:disabled),
.tags-randomize-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #7bfdf7, #8d6dff 54%, #eb61ad);
  border-color: transparent;
}

.tags-global-actions,
.tags-bottom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.tags-bottom-actions {
  margin-top: 0.9rem;
}

.field-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.free-text {
  display: block;
  width: 100%;
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(5, 9, 20, 0.36);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  min-height: 4.5rem;
}

.free-text::placeholder {
  color: rgba(168, 179, 198, 0.58);
}

.free-text:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-color: rgba(72, 245, 238, 0.45);
}

.aspect-fieldset {
  margin: 0 0 1rem;
  padding: 0;
  border: none;
}

.aspect-fieldset:last-child {
  margin-bottom: 0;
}

.aspect-fieldset .field-label {
  padding: 0;
}

.aspect-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.aspect-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.aspect-option:has(input:focus-visible) {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

.aspect-option:has(input:checked) {
  color: var(--text);
  border-color: rgba(72, 245, 238, 0.48);
  background: linear-gradient(135deg, rgba(72, 245, 238, 0.16), rgba(122, 88, 255, 0.2));
}

.aspect-option input {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.aspect-option span {
  position: relative;
  z-index: 0;
  user-select: none;
  pointer-events: none;
}

.aspect-mode-note {
  margin: 0.75rem 0 0;
  max-width: 42rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.aspect-mode-note[hidden] {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.generation-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.55rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.generation-status[hidden] {
  display: none;
}

.generation-status__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.45);
  animation: thinkingPulse 1.2s ease-out infinite;
}

@keyframes thinkingPulse {
  0% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.45);
  }
  70% {
    transform: scale(1.15);
    box-shadow: 0 0 0 0.5rem rgba(20, 184, 166, 0);
  }
  100% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(20, 184, 166, 0);
  }
}

.model-picker {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 12rem;
}

.model-picker .param-label {
  margin-bottom: 0;
}

.model-status {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.1em;
}

.model-status:empty {
  display: none;
}

.model-status[data-state="warming"] {
  color: var(--accent);
}

.model-status[data-state="warm"] {
  color: var(--text-muted);
}

.model-status[data-state="error"] {
  color: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

.btn:hover {
  background: rgba(32, 46, 72, 0.96);
  border-color: rgba(72, 245, 238, 0.28);
}

.btn:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-primary {
  color: #05111f;
  background: linear-gradient(135deg, #48f5ee, #7a58ff);
  border-color: transparent;
  box-shadow: 0 0 24px rgba(72, 245, 238, 0.18);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #7bfdf7, #8f72ff);
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(168, 179, 198, 0.3);
  background: rgba(255, 255, 255, 0.06);
}

.output-panel .aspect-ref {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.output-panel .aspect-ref span {
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.output-generated-title {
  margin: -0.35rem 0 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.prompt-sticky-bar {
  position: fixed;
  left: 50%;
  bottom: max(0.85rem, env(safe-area-inset-bottom));
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  width: min(calc(100% - 1.5rem), 860px);
  padding: 0.7rem;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(15, 23, 40, 0.92), rgba(7, 12, 24, 0.94)),
    radial-gradient(circle at 12% 0%, rgba(72, 245, 238, 0.16), transparent 70%);
  border: 1px solid rgba(72, 245, 238, 0.24);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 18px 48px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.prompt-sticky-title-wrap {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 0.05rem;
}

.prompt-sticky-kicker {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.prompt-sticky-title {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.prompt-sticky-actions {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.prompt-sticky-actions .btn {
  flex-shrink: 0;
  padding-inline: 0.85rem;
}

.output {
  display: block;
  width: 100%;
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  color: #dce9ff;
  background: rgba(3, 7, 15, 0.62);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  min-height: 12rem;
}

.output::placeholder {
  color: rgba(168, 179, 198, 0.5);
}

.output:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.output-inline-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.5rem;
  margin: -0.25rem 0 0.75rem;
}

@media (max-width: 520px) {
  body {
    padding-bottom: 8.5rem;
  }

  .page {
    padding: 1rem 0.75rem 2rem;
  }

  .site-header {
    grid-template-columns: 4.6rem 1fr;
    gap: 0.75rem;
    padding-top: 0.35rem;
  }

  .site-header-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
    padding-top: 0;
  }

  .site-header-actions .btn {
    width: 100%;
  }

  .site-logo {
    border-radius: 18px;
  }

  .site-kicker {
    font-size: 0.68rem;
    letter-spacing: 0.16em;
  }

  .site-title {
    font-size: clamp(1.35rem, 9vw, 2.05rem);
    letter-spacing: 0.1em;
  }

  .site-subtitle {
    font-size: 0.84rem;
  }

  .panel {
    padding: 1rem 0.85rem;
  }

  .actions .btn-primary {
    width: 100%;
  }

  .panel-heading-row,
  .tag-group-header {
    align-items: stretch;
    flex-direction: column;
  }

  .tags-global-actions,
  .tags-bottom-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .tags-global-actions .btn,
  .tags-bottom-actions .btn {
    padding-inline: 0.55rem;
  }

  .tag-card-actions {
    justify-content: flex-start;
  }

  .tag-card-grid {
    grid-template-columns: 1fr;
  }

  .model-picker {
    width: 100%;
    min-width: 0;
  }

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

  .output-actions .btn {
    width: 100%;
  }

  .prompt-sticky-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
    width: min(calc(100% - 1rem), 860px);
    padding: 0.65rem;
  }

  .prompt-sticky-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .prompt-sticky-actions .btn {
    width: 100%;
  }

  .prompt-sticky-actions #sticky-copy-positive-btn {
    grid-column: 1;
  }
}

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

  .generation-status__dot {
    animation: none;
  }
}

/* --- Additions (custom tag row, mode toggle, param panels, negative output) --- */

.custom-tag-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.template-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.template-row .category-template-select {
  flex: 1;
  min-width: 10rem;
}

.template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.template-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--indigo-dim);
  border: 1px solid rgba(109, 93, 252, 0.35);
  border-radius: var(--radius-pill);
}

.template-chip__remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
}

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

.template-add-btn.btn,
.template-create-open-btn.btn,
.template-edit-open-btn.btn,
.template-delete-btn.btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.template-delete-btn.btn {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: transparent;
}

.template-delete-btn.btn:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.6);
  color: var(--danger);
}

.template-edit-open-btn.btn:disabled,
.template-delete-btn.btn:disabled {
  display: none;
}

.template-tags-input {
  min-height: 7rem;
  resize: vertical;
}

.custom-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.custom-tag-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.3rem 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: rgba(5, 9, 20, 0.34);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: none;
}

.custom-tag-input::placeholder {
  color: rgba(168, 179, 198, 0.58);
}

.custom-tag-input:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-color: rgba(72, 245, 238, 0.45);
}

.custom-tag-add.btn {
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.tag-btn-custom {
  appearance: none;
  margin-top: 0.45rem;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.tag-btn-custom.is-selected {
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.24);
}

.mode-toggle,
.output-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 1rem;
}

.output-mode-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 34rem);
}

.mode-option,
.output-mode-option {
  min-width: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  text-align: center;
}

.mode-option.is-active,
.output-mode-option.is-active {
  background: linear-gradient(135deg, rgba(72, 245, 238, 0.95), rgba(122, 88, 255, 0.95));
  color: #06101d;
}

.mode-option:focus-visible,
.output-mode-option:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  z-index: 1;
}

.params-panel,
.param-panel {
  padding: 0.75rem;
  background: var(--surface-tinted);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.param-panel[hidden] {
  display: none;
}

.param-fieldset {
  flex: 1 1 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
}

.param-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-width: 8rem;
}

.param-help {
  margin: -0.25rem 0 0.1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.param-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.param-select,
.param-input {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(5, 9, 20, 0.34);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}

.param-select {
  color-scheme: dark;
  background-color: rgba(7, 13, 28, 0.86);
}

.param-select option,
.param-select optgroup {
  color: var(--text);
  background-color: #101827;
}

.param-select option:checked {
  color: #06101d;
  background-color: var(--accent);
}

.param-select:focus-visible,
.param-input:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-color: rgba(72, 245, 238, 0.45);
}

label[for="output-negative"],
.output-negative-wrap > .field-label {
  color: var(--danger);
}

#output-negative {
  border-left: 2px solid var(--danger);
  min-height: 14rem;
  max-height: 28rem;
  overflow-y: auto;
}

#output-settings {
  min-height: 8rem;
}

.tag-remove {
  margin-left: 0.35rem;
  font-size: 0.7rem;
  opacity: 0.6;
  cursor: pointer;
}

.tag-remove:hover {
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.58);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(480px, 100%);
  max-width: 480px;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-card .panel-title {
  margin: 0 0 0.25rem;
}

.modal-card .field-label {
  margin-bottom: 0.25rem;
}

.tip-modal-card {
  gap: 0.75rem;
}

.tip-modal-copy {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.tip-options {
  display: grid;
  gap: 0.65rem;
}

.tip-option {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem;
  color: var(--text);
  text-decoration: none;
  background: rgba(5, 9, 20, 0.34);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.tip-option:hover,
.tip-option:focus-visible {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(72, 245, 238, 0.14), rgba(216, 78, 159, 0.18));
  border-color: rgba(72, 245, 238, 0.52);
  box-shadow: 0 0 24px rgba(72, 245, 238, 0.12);
  outline: none;
}

.tip-option-title {
  font-weight: 800;
}

.tip-option-detail {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.modal-card input,
.modal-card textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(5, 9, 20, 0.36);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.modal-card input:focus-visible,
.modal-card textarea:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-color: rgba(72, 245, 238, 0.45);
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.modal-actions-right {
  display: flex;
  gap: 0.5rem;
}

/* --- Refine button --- */

.btn-refine {
  color: var(--text);
  background: linear-gradient(135deg, rgba(122, 88, 255, 0.78), rgba(216, 78, 159, 0.72));
  border-color: rgba(216, 78, 159, 0.26);
  box-shadow: 0 0 20px rgba(122, 88, 255, 0.18);
}

.btn-refine:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(137, 109, 255, 0.9), rgba(235, 97, 173, 0.86));
  border-color: rgba(216, 78, 159, 0.42);
}

.btn-refine:disabled {
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: none;
  border-color: var(--border);
}

.btn-refine__icon {
  margin-right: 0.35rem;
  font-size: 0.95em;
}

/* --- Save as favorite button --- */

.btn-favorite {
  color: var(--text);
  background: rgba(20, 184, 166, 0.08);
  border-color: var(--accent-border);
}

.btn-favorite[hidden] {
  display: none;
}

.btn-favorite:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

.btn-favorite__icon {
  margin-right: 0.35rem;
  color: var(--accent);
  font-size: 0.95em;
}

/* --- Favorites panel + cards --- */

.favorites-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.favorites-empty {
  margin: 0;
  padding: 0.9rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
}

.favorites-empty[hidden] {
  display: none;
}

.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.favorites-list:empty {
  display: none;
}

.favorite-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.favorite-card:hover {
  border-color: rgba(72, 245, 238, 0.34);
  background: rgba(21, 33, 53, 0.96);
  box-shadow: var(--shadow-soft);
}

.favorite-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.favorite-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.favorite-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.favorite-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--indigo-dim);
  border: 1px solid rgba(109, 93, 252, 0.35);
  border-radius: var(--radius-pill);
}

.favorite-mode-badge[data-mode="sdxl"] {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--text);
}

.favorite-generated-title {
  margin: -0.15rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  word-break: break-word;
}

.favorite-preview {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: #c6d1e3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.favorite-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.1rem;
}

.favorite-card-actions .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.favorite-card-actions .btn-delete {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
  background: transparent;
  margin-left: auto;
}

.favorite-card-actions .btn-delete:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.6);
  color: var(--danger);
}

.field-help {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--danger);
}

.field-help[hidden] {
  display: none;
}

@media (max-width: 520px) {
  .favorite-card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .favorite-card-actions .btn {
    width: 100%;
  }

  .favorite-card-actions .btn-delete {
    margin-left: 0;
  }

  .output-inline-actions {
    flex-wrap: wrap;
  }
}
