/* ── Base + app shell ───────────────────────────────────────────────────── */

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

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Micro-caps eyebrow — the app's structural label voice */
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mono { font-family: var(--font-mono); font-size: 0.9em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-secondary); }
.faint { color: var(--ink-faint); }

/* ── Shell layout ───────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.sidebar-brand .brand-mark {
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: var(--text-sm);
}

.sidebar-brand .brand-name {
  font-weight: 600;
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav { flex: 1; padding: var(--sp-3) var(--sp-2); }

.nav-group { margin-bottom: var(--sp-4); }
.nav-group > .eyebrow { display: block; padding: 0 var(--sp-3) var(--sp-1); }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.4rem var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-size: var(--text-base);
  position: relative;
}
.nav-item:hover { background: var(--surface-sunken); color: var(--ink); text-decoration: none; }
.nav-item.active {
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: 500;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -0.5rem;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.sidebar-footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar .spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: var(--text-xs);
  font-weight: 700;
}

.content { padding: var(--sp-5); max-width: 1280px; width: 100%; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.page-head h1 { font-size: var(--text-lg); }
.page-head .sub { color: var(--ink-secondary); font-size: var(--text-sm); margin-top: 2px; }
.page-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

/* Practice-mode banner — loud on purpose */
.practice-banner {
  background: repeating-linear-gradient(-45deg, var(--warning-tint), var(--warning-tint) 12px, transparent 12px, transparent 24px), var(--surface);
  border-bottom: 1px solid var(--warning);
  color: var(--warning);
  font-weight: 600;
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--sp-1) var(--sp-3);
}

/* Auth (centered card) layout */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}
.auth-card .auth-brand {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}
.auth-card h1 { font-size: var(--text-md); margin-bottom: var(--sp-4); }

/* Responsive: sidebar collapses under 900px */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-modal); }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 50;
  }
  .sidebar-backdrop.open { display: block; }
  .content { padding: var(--sp-4); }
}

.menu-btn { display: none; }
@media (max-width: 900px) { .menu-btn { display: inline-flex; } }
