/* ── Design Tokens ────────────────────────────────────────────────────────── */
@import url("tokens.css");

/* ── Top Bar ──────────────────────────────────────────────────────────────── */

.top-bar {
  height: var(--topbar-h);   /* 48px — 8px grid aligned */
  min-height: var(--topbar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--space-4);
  background: var(--color-surface-1);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  z-index: 100;
}

.top-bar-logo {
  font-family: 'Arimo', sans-serif;
  font-size: var(--text-ui-md);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-widest);
  color: var(--color-text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.top-bar-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.tool-link {
  font-size: var(--text-ui-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  transition: color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  letter-spacing: var(--tracking-wide);
}

.tool-link:hover {
  color: var(--color-text-primary);
}

.tool-link.active {
  color: var(--color-accent);
  text-shadow: 0 0 12px rgba(184,149,106,0.7), 0 0 24px rgba(184,149,106,0.35);
}

.tool-link.dimmed {
  color: var(--color-text-disabled);
  pointer-events: none;
}

.tool-coming {
  color: var(--color-accent);
  margin-left: 2px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.top-bar-settings {
  width: var(--btn-icon-size-sm);
  height: var(--btn-icon-size-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-3);
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-full);
  font-size: 14px;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.top-bar-settings:hover {
  background: var(--color-surface-4);
  color: var(--color-info);
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: var(--text-ui-md);   /* 14px — UI label base */
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Layout ───────────────────────────────────────────────────────────── */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--color-surface-1);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.2s var(--ease-in-out), min-width 0.2s var(--ease-in-out);
}

.sidebar.collapsed {
  width: 36px;
  min-width: 36px;
}

.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: 8px;
  z-index: 10;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--radius-xs);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  color: var(--color-text-primary);
  background: rgba(255,255,255,0.05);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.15s;
}

.sidebar.collapsed .sidebar-inner {
  opacity: 0;
  pointer-events: none;
}

/* Shared section label for sidebar headers (model-creator, analyzer, …) */
.sidebar-header {
  padding: var(--space-3) var(--space-4) var(--space-2);
  font-size: var(--text-ui-2xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  border-bottom: 1px solid var(--color-border);
}

/* ── History Folders ──────────────────────────────────────────────────────── */

.history-folders {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.history-folders::-webkit-scrollbar { width: 2px; }
.history-folders::-webkit-scrollbar-track { background: transparent; }
.history-folders::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: 2px;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.folder-header:hover { background: rgba(255,255,255,0.04); }

.folder-chevron {
  font-size: 7px;
  color: var(--color-text-muted);
  width: 10px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.project-folder.open > .folder-header .folder-chevron { transform: rotate(90deg); }

.folder-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
  border-radius: 2px;
  cursor: pointer;
}

.folder-name[contenteditable="true"] {
  background: var(--color-surface-3);
  padding: 1px 4px;
  outline: 1px solid var(--color-accent);
  white-space: normal;
  cursor: text;
}

.folder-count {
  font-size: 10px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.folder-grid {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px 4px 8px;
}

.project-folder.open > .folder-grid { display: grid; }

.history-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--color-surface-3);
  border: 0.5px solid var(--color-border);
  transition: transform 0.15s var(--ease-spring), border-color 0.2s;
}

.history-thumb:hover { transform: scale(1.04); border-color: var(--color-border-strong); }
.history-thumb.active { border-color: var(--color-accent); }
.history-thumb.active img { filter: none; }

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.5) brightness(0.7);
  transition: filter 0.2s;
}

.history-thumb:hover img { filter: saturate(0.75) brightness(0.85); }

.history-thumb.pending {
  display: flex;
  align-items: center;
  justify-content: center;
  border-color: var(--color-border-strong);
  border-style: dashed;
  animation: pending-pulse 2s ease-in-out infinite;
}

@keyframes pending-pulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

.thumb-spinner {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--color-border-strong);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.history-empty {
  color: var(--color-text-muted);
  font-size: 11px;
  text-align: center;
  padding: 28px 0;
}

/* ── Canvas ───────────────────────────────────────────────────────────────── */

.canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ── Image Area ───────────────────────────────────────────────────────────── */

.image-area {
  position: absolute;
  inset: 0;
  padding-bottom: var(--ph, 240px);
  transition: padding-bottom 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg);
  background-image:
    linear-gradient(rgba(245,240,235,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245,240,235,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  overflow: hidden;
}

.image-area::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 75% 65% at 50% 50%,
    transparent 25%,
    var(--color-bg) 100%
  );
  pointer-events: none;
  animation: gridPulse 8s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--color-text-muted);
  font-size: 12px;
  user-select: none;
  position: relative;
  z-index: 1;
}

.image-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--color-border-strong);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.generated-image {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  cursor: default;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 1;
}

/* ── Download Button ──────────────────────────────────────────────────────── */


/* ── Upscale Panel ────────────────────────────────────────────────────────── */

.upscale-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  background: rgba(17,15,14,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border-strong);
  border-radius: 20px;
  padding: 14px 14px;
}

.upscale-panel.visible { display: flex; }

.panel-sep {
  width: 100%;
  height: 1px;
  background: var(--color-border-strong);
  flex-shrink: 0;
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  justify-content: space-between;
}

.slider-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.slider-group input[type="range"] {
  -webkit-appearance: none;
  width: 64px;
  height: 2px;
  background: var(--color-border-strong);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border-strong);
  cursor: pointer;
  border: none;
  box-shadow: none;
}

.slider-group input[type="range"]::-moz-range-thumb {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border-strong);
  cursor: pointer;
  border: none;
  box-shadow: none;
}

.slider-val {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  width: 20px;
  text-align: right;
}

.btn-upscale {
  width: 100%;
}

/* ── Upscale Engine Dropdown ─────────────────────────────────────────────── */

.upscale-engine-wrap { position: relative; }

.upscale-engine-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 8px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: border-color 0.2s, color 0.2s;
}

.upscale-engine-trigger:hover,
.upscale-engine-trigger.open { border-color: var(--color-accent); color: var(--color-text-primary); }

.upscale-engine-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.upscale-engine-menu.open { display: block; }

.upscale-engine-opt {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s;
}

.upscale-engine-opt:hover { background: var(--color-surface-3); color: var(--color-text-primary); }
.upscale-engine-opt.active { color: var(--color-accent); }

/* ── Upscale Control Groups ──────────────────────────────────────────────── */

.upscale-ctrl {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upscale-ctrl .toggle-group {
  width: 100%;
  flex-shrink: 1;
}

.upscale-ctrl .toggle-btn {
  flex: 1;
  text-align: center;
}

.upscale-ctrl .select-input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  padding: 5px 8px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}

.upscale-ctrl .select-input:focus { border-color: var(--color-accent); }

.upscale-prompt {
  width: 100%;
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 10px;
  font-family: inherit;
  padding: 5px 8px;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.upscale-prompt:focus { border-color: var(--color-accent); }
.upscale-prompt::placeholder { color: var(--color-text-disabled); }

.upscale-skin-note { padding: 2px 0; }

/* ── Floating Prompt Panel ────────────────────────────────────────────────── */

.prompt-panel {
  position: absolute;
  bottom: var(--panel-bottom);
  left: 50%;
  transform: translateX(-50%);
  width: min(var(--panel-width), calc(100% - var(--panel-side-gap)));
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--color-border-strong);
  border-radius: var(--panel-radius);
  z-index: 10;
}

/* ── Panel Bar ────────────────────────────────────────────────────────────── */

.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Top: panel-padding-top (16px). Seiten: panel-padding-x (16px). Kein Bottom-Padding. */
  padding: var(--panel-padding-top) var(--panel-padding-x) var(--space-2);
  flex-shrink: 0;
}

.panel-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: var(--space-2); /* +8px → Button auf Linie mit Prompt-Text */
}

.panel-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* ── Project Chip ─────────────────────────────────────────────────────────── */

.project-wrap {
  position: relative;
}

.project-chip {
  background: var(--color-surface-3);
  border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-ui-xs);
  font-weight: var(--weight-medium);
  height: 28px;
  padding: 0 var(--space-3);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: var(--tracking-wide);
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.project-chip:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-4);
}

.project-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 0;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
  z-index: 50;
  min-width: 168px;
  box-shadow: var(--shadow-lg);
}

.project-menu.open { display: block; }

.project-menu-item {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-ui-xs);
  font-weight: var(--weight-regular);
  color: var(--color-text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast);
  white-space: nowrap;
}

.project-menu-item:hover {
  background: var(--color-surface-4);
  color: var(--color-text-primary);
}

.project-menu-item.active { color: var(--color-accent); }

.project-menu-item.new-project {
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-1);
  padding-top: var(--space-2);
}

/* ── Mode Tabs ────────────────────────────────────────────────────────────── */

.mode-tabs {
  display: flex;
  background: var(--color-surface-3);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
}

.mode-tab {
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-ui-2xs);
  font-weight: var(--weight-medium);
  padding: 1px var(--space-2);
  height: 16px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: var(--tracking-wide);
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.mode-tab:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-4);
}

.mode-tab.active {
  background: var(--color-surface-4);
  color: var(--color-accent);
}

.mode-tab.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Ad Toggle ────────────────────────────────────────────────────────────── */

.ad-toggle {
  display: none;
  width: var(--btn-icon-size-sm);
  height: var(--btn-icon-size-sm);
  background: var(--color-surface-3);
  border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
  font-family: inherit;
  flex-shrink: 0;
}

.ad-toggle.visible { display: flex; }

.ad-toggle:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-4);
}

.ad-toggle.active {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* ── Panel Minimize ───────────────────────────────────────────────────────── */

.panel-minimize {
  width: var(--btn-icon-size-sm);
  height: var(--btn-icon-size-sm);
  background: var(--color-surface-3);
  border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
  font-family: inherit;
  flex-shrink: 0;
}

.panel-minimize:hover {
  background: var(--color-surface-4);
  color: var(--color-text-primary);
}

/* ── Panel Body ───────────────────────────────────────────────────────────── */

.panel-body {
  padding: 0 var(--panel-padding-x) var(--panel-padding-bot);
  /* Links/Rechts = panel-padding-x (16px), unten = panel-padding-bot (16px) */
}

.prompt-panel.minimized .panel-body { display: none; }

/* ── Refs Strip ───────────────────────────────────────────────────────────── */

.refs-strip {
  display: flex;
  align-items: center;
  gap: 4px;
}

.refs-thumbs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ref-thumb-sm {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
}

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

.ref-remove-sm {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

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

.refs-add {
  background: none;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  width: var(--btn-icon-size-sm);
  height: var(--btn-icon-size-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.refs-add:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* ── Refs Add Dropdown ─────────────────────────────────────────────────────── */

.refs-strip {
  position: relative;
}

.refs-add-menu {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  min-width: 170px;
  overflow: hidden;
}

.refs-add-menu.open {
  display: flex;
}

.refs-add-opt {
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 13px;
  text-align: left;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s;
}

.refs-add-opt:hover {
  background: var(--color-surface-3);
}

.refs-strip.drag-over .refs-add {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SKELETON LOADING SYSTEM
   ─────────────────────────────────────────────────────────────────────────
   Text skeletons shown while content/enhanced prompt is loading.
   Usage:
     <div class="field-skeleton">
       <div class="skeleton-line" style="width:92%"></div>
       <div class="skeleton-line" style="width:78%"></div>
       <div class="skeleton-line skeleton-line--short" style="width:55%"></div>
     </div>
   Modifiers: --short (caption height), --heading (larger height)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Shimmer gradient — warm subtle pulse aligned to dark bg */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes skeleton-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Container */
.field-skeleton {
  display: none;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  min-height: 80px;
  animation: skeleton-fade-in var(--duration-slow) var(--ease-out);
}

.field-skeleton.visible {
  display: flex;
}

/* Base skeleton line — matches body text height */
.skeleton-line {
  height: 13px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    90deg,
    var(--color-surface-3)  0%,
    var(--color-surface-4) 40%,
    var(--color-surface-3) 60%,
    var(--color-surface-3) 100%
  );
  background-size: 250% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

/* Slight stagger so lines don't pulse in lockstep */
.skeleton-line:nth-child(2) { animation-delay: 0.15s; }
.skeleton-line:nth-child(3) { animation-delay: 0.30s; }
.skeleton-line:nth-child(4) { animation-delay: 0.45s; }
.skeleton-line:nth-child(5) { animation-delay: 0.60s; }

/* Caption-height line */
.skeleton-line--short {
  height: 10px;
}

/* Heading-height line */
.skeleton-line--heading {
  height: 18px;
}

/* Paragraph gap — extra space after a heading skeleton */
.skeleton-line--heading + .skeleton-line {
  margin-top: var(--space-2);
}

/* Standalone skeleton block (not field-specific) */
.skeleton-block {
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--color-surface-3)  0%,
    var(--color-surface-4) 40%,
    var(--color-surface-3) 60%,
    var(--color-surface-3) 100%
  );
  background-size: 250% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

/* ── Prompt Field ─────────────────────────────────────────────────────────── */

.prompt-field {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
  font-size: var(--text-caption);  /* 14px — 8px-grid aligned, kompakt im Panel */
  font-weight: var(--weight-regular);
  padding: var(--space-2) 0 var(--space-2) var(--space-2); /* 8px vertikal, +8px links */
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: var(--leading-relaxed);
  min-height: 48px;   /* 6×8px — genug für 1-2 Zeilen ohne übermäßig Leerraum */
  max-height: 260px;
  overflow-y: auto;
}

.prompt-field::placeholder {
  color: var(--color-text-muted);
  font-weight: var(--weight-light);
}

/* ── Art Direction ────────────────────────────────────────────────────────── */

.art-direction {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 4px;
}

.art-direction.visible { display: flex; }

.ad-item {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
  padding-left: 12px;
  position: relative;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.ad-item::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--color-border-strong);
  font-weight: 400;
  font-size: 10px;
}

/* ── Panel Controls ───────────────────────────────────────────────────────── */

.panel-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-4);
  flex-wrap: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOGGLE GROUPS & SETTING CONTROLS
   ─────────────────────────────────────────────────────────────────────────
   Pill container, surface-elevated. No prominent border.
   Active state: elevated surface + accent color text.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Toggle Group Container — Pill ───────────────────────────────────────── */

.toggle-group {
  display: flex;
  background: var(--color-surface-3);
  border-radius: var(--control-radius);
  padding: var(--space-1);
  gap: var(--space-1);
  flex-shrink: 0;
}

/* ── Toggle Button ───────────────────────────────────────────────────────── */

.toggle-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-ui-2xs);
  font-weight: var(--weight-medium);
  padding: 2px 8px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: var(--tracking-wide);
}

.toggle-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-4);
}

.toggle-btn.active {
  background: var(--color-surface-4);
  color: var(--color-accent);
}

/* Info/Settings context — blue active state */
.toggle-group--info .toggle-btn.active {
  color: var(--color-info);
  background: var(--color-info-subtle);
}

/* ── Ratio Dropdown ───────────────────────────────────────────────────────── */

.ratio-dropdown {
  position: relative;
  flex-shrink: 0;
}

.ratio-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface-3);
  border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  font-size: var(--text-ui-xs);
  font-weight: var(--weight-medium);
  padding: 3px var(--space-3);
  height: 28px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
  min-width: 80px;
}

.ratio-trigger:hover {
  background: var(--color-surface-4);
  color: var(--color-text-primary);
}

.ratio-trigger.open {
  background: var(--color-surface-4);
  color: var(--color-accent);
}

.ratio-chevron {
  font-size: 9px;
  color: var(--color-text-muted);
  margin-left: auto;
  padding-left: var(--space-1);
}

.ratio-icon-sm {
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: 1px;
  flex-shrink: 0;
  opacity: 0.7;
}

.ratio-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 0;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  z-index: 50;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  min-width: 168px;
  box-shadow: var(--shadow-lg);
}

.ratio-menu.open { display: grid; }

.ratio-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-ui-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast);
  white-space: nowrap;
}

.ratio-option:hover    { background: var(--color-surface-4); color: var(--color-text-primary); }
.ratio-option.active   { color: var(--color-accent); }
.ratio-option.disabled { opacity: 0.2; pointer-events: none; }
.ratio-option .ratio-icon-sm { border-color: currentColor; }

/* ── Select Input ─────────────────────────────────────────────────────────── */

.select-input {
  background: var(--color-surface-3);
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--text-ui-xs);
  font-weight: var(--weight-medium);
  padding: var(--space-1) var(--space-3);
  height: 28px;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.select-input:hover  { background: var(--color-surface-4); color: var(--color-text-primary); }
.select-input:focus  { outline: 2px solid var(--color-focus-ring); outline-offset: 1px; }

/* ── Advanced Toggle Button ───────────────────────────────────────────────── */

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTON SYSTEM
   ─────────────────────────────────────────────────────────────────────────
   All buttons use --btn-radius (9999px pill) by default.
   Variants: primary, secondary, ghost
   Sizes:    sm (28px), md (36px — default), lg (44px)
   Special:  icon-btn (square→circle), canvas overlay buttons
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Shared Button Base ───────────────────────────────────────────────────── */

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-smart,
.btn-upscale {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height-md);
  padding: var(--btn-padding-md);
  border-radius: var(--btn-radius);
  border: none;
  font-family: var(--btn-font-family);
  font-size: var(--btn-font-size-md);
  font-weight: var(--btn-font-weight);
  letter-spacing: var(--btn-tracking);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition:
    background var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-slow) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-ghost:focus-visible,
.btn-smart:focus-visible,
.btn-upscale:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-ghost:disabled,
.btn-smart:disabled,
.btn-upscale:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Primary Button — Gold Glow ──────────────────────────────────────────── */
/* Used for main CTAs: Erstellen, Upscale                                     */

.btn-primary,
.btn-smart,
.btn-upscale {
  position: relative;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-500));
  color: var(--brand-100);
  overflow: hidden;
  box-shadow: var(--glow-accent);
}

/* Glow layer */
.btn-primary::before,
.btn-smart::before,
.btn-upscale::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-400));
  filter: blur(12px);
  opacity: 0.50;
  transition: opacity var(--duration-slow) var(--ease-out),
              filter var(--duration-slow) var(--ease-out);
  border-radius: inherit;
  z-index: 0;
}

.btn-primary:hover::before,
.btn-smart:hover::before,
.btn-upscale:hover::before {
  opacity: 0.90;
  filter: blur(14px);
}

.btn-primary:hover,
.btn-smart:hover,
.btn-upscale:hover {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-400));
  color: var(--brand-100);
  box-shadow: var(--glow-accent-hover);
}

.btn-primary:active,
.btn-smart:active,
.btn-upscale:active {
  transform: scale(0.98);
}

/* Content layer above glow */
.btn-primary > *,
.btn-smart > *,
.btn-upscale > * {
  position: relative;
  z-index: 1;
}

/* ── Secondary Button — Surface Elevated ─────────────────────────────────── */
/* Filled surface, no prominent border                                        */

.btn-secondary {
  background: var(--color-surface-4);
  color: var(--brand-600);
}

.btn-secondary:hover {
  background: var(--color-surface-4);
  color: var(--brand-400);
}

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

/* ── Ghost Button — Transparent ──────────────────────────────────────────── */

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

.btn-ghost:hover {
  background: var(--color-surface-3);
  color: var(--color-text-primary);
}

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

/* ── Size Modifiers ──────────────────────────────────────────────────────── */

.btn-sm {
  height: var(--btn-height-sm);
  padding: var(--btn-padding-sm);
  font-size: var(--btn-font-size-sm);
}

.btn-lg {
  height: var(--btn-height-lg);
  padding: var(--btn-padding-lg);
  font-size: var(--btn-font-size-lg);
}

/* ── Icon Button — Surface Elevated, Circular ────────────────────────────── */
/* For settings, toggles, and small action controls                           */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--btn-icon-size-md);
  height: var(--btn-icon-size-md);
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-surface-3);
  color: var(--color-text-muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.btn-icon:hover {
  background: var(--color-surface-4);
  color: var(--color-text-primary);
}

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

.btn-icon.btn-icon--sm {
  width: var(--btn-icon-size-sm);
  height: var(--btn-icon-size-sm);
  font-size: 12px;
}

.btn-icon.btn-icon--lg {
  width: var(--btn-icon-size-lg);
  height: var(--btn-icon-size-lg);
  font-size: 16px;
}

/* Info/Settings variant — blue accent on active */
.btn-icon.btn-icon--info {
  color: var(--color-info);
}

.btn-icon.btn-icon--info:hover {
  background: var(--color-info-subtle);
  color: var(--color-info-hover);
}

/* ── Settings Gear in Panel Controls ─────────────────────────────────────── */
/* (was .btn-advanced-toggle) */

.btn-advanced-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--btn-icon-size-sm);
  height: var(--btn-icon-size-sm);
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-surface-3);
  color: var(--color-text-muted);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
  font-family: inherit;
}

.btn-advanced-toggle:hover {
  background: var(--color-surface-4);
  color: var(--color-info);
}

.btn-advanced-toggle.active {
  background: var(--color-info-subtle);
  color: var(--color-info);
}

/* ── Primary Button Layout Override ──────────────────────────────────────── */

.btn-smart { margin-left: auto; }

/* ── Canvas Overlay Buttons ──────────────────────────────────────────────── */
/* Floating over the generated image — ghost pill with backdrop blur         */

.btn-panel-action {
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  font-size: var(--text-ui-2xs);
  font-weight: var(--weight-medium);
  padding: 2px 8px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: var(--tracking-wide);
}

.btn-panel-action:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-4);
}

.btn-panel-action.added,
.toggle-btn.added {
  color: var(--color-success) !important;
}

.panel-actions-cluster {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.btn-panel-download {
  font-size: 13px;
}


/* ── Advanced Panel ───────────────────────────────────────────────────────── */

.advanced-panel {
  display: none;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
}

.advanced-panel.visible { display: flex; }

/* ── Toast ────────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: rgba(17, 15, 14, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  font-size: var(--text-caption);   /* 14px — readable but compact */
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap;
  pointer-events: auto;
  animation: toastIn 0.2s var(--ease-spring) forwards;
}

.toast.toast-out {
  animation: toastOut 0.2s var(--ease-in-out) forwards;
}

.toast-icon {
  font-size: var(--text-ui-md);
  flex-shrink: 0;
}

.toast.toast-warn  { border-color: rgba(234,179,8,0.3); }
.toast.toast-warn  .toast-icon { color: var(--color-warning); }

.toast.toast-error { border-color: rgba(239,68,68,0.3); }
.toast.toast-error .toast-icon { color: var(--color-error); }

.toast.toast-info  .toast-icon { color: var(--color-accent); }

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

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0)    scale(1);    }
  to   { opacity: 0; transform: translateY(-4px) scale(0.97); }
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.lightbox.open { display: flex; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.92);
  cursor: zoom-out;
}

.lightbox-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 1;
  max-width: 88vw;
}

.lightbox-img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  cursor: zoom-out;
  display: block;
}

.lightbox-prompt {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.lightbox-prompt-text {
  flex: 1;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary);
  line-height: 1.65;
  word-break: break-word;
  letter-spacing: 0.01em;
}

.lightbox-copy {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.lightbox-copy:hover { border-color: var(--color-accent); color: var(--color-accent); }
.lightbox-copy.copied { border-color: var(--color-success); color: var(--color-success); }

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
  transition: color 0.15s;
}

.lightbox-close:hover { color: var(--color-text-primary); }

/* ── Character Picker Modal ────────────────────────────────────────────────── */

.char-picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
}

.char-picker-overlay.open {
  display: flex;
}

.char-picker-modal {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  width: 480px;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.char-picker-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-3) var(--space-4);
  flex-shrink: 0;
}

.char-picker-search {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  color: var(--color-text-base);
  font-size: var(--text-xs);
  font-family: inherit;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}

.char-picker-search::placeholder {
  color: var(--color-text-muted);
}

.char-picker-search:focus {
  border-color: var(--color-accent);
  background: var(--color-surface-3);
}

.char-picker-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.12s;
  flex-shrink: 0;
}

.char-picker-close:hover {
  color: var(--color-text-primary);
}

.char-picker-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.char-picker-back {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.12s;
  flex-shrink: 0;
}

.char-picker-back:hover {
  color: var(--color-text-primary);
}

.char-picker-sub-title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-picker-grid {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
  align-content: start;
}

.char-picker-card {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.char-picker-card:hover {
  background: var(--color-surface-3);
  transform: translateY(-1px);
}

.char-picker-card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.char-picker-card span {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-ui-2xs);
  color: var(--color-text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  padding: var(--space-8) 0;
}

/* ── Character Chip ────────────────────────────────────────────────────────── */

.char-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--color-accent-subtle);
  border: 1px solid var(--color-accent);
  border-radius: 20px;
  padding: 3px 6px 3px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}

.char-chip:hover {
  border-color: var(--color-accent-hover);
}

.char-chip-name {
  font-size: 12px;
  color: var(--color-accent);
  font-weight: 500;
  white-space: nowrap;
}

.char-chip-remove {
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: 15px;
  font-weight: 300;
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
  padding: 0 2px;
  transition: opacity 0.12s;
}

.char-chip-remove:hover {
  opacity: 1;
}

/* ── Shared Slice Picker ─────────────────────────────────────────────────── */
.slice-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.slice-picker-modal {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: min(560px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
.slice-picker-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.slice-picker-title {
  font-size: var(--text-ui-md);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-right: auto;
}
.slice-picker-close {
  width: 28px; height: 28px;
  background: none; border: none;
  color: var(--color-text-muted);
  font-size: 20px; cursor: pointer;
}
.slice-picker-close:hover { color: var(--color-text-primary); }
.slice-picker-filters {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.slice-picker-list {
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
/* Analysis sections in slice picker */
.sp-analysis {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.sp-analysis-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.sp-analysis-header:hover { background: var(--color-surface-3); }
.sp-chevron {
  font-size: 10px;
  color: var(--color-text-muted);
  width: 14px;
  flex-shrink: 0;
}
.sp-analysis-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-surface-4);
}
.sp-analysis-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-analysis-count {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.sp-analysis-body {
  display: flex;
  flex-direction: column;
}
.sp-slice-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-6);
  cursor: pointer;
  transition: background var(--duration-fast);
  border-top: 1px solid var(--color-border-subtle);
}
.sp-slice-row:hover { background: var(--color-surface-3); }
.sp-checkbox {
  flex-shrink: 0;
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.sp-slice-badge {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
  width: 80px;
}
.sp-slice-summary {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── Slice Chips in Panel Bar (Kampagne) ─────────────────────────────────── */
.slice-chips {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  flex-wrap: wrap;
}
.slice-chip-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background var(--duration-fast);
  white-space: nowrap;
}
.slice-chip-inline:hover { background: rgba(255,255,255,0.05); }
.slice-chip-label { pointer-events: none; }
.slice-chip-remove {
  background: none;
  border: none;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
}
.slice-chip-remove:hover { opacity: 1; }

/* ── Wallet Panel ────────────────────────────────────────────────────────── */
.wallet-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-300);
}
.wallet-balance { display: flex; align-items: baseline; gap: 4px; }
.wallet-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-400); }
.wallet-amount { font-weight: 600; color: var(--brand-300); font-variant-numeric: tabular-nums; }
.wallet-reserved { font-size: 11px; color: var(--gray-400); }
.wallet-topup {
  padding: 3px 10px;
  border: 1px solid var(--gray-600);
  border-radius: 4px;
  background: transparent;
  color: var(--gray-200);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.wallet-topup:hover { border-color: var(--brand-300); color: var(--brand-200); }

/* ── Cost Badge (on action buttons) ──────────────────────────────────────── */
.cost-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: var(--gray-750);
  color: var(--brand-300);
  vertical-align: middle;
  pointer-events: none;
}
.cost-badge:empty { display: none; }
.cost-badge--insufficient {
  background: rgba(220, 60, 60, 0.15);
  color: #e06060;
}
