/* ── DoubleSlit Engine — Application Styles ─────────────────────────────────
   DM Sans · B&W · PWA-ready · Responsive
   ─────────────────────────────────────────────────────────────────────────── */

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

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-base);
  transition: background-color var(--transition-slow), color var(--transition-slow);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-snug);
  color: var(--text-primary);
}
h1 { font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl)); font-weight: 700; }
h2 { font-size: clamp(var(--text-2xl), 3.5vw, var(--text-4xl)); }
h3 { font-size: clamp(var(--text-xl), 2.5vw, var(--text-2xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p { color: var(--text-secondary); line-height: var(--leading-relaxed); }
a { color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; transition: opacity var(--transition-fast); }
a:hover { opacity: 0.7; }
code, pre { font-family: var(--font-mono); font-size: 0.9em; }
pre { background: var(--bg-muted); padding: var(--space-4); border-radius: var(--radius-md); overflow-x: auto; }
strong { font-weight: 600; color: var(--text-primary); }

/* ── Layout Shell ─────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100dvh;
}
.app-shell.no-sidebar {
  grid-template-columns: 1fr;
  grid-template-areas: "topbar" "main";
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-snug);
  color: var(--text-primary);
}
.topbar__logo .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  color: var(--bg-base);
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0;
  flex-shrink: 0;
}
.topbar__search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar__search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 0 var(--space-4) 0 var(--space-8);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.topbar__search input:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.topbar__search .search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100dvh - var(--topbar-height));
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  padding: var(--space-4) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 2px; }

.nav-section { padding: var(--space-3) var(--space-4) var(--space-1); }
.nav-section__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-faint);
  display: block;
  margin-bottom: var(--space-1);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { color: var(--text-primary); background: var(--accent-subtle); }
.nav-item.active {
  color: var(--text-primary);
  background: var(--accent-subtle);
  font-weight: 600;
  border-left: 2px solid var(--accent);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  grid-area: main;
  padding: var(--space-8) var(--space-8);
  overflow-y: auto;
  max-width: 100%;
}
.page-header {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.page-header h1 { margin-bottom: var(--space-2); }
.page-header p { font-size: var(--text-lg); color: var(--text-muted); }
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--space-2);
  display: block;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-default);
}
.btn-ghost:hover { background: var(--accent-subtle); color: var(--text-primary); border-color: var(--accent); }

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--text-primary); color: var(--bg-base); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-8); font-size: var(--text-base); }
.btn-icon { padding: var(--space-2); aspect-ratio: 1; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card--elevated { box-shadow: var(--shadow-md); border-color: transparent; }
.card--interactive { cursor: pointer; transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.card--interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card__body { padding: var(--space-6); }
.card__header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border-subtle); }
.card__footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-subtle); background: var(--bg-subtle); }
.card__title { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-1); }
.card__meta { font-size: var(--text-sm); color: var(--text-muted); }

/* ── Grid System ──────────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--space-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Form Elements ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-5); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.form-label.required::after { content: " *"; color: var(--error); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-4);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.form-input::placeholder { color: var(--text-faint); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-hint { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); }
.form-error { font-size: var(--text-sm); color: var(--error); margin-top: var(--space-1); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-radius: var(--radius-full);
  border: 1px solid currentColor;
}
.badge-default { color: var(--text-muted); }
.badge-success { color: var(--success); }
.badge-error   { color: var(--error); }
.badge-warning { color: var(--warning); }
.badge-info    { color: var(--info); }
.badge-solid { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody tr:hover td { background: var(--accent-subtle); }
tbody tr:last-child td { border-bottom: none; }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-8) 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-faint);
  font-size: var(--text-sm);
}
.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-subtle);
}

/* ── Alert / Toast ────────────────────────────────────────────────────────── */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: var(--text-sm);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.alert-success { background: color-mix(in srgb, var(--success) 8%, transparent); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.alert-error   { background: color-mix(in srgb, var(--error) 8%, transparent); border-color: color-mix(in srgb, var(--error) 30%, transparent); color: var(--error); }
.alert-warning { background: color-mix(in srgb, var(--warning) 8%, transparent); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--warning); }
.alert-info    { background: color-mix(in srgb, var(--info) 8%, transparent); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info); }

/* Toast container */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}
.toast {
  pointer-events: all;
  padding: var(--space-3) var(--space-5);
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 260px;
  max-width: 380px;
  animation: toast-in 0.25s ease;
}
.toast.removing { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  place-items: center;
  padding: var(--space-4);
}
.modal-backdrop.open { display: grid; animation: fade-in 0.2s ease; }
.modal {
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slide-up 0.25s ease;
}
.modal__header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal__body { padding: var(--space-6); }
.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

@keyframes fade-in  { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(20px); opacity: 0; } }

/* ── Hero / Landing ───────────────────────────────────────────────────────── */
.hero {
  min-height: calc(100dvh - var(--topbar-height));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, var(--accent-subtle) 0%, transparent 70%);
  pointer-events: none;
}
.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-4);
  margin-bottom: var(--space-6);
}
.hero__title {
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 14ch;
  margin-bottom: var(--space-6);
}
.hero__subtitle {
  font-size: clamp(var(--text-base), 2.5vw, var(--text-xl));
  color: var(--text-muted);
  max-width: 52ch;
  margin-bottom: var(--space-10);
  line-height: var(--leading-relaxed);
}
.hero__actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}
.hero__glyphs {
  position: absolute;
  font-size: 5rem;
  opacity: 0.03;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stat-card {
  padding: var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
}
.stat-card__value {
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  margin-bottom: var(--space-1);
}
.stat-card__label { font-size: var(--text-sm); color: var(--text-muted); font-weight: 500; }
.stat-card__delta { font-size: var(--text-xs); color: var(--success); margin-top: var(--space-2); }

/* ── Profile / User ───────────────────────────────────────────────────────── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-muted);
  border: 1px solid var(--border-default);
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: var(--text-xl); }
.avatar-xl { width: 96px; height: 96px; font-size: var(--text-3xl); }

/* ── Helix Soul ID display ────────────────────────────────────────────────── */
.soul-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  color: var(--text-faint);
  background: var(--bg-muted);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

/* ── LLM / iON Stream ────────────────────────────────────────────────────── */
.ion-stream {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  padding: var(--space-6);
}
.ion-stream__output {
  min-height: 200px;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}
.ion-stream__cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text-primary);
  animation: blink 1s step-start infinite;
  vertical-align: text-bottom;
}
@keyframes blink { 50% { opacity: 0; } }
.ion-stream__input-row {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* ── Channel badges (SYMBiON) ────────────────────────────────────────────── */
.channel-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-widest);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-muted);
  text-transform: uppercase;
  font-family: var(--font-mono);
}

/* ── Theme Toggle ─────────────────────────────────────────────────────────── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.theme-toggle:hover { background: var(--accent-subtle); color: var(--text-primary); }

/* ── Mobile hamburger ─────────────────────────────────────────────────────── */
.hamburger {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--text-primary);
}

/* ── Offline Banner ───────────────────────────────────────────────────────── */
#offline-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: var(--space-2) var(--space-6);
  background: var(--warning);
  color: #000;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
}
#offline-banner.visible { display: block; }

/* ── PWA install prompt ───────────────────────────────────────────────────── */
#pwa-prompt {
  display: none;
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-width: 380px;
  width: calc(100% - var(--space-8));
  animation: slide-up 0.3s ease;
}
#pwa-prompt.visible { display: flex; gap: var(--space-4); align-items: center; }
#pwa-prompt .pwa-icon { font-size: 2rem; flex-shrink: 0; }
#pwa-prompt .pwa-text h4 { font-size: var(--text-base); margin-bottom: var(--space-1); }
#pwa-prompt .pwa-text p { font-size: var(--text-sm); color: var(--text-muted); }
#pwa-prompt .pwa-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

/* ── Utility Classes ──────────────────────────────────────────────────────── */
.container { max-width: var(--container-xl); margin: 0 auto; padding: 0 var(--space-6); }
.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; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); } .gap-6 { gap: var(--space-6); } .gap-8 { gap: var(--space-8); }
.d-block { display: block; }
.mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); } .mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded { border-radius: var(--radius-md); }

/* ── Scrollbar Global ─────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border-default) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar {
    position: fixed;
    left: -100%;
    top: var(--topbar-height);
    height: calc(100dvh - var(--topbar-height));
    z-index: 150;
    width: var(--sidebar-width);
    transition: left var(--transition-slow);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: rgba(0,0,0,0.5);
    z-index: 140;
  }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: grid; place-items: center; }
  .main-content { padding: var(--space-6) var(--space-4); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar { padding: 0 var(--space-4); }
  .topbar__search { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero__title { font-size: clamp(2rem, 8vw, 2.5rem); }
  .main-content { padding: var(--space-4); }
  #toast-container { bottom: var(--space-4); right: var(--space-4); left: var(--space-4); }
  .toast { max-width: 100%; min-width: 0; }
}

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, #toast-container, #pwa-prompt, #offline-banner { display: none !important; }
  .app-shell { display: block; }
  .main-content { padding: 0; }
}

/* ── Reduced Motion ───────────────────────────────────────────────────────── */
@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;
  }
}
