/* ============================================================
   Spotitap App — Design System
   Themes: light | dim | dark
   Brand:  #0B7E8A (teal)
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; line-height: 1.5; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
input, button, select, textarea { font: inherit; }
a { text-decoration: none; }

/* ── Typography ────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  font-size: 0.9375rem;
}

/* ── Brand tokens ──────────────────────────────────────────── */
:root {
  --accent:        #0B7E8A;
  --accent-hover:  #096873;
  --accent-dim:    rgba(11, 126, 138, 0.12);
  --accent-text:   #0B7E8A;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.14);

  --sidebar-w: 240px;
  --topbar-h:  60px;

  --transition: .18s ease;
}

/* ── Light theme ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg:            #f2f2f7;
  --bg-secondary:  #e8e8ed;
  --surface:       #ffffff;
  --surface-2:     #f9fafb;
  --surface-hover: #f3f4f6;
  --border:        #e5e7eb;
  --border-strong: #d1d5db;

  --text:          #111827;
  --text-sub:      #6b7280;
  --text-muted:    #9ca3af;
  --text-inverse:  #ffffff;

  --sidebar-bg:    #ffffff;
  --sidebar-nav:   #374151;
  --sidebar-nav-active-bg: var(--accent-dim);
  --sidebar-nav-active:    var(--accent);

  --input-bg:      #ffffff;
  --input-border:  #d1d5db;
  --input-focus:   var(--accent);

  --badge-done-bg:     #dcfce7;
  --badge-done-text:   #16a34a;
  --badge-warn-bg:     #fef9c3;
  --badge-warn-text:   #a16207;
  --badge-info-bg:     #dbeafe;
  --badge-info-text:   #1d4ed8;
  --badge-muted-bg:    #f3f4f6;
  --badge-muted-text:  #6b7280;

  color-scheme: light;
}

/* ── Dim theme ─────────────────────────────────────────────── */
[data-theme="dim"] {
  --bg:            #0d1117;
  --bg-secondary:  #090d12;
  --surface:       #161b22;
  --surface-2:     #1c2128;
  --surface-hover: #21282f;
  --border:        #30363d;
  --border-strong: #3d444d;

  --text:          #c9d1d9;
  --text-sub:      #8b949e;
  --text-muted:    #6e7681;
  --text-inverse:  #0d1117;

  --sidebar-bg:    #161b22;
  --sidebar-nav:   #8b949e;
  --sidebar-nav-active-bg: rgba(11, 126, 138, 0.15);
  --sidebar-nav-active:    #3dcfdb;

  --input-bg:      #0d1117;
  --input-border:  #30363d;
  --input-focus:   #3dcfdb;

  --badge-done-bg:     rgba(22, 163, 74, 0.15);
  --badge-done-text:   #4ade80;
  --badge-warn-bg:     rgba(234, 179, 8, 0.15);
  --badge-warn-text:   #facc15;
  --badge-info-bg:     rgba(59, 130, 246, 0.15);
  --badge-info-text:   #60a5fa;
  --badge-muted-bg:    rgba(255,255,255,.06);
  --badge-muted-text:  #8b949e;

  color-scheme: dark;
}

/* ── Dark theme ────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:            #000000;
  --bg-secondary:  #050505;
  --surface:       #111111;
  --surface-2:     #1a1a1a;
  --surface-hover: #1f1f1f;
  --border:        #1f1f1f;
  --border-strong: #2a2a2a;

  --text:          #f5f5f5;
  --text-sub:      #a0a0a0;
  --text-muted:    #555555;
  --text-inverse:  #000000;

  --sidebar-bg:    #0a0a0a;
  --sidebar-nav:   #888888;
  --sidebar-nav-active-bg: rgba(11, 126, 138, 0.18);
  --sidebar-nav-active:    #3dcfdb;

  --input-bg:      #111111;
  --input-border:  #2a2a2a;
  --input-focus:   #3dcfdb;

  --badge-done-bg:     rgba(74, 222, 128, 0.1);
  --badge-done-text:   #4ade80;
  --badge-warn-bg:     rgba(250, 204, 21, 0.1);
  --badge-warn-text:   #facc15;
  --badge-info-bg:     rgba(96, 165, 250, 0.1);
  --badge-info-text:   #60a5fa;
  --badge-muted-bg:    rgba(255,255,255,.05);
  --badge-muted-text:  #666666;

  color-scheme: dark;
}

/* ── Base ──────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

/* ── Auth layout ───────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.auth-logo__mark {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: -1px;
}
.auth-logo__name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field__input {
  width: 100%;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field__input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.field__input::placeholder { color: var(--text-muted); }

.auth-error {
  display: none;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.auth-error.visible { display: block; }

.auth-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.auth-footer__link {
  font-size: 0.8rem;
  color: var(--accent-text);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.auth-footer__link:hover { text-decoration: underline; }

/* ── App layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition), background var(--transition);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar__logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
  letter-spacing: -1px;
}
.sidebar__logo-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.nav-section:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.nav-section__label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 0 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--sidebar-nav);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--sidebar-nav-active-bg);
  color: var(--sidebar-nav-active);
  font-weight: 600;
}
.nav-item__icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.8;
}
.nav-item.active .nav-item__icon { opacity: 1; }
.nav-item__badge {
  margin-left: auto;
  background: var(--accent-dim);
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}

.sidebar__footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar__user:hover { background: var(--surface-hover); }
.sidebar__avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-dim);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-text);
  overflow: hidden;
}
.sidebar__avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__user-plan {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ── Main content ──────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar__btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 15px;
}
.topbar__btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

/* ── Page content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1100px;
  width: 100%;
}

.page-header { margin-bottom: 24px; }
.page-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}
.page-header__sub { font-size: 0.9rem; color: var(--text-sub); }

/* ── Stats row ─────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.stat-card__icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}
.stat-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card__label { font-size: 0.8rem; color: var(--text-sub); font-weight: 500; }

/* ── Section header ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.section-header__count {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* ── Product cards grid ────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  cursor: default;
}
.product-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 24px rgba(11,126,138,.12);
  transform: translateY(-1px);
}

.product-card__top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.product-card__icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: var(--accent-dim);
}
.product-card__meta { flex: 1; min-width: 0; }
.product-card__name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.product-card__type {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: capitalize;
}
.product-card__badge { flex-shrink: 0; }

.qty-badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent-dim);
  color: var(--accent-text);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

.product-card__stats {
  display: flex;
  gap: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.stat-pill { flex: 1; }
.stat-pill__val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.stat-pill__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.product-card__url {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
  cursor: pointer;
  transition: background var(--transition);
}
.product-card__url:hover { background: var(--surface-hover); }
.product-card__url svg { flex-shrink: 0; color: var(--text-muted); }

.product-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none !important;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(11,126,138,.3);
}

.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--text-sub);
  border: 1.5px solid var(--border);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn--sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn--full { width: 100%; }

.btn--loading .btn-text { opacity: 0; }
.btn--loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn { position: relative; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge--done    { background: var(--badge-done-bg);  color: var(--badge-done-text);  }
.badge--warn    { background: var(--badge-warn-bg);  color: var(--badge-warn-text);  }
.badge--info    { background: var(--badge-info-bg);  color: var(--badge-info-text);  }
.badge--muted   { background: var(--badge-muted-bg); color: var(--badge-muted-text); }
.badge--premium {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px;
  gap: 12px;
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-xl);
}
.empty-state__icon { font-size: 48px; }
.empty-state__title { font-size: 1rem; font-weight: 700; color: var(--text); }
.empty-state__sub { font-size: 0.875rem; color: var(--text-sub); max-width: 340px; line-height: 1.6; }

/* ── Skeleton loader ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes spin    { to { transform: rotate(360deg); } }

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Dropdown ──────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  display: none;
}
.dropdown__menu.open { display: block; }
.dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background var(--transition);
}
.dropdown__item:hover { background: var(--surface-hover); }
.dropdown__item--danger { color: #ef4444; }
.dropdown__divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text);
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toast-in .25s ease;
}
.toast--success { border-left: 3px solid #22c55e; }
.toast--error   { border-left: 3px solid #ef4444; }
.toast--info    { border-left: 3px solid var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Theme/Lang picker ─────────────────────────────────────── */
.theme-picker {
  display: flex;
  gap: 6px;
}
.theme-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.theme-btn:hover { transform: scale(1.1); }
.theme-btn.active { border-color: var(--accent); }

.lang-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.8rem;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

/* ── Top controls (auth page) ──────────────────────────────── */
.top-controls {
  position: fixed;
  top: 16px; right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 50;
}

/* ── Sidebar mobile toggle ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 90;
  backdrop-filter: blur(2px);
}
.menu-btn {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-sub);
}

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--border-strong); color: var(--text); }
.filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .menu-btn { display: flex; }
  .main { margin-left: 0; }
  .page-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }

  .auth-card { padding: 28px 20px; }
  .auth-form__row { grid-template-columns: 1fr; }

  .cards-grid { grid-template-columns: 1fr; }
  .stats-row  { grid-template-columns: repeat(2, 1fr); }

  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: 100%; }
}

/* ── Editor Drawer ─────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
  backdrop-filter: blur(3px);
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -16px 0 48px rgba(0,0,0,.18);
}
.drawer.open { transform: translateX(0); }

.drawer__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer__icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.drawer__title {
  flex: 1;
  min-width: 0;
}
.drawer__title-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer__title-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.drawer__close {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: all var(--transition);
  line-height: 1;
}
.drawer__close:hover { background: var(--surface-hover); color: var(--text); }

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.drawer__footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
}

/* Editor sections */
.editor-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.editor-section__title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.editor-row--full { grid-template-columns: 1fr; }

/* Social link row */
.social-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}
.social-row:focus-within { border-color: var(--accent); }
.social-row__icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
}
.social-row__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  width: 72px;
  flex-shrink: 0;
}
.social-row__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.875rem;
}
.social-row__input::placeholder { color: var(--text-muted); }

/* Accent color picker */
.accent-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.accent-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
  outline: none;
}
.accent-swatch:hover { transform: scale(1.15); }
.accent-swatch.active { border-color: var(--text); }

/* Theme mode picker */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mode-btn {
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}
.mode-btn:hover { border-color: var(--border-strong); }
.mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.mode-btn__icon { font-size: 20px; margin-bottom: 4px; }
.mode-btn__label { font-size: 0.72rem; font-weight: 600; color: var(--text-sub); }
.mode-btn.active .mode-btn__label { color: var(--accent-text); }

/* Info row (read-only display) */
.info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.info-row__label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  width: 80px;
  flex-shrink: 0;
  padding-top: 2px;
}
.info-row__value {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
  word-break: break-all;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.info-row__copy {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: color var(--transition);
}
.info-row__copy:hover { color: var(--accent-text); }

/* QR preview */
.qr-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.qr-preview img {
  width: 140px; height: 140px;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 8px;
}
.qr-preview__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Editor loading */
.drawer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@media (max-width: 600px) {
  .drawer { width: 100vw; border-left: none; border-top: 1px solid var(--border); }
  .editor-row { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
}
