/* ─────────────────────────────────────────────────────────────
   AdFlow Campaign Studio — Light SaaS Theme
   ───────────────────────────────────────────────────────────── */

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

:root {
  /* Backgrounds */
  --bg:          #f4f5f7;
  --surface:     #ffffff;
  --surface-2:   #f9fafb;

  /* Borders */
  --border:      #e5e7eb;
  --border-md:   #d1d5db;

  /* Text */
  --text:        #111827;
  --text-2:      #4b5563;
  --text-3:      #9ca3af;

  /* Accent */
  --accent:      #4f46e5;
  --accent-h:    #4338ca;
  --accent-dim:  rgba(79, 70, 229, 0.08);
  --accent-dim2: rgba(79, 70, 229, 0.14);

  /* Status */
  --success:  #16a34a;
  --warning:  #d97706;
  --danger:   #dc2626;
  --success-bg: #f0fdf4;
  --warning-bg: #fffbeb;
  --danger-bg:  #fef2f2;

  /* Radii */
  --r-sm: 5px;
  --r:    8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 8px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.14), 0 8px 20px rgba(0,0,0,0.08);

  /* Layout */
  --topbar-h:   52px;
  --panel-w:    272px;
  --context-w:  240px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Login Screen ───────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  background: #0f1117;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #1a1d27;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 40px 36px 36px;
  box-shadow: 0 32px 64px rgba(0,0,0,0.5);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.login-logo-mark { color: var(--accent); font-size: 1.1rem; }
.login-subtitle {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.35);
  margin-bottom: 32px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.02em;
}
.login-input {
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.login-input::placeholder { color: rgba(255,255,255,0.2); }
.login-input:focus {
  border-color: var(--accent);
  background: rgba(79,70,229,0.08);
}
.login-error {
  font-size: 0.8125rem;
  color: #f87171;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: 6px;
  padding: 8px 12px;
}
.login-btn {
  margin-top: 4px;
  padding: 11px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
}
.login-btn:hover { background: var(--accent-h); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-hint { font-weight: 400; color: rgba(255,255,255,0.3); font-size: 0.6875rem; }

.login-tabs {
  display: flex;
  gap: 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 20px;
}
.login-tab {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,0.4);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.login-tab.active {
  background: var(--accent);
  color: #fff;
}

/* Logout button in topbar */
.topbar-btn-logout {
  padding: 6px 10px;
  font-size: 1rem;
  color: var(--text-3);
  border-color: transparent;
  background: transparent;
}
.topbar-btn-logout:hover { color: var(--danger); border-color: transparent; background: var(--danger-bg); }

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted   { color: var(--text-3); }
.text-muted-sm { color: var(--text-3); font-size: 0.8125rem; }
.text-accent  { color: var(--accent); }
.loading-text { color: var(--text-3); font-size: 0.8125rem; padding: 12px 0; }

/* ── Toast ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  background: var(--text);
  color: #fff;
  border-radius: var(--r);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  max-width: 320px;
  border-left: 3px solid transparent;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 200;
}
.topbar-start { display: flex; align-items: center; gap: 4px; min-width: 0; }
.topbar-end   { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.app-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  padding-right: 4px;
}
.app-logo-mark { color: var(--accent); font-size: 1rem; }

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 8px;
  flex-shrink: 0;
}

/* Switchers */
.switcher { position: relative; }
.switcher-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
  max-width: 200px;
}
.switcher-btn:hover { background: var(--bg); border-color: var(--border); }
.switcher-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.switcher-caret { color: var(--text-3); font-size: 0.625rem; }

.switcher-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  z-index: 300;
  overflow: hidden;
  padding: 4px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text);
  transition: background 0.1s;
}
.dropdown-item:hover  { background: var(--bg); }
.dropdown-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.dropdown-item-name   { font-weight: 500; }
.dropdown-item-sub    { font-size: 0.75rem; color: var(--text-3); }
.dropdown-sep   { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-action {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 500;
  border-radius: var(--r-sm);
  transition: background 0.1s;
}
.dropdown-action:hover { background: var(--accent-dim); }

/* Topbar buttons */
.topbar-btn {
  padding: 6px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.topbar-btn:hover { border-color: var(--border-md); color: var(--text); background: var(--bg); }
.topbar-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.topbar-btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }
.topbar-btn-admin {
  text-decoration: none;
  font-size: 0.75rem;
  color: var(--text-2);
  background: var(--surface-2);
  border-color: var(--border);
}
.topbar-btn-admin:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ── App Body ───────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Campaign Panel (left) ─────────────────────────────────── */
.campaign-panel {
  width: var(--panel-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-campaign-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.panel-campaign-status {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.panel-mode-badge {
  font-size: 0.6875rem;
  padding: 2px 7px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-tab {
  flex: 1;
  padding: 9px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.12s;
  margin-bottom: -1px;
}
.panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.panel-tab:hover:not(.active) { color: var(--text-2); }

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Upload Slots ───────────────────────────────────────────── */
.upload-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.upload-slot-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 5px;
}
.drop-zone {
  border: 1.5px dashed var(--border-md);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  aspect-ratio: 1;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-zone.has-file { border-style: solid; border-color: var(--border); }
.drop-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
}
.drop-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.drop-icon { font-size: 1.25rem; color: var(--text-3); }
.drop-text { font-size: 0.6875rem; color: var(--text-3); text-align: center; }
.drop-link { color: var(--accent); cursor: pointer; }

.drop-zone-sm { aspect-ratio: 16/7; }

/* ── Field Groups ───────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
}
.field-hint { font-weight: 400; color: var(--text-3); }

/* ── AI Toolbar ─────────────────────────────────────────────── */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 18px;
}
.ai-toolbar {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.ai-toolbar-top {
  display: flex;
  align-items: center;
  gap: 3px;
}
.ai-btn-wide {
  width: 100%;
  justify-content: center;
}
.ai-provider-select {
  font-size: 0.67rem;
  font-family: inherit;
  padding: 2px 20px 2px 6px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  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='M1 1l3 3 3-3' stroke='%239ca3af' stroke-width='1.2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  transition: border-color 0.15s, color 0.15s;
}
.ai-provider-select:focus { outline: none; border-color: var(--accent); color: var(--text); }
.ai-provider-select:disabled { opacity: 0.4; cursor: not-allowed; }
.ai-btn {
  font-size: 0.67rem;
  font-family: inherit;
  padding: 0 7px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
  letter-spacing: 0.01em;
}
.ai-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(91,106,240,0.3);
}
.ai-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.ai-btn-generate {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(91,106,240,0.25);
  font-weight: 500;
}
.ai-btn-generate:hover:not(:disabled) {
  background: rgba(91,106,240,0.18);
}

/* ── Avoid While Generating Section ────────────────────────── */
/* ── Avoid While Generating ─────────────────────────────────── */
/* Section: NO overflow:hidden — lets the body expand freely in normal flow */
.avoid-section {
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-top: 2px;
  overflow: visible;
}
/* Toggle button: rounded top corners, square bottom when open */
.avoid-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  cursor: pointer;
  background: var(--surface-2);
  border: none;
  border-radius: var(--r) var(--r) 0 0;
  width: 100%;
  text-align: left;
  user-select: none;
  pointer-events: auto;
}
.avoid-section:not(.open) .avoid-toggle { border-radius: var(--r); }
.avoid-toggle:hover { background: var(--accent-dim); }
.avoid-toggle-icon { font-size: 0.78rem; line-height: 1; }
.avoid-toggle-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  flex: 1;
}
.avoid-toggle-hint {
  font-size: 0.65rem;
  color: var(--text-3);
  flex: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avoid-chevron {
  font-size: 0.65rem;
  color: var(--text-3);
  transition: transform 0.25s ease;
  margin-left: auto;
  flex-shrink: 0;
  display: inline-block;
}
.avoid-section.open .avoid-chevron    { transform: rotate(0deg); }
.avoid-section:not(.open) .avoid-chevron { transform: rotate(-90deg); }
/* Body: overflow:hidden is required for max-height animation */
.avoid-body {
  max-height: 600px;
  opacity: 1;
  overflow: hidden;
  transition: all 0.25s ease;
  padding: 10px 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* DEBUG: confirm body is rendering */
  outline: 2px solid red;
  outline-offset: -2px;
}
.avoid-body.hidden {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: transparent;
}
.avoid-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.avoid-chip {
  font-size: 0.65rem;
  padding: 3px 7px;
  border: 1px solid var(--border-md);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  line-height: 1.5;
}
.avoid-chip:hover { border-color: var(--accent); color: var(--accent); }
.avoid-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.avoid-input-wrap { display: flex; flex-direction: column; gap: 3px; }
.avoid-textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 120px;
  height: auto;
  resize: none;
  overflow: hidden;
  font-size: 0.72rem;
  padding: 7px 8px 7px;
  border: 1px solid var(--border-md);
  border-radius: var(--r-sm);
  color: var(--text);
  background: var(--surface-2);
  font-family: inherit;
  line-height: 1.45;
  pointer-events: auto;
  user-select: text;
  cursor: text;
}
.avoid-textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.avoid-counter {
  font-size: 0.6rem;
  color: var(--text-3);
  text-align: right;
  pointer-events: none;
  line-height: 1;
}

/* ── Concept Strategy Presets ───────────────────────────────── */
.ai-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.ai-preset-label {
  font-size: 0.67rem;
  color: var(--text-3);
  margin-right: 1px;
  white-space: nowrap;
}
.ai-preset-chip {
  font-size: 0.67rem;
  font-family: inherit;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.14s;
  white-space: nowrap;
}
.ai-preset-chip:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(91,106,240,0.3);
}

.field-input, .field-textarea, .field-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.field-input:focus, .field-textarea:focus, .field-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.field-textarea { resize: vertical; min-height: 56px; line-height: 1.5; }
.field-row { display: flex; gap: 8px; }
.field-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }

/* ── Ratio Selector ─────────────────────────────────────────── */
.ratio-selector { display: flex; gap: 6px; }
.ratio-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.ratio-btn:hover { border-color: var(--border-md); color: var(--text-2); }
.ratio-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.ratio-box { border: 1.5px solid currentColor; border-radius: 2px; flex-shrink: 0; }

/* ── Volume Input ───────────────────────────────────────────── */
.volume-input-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.volume-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.volume-step-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: none;
  color: var(--text-2);
  font-size: 1.125rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  user-select: none;
  line-height: 1;
}
.volume-step-btn:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.volume-step-btn:active:not(:disabled) { background: var(--accent-dim); color: var(--accent); }
.volume-step-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.volume-step-btn:first-child { border-right: 1px solid var(--border); }
.volume-step-btn:last-child  { border-left:  1px solid var(--border); }
.volume-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  border: none;
  outline: none;
  padding: 7px 4px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  font-family: inherit;
  -moz-appearance: textfield;
}
.volume-input::-webkit-inner-spin-button,
.volume-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.volume-hint {
  font-size: 0.6875rem;
  color: var(--text-3);
  margin-top: 3px;
  display: block;
}
.volume-error {
  font-size: 0.6875rem;
  color: var(--danger);
  margin-top: 2px;
  font-weight: 500;
}
.volume-input-wrap.has-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }

/* ── Speed Mode Selector ────────────────────────────────────── */
.speed-selector {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
}
.speed-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 7px 4px;
  background: var(--surface-2);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
}
.speed-btn:last-child { border-right: none; }
.speed-btn:hover { background: var(--bg); color: var(--text-2); }
.speed-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.speed-btn-name {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}
.speed-btn-tag {
  font-size: 0.625rem;
  font-weight: 500;
  opacity: 0.7;
  line-height: 1;
}

/* ── Generation timer ───────────────────────────────────────── */
.ws-gen-timer-sep {
  color: var(--accent);
  opacity: 0.5;
  font-size: 0.75rem;
}
.ws-gen-timer {
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: 0.02em;
}

/* ── Generate Button ────────────────────────────────────────── */
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  width: 100%;
  margin-top: 4px;
}
.btn-generate:hover:not(:disabled) { background: var(--accent-h); box-shadow: 0 2px 8px rgba(79,70,229,0.35); }
.btn-generate:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-generate-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-generate-outline:hover:not(:disabled) { background: var(--accent-dim); box-shadow: none; }

/* Format chips */
.format-chips, .persona-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.format-chip, .persona-chip {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.12s;
  background: var(--surface-2);
}
.format-chip:hover, .persona-chip:hover { border-color: var(--border-md); color: var(--text-2); }
.format-chip.selected, .persona-chip.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Concept plan area */
.concept-plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 6px;
}
.concept-plan-title { font-size: 0.75rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.07em; }
.btn-icon-sm {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.btn-icon-sm:hover { border-color: var(--border-md); color: var(--text); }

.concept-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.concept-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px;
  position: relative;
}
.concept-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 6px;
}
.concept-card-format {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.concept-card-persona {
  font-size: 0.6875rem;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.concept-card-angle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}
.concept-card-hook {
  font-size: 0.7rem;
  color: var(--text-2);
  font-style: italic;
  line-height: 1.4;
  margin-bottom: 6px;
}
.concept-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.concept-card-dist {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 7px;
}
.concept-card-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-3);
  padding: 2px;
  border-radius: var(--r-sm);
  transition: color 0.12s;
}
.concept-card-remove:hover { color: var(--danger); }

/* ── Concept Plan Workspace (center panel) ──────────────────── */
.concept-plan-workspace {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.concept-plan-ws-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.concept-plan-ws-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}
.concept-plan-ws-sub {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-left: 8px;
}
.concept-plan-ws-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}
.concept-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 16px 20px 24px;
  align-content: start;
}

/* ── Workspace (center) ─────────────────────────────────────── */
.workspace {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Workspace tab bar */
.workspace-tabbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  height: 44px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.workspace-tabs      { display: flex; align-items: center; gap: 0; height: 100%; }
.workspace-tabbar-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.workspace-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.12s;
  margin-bottom: -1px;
  white-space: nowrap;
}
.workspace-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.workspace-tab:hover:not(.active) { color: var(--text-2); }

.ws-tab-badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  line-height: 1.4;
}

/* Live generation indicator */
.ws-gen-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent-dim);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.ws-gen-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: gen-pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes gen-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Workspace panels */
.workspace-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.badge-neutral { background: var(--bg); border: 1px solid var(--border); color: var(--text-3); }

.board-search {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  width: 140px;
  transition: border-color 0.15s;
}
.board-search:focus { border-color: var(--accent); }
.board-filter {
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* Board empty state */
.board-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  text-align: center;
}
.board-empty-icon   { font-size: 2.5rem; color: var(--text-3); }
.board-empty-title  { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.board-empty-text   { font-size: 0.875rem; color: var(--text-2); max-width: 340px; line-height: 1.6; }

/* ── Generation Board Grid (masonry) ───────────────────────── */
.board-grid {
  padding: 16px 20px 32px;
  column-width: 210px;
  column-gap: 12px;
}

.board-card {
  break-inside: avoid;
  page-break-inside: avoid;
  display: inline-block;
  width: 100%;
  vertical-align: top;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  position: relative;
}
.board-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--border-md);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.board-card-img-wrap {
  width: 100%;
  overflow: hidden;
  background: var(--surface-2);
  position: relative;
  /* No forced aspect-ratio — images define their own height */
}
.board-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s;
}
.board-card-img-fail {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--text-3);
  font-size: 0.72rem;
  background: var(--surface-2);
}
.board-card-footer {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-top: 1px solid var(--border);
}
.board-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}
.board-card-tag {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}
.board-card-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-draft    { background: var(--border-md); }
.status-approved { background: var(--success); }
.status-rejected { background: var(--danger); }

/* Hover overlay actions */
.board-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  padding: 10px;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.18s;
}
.board-card:hover .board-card-overlay { opacity: 1; }
.board-card-action {
  flex: 1;
  padding: 6px 8px;
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  text-align: center;
}
.board-card-action:hover { background: #fff; }

/* ── Skeleton loading ─────────────────────────────────────────*/
.board-card.skeleton { cursor: default; pointer-events: none; }
.board-card.skeleton .board-card-img-wrap {
  background: linear-gradient(90deg, #f1f5f9 25%, #e8ecf2 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.board-card.skeleton .board-card-footer {
  background: linear-gradient(90deg, #f8f9fb 25%, #f0f2f6 50%, #f8f9fb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite 0.2s;
  height: 36px;
}
@keyframes shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Generation Slot Cards ───────────────────────────────────── */
.board-card.gen-slot-card { cursor: default; pointer-events: none; }

.slot-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}

/* Queued — neutral shimmer */
.slot-queued {
  background: linear-gradient(90deg, #f1f5f9 25%, #e8ecf2 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite;
}

/* Processing — accent shimmer */
.slot-processing {
  background: linear-gradient(90deg, #eff0ff 25%, #dde0ff 50%, #eff0ff 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

/* Retrying — amber pulse */
.slot-retrying {
  background: linear-gradient(90deg, #fffbeb 25%, #fef3c7 50%, #fffbeb 75%);
  background-size: 200% 100%;
  animation: shimmer 0.9s infinite;
}

/* Failed — muted red */
.slot-failed {
  background: #fff5f5;
  border: 1px solid rgba(220,38,38,0.15);
}

.slot-icon {
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0.7;
}
.slot-retry-icon {
  color: #d97706;
  opacity: 1;
  font-size: 1.6rem;
}
.slot-failed .slot-icon { color: #dc2626; opacity: 0.8; }

.slot-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.slot-processing .slot-label { color: #5b6af0; }
.slot-retrying .slot-label   { color: #d97706; }
.slot-failed .slot-label     { color: #dc2626; }

.slot-sub {
  font-size: 0.68rem;
  color: var(--text-3);
}

/* Processing spinner (CSS-only) */
.slot-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(91,106,240,0.2);
  border-top-color: #5b6af0;
  border-radius: 50%;
  animation: slot-spin 0.75s linear infinite;
  margin-bottom: 2px;
}
@keyframes slot-spin { to { transform: rotate(360deg); } }

/* ── Score Badge (overlaid on card image) ───────────────────── */
.card-score-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: default;
  white-space: nowrap;
}
.score-high { background: rgba(22,163,74,0.88);  color: #fff; }
.score-mid  { background: rgba(217,119,6,0.88);  color: #fff; }
.score-low  { background: rgba(220,38,38,0.88);  color: #fff; }

/* ── Best Badge ─────────────────────────────────────────────── */
.card-best-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(91,106,240,0.92);
  color: #fff;
  letter-spacing: 0.03em;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.card-best { box-shadow: 0 0 0 2px #5b6af0, 0 4px 16px rgba(91,106,240,0.25); }

/* ── Rejected Card Indicator ───────────────────────────────── */
.card-reject-banner {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 0.67rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(220,38,38,0.85);
  color: #fff;
  pointer-events: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.card-rejected {
  opacity: 0.75;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.4);
}

/* ── Context Panel (right) ──────────────────────────────────── */
.context-panel {
  width: var(--context-w);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.context-section { display: flex; flex-direction: column; gap: 8px; }
.context-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.strategy-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border-md);
}
.strategy-indicator.active { background: var(--accent); }
.context-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.context-stat-row:last-child { border-bottom: none; }
.context-stat-label { font-size: 0.8125rem; color: var(--text-2); }
.context-stat-val   { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.context-empty-hint {
  font-size: 0.75rem;
  color: var(--text-3);
  line-height: 1.5;
}
.context-strategy-rows { display: flex; flex-direction: column; gap: 6px; }
.context-strategy-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.context-strategy-label { font-size: 0.6875rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.context-strategy-value { font-size: 0.75rem; color: var(--text); line-height: 1.4; }

/* ── Ad Detail Studio ───────────────────────────────────────── */
.studio-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.studio-modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: min(1000px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.studio-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  transition: all 0.12s;
}
.studio-close:hover { background: var(--bg); color: var(--text); }

.studio-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  overflow: hidden;
  max-height: 92vh;
  min-width: 0;
}
.studio-preview-col {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  min-width: 0;
}
.studio-img {
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
}
.studio-img-fail {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border-radius: var(--r);
  border: 1px dashed var(--border);
  color: var(--text-3);
  font-size: 0.8rem;
}
.studio-meta-col {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  width: 340px;
  box-sizing: border-box;
}
.studio-meta-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.studio-format-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.studio-created-at {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 3px;
}
.studio-status-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}
.studio-status-badge.draft    { background: var(--bg);        color: var(--text-3);  border: 1px solid var(--border); }
.studio-status-badge.approved { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.studio-status-badge.rejected { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fecaca; }

.studio-meta-grid { display: flex; flex-direction: column; gap: 8px; }
.studio-meta-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.studio-meta-label { font-size: 0.6875rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.studio-meta-val   { font-size: 0.8125rem; color: var(--text); line-height: 1.4; }
.studio-meta-val-wrap { white-space: normal; }

.studio-details {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.studio-details summary {
  padding: 9px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  background: var(--surface-2);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.studio-details summary::after { content: '▾'; color: var(--text-3); font-size: 0.6875rem; }
.studio-details[open] summary::after { content: '▴'; }
.studio-details-body {
  padding: 10px 12px;
  font-size: 0.7875rem;
  color: var(--text-2);
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
.studio-prompt-text { font-family: monospace; font-size: 0.75rem; white-space: pre-wrap; }

.studio-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 6px;
}
.btn-studio {
  padding: 8px 10px;
  border-radius: var(--r);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  border: 1px solid transparent;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-studio-primary   { background: var(--accent); color: #fff; }
.btn-studio-primary:hover { background: var(--accent-h); }
.btn-studio-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-studio-secondary:hover { border-color: var(--border-md); background: var(--bg); }
.btn-studio-ghost  { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-studio-ghost:hover { background: var(--bg); }
.btn-studio-danger { background: transparent; color: var(--danger); border-color: #fecaca; }
.btn-studio-danger:hover { background: var(--danger-bg); }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(2px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: min(440px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-lg { width: min(640px, 96vw); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.modal-footer { padding: 12px 20px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* Mode selector in new campaign modal */
.mode-selector { display: flex; flex-direction: column; gap: 6px; }
.mode-btn {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
  transition: all 0.12s;
}
.mode-btn:hover { border-color: var(--border-md); }
.mode-btn.active { border-color: var(--accent); background: var(--accent-dim); }
.mode-btn strong { display: block; font-size: 0.875rem; color: var(--text); margin-bottom: 3px; }
.mode-btn small  { font-size: 0.75rem; color: var(--text-3); }

/* Modal tabs */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.modal-tab {
  padding: 7px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Form grid in modal */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
.modal-form-actions { margin-top: 10px; display: flex; gap: 8px; }

/* Section divider */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 2px;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-divider-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* Typography preview chips */
.typography-preview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.typography-chip {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  background: var(--accent-dim);
  border-radius: 4px;
  white-space: nowrap;
}
.typography-chip-sep {
  font-size: 0.6875rem;
  color: var(--text-3);
  font-weight: 400;
  align-self: center;
}

/* Asset upload zone */
.asset-upload-zone {
  padding: 20px;
  border: 1.5px dashed var(--border-md);
  border-radius: var(--r);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-3);
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.asset-upload-zone:hover { border-color: var(--accent); background: var(--accent-dim); }
.asset-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}
.asset-thumb {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
}
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset-thumb-del {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.5625rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.12s;
  cursor: pointer;
  border: none;
}
.asset-thumb:hover .asset-thumb-del { opacity: 1; }

/* Persona list in modal */
.persona-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  margin-bottom: 6px;
}
.persona-item-name { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.persona-item-meta { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

/* Standard buttons */
.btn-primary {
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost {
  padding: 8px 18px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.btn-ghost:hover { border-color: var(--border-md); color: var(--text); background: var(--bg); }
.btn-danger {
  padding: 8px 18px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-sm-primary {
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-sm-primary:hover { background: var(--accent-h); }
.btn-sm-ghost {
  padding: 6px 14px;
  background: none;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.btn-sm-ghost:hover { background: var(--surface-2); color: var(--text-1); }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Brand Kit UI ───────────────────────────────────────────── */
.brand-kit-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  background: var(--warning-bg);
  border-bottom: 1px solid #fde68a;
  flex-shrink: 0;
}
.brand-kit-banner-icon {
  font-size: 0.875rem;
  color: var(--warning);
  flex-shrink: 0;
  margin-top: 1px;
}
.brand-kit-banner-text {
  font-size: 0.75rem;
  color: #92400e;
  line-height: 1.4;
  flex: 1;
}
.brand-kit-banner-text strong { display: block; margin-bottom: 2px; }
.brand-kit-banner-btn {
  flex-shrink: 0;
  padding: 4px 9px;
  background: var(--warning);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
  white-space: nowrap;
}
.brand-kit-banner-btn:hover { opacity: 0.85; }

.brand-kit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--warning);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.kit-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 4px;
  font-size: 0.8125rem;
}
.kit-status-bar.complete {
  background: var(--success-bg);
  border-color: #bbf7d0;
}
.kit-status-bar.incomplete {
  background: var(--warning-bg);
  border-color: #fde68a;
}
.kit-status-icon {
  font-size: 0.6875rem;
  color: var(--text-3);
  flex-shrink: 0;
}
.kit-status-bar.complete .kit-status-icon { color: var(--success); }
.kit-status-bar.incomplete .kit-status-icon { color: var(--warning); }
.kit-status-text {
  font-size: 0.8125rem;
  color: var(--text-2);
  font-weight: 500;
}
.kit-status-bar.complete .kit-status-text { color: var(--success); }
.kit-status-bar.incomplete .kit-status-text { color: #92400e; }

/* ── Asset Picker ────────────────────────────────────────────── */
.asset-picker-btn {
  width: 100%;
  margin-top: 5px;
  padding: 5px 8px;
  font-size: 0.7rem;
  color: var(--accent);
  background: transparent;
  border: 1px dashed var(--border-md);
  border-radius: var(--r);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
  font-family: inherit;
}
.asset-picker-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.modal-asset-picker { max-width: 600px; }

.asset-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  min-height: 100px;
  max-height: 420px;
  overflow-y: auto;
  padding: 2px;
}

.asset-picker-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.asset-picker-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(79,70,229,0.12);
}
.asset-picker-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.asset-picker-card-name {
  font-size: 0.65rem;
  color: var(--text-3);
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selected asset shown inside the drop zone */
.asset-in-use {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
  padding: 8px;
}
.asset-in-use img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.asset-in-use-label {
  font-size: 0.65rem;
  color: var(--text-2);
  max-width: 110px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-in-use-remove {
  font-size: 0.65rem;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
}
.asset-in-use-remove:hover { color: var(--error, #dc2626); }

/* ── Brand Memory ───────────────────────────────────────────── */
.memory-action-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.memory-section {
  margin-bottom: 24px;
}
.memory-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.memory-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.memory-section-hint {
  font-size: 0.72rem;
  color: var(--text-3);
}
.memory-filter-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.memory-filter-btn {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.memory-filter-btn:hover  { background: var(--surface-2); color: var(--text-1); }
.memory-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.memory-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
}
.memory-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.memory-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.memory-badge.badge-approved  { background: rgba(34,197,94,0.15);  color: #16a34a; }
.memory-badge.badge-rejected  { background: rgba(239,68,68,0.12);  color: #dc2626; }
.memory-badge.badge-reference { background: rgba(99,102,241,0.15); color: #6366f1; }
.memory-badge.badge-note      { background: rgba(234,179,8,0.15);  color: #ca8a04; }
.memory-card-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 0.7rem;
  padding: 0 2px;
  line-height: 1;
  font-family: inherit;
}
.memory-card-del:hover { color: var(--error, #dc2626); }
.memory-card-summary {
  color: var(--text-1);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.memory-card-meta {
  color: var(--text-3);
  font-size: 0.7rem;
}
.memory-card-reason {
  color: #dc2626;
  font-size: 0.7rem;
  font-style: italic;
}
.memory-card-time {
  color: var(--text-3);
  font-size: 0.65rem;
  margin-top: auto;
}
.memory-angle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.memory-angle-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.memory-angle-body {
  flex: 1;
  min-width: 0;
}
.memory-angle-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 3px;
}
.memory-angle-hook {
  font-size: 0.74rem;
  color: var(--text-2);
  line-height: 1.4;
}

/* Studio memory action buttons */
.studio-memory-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.btn-memory-approve,
.btn-memory-reject {
  flex: 1;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, opacity 0.15s;
}
.btn-memory-approve {
  background: rgba(34,197,94,0.12);
  color: #16a34a;
  border-color: rgba(34,197,94,0.25);
}
.btn-memory-approve:hover:not(:disabled) { background: rgba(34,197,94,0.22); }
.btn-memory-reject {
  background: rgba(239,68,68,0.10);
  color: #dc2626;
  border-color: rgba(239,68,68,0.2);
}
.btn-memory-reject:hover:not(:disabled) { background: rgba(239,68,68,0.18); }
.btn-memory-approve:disabled,
.btn-memory-reject:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Studio Figma Export (single button) ────────────────────── */
.studio-figma-export {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.btn-figma-export {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  border-radius: var(--r);
  border: 1px solid rgba(100,88,255,0.35);
  background: rgba(100,88,255,0.08);
  color: #7c6fff;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-figma-export:hover:not(:disabled) {
  background: rgba(100,88,255,0.18);
  color: #9d91ff;
  border-color: rgba(100,88,255,0.5);
}
.btn-figma-export:disabled { opacity: 0.5; cursor: not-allowed; }
.studio-figma-hint {
  font-size: 0.7rem;
  color: var(--text-3);
  text-align: center;
  line-height: 1.4;
}

/* Legacy individual export button styles — kept for old endpoints, not shown in UI */
.btn-studio-figma { display: none; }
.studio-export-hint { display: none; }

/* ── Generation Mode Toggle ─────────────────────────────────── */
.gen-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.gen-mode-btn {
  flex: 1;
  padding: 5px 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 0.7rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gen-mode-btn.active {
  background: var(--surface-1);
  color: var(--text-1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.gen-mode-btn:hover:not(.active) { color: var(--text-2); }

/* ── Editable Design Preview (Studio) ───────────────────────── */
.studio-editable-preview {
  width: 100%;
  max-height: 640px;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.studio-editable-preview img {
  max-width: 100%;
  display: block;
}

/* ── Board Card — Editable Design Placeholder ───────────────── */
.board-card-editable {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: rgba(255,255,255,0.9);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
}
.board-card-editable span:first-child { font-size: 1.4rem; }

/* ── Load More button ───────────────────────────────────────── */
.btn-load-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-load-more:hover { background: var(--surface-3); color: var(--text-1); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  :root { --context-w: 0px; }
  .context-panel { display: none; }
}
@media (max-width: 720px) {
  :root { --panel-w: 0px; }
  .campaign-panel { display: none; }
}
