/* =========================================================
   Social Content Studio Pro — Design System
   ========================================================= */

/* ---- 1. Custom Properties ---- */
:root {
  /* Color ramps */
  --primary-50:  #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;

  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-850: #172033;
  --slate-900: #0f172a;
  --slate-950: #020617;

  --amber-400: #fbbf24;
  --amber-500: #f59e0b;

  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;

  --red-400:   #f87171;
  --red-500:   #ef4444;
  --red-600:   #dc2626;

  --yellow-400: #facc15;
  --yellow-500: #eab308;

  /* Semantic */
  --color-success: var(--green-500);
  --color-warning: var(--amber-500);
  --color-error:   var(--red-500);
  --color-info:    var(--sky-500);

  /* Dark theme (default) */
  --bg-base:    var(--slate-900);
  --bg-surface: var(--slate-800);
  --bg-card:    var(--slate-800);
  --bg-input:   var(--slate-900);
  --bg-hover:   var(--slate-700);
  --bg-sidebar: var(--slate-850);

  --border:       var(--slate-700);
  --border-light: var(--slate-600);

  --text-primary:   var(--slate-50);
  --text-secondary: var(--slate-300);
  --text-muted:     var(--slate-400);
  --text-accent:    var(--sky-400);

  --accent:        var(--sky-500);
  --accent-hover:  var(--sky-400);
  --brand:         var(--primary-600);
  --brand-hover:   var(--primary-500);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  --font-normal:   400;
  --font-medium:   500;
  --font-semibold: 600;

  /* Spacing (8px grid) */
  --space-1:  0.25rem;   /* 4px */
  --space-2:  0.5rem;    /* 8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */

  /* Radius */
  --radius-sm:  0.25rem;
  --radius:     0.5rem;
  --radius-md:  0.75rem;
  --radius-lg:  1rem;
  --radius-xl:  1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.3),  0 1px 2px rgba(0,0,0,.2);
  --shadow:     0 4px 6px rgba(0,0,0,.3),  0 2px 4px rgba(0,0,0,.2);
  --shadow-md:  0 10px 15px rgba(0,0,0,.3), 0 4px 6px rgba(0,0,0,.2);
  --shadow-lg:  0 20px 25px rgba(0,0,0,.4), 0 10px 10px rgba(0,0,0,.2);
  --shadow-glow: 0 0 20px rgba(14,165,233,.25);

  /* Transitions */
  --transition: 150ms ease;
  --transition-md: 250ms ease;

  /* Sidebar */
  --sidebar-w: 260px;
}

/* Light mode */
[data-theme="light"] {
  --bg-base:    var(--slate-100);
  --bg-surface: #ffffff;
  --bg-card:    #ffffff;
  --bg-input:   var(--slate-50);
  --bg-hover:   var(--slate-100);
  --bg-sidebar: var(--primary-900);

  --border:       var(--slate-200);
  --border-light: var(--slate-300);

  --text-primary:   var(--slate-900);
  --text-secondary: var(--slate-700);
  --text-muted:     var(--slate-500);
  --text-accent:    var(--primary-700);

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow:     0 4px 6px rgba(0,0,0,.06);
  --shadow-md:  0 10px 15px rgba(0,0,0,.08);
}

/* ---- 2. Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; height: auto; display: block; }

input, textarea, select, button { font-family: inherit; font-size: inherit; }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition-md);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.page-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-body {
  padding: var(--space-8);
  flex: 1;
}

/* ---- 4. Sidebar ---- */
.sidebar-logo {
  padding: var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo .logo-mark {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary-500), var(--sky-500));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: white;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: white;
  line-height: 1.3;
}

.sidebar-logo .logo-text span {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-normal);
  color: rgba(255,255,255,.5);
}

.sidebar-nav {
  padding: var(--space-4) var(--space-3);
  flex: 1;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: var(--font-semibold);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: rgba(255,255,255,.7);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin-bottom: var(--space-1);
}

.nav-item:hover { background: rgba(255,255,255,.08); color: white; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.12); color: white; }
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ---- 5. Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* ---- 6. Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none !important;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); box-shadow: var(--shadow-glow); }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-surface); border-color: var(--border-light); }

.btn-accent {
  background: linear-gradient(135deg, var(--sky-600), var(--primary-600));
  color: white;
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.1); box-shadow: var(--shadow-glow); }

.btn-success {
  background: var(--green-600);
  color: white;
}
.btn-success:hover:not(:disabled) { background: var(--green-500); }

.btn-danger {
  background: transparent;
  color: var(--red-400);
  border: 1px solid var(--red-500);
}
.btn-danger:hover:not(:disabled) { background: var(--red-500); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-base); }
.btn-full { width: 100%; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius);
}

/* ---- 7. Forms ---- */
.form-group { margin-bottom: var(--space-5); }

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-control {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: var(--text-sm);
  line-height: 1.6;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 120px; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

/* Toggle */
.toggle-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.toggle {
  position: relative;
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: var(--radius-full);
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}

input:checked + .toggle { background: var(--accent); }
input:checked + .toggle::after { transform: translateX(20px); }

/* ---- 8. Tabs ---- */
.tab-list {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  margin-bottom: var(--space-6);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-list::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--text-accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- 9. Badges & Tags ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

.badge-primary { background: rgba(37,99,235,.2); color: var(--primary-400); }
.badge-success { background: rgba(34,197,94,.15); color: var(--green-400); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--amber-400); }
.badge-error   { background: rgba(239,68,68,.15);  color: var(--red-400); }
.badge-info    { background: rgba(14,165,233,.15); color: var(--sky-400); }
.badge-neutral { background: var(--bg-hover); color: var(--text-secondary); }

/* ---- 10. Platform Result Cards ---- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.result-card:hover { border-color: var(--border-light); box-shadow: var(--shadow-md); }

.result-card-header {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-card-platform {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.result-card-dims {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.result-card-preview {
  background: var(--slate-950);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.result-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-card-preview.ratio-portrait { aspect-ratio: 9/16; }
.result-card-preview.ratio-landscape { aspect-ratio: 16/9; }
.result-card-preview.ratio-tall { aspect-ratio: 4/5; }
.result-card-preview.ratio-wide { aspect-ratio: 16/9; }
.result-card-preview.ratio-pinterest { aspect-ratio: 2/3; }

.result-card-body { padding: var(--space-4); }

.result-caption {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.65;
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.hashtag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-3);
}

.hashtag-tag {
  background: rgba(14,165,233,.1);
  color: var(--sky-400);
  border: 1px solid rgba(14,165,233,.2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  padding: 1px var(--space-2);
  cursor: pointer;
  transition: background var(--transition);
}
.hashtag-tag:hover { background: rgba(14,165,233,.2); }

.result-card-actions {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ---- 11. Drop Zone ---- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(14,165,233,.04);
}

.dropzone-icon {
  width: 48px; height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--text-muted);
}

.dropzone-title {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.dropzone-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---- 12. Progress ---- */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-600), var(--sky-500));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.2) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---- 13. Toast Notifications ---- */
#toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  min-width: 280px;
  pointer-events: all;
  animation: toast-in .3s cubic-bezier(.34,1.56,.64,1) both;
}

.toast.leaving { animation: toast-out .25s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(60px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(60px); }
}

.toast-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--text-primary); }
.toast-msg   { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-error); }
.toast.info    { border-left: 3px solid var(--color-info); }
.toast.warning { border-left: 3px solid var(--color-warning); }

/* ---- 14. Loading States ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-surface) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease infinite;
  border-radius: var(--radius);
}

@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

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

.btn-loading .loading-spinner { width: 14px; height: 14px; }

/* ---- 15. Typography Utilities ---- */
.text-xs  { font-size: var(--text-xs); }
.text-sm  { font-size: var(--text-sm); }
.text-base{ font-size: var(--text-base); }
.text-lg  { font-size: var(--text-lg); }
.text-xl  { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.font-medium  { font-weight: var(--font-medium); }
.font-semibold{ font-weight: var(--font-semibold); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--text-accent); }
.text-success   { color: var(--color-success); }
.text-error     { color: var(--color-error); }
.text-warning   { color: var(--color-warning); }

/* ---- 16. Spacing utilities ---- */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* ---- 17. Flex / Grid utilities ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--space-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--space-4); }

/* ---- 18. Content Tabs (input type selector) ---- */
.input-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.input-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}

.input-type-btn:hover { border-color: var(--accent); background: rgba(14,165,233,.03); }
.input-type-btn.active {
  border-color: var(--accent);
  background: rgba(14,165,233,.08);
  box-shadow: 0 0 0 1px var(--accent);
}

.input-type-btn .icon {
  width: 32px; height: 32px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.input-type-btn.active .icon,
.input-type-btn:hover .icon { color: var(--accent); }

.input-type-btn .label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

/* ---- 19. Platform selector checkboxes ---- */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-2);
}

.platform-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  user-select: none;
}

.platform-check:hover { border-color: var(--accent); color: var(--text-primary); }
.platform-check input[type="checkbox"] { accent-color: var(--accent); }

/* ---- 20. Campaign history ---- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: border-color var(--transition);
}

.history-item:hover { border-color: var(--border-light); }

.history-thumb {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  object-fit: cover;
  flex-shrink: 0;
}

.history-info { flex: 1; min-width: 0; }
.history-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ---- 21. Settings page ---- */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.settings-section-header {
  padding: var(--space-4) var(--space-6);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.settings-section-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.settings-section-body { padding: var(--space-6); }

/* ---- 22. Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: var(--space-6);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-logo .mark {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary-600), var(--sky-500));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: white;
  margin: 0 auto var(--space-4);
  box-shadow: var(--shadow-glow);
}

.login-logo h1 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.login-logo p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.alert-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--red-400);
}

.alert-success {
  background: rgba(34,197,94,.1);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--green-400);
}

.alert-info {
  background: rgba(14,165,233,.1);
  border: 1px solid rgba(14,165,233,.3);
  color: var(--sky-400);
}

/* ---- 23. Color swatch ---- */
.color-swatch-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.color-swatch {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  cursor: pointer;
  overflow: hidden;
}

.color-swatch input[type="color"] {
  width: 100%; height: 100%;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* ---- 24. Responsive ---- */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-2);
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-menu-btn { display: flex; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
  }
  .sidebar-overlay.active { display: block; }
  .form-row, .form-row-3, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-body { padding: var(--space-4); }
}

@media (max-width: 640px) {
  .tab-btn { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
  .results-grid { grid-template-columns: 1fr; }
  .input-type-grid { grid-template-columns: repeat(3, 1fr); }
  .platform-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- 25. Misc Utilities ---- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pointer { cursor: pointer; }
.w-full { width: 100%; }
.relative { position: relative; }
.block { display: block; }

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

/* Glow accent on focus-visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
