/* ═══════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════ */
/* Dark theme (default) */
:root {
  --bg: #0a0a0a;
  --bg-sidebar: #0e0e0e;
  --bg-card: rgba(20, 20, 20, 0.6);
  --bg-card-hover: rgba(26, 26, 26, 0.7);
  --bg-elevated: #1a1a1a;
  --bg-input: #111111;
  --bg-popup: #141414;
  --text: #ededec;
  --text-s: #b0b0b0;
  --text-m: #787878;
  --accent: #2E7D6F;
  --accent-hover: #245F54;
  --accent-dim: rgba(46, 125, 111, 0.12);
  --accent-glow: rgba(46, 125, 111, 0.25);
  --border: rgba(255, 255, 255, 0.06);
  --border-l: rgba(255, 255, 255, 0.10);
  --border-active: rgba(255, 255, 255, 0.18);
  --red: #ef4444;
  --green: #53E826;
  --gold: #F39C12;
  --font: -apple-system, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Geist Mono', 'Cascadia Code', monospace;
  --sidebar-w: 260px;
  --radius: 5px;
  --radius-sm: 4px;
  --radius-lg: 6px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
}

/* Light theme — Apple style */
[data-theme="light"] {
  --bg: #f0f0f2;
  --bg-sidebar: #f8f8fa;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-elevated: #f5f5f7;
  --bg-input: #eeeef0;
  --bg-popup: #ffffff;
  --text: #1d1d1f;
  --text-s: #3a3a3c;
  --text-m: #86868b;
  --accent: #2E7D6F;
  --accent-hover: #245F54;
  --accent-dim: rgba(46, 125, 111, 0.08);
  --accent-glow: rgba(46, 125, 111, 0.15);
  --border: rgba(0, 0, 0, 0.08);
  --border-l: rgba(0, 0, 0, 0.12);
  --border-active: rgba(0, 0, 0, 0.22);
  --red: #ff3b30;
  --green: #34c759;
  --gold: #ff9500;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.04);
}

[data-theme="light"] .sidebar {
  background: #f8f8fa;
  border-right: 1px solid rgba(0,0,0,0.08);
}

[data-theme="light"] .card,
[data-theme="light"] .library-card,
[data-theme="light"] .comp-gallery-card {
  box-shadow: var(--shadow-sm);
  backdrop-filter: none;
  border-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .card:hover,
[data-theme="light"] .library-card:hover,
[data-theme="light"] .comp-gallery-card:hover {
  box-shadow: var(--shadow-md);
}

/* Card preview bg slightly darker so it stands out */
[data-theme="light"] .card__preview {
  background: #e8e8ec;
}

[data-theme="light"] .popup-backdrop {
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
}

[data-theme="light"] .popup {
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.06);
}

[data-theme="light"] .glow { display: none; }

/* Brand logos — dark version in light mode (no invert hack) */
[data-theme="light"] .brand-btn__logo { opacity: 0.6; filter: brightness(0) saturate(0); }
[data-theme="light"] .brand-btn.active .brand-btn__logo,
[data-theme="light"] .brand-btn:hover .brand-btn__logo { opacity: 0.9; }

[data-theme="light"] .sidebar__logo-img { filter: brightness(0) saturate(0); opacity: 0.5; }

/* Generate popup brand logos — dark on light bg */
[data-theme="light"] .brand-select .option img { filter: brightness(0) saturate(0); opacity: 0.5; }
[data-theme="light"] .brand-select .option.active img,
[data-theme="light"] .brand-select .option:hover img { opacity: 0.85; }

/* Nav items slightly more contrast */
[data-theme="light"] .nav-item.active {
  background: rgba(46,125,111,0.1);
}

/* ═══════════════════════════════════════════
   RESET
═══════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 200;
  transition: transform 0.35s var(--ease);
}

.sidebar__top { padding: 24px 20px; }

.sidebar__logo {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.sidebar__logo-img {
  max-width: 140px;
  height: auto;
  opacity: 0.45;
}

.sidebar__logo-text {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-s);
}

.sidebar__logo-text span { color: var(--accent); }

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-m);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.nav-item:hover {
  color: var(--text-s);
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
  color: var(--text);
  background: var(--accent-dim);
}

.nav-item.active svg { color: var(--accent); }

/* Theme switch — Apple segmented control */
.theme-switch {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.theme-switch__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-m);
  cursor: pointer;
  transition: all 0.2s;
}

.theme-switch__btn:hover { color: var(--text-s); }

.theme-switch__btn.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="light"] .theme-switch__btn.active {
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1), 0 0 0 0.5px rgba(0,0,0,0.06);
}

/* User section */
.sidebar__bottom {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar__user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-s);
  display: block;
}

.sidebar__user-email {
  font-size: 11px;
  color: var(--text-m);
  font-family: var(--mono);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}

/* ═══════════════════════════════════════════
   MOBILE HEADER
═══════════════════════════════════════════ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 150;
}

.mobile-header__menu {
  background: none;
  border: none;
  color: var(--text-s);
  cursor: pointer;
  padding: 6px;
}

.mobile-header__title {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-s);
}

.mobile-header__title span { color: var(--accent); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 199;
}

.sidebar-overlay.visible { display: block; }

/* ═══════════════════════════════════════════
   CONTENT
═══════════════════════════════════════════ */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Glow orbs */
.glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(200px);
  z-index: 0;
  opacity: 0.6;
}

.glow--1 { width: 600px; height: 600px; top: -100px; right: -150px; background: rgba(30, 58, 138, 0.35); }
.glow--2 { width: 500px; height: 500px; top: 600px; left: -100px; background: rgba(46, 125, 111, 0.2); }
.glow--3 { width: 700px; height: 700px; top: 1400px; right: -80px; background: rgba(59, 30, 138, 0.2); }

/* ═══════════════════════════════════════════
   VIEW
═══════════════════════════════════════════ */
.view {
  position: relative;
  z-index: 1;
  padding: 40px;
}

.view[hidden] { display: none; }

.view__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.view__title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.view__count {
  font-size: 13px;
  color: var(--text-m);
  margin-top: 4px;
}

.view__sort {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.view__sort-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-m);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}

.view__sort-btn:hover { border-color: var(--border-l); color: var(--text-s); }
.view__sort-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim);
}

/* ═══════════════════════════════════════════
   CARD GRID — 4 columns
═══════════════════════════════════════════ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ═══════════════════════════════════════════
   CARD
═══════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-lg);
  overflow: hidden;
  isolation: isolate;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s, transform 0.3s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transform: translateY(-2px);
}


/* Card preview — scrollable like checkoutchamp */
.card__preview {
  width: 100%;
  max-height: 140px;
  overflow-y: scroll;
  overflow-x: hidden;
  background: #fff;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.card__preview::-webkit-scrollbar { width: 4px; }
.card__preview::-webkit-scrollbar-track { background: #eee; }
.card__preview::-webkit-scrollbar-thumb { background: #bbb; border-radius: 2px; }
.card__preview::-webkit-scrollbar-thumb:hover { background: #999; }

.card__preview-inner {
  position: relative;
  width: 100%;
}

.card__preview-inner iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1440px;
  height: 8000px;
  border: none;
  pointer-events: none;
  transform-origin: top left;
}

/* Card info */
.card__info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card__badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card__flag {
  display: inline-flex;
  align-items: center;
}

.card__flag svg {
  border-radius: 2px;
}
.badge--longform { background: rgba(46, 125, 111, 0.12); color: var(--accent); }
.badge--comparison { background: rgba(243, 156, 18, 0.12); color: var(--gold); }
.badge--listicle { background: rgba(148, 163, 184, 0.1); color: #94a3b8; }
.badge--quiz { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.badge--brand { background: rgba(255, 255, 255, 0.06); color: var(--text-m); font-family: var(--mono); }

.card__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__bottom {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card__date {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-m);
}

.card__actions {
  display: flex;
  gap: 8px;
}

.card__actions .btn { flex: 1; font-size: 12px; padding: 7px 10px; }

/* ═══════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.empty[hidden] { display: none !important; }

.empty__icon {
  color: var(--text-m);
  margin-bottom: 20px;
  opacity: 0.4;
}

.empty__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-s);
}

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

/* ═══════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--ghost { background: transparent; color: var(--text-s); border: 1px solid var(--border-l); }
.btn--ghost:hover { color: var(--text); border-color: var(--border-active); }

.btn--copy {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(46, 125, 111, 0.25);
}
.btn--copy:hover { background: rgba(46, 125, 111, 0.2); }

.btn--sm { font-size: 12px; padding: 6px 12px; }
.btn--lg { width: 100%; height: 48px; font-size: 14px; margin-top: 8px; }

.btn--generate {
  padding: 10px 20px;
  font-size: 13px;
}

.btn__time {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.6;
  margin-left: 2px;
}

/* ═══════════════════════════════════════════
   POPUP (shared)
═══════════════════════════════════════════ */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.popup-overlay[hidden] { display: none; }

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.popup {
  position: relative;
  background: var(--bg-popup);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-lg);
  animation: popupIn 0.3s var(--ease);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@keyframes popupIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.popup__title {
  font-size: 16px;
  font-weight: 600;
}

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

.popup__close {
  background: none;
  border: none;
  color: var(--text-m);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
}

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

/* ═══════════════════════════════════════════
   GENERATE POPUP
═══════════════════════════════════════════ */
.generate-popup {
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
}

.generate-popup--wide {
  width: 760px;
}

.brand-select--row {
  flex-wrap: nowrap;
}

.brand-select--row .option {
  flex: 1;
  justify-content: center;
  min-width: 0;
  padding: 10px 8px;
}

.brand-select--row .option img {
  height: 22px;
}

.gen-mode-options .option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.gen-mode-options .option svg {
  flex-shrink: 0;
}

.gen-mode-options .option span {
  white-space: nowrap;
}

.gen-fields-row {
  display: flex;
  gap: 16px;
}

@media (max-width: 600px) {
  .gen-fields-row { flex-direction: column; gap: 12px; }
  .brand-select--row { flex-wrap: wrap; }
}

.popup__body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: calc(90vh - 70px);
}

.popup__loading {
  padding: 60px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup__loading[hidden] { display: none; }

/* ═══════════════════════════════════════════
   EDIT POPUP
═══════════════════════════════════════════ */
.edit-popup {
  width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  max-width: 1400px;
}

/* Device toggle */
.device-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  padding: 3px;
}

.popup__header-actions .device-toggle {
  min-width: 120px;
}

.device-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 30px;
  min-width: 38px;
  background: none;
  border: none;
  border-radius: 2px;
  color: var(--text-m);
  cursor: pointer;
  transition: all 0.15s;
}

.device-toggle__btn:hover { color: var(--text-s); }
.device-toggle__btn.active { background: var(--accent-dim); color: var(--accent); }

.edit-popup__preview {
  transition: max-width 0.3s ease, margin 0.3s ease;
  background: #e8e8ec;
}

[data-theme="dark"] .edit-popup__preview {
  background: #333;
}

.edit-popup__iframe {
  background: #fff;
}

.edit-popup__preview {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #d4d4d8;
  transition: max-width 0.3s ease, margin 0.3s ease;
}

[data-theme="dark"] .edit-popup__preview { background: #222; }

.edit-popup__iframe { background: #fff; width: 100%; height: 100%; }

.edit-popup__iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.edit-popup__ai-bar {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.edit-popup__ai-input {
  flex: 1;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.edit-popup__ai-input:focus { border-color: var(--accent); }
.edit-popup__ai-input::placeholder { color: var(--text-m); }

.edit-popup__hint {
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-m);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  text-align: center;
}


.edit-popup__loading {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.edit-popup__loading[hidden] { display: none; }

/* ═══════════════════════════════════════════
   FORM FIELDS
═══════════════════════════════════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field[hidden] { display: none; }

.field__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-m);
}

.field__hint {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.5;
}

.field__input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.field__input:focus { border-color: var(--accent); }
.field__input::placeholder { color: var(--text-m); }

.field__textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.field__textarea:focus { border-color: var(--accent); }
.field__textarea::placeholder { color: var(--text-m); }

.field__url-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.field__url-prefix {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-m);
  padding: 0 10px;
  height: 42px;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-l);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  white-space: nowrap;
}

.field__url-row .field__input {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.field__select {
  height: 42px;
  padding: 0 32px 0 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23787878' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 180px;
}

.field__select:focus { border-color: var(--accent); }

/* Option buttons */
.field__options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.option {
  padding: 8px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  color: var(--text-m);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.option:hover {
  border-color: var(--accent);
  color: var(--text-s);
}

.option.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════════════════════════════════════
   LOADER
═══════════════════════════════════════════ */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.loader__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

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

.loader__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.loader__desc {
  font-size: 13px;
  color: var(--text-m);
  max-width: 340px;
  line-height: 1.5;
}

.loader__progress {
  width: 200px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 16px;
  overflow: hidden;
}

.loader__progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s linear;
}

.loader__timer {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-m);
  margin-top: 8px;
}

/* ═══════════════════════════════════════════
   ACTIVITY LOG
═══════════════════════════════════════════ */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-day {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-m);
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-item__dot--create { background: var(--green); }
.activity-item__dot--edit { background: var(--gold); }
.activity-item__dot--delete { background: var(--red); }

.activity-item__user {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-s);
  min-width: 80px;
}

.activity-item__action {
  font-size: 13px;
  color: var(--text-m);
  flex: 1;
}

.activity-item__action strong {
  color: var(--text-s);
  font-weight: 600;
}

.activity-item__time {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-m);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 100px;
  z-index: 3000;
  animation: toastIn 0.3s var(--ease);
}

.toast[hidden] { display: none; }

@keyframes toastIn {
  from { transform: translateX(-50%) translateY(12px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
    padding-top: 56px;
  }

  .view { padding: 24px 16px; }

  .view__header {
    flex-direction: column;
    gap: 12px;
  }

  .btn--generate { width: 100%; }

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

  .library-grid { columns: 140px; }

  .edit-popup {
    width: 100vw;
    height: 100vh;
  }


  .popup-overlay { padding: 0; }

  .generate-popup {
    width: 100%;
    height: 100%;
    max-height: 100%;
  }

  .popup__body { max-height: calc(100vh - 70px); }

}


/* ═══════════════════════════════════════════
   IMAGES LIBRARY
═══════════════════════════════════════════ */
.library-grid {
  columns: 200px;
  column-gap: 16px;
}

.library-grid[hidden] { display: none; }

.library-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s, transform 0.3s;
  display: inline-flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: 16px;
  break-inside: avoid;
}

.library-card:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transform: translateY(-2px);
}

.library-card__thumb {
  width: 100%;
  object-fit: contain;
  display: block;
  background: var(--bg-input);
}

.library-card__info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.library-card__name {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-s);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-card__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.library-card__tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-dim);
  color: var(--accent);
}

.library-card__brand {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-m);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 6px;
}

.library-card__delete {
  background: none;
  border: none;
  color: var(--text-m);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 16px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.library-card__delete:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

/* Stagger for library cards */

/* Upload popup */
.upload-popup {
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  border: 2px dashed var(--border-l);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--text-m);
  text-align: center;
  gap: 8px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.upload-zone__text {
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

.upload-zone__hint {
  font-size: 12px;
  opacity: 0.6;
}

.upload-preview {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-l);
}

.upload-preview[hidden] { display: none; }

.upload-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
  background: var(--bg-input);
}

.upload-preview__remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.upload-preview__remove:hover {
  background: var(--red);
}

.upload-brand-hint {
  font-size: 12px;
  color: var(--text-m);
  padding: 8px 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(46, 125, 111, 0.15);
  border-radius: var(--radius-sm);
  display: none;
}

.upload-brand-hint.visible { display: flex; align-items: center; gap: 6px; }

.upload-brand-hint img { height: 14px; width: auto; opacity: 0.7; }

/* Library filters */
.library-filters {
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════
   IMAGE PICKER POPUP
═══════════════════════════════════════════ */
.imagepicker-popup {
  width: 640px;
  max-width: 100%;
  max-height: 80vh;
}

.imagepicker-popup .popup__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.imagepicker-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.imagepicker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.imagepicker-grid img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, opacity 0.15s;
}

.imagepicker-grid img:hover {
  border-color: var(--accent);
  opacity: 0.85;
}

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

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

/* ═══════════════════════════════════════════
   VIEW HEADER ACTIONS
═══════════════════════════════════════════ */
.view__header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   AI GENERATE POPUP
═══════════════════════════════════════════ */
.aigenerate-popup {
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
}

.aigenerate-ref__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--bg-input);
  border: 1px dashed var(--border-l);
  border-radius: var(--radius-sm);
  color: var(--text-m);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.aigenerate-ref__btn:hover {
  border-color: var(--accent);
  color: var(--text-s);
}

.aigenerate-ref__preview {
  position: relative;
  display: inline-block;
}

.aigenerate-ref__preview[hidden] { display: none; }

.aigenerate-ref__preview img {
  height: 80px;
  border-radius: var(--radius-sm);
  display: block;
}

.aigenerate-ref__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.aigenerate-picker {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--bg-input);
}

.aigenerate-picker[hidden] { display: none; }

.aigenerate-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
}

.aigenerate-picker__grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.aigenerate-picker__grid img:hover {
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════
   CONFIRM DELETE POPUP
═══════════════════════════════════════════ */
.confirm-popup {
  width: 400px;
  max-width: 100%;
}

.confirm-popup .popup__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}

.confirm-preview {
  width: 160px;
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
}

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

.confirm-name {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-s);
  word-break: break-all;
}

.confirm-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--red);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.confirm-actions .btn { flex: 1; }

.btn--delete {
  background: var(--red);
  color: #fff;
}

.btn--delete:hover { background: #dc2626; }
.btn--delete:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--delete-text {
  background: none;
  border: none;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: var(--font);
}

.btn--delete-text:hover { opacity: 1; }

/* ═══════════════════════════════════════════
   LIGHTBOX
═══════════════════════════════════════════ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.lightbox[hidden] { display: none; }

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.lightbox__img {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  animation: popupIn 0.25s var(--ease);
}

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 22px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1;
}

.lightbox__close:hover { background: rgba(255, 255, 255, 0.15); }

.library-card__thumb { cursor: pointer; }

/* ═══════════════════════════════════════════
   COMPONENT PICKER POPUP
═══════════════════════════════════════════ */
.component-picker-popup {
  width: 740px;
  max-width: 100%;
  max-height: 85vh;
}

.component-picker__categories {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.comp-category__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-m);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.comp-category__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.comp-card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  gap: 6px;
}

.comp-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.comp-card__name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.comp-card__desc {
  font-size: 11px;
  color: var(--text-m);
  line-height: 1.4;
}

.comp-card__insert {
  align-self: flex-end;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.comp-card:hover .comp-card__insert { opacity: 1; }

.comp-card__preview {
  width: 100%;
  height: 80px;
  overflow: hidden;
  border-radius: 2px;
  background: #fff;
  position: relative;
  margin-bottom: 4px;
}

.comp-card__preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1000px;
  height: 600px;
  border: none;
  transform-origin: top left;
  pointer-events: none;
}

/* Components gallery view */
.comp-gallery-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.3s, background 0.3s, transform 0.3s;
  display: flex;
  flex-direction: column;
}

.comp-gallery-card:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.comp-gallery-card__preview {
  width: 100%;
  height: 120px;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.comp-gallery-card__preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1000px;
  height: 800px;
  border: none;
  transform-origin: top left;
  pointer-events: none;
}

.comp-card__preview,
.comp-gallery-card__preview {
  position: relative;
  overflow: hidden;
}

.comp-gallery-card__info {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comp-gallery-card__name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.comp-gallery-card__cat {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comp-gallery-card__desc {
  font-size: 11px;
  color: var(--text-m);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════
   SKILLS & RULES VIEW
═══════════════════════════════════════════ */
.skills-section {
  margin-bottom: 32px;
}

.skills-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.skills-section__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-s);
}

.skills-section__title span {
  font-weight: 500;
  color: var(--text-m);
  font-size: 13px;
}

/* SOP Workflow */
.sop-flow {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.sop-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  width: 100%;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.sop-step:hover { background: rgba(255,255,255,0.02); }

.sop-step--ai {
  background: var(--accent-dim);
  border: 1px solid rgba(46,125,111,0.2);
}

.sop-step__num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-l);
  color: var(--text-m);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sop-step--ai .sop-step__num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sop-step__text {
  font-size: 13px;
  color: var(--text-s);
  line-height: 1.4;
}

.sop-step__text strong { color: var(--text); }

.sop-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .sop-modes { grid-template-columns: 1fr; }
}

.sop-mode__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  padding: 0 14px;
  font-family: var(--mono);
}

.sop-note {
  font-size: 11px;
  color: var(--text-m);
  padding: 8px 14px 0;
  line-height: 1.5;
  font-style: italic;
}

.sop-arrow {
  color: var(--text-m);
  font-size: 14px;
  padding-left: 18px;
  opacity: 0.4;
  line-height: 1;
}

/* Skill Cards */
.skills-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.skill-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s;
}

.skill-card:hover { border-color: var(--border-l); }

.skill-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}

.skill-card__toggle {
  color: var(--text-m);
  font-size: 10px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.skill-card.open .skill-card__toggle { transform: rotate(90deg); }

.skill-card__name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.skill-card__source {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 10px;
}

.skill-card__source--builtin { background: var(--accent-dim); color: var(--accent); }
.skill-card__source--custom { background: rgba(243,156,18,0.1); color: var(--gold); }

/* Skill groups */
.skill-group__header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 8px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-group__header:first-child { margin-top: 0; }

.skill-group__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skill-group__count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-m);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
}

.skill-group__sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-m);
}

.skill-card--disabled {
  opacity: 0.5;
  border-style: dashed;
}

.skill-card--disabled:hover {
  opacity: 0.7;
}

.skill-card--disabled .skill-card__name {
  text-decoration: line-through;
}

.skill-card__status {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.skill-card__status--off {
  background: rgba(239,68,68,0.1);
  color: var(--red);
}

.skill-card__status--on {
  background: var(--accent-dim);
  color: var(--accent);
}

.skill-card__desc {
  font-size: 12px;
  color: var(--text-m);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-card__actions {
  display: none;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.skill-card__actions.visible { display: flex; }

.skill-card__btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-m);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.skill-card__btn:hover { color: var(--text-s); border-color: var(--border-l); }
.skill-card__btn--delete:hover { color: var(--red); border-color: rgba(239,68,68,0.3); }

.skill-card__body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.skill-card.open .skill-card__body { display: block; }

.skill-card__content {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-s);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  padding: 12px 0;
}

/* Rules List */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.rule-item__bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 6px;
}

.rule-item__text {
  font-size: 13px;
  color: var(--text-s);
  line-height: 1.5;
  flex: 1;
}

.rule-item__date {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-m);
  flex-shrink: 0;
}

.rule-item__delete {
  background: none;
  border: none;
  color: var(--text-m);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  display: none;
  transition: color 0.15s;
}

.rule-item__delete.visible { display: block; }
.rule-item__delete:hover { color: var(--red); }

/* Skill editor popup */
.skill-editor-popup {
  width: 700px;
  max-width: 100%;
  max-height: 90vh;
}

/* Admin unlock button */
.btn--admin.unlocked {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--admin-only[hidden] { display: none !important; }

/* ═══════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.14); }

/* ═══════════════════════════════════════════
   BRAND SWITCHER
═══════════════════════════════════════════ */
.brand-switcher {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.brand-switcher__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-m);
  margin-bottom: 10px;
}

.brand-btn--all {
  width: 100%;
  margin-bottom: 6px;
  height: 30px;
  font-size: 11px;
}

.brand-switcher__list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.brand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 8px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-l);
  border-radius: var(--radius-sm);
  color: var(--text-m);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
}

.brand-btn:hover {
  border-color: var(--accent);
  color: var(--text-s);
  background: rgba(46, 125, 111, 0.05);
}

.brand-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.brand-btn__logo {
  height: 22px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.brand-btn.active .brand-btn__logo,
.brand-btn:hover .brand-btn__logo {
  opacity: 1;
}

.brand-btn__edit {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 14px;
  height: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-l);
  border-radius: 0 var(--radius-sm) 0 var(--radius-sm);
  color: var(--text-m);
  font-size: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

.brand-btn:hover .brand-btn__edit {
  display: flex;
}

.brand-btn__edit:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* No brand selected warning */
.brand-required {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(243, 156, 18, 0.08);
  border: 1px solid rgba(243, 156, 18, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 16px;
}

.brand-required.visible {
  display: flex;
}

/* ═══════════════════════════════════════════
   BRAND EDITOR POPUP
═══════════════════════════════════════════ */
.brand-editor-popup {
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
}

.brand-editor__row {
  display: flex;
  gap: 12px;
}

.brand-editor__colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.brand-editor__color-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.brand-editor__color-picker {
  width: 42px;
  height: 42px;
  padding: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border-l);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Brand select in generate form */
.brand-select .option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
}

.brand-select .option img {
  height: 18px;
  width: auto;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.brand-select .option:hover img,
.brand-select .option.active img {
  opacity: 1;
}
