/* ═══════════════════════════════════════════════════════════════════
   Base — resets, typography, defaults.
   ═══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--surface-sunken);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "calt", "ss01";
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
h5 { font-size: var(--fs-base); }
h6 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-secondary); }

p { margin: 0; color: var(--text-primary); }
small { font-size: var(--fs-sm); color: var(--text-secondary); }

a { color: var(--text-link); text-decoration: none; transition: opacity var(--dur-fast) var(--ease-out); }
a:hover { opacity: 0.78; }

button { font-family: inherit; cursor: pointer; }

/* Hide attribute respected everywhere */
[hidden] { display: none !important; }

/* Selection */
::selection { background: var(--brand-100); color: var(--brand-600); }
html[data-theme="dark"] ::selection { background: var(--brand-500); color: #fff; }

/* Focus ring — consistent across the app */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* Scrollbars — subtle, Apple-style */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); background-clip: padding-box; border: 2px solid transparent; }

/* HR */
hr { border: none; border-top: 1px solid var(--border-subtle); margin: var(--s-4) 0; }

/* Utility classes */
.u-muted { color: var(--text-secondary); }
.u-tertiary { color: var(--text-tertiary); }
.u-mono { font-family: var(--font-mono); font-size: 0.92em; }
.u-caps { text-transform: uppercase; letter-spacing: var(--tracking-wide); font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-row { display: flex; align-items: center; gap: var(--s-2); }
.u-col { display: flex; flex-direction: column; gap: var(--s-2); }
.u-grow { flex: 1; min-width: 0; }
.u-right { margin-left: auto; }

/* Animations — reusable */
@keyframes bm-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes bm-slide-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bm-slide-right { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes bm-drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes bm-scale-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes bm-pulse-ring { 0%{box-shadow:0 0 0 0 rgba(14,82,89,.4);} 70%{box-shadow:0 0 0 12px rgba(14,82,89,0);} 100%{box-shadow:0 0 0 0 rgba(14,82,89,0);} }
@keyframes bm-shimmer { 0%{background-position:-200% 0;} 100%{background-position:200% 0;} }

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