/* Reset, typography and app shell */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md) / var(--lh-body) var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, iframe { display: block; max-width: 100%; }
.icon { display: inline-block; flex: none; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: var(--lh-tight); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-xl); font-weight: 600; }
h3, .h3 { font-size: var(--fs-lg); font-weight: 600; }
.h4 { font-size: var(--fs-md); font-weight: 600; }
p { margin: 0; }
code, kbd { font-family: var(--font-mono); font-size: 0.85em; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 0.35em; font-size: 0.75em; color: var(--text-2); background: var(--surface); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-2) 0; width: 100%; }
ul, ol { margin: 0; padding: 0; }
ul[class], ol[class] { list-style: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); color: var(--primary-ink); }

[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

/* Utilities */
.muted { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.center { text-align: center; justify-content: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.spacer { flex: 1; }
.link { font-size: var(--fs-sm); font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ */
/* Shell                                                               */
/* ------------------------------------------------------------------ */

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-4);
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); font: 700 var(--fs-lg) / 1 var(--font-display); color: var(--text); text-decoration: none; letter-spacing: -0.02em; padding: 0 var(--sp-2); }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: var(--primary); color: var(--on-primary); font-size: 18px;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.18);
}

.profile-card {
  display: flex; gap: var(--sp-3); align-items: center;
  padding: var(--sp-3); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); text-decoration: none;
  transition: background var(--dur-fast);
}
.profile-card:hover { background: var(--surface-3); }
.profile-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.profile-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-sub { font-size: var(--fs-xs); color: var(--text-2); }

.mini-timer {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  background: var(--primary-soft); color: var(--primary-ink); text-decoration: none; font-weight: 700;
}
.mini-timer strong { margin-left: auto; font-variant-numeric: tabular-nums; }

.nav { display: flex; flex-direction: column; gap: var(--sp-4); flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-heading { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 0 var(--sp-3) var(--sp-1); }
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-weight: 700; font-size: var(--fs-sm);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); }
.nav-link[aria-current="page"] .icon { color: var(--primary); }

.theme-toggle {
  display: flex; align-items: center; gap: var(--sp-2);
  border: 1px solid var(--border); background: transparent; border-radius: var(--r-pill);
  padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); text-transform: capitalize;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }

.main { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--sp-6) clamp(16px, 4vw, 48px) var(--sp-7); outline: none; min-width: 0; }
.view { display: flex; flex-direction: column; gap: var(--sp-5); animation: view-in var(--dur) var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.topbar { display: none; }
.scrim { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; gap: var(--sp-3);
    position: sticky; top: 0; z-index: 30;
    padding: var(--sp-2) 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .topbar .xp-pill { margin-left: auto; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 60;
    transform: translateX(-102%); transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow-3);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(0 0 0 / 0.35); }
  .hide-mobile { display: none; }
  .main { padding: var(--sp-4) 16px var(--sp-7); }
}
@media (max-width: 560px) {
  .hide-sm { display: none; }
  h1 { font-size: var(--fs-xl); }
}
