/* Auto-organizer design system — Tier 1 polish.
 *
 * Design tokens + type scale + 8pt grid + animations.
 * Replaces previous ad-hoc styles with consistent system.
 */

* { box-sizing: border-box; }

/* ─── Design tokens ──────────────────────────────────────────────────── */
/* ─── Dark mode tokens ────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --gray-50:  #0f172a;
  --gray-100: #1e293b;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --gray-900: #f8fafc;

  --brand-50:  #1e1b4b;
  --brand-100: #312e81;
  --brand-200: #3730a3;
  --brand-700: #c7d2fe;
  --brand-800: #ddd6fe;

  --color-success-bg: #052e16;
  --color-success-border: #14532d;
  --color-warning-bg: #422006;
  --color-warning-border: #713f12;
  --color-error-bg: #450a0a;
  --color-error-border: #7f1d1d;
  --color-info-bg: #172554;
  --color-info-border: #1e3a8a;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

:root[data-theme="dark"] body {
  background: var(--gray-50);
  color: var(--gray-800);
}
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .ws-card,
:root[data-theme="dark"] #sidebar {
  background: var(--gray-100);
  border-color: var(--gray-200);
}
:root[data-theme="dark"] .form-input,
:root[data-theme="dark"] .form-select,
:root[data-theme="dark"] .form-textarea {
  background: var(--gray-100);
  border-color: var(--gray-300);
  color: var(--gray-800);
}
:root[data-theme="dark"] .btn-secondary {
  background: var(--gray-100);
  border-color: var(--gray-300);
  color: var(--gray-700);
}
:root[data-theme="dark"] .btn-secondary:hover {
  background: var(--gray-200);
}
:root[data-theme="dark"] .table th { background: var(--gray-100); }
:root[data-theme="dark"] .table tr:hover td { background: var(--gray-100); }
:root[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.7); }
:root[data-theme="dark"] .loading-overlay { background: rgba(15, 23, 42, 0.85); }
:root[data-theme="dark"] .tag-pill { background: var(--gray-200); color: var(--gray-700); }
:root[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--gray-200) 0%, var(--gray-300) 50%, var(--gray-200) 100%);
  background-size: 200% 100%;
}
:root[data-theme="dark"] .card-hero {
  background: linear-gradient(135deg, var(--gray-100), var(--brand-100));
}

:root {
  /* Spacing — 8pt grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Type scale — 1.25 ratio */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Semantic colors */
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;

  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-error-border: #fecaca;

  --color-info: #2563eb;
  --color-info-bg: #eff6ff;
  --color-info-border: #bfdbfe;

  /* Brand */
  --brand-50:  #f4f6ff;
  --brand-100: #e6ecff;
  --brand-200: #c8d4ff;
  --brand-500: #5364ff;
  --brand-600: #3f47e8;
  --brand-700: #3138be;
  --brand-800: #2a3097;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Motion */
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--gray-800);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Type scale utility classes ─────────────────────────────────────── */
.t-xs { font-size: var(--text-xs); }
.t-sm { font-size: var(--text-sm); }
.t-base { font-size: var(--text-base); }
.t-lg { font-size: var(--text-lg); font-weight: 500; }
.t-xl { font-size: var(--text-xl); font-weight: 600; }
.t-2xl { font-size: var(--text-2xl); font-weight: 600; line-height: var(--leading-tight); }
.t-3xl { font-size: var(--text-3xl); font-weight: 700; line-height: var(--leading-tight); }

.t-mono { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace; }
.t-muted { color: var(--gray-500); }
.t-subtle { color: var(--gray-400); }

/* ─── Layout / sidebar ───────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; }

#sidebar {
  width: 256px;
  border-right: 1px solid var(--gray-200);
  background: white;
  display: flex;
  flex-direction: column;
  transition: transform var(--duration-base) var(--ease-in-out);
}

#main {
  flex: 1;
  overflow-y: auto;
  background: var(--gray-50);
}

/* Mobile drawer */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 50;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 30;
  animation: fadeIn var(--duration-base) var(--ease-out);
}

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  #sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .sidebar-backdrop.show { display: block; }
  #main { padding-top: var(--space-12); }
}

/* ─── Navigation items ───────────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--gray-600);
  cursor: pointer;
  text-decoration: none;
  font-size: var(--text-sm);
  transition: background var(--duration-fast) var(--ease-out);
}
.nav-item:hover { background: var(--gray-100); }
.nav-item.active {
  background: var(--brand-100);
  color: var(--brand-700);
  font-weight: 500;
}
.nav-item-icon { width: 18px; text-align: center; flex-shrink: 0; }

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.card-hero {
  background: linear-gradient(135deg, white, var(--brand-50));
  border-color: var(--brand-200);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.card-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

/* Stat card variants */
.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.stat-card .label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card .value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  line-height: var(--leading-tight);
}
.stat-card-hero {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700);
  color: white;
}
.stat-card-hero .label { color: rgba(255, 255, 255, 0.8); }
.stat-card-hero .value { color: white; font-size: var(--text-3xl); }

/* Workspace card */
.ws-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
}
.ws-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-500);
}

/* ─── Tree view ──────────────────────────────────────────────────────── */
.tree-node {
  padding: var(--space-2) var(--space-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  transition: background var(--duration-fast) var(--ease-out);
}
.tree-node:hover { background: var(--gray-100); }
.tree-node.selected {
  background: var(--brand-100);
  color: var(--brand-700);
  font-weight: 500;
}
.tree-node .arrow {
  display: inline-block;
  width: var(--space-4);
  color: var(--gray-400);
}
.tree-node-children {
  margin-left: var(--space-4);
  border-left: 1px dashed var(--gray-300);
  padding-left: var(--space-2);
}

/* ─── Drop zone ──────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-4);
  text-align: center;
  background: var(--gray-50);
  cursor: pointer;
  transition: border-color var(--duration-base) var(--ease-out), background var(--duration-base) var(--ease-out);
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--brand-500);
  background: var(--brand-50);
}
.drop-zone.dragover {
  border-style: solid;
  transform: scale(1.005);
}

/* ─── Badges with icons (a11y: text + color + icon) ────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.badge::before { font-weight: 700; }

.badge-success, .badge-high {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}
.badge-success::before, .badge-high::before { content: '✓'; }

.badge-warning, .badge-med {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}
.badge-warning::before, .badge-med::before { content: '⚠'; }

.badge-error, .badge-low {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid var(--color-error-border);
}
.badge-error::before, .badge-low::before { content: '✗'; }

.badge-info {
  background: var(--color-info-bg);
  color: var(--color-info);
  border: 1px solid var(--color-info-border);
}
.badge-info::before { content: 'i'; font-style: italic; font-family: serif; }

.badge-moved {
  background: var(--brand-100);
  color: var(--brand-700);
  border: 1px solid var(--brand-200);
}
.badge-moved::before { content: '→'; }

.badge-rejected, .badge-neutral {
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

/* Status pulse for live state */
.badge-pulse::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-left: 4px;
  animation: pulse 1.5s var(--ease-in-out) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── Tag pills ──────────────────────────────────────────────────────── */
.tag-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: var(--text-xs);
  margin-right: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  border: 1px solid var(--gray-200);
}
.tag-pill:hover {
  background: var(--brand-50);
  color: var(--brand-700);
  border-color: var(--brand-200);
  cursor: pointer;
}

/* ─── Toast (stacked, dismissible) ───────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: var(--space-3) var(--space-4);
  padding-right: var(--space-10);
  border-radius: var(--radius-lg);
  color: white;
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  max-width: 420px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  animation: toastIn var(--duration-base) var(--ease-out);
  position: relative;
  font-size: var(--text-sm);
}
.toast.dismissing { animation: toastOut var(--duration-base) var(--ease-in-out) forwards; }
.toast-icon { flex-shrink: 0; font-size: var(--text-base); }
.toast-content { flex: 1; line-height: var(--leading-normal); }
.toast-close {
  position: absolute;
  right: var(--space-2);
  top: var(--space-2);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.6;
  background: transparent;
  border: 0;
  color: white;
  font-size: var(--text-base);
}
.toast-close:hover { opacity: 1; }

.toast-ok { background: var(--color-success); }
.toast-err { background: var(--color-error); }
.toast-info { background: var(--color-info); }

@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
}
@keyframes toastOut {
  to { transform: translateY(20px); opacity: 0; }
}

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  animation: fadeIn var(--duration-base) var(--ease-out);
  padding: var(--space-4);
}
.modal {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  max-width: 32rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--duration-base) var(--ease-out);
}
.modal-lg { max-width: 48rem; }
.modal-xl { max-width: 64rem; }

@keyframes fadeIn {
  from { opacity: 0; }
}
@keyframes modalIn {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
}

/* ─── 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-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  line-height: 1.25;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--brand-500);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--brand-600); box-shadow: var(--shadow-md); }
.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: white;
  border-color: var(--gray-300);
  color: var(--gray-700);
}
.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: var(--color-error);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover {
  background: var(--gray-100);
}

.btn-success {
  background: var(--color-success);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-success:hover { background: #15803d; }

.btn-sm { padding: 4px 10px; font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-5); font-size: var(--text-base); }

/* ─── Forms ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-3); }
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  outline: none;
  background: white;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(83, 100, 255, 0.15);
}
.form-textarea {
  font-family: inherit;
  resize: vertical;
  min-height: 64px;
  line-height: var(--leading-normal);
}
.form-hint {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

/* ─── Tables ─────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-600);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
}
.table td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.table tr:hover td { background: var(--gray-50); }

/* ─── Progress bar (per-file) ────────────────────────────────────────── */
.progress {
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-600));
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
  animation: progressShimmer 2s linear infinite;
  background-size: 200% 100%;
}
@keyframes progressShimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ─── Skeleton loader ────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 0%, var(--gray-100) 50%, var(--gray-200) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 12px; margin-bottom: var(--space-2); }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }

@keyframes skeletonShimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ─── Activity items ─────────────────────────────────────────────────── */
.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--gray-100);
}
.activity-item:last-child { border-bottom: 0; }
.activity-item-time {
  color: var(--gray-400);
  font-size: var(--text-xs);
  min-width: 64px;
}
.activity-item-icon { font-size: var(--text-base); }

/* ─── Misc utilities ─────────────────────────────────────────────────── */
.muted { color: var(--gray-500); }
.subtle { color: var(--gray-400); }
.mono {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 0.9em;
}
.kbd {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: var(--text-xs);
  color: var(--gray-700);
}

/* ─── Loading overlay (less aggressive) ──────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}
.loading-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  min-width: 240px;
  text-align: center;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Empty state ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
}
.empty-state .icon {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-3);
}
.empty-state .title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: var(--space-2);
}
.empty-state .description {
  color: var(--gray-500);
  max-width: 400px;
  margin: 0 auto var(--space-4);
  line-height: var(--leading-relaxed);
}

/* ─── A11y: focus visible ────────────────────────────────────────────── */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.btn:focus-visible { outline-offset: 3px; }

/* Skip-to-content link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand-700);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: 100;
}
.skip-link:focus-visible {
  left: var(--space-3);
  top: var(--space-3);
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Command palette ────────────────────────────────────────────────── */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 70;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 96px;
  animation: fadeIn 150ms var(--ease-out);
}
.cmd-palette {
  background: var(--gray-100);
  border-radius: var(--radius-xl);
  width: 600px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalIn 200ms var(--ease-out);
  border: 1px solid var(--gray-200);
}
.cmd-input-wrap {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--gray-50);
}
.cmd-input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: var(--text-base);
  outline: none;
  color: var(--gray-900);
}
.cmd-input::placeholder { color: var(--gray-400); }
.cmd-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: var(--space-2);
}
.cmd-section-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding: var(--space-2) var(--space-3);
  font-weight: 600;
}
.cmd-result {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  font-size: var(--text-sm);
}
.cmd-result:hover,
.cmd-result.active {
  background: var(--brand-50);
}
.cmd-result-icon { font-size: var(--text-base); }
.cmd-result-label { flex: 1; }
.cmd-result-meta { color: var(--gray-500); font-size: var(--text-xs); }
.cmd-footer {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--gray-500);
}

/* ─── Onboarding tour ────────────────────────────────────────────────── */
.tour-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 80;
  pointer-events: auto;
}
.tour-tooltip {
  position: fixed;
  z-index: 81;
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  max-width: 360px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--gray-200);
  animation: modalIn 250ms var(--ease-out);
}
:root[data-theme="dark"] .tour-tooltip { background: var(--gray-100); }
.tour-tooltip .step {
  font-size: var(--text-xs);
  color: var(--brand-700);
  font-weight: 600;
  margin-bottom: 4px;
}
.tour-tooltip .title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.tour-tooltip .description {
  font-size: var(--text-sm);
  color: var(--gray-600);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}
.tour-tooltip .footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─── Theme toggle ───────────────────────────────────────────────────── */
.theme-toggle {
  position: absolute;
  bottom: var(--space-3);
  right: var(--space-3);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--gray-600);
  transition: background var(--duration-fast) var(--ease-out);
}
.theme-toggle:hover { background: var(--gray-100); }

/* ─── Logo ───────────────────────────────────────────────────────────── */
.logo-mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.logo-text {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--brand-700);
  font-weight: 700;
  font-size: var(--text-base);
  text-decoration: none;
}
.logo-text:hover { text-decoration: none; }

/* ─── Tabs ───────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: var(--space-4);
}
.tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}
.tab:hover { color: var(--gray-700); }
.tab.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-600);
  font-weight: 600;
}
