/* ============================================================
   Unified AI Studio — base stylesheet
   Design language: Linear / Vercel / Stripe Dashboard.
   Flat surfaces, 1px borders, one indigo accent, 8px spacing
   grid, Inter typography. No gradients, no blur, no glow.

   This file also carries the compatibility layer for every
   class/variable used by templates and page stylesheets
   (project_detail.css, providers.css) that are not part of
   this redesign: all legacy names keep working.
   ============================================================ */

/* ------------------------------------------------------------
   Design tokens — light theme (default)
   ------------------------------------------------------------ */
:root {
  color-scheme: light;

  /* Spacing scale (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Type scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;

  /* Surfaces */
  --bg: #FFFFFF;
  --surface: #F8F9FA;
  --surface-elevated: #FFFFFF;
  --surface-border: #E2E8F0;
  --card-bg: #FFFFFF;
  --input-bg: #FFFFFF;
  --sidebar-bg: #F8F9FA;

  /* Text */
  --text: #0F172A;
  --text-secondary: #475569;
  --muted: #64748B;

  /* Lines */
  --line: #E2E8F0;
  --line-strong: #CBD5E1;

  /* Accent — single indigo */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --accent-text: #4338CA;
  --primary-glow: rgba(79, 70, 229, 0.10);
  --primary-soft: rgba(79, 70, 229, 0.08);

  /* Status */
  --success: #059669;
  --danger: #DC2626;
  --warning: #D97706;
  --success-bg: #ECFDF5;
  --success-fg: #047857;
  --danger-bg: #FEF2F2;
  --danger-fg: #B91C1C;
  --warning-bg: #FFFBEB;
  --warning-fg: #B45309;
  --neutral-pill-bg: #F1F5F9;
  --neutral-pill-fg: #475569;

  /* Legacy aliases: kept so dependent rules render flat */
  --primary-gradient: var(--primary);
  --bg-gradient: none;
  --shadow-glow: none;
  --blur: none;

  /* Radii — small and crisp */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  /* Shadows — hover/elevated states only */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Motion — short and quiet */
  --transition: 150ms ease;

  /* Layout */
  --sidebar-width: 240px;
  --content-max-width: 1280px;
}

/* ------------------------------------------------------------
   Design tokens — dark theme
   ------------------------------------------------------------ */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0A0A0A;
  --surface: #141414;
  --surface-elevated: #141414;
  --surface-border: #262626;
  --card-bg: #141414;
  --input-bg: #0F0F0F;
  --sidebar-bg: #0C0C0C;

  --text: #FAFAFA;
  --text-secondary: #A1A1A1;
  --muted: #737780;

  --line: #262626;
  --line-strong: #36363A;

  --primary: #6366F1;
  --primary-hover: #818CF8;
  --accent-text: #A5B4FC;
  --primary-glow: rgba(99, 102, 241, 0.16);
  --primary-soft: rgba(99, 102, 241, 0.12);

  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-fg: #34D399;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-fg: #F87171;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-fg: #FBBF24;
  --neutral-pill-bg: #1E1E20;
  --neutral-pill-fg: #A1A1A1;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

img, svg { display: block; max-width: 100%; }

::selection { background: var(--primary-glow); }

/* ------------------------------------------------------------
   Typography
   ------------------------------------------------------------ */
h1, h2, h3, h4, h5 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  margin: 0 0 var(--space-3);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-md); }
h4, h5 { font-size: var(--text-base); }

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.text-secondary { color: var(--text-secondary); }
.subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-1);
}

/* ------------------------------------------------------------
   App shell — sidebar + main area
   ------------------------------------------------------------ */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-7);
}

main:focus { outline: none; }

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--line);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-brand-link:hover { text-decoration: none; }

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #FFFFFF;
  flex-shrink: 0;
}
.logo-mark svg { width: 14px; height: 14px; }

.sidebar-brand-name {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav a:hover {
  background: var(--primary-soft);
  color: var(--text);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--primary-soft);
  color: var(--accent-text);
}

.sidebar-nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
}
.sidebar-nav a:hover svg,
.sidebar-nav a.active svg { color: currentColor; }

.sidebar-nav-label {
  margin: var(--space-3) 0 var(--space-1);
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  border-top: 1px solid var(--line);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
  padding: 0 var(--space-1);
}

.sidebar-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.sidebar-user-email {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--muted);
  text-transform: capitalize;
}

/* Mobile top bar */
.topbar {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* ------------------------------------------------------------
   Page header (dashboard and inner pages)
   ------------------------------------------------------------ */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.page-head h1,
.page-head h2 {
  margin: 0;
}
.page-head-sub {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
}
.page-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.section-head h2,
.section-head h3 { margin: 0; }

/* ------------------------------------------------------------
   Cards — 1px border, 8px radius, no default shadow
   ------------------------------------------------------------ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5);
}

.card.interactive { cursor: pointer; }

.card.interactive:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.card.interactive:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   Buttons — solid primary, outline ghost, text link
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn.primary {
  background: var(--primary);
  color: #FFFFFF;
}
.btn.primary:hover { background: var(--primary-hover); }

.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-secondary);
}
.btn.ghost:hover {
  background: var(--surface);
  border-color: var(--muted);
  color: var(--text);
}

/* Text/link button */
.btn.text,
.btn.link {
  background: transparent;
  color: var(--accent-text);
  padding: 0 var(--space-2);
}
.btn.text:hover,
.btn.link:hover { background: var(--primary-soft); }

.btn.small {
  height: 28px;
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-xs);
}
.btn.small svg { width: 14px; height: 14px; }

.btn.large {
  height: 40px;
  padding: 0 var(--space-5);
}

.btn.icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
}
.btn.icon-only:hover {
  background: var(--surface);
  color: var(--text);
}

.inline-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.field { margin-bottom: var(--space-4); }

.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--input-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="date"],
select { height: 36px; }

textarea { min-height: 80px; resize: vertical; }

input::placeholder,
textarea::placeholder { color: var(--muted); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}

input[type="file"] { width: auto; }

select { cursor: pointer; }

/* ------------------------------------------------------------
   Pills / badges — 4px radius, 11px font, solid tint
   ------------------------------------------------------------ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.5;
  background: var(--neutral-pill-bg);
  color: var(--neutral-pill-fg);
  white-space: nowrap;
}
.pill.small { font-size: var(--text-xs); padding: 1px var(--space-1); }

.pill.ok,
.pill.success { background: var(--success-bg); color: var(--success-fg); }
.pill.bad,
.pill.error,
.pill.failed { background: var(--danger-bg); color: var(--danger-fg); }
.pill.warning,
.pill.warn { background: var(--warning-bg); color: var(--warning-fg); }
.pill.pending { background: var(--primary-glow); color: var(--accent-text); }

/* ------------------------------------------------------------
   Tables — horizontal rules only, compact
   ------------------------------------------------------------ */
.table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th,
.table td,
.admin-table th,
.admin-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th,
.admin-table th {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
.table tr:last-child td,
.admin-table tr:last-child td { border-bottom: none; }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-5);
}
.admin-grid > .card { grid-column: span 4; }

/* ------------------------------------------------------------
   Grids
   ------------------------------------------------------------ */
.grid { display: grid; gap: var(--space-4); }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* ------------------------------------------------------------
   Project cards (dashboard)
   ------------------------------------------------------------ */
.project-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  color: var(--text);
  text-decoration: none;
}
.project-card:hover { text-decoration: none; }

.project-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
}

.project-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}

.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ------------------------------------------------------------
   Empty state
   ------------------------------------------------------------ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-7) var(--space-5);
}
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.empty-state-icon svg { width: 20px; height: 20px; }
.empty-state h3 { margin: 0 0 var(--space-1); }
.empty-state p { margin: 0 0 var(--space-4); max-width: 420px; }

/* ------------------------------------------------------------
   Dashboard stats
   ------------------------------------------------------------ */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.dash-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dash-stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.dash-stat-value {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.dash-stat-active { color: var(--primary); }

.dash-hero { padding: var(--space-5); }
.dash-hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.dash-hero-cta {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------
   Recent activity
   ------------------------------------------------------------ */
.recent-run-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: background var(--transition);
}
.recent-run-row:last-child { border-bottom: none; }
.recent-run-row:hover { background: var(--surface); text-decoration: none; }

/* ------------------------------------------------------------
   Run progress & status pills
   ------------------------------------------------------------ */
.run-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: var(--space-3) 0;
}
.run-progress-track {
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.run-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0;
  transition: width 0.3s ease;
}
.run-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--muted);
}
.run-progress-meta .step {
  font-weight: 500;
  color: var(--text-secondary);
}

.run-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: capitalize;
  letter-spacing: 0.01em;
}
.run-status-pill[data-status="running"],
.run-status-pill[data-status="pending"] {
  background: var(--primary-glow);
  color: var(--accent-text);
}
.run-status-pill[data-status="completed"] {
  background: var(--success-bg);
  color: var(--success-fg);
}
.run-status-pill[data-status="failed"] {
  background: var(--danger-bg);
  color: var(--danger-fg);
}
.run-status-pill[data-status="cancelled"] {
  background: var(--neutral-pill-bg);
  color: var(--neutral-pill-fg);
}

/* ------------------------------------------------------------
   Toasts
   ------------------------------------------------------------ */
.toast-container,
#toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 9999;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}
.toast.err {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

.uas-toast {
  pointer-events: auto;
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.45;
  white-space: pre-wrap;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
.uas-toast-show { opacity: 1; transform: translateY(0); }
.uas-toast-hide { opacity: 0; transform: translateY(-4px); }

.uas-toast-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: var(--success-bg);
}
.uas-toast-error {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: var(--danger-bg);
}
.uas-toast-warn {
  background: var(--warning-bg);
  color: var(--warning-fg);
  border-color: var(--warning-bg);
}
.uas-toast-info {
  background: var(--surface-elevated);
  color: var(--text);
  border-color: var(--line-strong);
}

/* ------------------------------------------------------------
   Small components
   ------------------------------------------------------------ */
kbd {
  display: inline-block;
  padding: 1px var(--space-1);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
}

.char-counter {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  margin-top: var(--space-1);
}
.char-counter.too-short { color: var(--warning-fg); }
.char-counter.ok { color: var(--success-fg); }

.copy-btn,
[data-copy] {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 3px var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition);
}
.copy-btn:hover,
[data-copy]:hover {
  background: var(--primary-soft);
  color: var(--accent-text);
  border-color: var(--primary);
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Theme toggle shows moon in light mode, sun in dark mode */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.hidden { display: none !important; }

/* ------------------------------------------------------------
   Search results (search.html)
   ------------------------------------------------------------ */
.search-result-list { list-style: none; margin: 0; padding: 0; }
.search-hit { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.search-hit:last-child { border-bottom: none; }
.search-hit-title { font-weight: 500; color: var(--accent-text); }
.search-hit-title:hover { color: var(--primary); }

/* ------------------------------------------------------------
   Artifacts
   ------------------------------------------------------------ */
.artifact-content {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
  overflow: auto;
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.7;
}

.meta-block {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

.artifact-meta { align-items: center; }
.md-rendered { line-height: 1.65; }
.md-rendered h1, .md-rendered h2, .md-rendered h3 { margin: var(--space-4) 0 var(--space-2); }
.md-rendered pre {
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

/* ------------------------------------------------------------
   Skeleton loading states (flat pulse, no gradient sweep)
   ------------------------------------------------------------ */
.skeleton {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  color: transparent;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.skeleton-line { height: 12px; margin-bottom: var(--space-2); }
.skeleton-line.short { width: 30%; }
.skeleton-line.medium { width: 60%; }
.skeleton-line.long { width: 90%; }
.skeleton-card { padding: var(--space-4); }
.skeleton-card .skeleton-line:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------
   Error pages
   ------------------------------------------------------------ */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-7) var(--space-5);
  min-height: 60vh;
}
.error-page h1 {
  font-size: 56px;
  margin: 0;
  letter-spacing: -0.04em;
  color: var(--primary);
}
.error-page p {
  font-size: var(--text-md);
  color: var(--text-secondary);
  max-width: 480px;
  margin: var(--space-2) auto var(--space-5);
}

/* ------------------------------------------------------------
   Auth (login) page — full-height centered card
   ------------------------------------------------------------ */
.auth-main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-6);
  animation: auth-fade-in 0.25s ease-out both;
}

@keyframes auth-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #FFFFFF;
  margin: 0 auto var(--space-4);
}
.auth-logo svg { width: 22px; height: 22px; }

.auth-title {
  font-size: var(--text-lg);
  text-align: center;
  margin: 0 0 var(--space-1);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
  margin: 0 0 var(--space-5);
}

.auth-error {
  margin-bottom: var(--space-4);
}

.auth-divider {
  margin: var(--space-5) 0 var(--space-4);
  border: none;
  border-top: 1px solid var(--line);
}

.auth-footer {
  text-align: center;
  font-size: var(--text-sm);
  margin-top: var(--space-5);
}

.auth-password-wrap { position: relative; }
.auth-password-wrap input { padding-right: 64px; }
.auth-password-toggle {
  position: absolute;
  right: var(--space-1);
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: var(--radius-xs);
}
.auth-password-toggle:hover { color: var(--text); }

/* ------------------------------------------------------------
   Accessibility helpers
   ------------------------------------------------------------ */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--primary);
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
  z-index: 1000;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: var(--space-2);
  outline: 2px solid var(--primary-hover);
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------
   Responsive — sidebar collapses to a top bar under 768px
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  .app-shell {
    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 50;
  }
  [data-theme="dark"] .sidebar-overlay { background: rgba(0, 0, 0, 0.6); }
  body.sidebar-open .sidebar-overlay { display: block; }

  .topbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 56px;
    padding: 0 var(--space-3);
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }

  .topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .topbar-brand:hover { text-decoration: none; }

  .topbar-spacer { flex: 1; }

  .main-area { padding-top: 0; }

  .content {
    padding: var(--space-4) var(--space-3) var(--space-7);
  }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-head-actions { justify-content: space-between; }
  .page-head-actions input { flex: 1; min-width: 0; }
  .page-head-actions .btn { flex: 1; }

  .project-grid { grid-template-columns: 1fr; }
  .dash-stats { grid-template-columns: 1fr 1fr; }
  .dash-hero-head { flex-direction: column; align-items: stretch; }
  .dash-hero-cta { flex-direction: column; align-items: stretch; }
  .dash-hero-cta input { width: 100%; }

  .admin-grid { grid-template-columns: 1fr !important; }
  .admin-grid > .card { grid-column: span 1 !important; }

  .admin-table { display: block; overflow-x: auto; }

  .artifact-grid { grid-template-columns: 1fr !important; }
  .artifact-grid > .card { grid-column: span 1 !important; }
  .artifact-grid > .card[style*="span 4"],
  .artifact-grid > .card[style*="span 8"] { grid-column: span 1 !important; }

  .recent-run-row { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
  .artifact-actions { width: 100%; }
  .artifact-actions .btn { flex: 1; }
}

/* ------------------------------------------------------------
   Compatibility additions — second page-redesign pass
   (artifact detail / rewrite, project artifacts / run / settings,
   search, change password, error pages, providers).
   Appended below the original rules; nothing above changes.
   ------------------------------------------------------------ */

/* 12-column page grid (used together with .grid) */
.artifact-grid {
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-5);
}
.span-12 { grid-column: span 12; }
.span-8  { grid-column: span 8; }
.span-6  { grid-column: span 6; }
.span-4  { grid-column: span 4; }
@media (max-width: 960px) {
  .artifact-grid .span-8,
  .artifact-grid .span-6,
  .artifact-grid .span-4 { grid-column: span 12; }
}

/* Back link above page titles */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}
.back-link:hover { color: var(--text); text-decoration: none; }
.back-link svg { width: 16px; height: 16px; }

/* Heading that leads with an icon */
.icon-heading { display: flex; align-items: center; gap: var(--space-2); }
.icon-heading svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }

/* First heading inside a card (no top margin) */
.first-heading { margin-top: 0; }

/* Rows of pills / small tags */
.pill-row { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.pill svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Artifact header meta line */
.artifact-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.meta-item { display: inline-flex; align-items: center; gap: 5px; }
.meta-item svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }

/* Flexible head rows inside cards */
.artifact-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.head-main { min-width: 0; flex: 1; }
.artifact-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.toolbar-row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.content-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.content-head h3 { margin: 0; }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--space-4);
}
.form-actions .grow { flex: 1; }
.check-inline { display: inline-flex; gap: var(--space-2); align-items: center; cursor: pointer; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* Inline notices (privacy notice, hints) */
.notice {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
}
.notice svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.notice-title { font-weight: 600; }
.notice p { margin: 2px 0 0; }
.notice.warning {
  background: var(--warning-bg);
  border-color: var(--warning-bg);
  color: var(--warning-fg);
}

/* Form-level success / error banners */
.form-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}
.form-alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.form-alert.err { background: var(--danger-bg); border-color: var(--danger-bg); color: var(--danger-fg); }
.form-alert.ok { background: var(--success-bg); border-color: var(--success-bg); color: var(--success-fg); }

/* Narrow centered card (change password) */
.narrow-card { max-width: 480px; margin: 0 auto; }

/* Error pages */
.error-page-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; }
.error-page-footnote { margin-top: var(--space-6); font-size: var(--text-sm); color: var(--muted); }
.request-id {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

/* Key/value metadata lists (run sidebar, project info) */
.meta-list { display: grid; gap: var(--space-2); margin: var(--space-3) 0 0; }
.meta-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: var(--space-2); font-size: var(--text-sm); }
.meta-key { color: var(--muted); }
.meta-val { color: var(--text); min-width: 0; word-break: break-word; }

/* Divided sections inside a card */
.card-section { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--line); }

/* Quality report score stats */
.qr-scores { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-6); margin-bottom: var(--space-3); }
.qr-score-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.qr-score-value { font-size: var(--text-md); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Table helpers */
.table-scroll { max-height: 320px; overflow: auto; }
.code-cell { font-family: var(--font-mono); font-size: 0.85em; }

/* Versions timeline */
.version-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.version-row:last-child { border-bottom: none; }
.version-main { min-width: 0; flex: 1; }
.version-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-meta { font-size: var(--text-sm); color: var(--muted); }

/* Collapsible card summaries (editorial checks) */
.details-summary { cursor: pointer; }
.details-summary h3 { display: inline; margin: 0; font-size: var(--text-md); }
.details-summary .muted { margin-left: var(--space-2); }
.editorial-stack { display: grid; gap: var(--space-5); margin-top: var(--space-3); }

/* Plain issue/strength lists */
.list-plain { list-style: none; padding-left: 0; margin: 2px 0 0; display: grid; gap: 4px; }

/* Search page */
.search-form { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }
.search-form input[type="search"] { flex: 1; min-width: 240px; }
.search-form select { width: auto; min-width: 150px; }
.search-hit-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.search-hit-snippet { margin: var(--space-1) 0 0; }

/* Artifact kinds list */
.kinds-list { margin: var(--space-2) 0 0 18px; font-size: var(--text-sm); color: var(--text-secondary); display: grid; gap: 2px; }

/* File upload preview list (JS-built) */
.file-preview-list { list-style: none; padding: 0; margin: var(--space-2) 0 0; font-size: var(--text-sm); display: grid; gap: 4px; }
.file-preview-list .too-big { color: var(--danger-fg); font-weight: 500; }
.file-hint { margin-top: var(--space-2); }

/* Persons & experts */
.person-row {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  flex-wrap: wrap;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
}
.person-row:last-child { border-bottom: none; }

/* Stacked action links (quick ops) */
.stack-actions { display: grid; gap: var(--space-2); }
.stack-actions .btn { justify-content: flex-start; }

/* Small panel helpers (revise / variants panels) */
.preset-select { max-width: 280px; }
.panel-result { margin-top: var(--space-2); }
.md-cap-note { margin: var(--space-2) 0 0; }
.md-show-all { margin-left: var(--space-2); }

/* Variant target chips (JS-built) */
.variant-target-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-weight: 400;
  font-size: var(--text-sm);
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.variant-target-chip:hover { border-color: var(--primary); color: var(--text); }

/* Citation report details (JS-built) */
.citation-report-pre {
  white-space: pre-wrap;
  font-size: var(--text-sm);
  padding: var(--space-3);
  margin: var(--space-2) 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* Ordered hint list (how it works) */
.hint-list { padding-left: 18px; line-height: 1.7; }

/* Providers list placeholder rows (JS-built) */
.list-placeholder { padding: var(--space-5); text-align: center; color: var(--muted); }

/* Misc utilities */
.capitalize { text-transform: capitalize; }

/* 720px: single-column grid for admin tables (parity test contract) */
@media (max-width: 720px) {
    .admin-grid { grid-template-columns: 1fr; }
    .col-3, .col-4, .col-6, .col-8, .col-12 { grid-column: span 1; }
}
