/* Reset, typography and the app shell (sidebar, top bar, content, mobile nav). */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
  overflow-x: hidden;
}
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color var(--t-slow) var(--ease), border-color var(--t-slow) var(--ease),
    color var(--t-slow) var(--ease), fill var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease) !important;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
p { text-wrap: pretty; }
::selection { background: var(--brand-soft); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }
[hidden] { display: none !important; }

.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;
}
.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 1000; padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--surface); font-weight: 700; transform: translateY(-160%);
  transition: transform var(--t-med) var(--ease);
}
.skip-link:focus { transform: none; text-decoration: none; }
.noscript { padding: 40px; text-align: center; }

.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; font-optical-sizing: auto; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--brand);
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ------------------------------------------------------------ background */
.aurora { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.aurora::before, .aurora::after, .aurora span {
  content: ''; position: absolute; border-radius: 50%; filter: blur(70px);
}
.aurora::before { width: 620px; height: 620px; top: -240px; right: -120px; background: var(--bg-grad-1); }
.aurora::after { width: 560px; height: 560px; bottom: -260px; left: 18%; background: var(--bg-grad-2); }
.aurora span { width: 420px; height: 420px; top: 30%; left: -160px; background: var(--bg-grad-3); }
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .035;
  background-image: radial-gradient(var(--ink) .6px, transparent .6px);
  background-size: 3px 3px;
}

/* ------------------------------------------------------------------ boot */
.app-boot { min-height: 100vh; display: grid; place-items: center; }
.boot { display: grid; justify-items: center; gap: 14px; }
.boot__logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--coral-2), var(--coral) 55%, var(--violet));
  box-shadow: 0 10px 30px -6px var(--brand-glow);
  animation: pulse 1.4s var(--ease) infinite;
}
.boot__text { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(.92); opacity: .8; } }

/* ----------------------------------------------------------------- shell */
.shell {
  position: relative;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.shell::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 0; pointer-events: none;
  background: var(--sidebar-bg); border-right: 1px solid var(--line);
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--sp-6);
  padding: var(--sp-5) var(--sp-4);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--coral-2), var(--coral) 55%, var(--violet));
  box-shadow: 0 8px 20px -6px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand__mark svg { width: 22px; height: 22px; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 1.18rem; letter-spacing: -.02em; line-height: 1; }
.brand__sub { display: block; font-family: var(--font-ui); font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

.nav { display: grid; gap: 2px; }
.nav__label { font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); padding: 0 12px 6px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 650; font-size: var(--fs-md);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav__link svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav__link:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav__link[aria-current='page'] {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
}
.nav__link[aria-current='page'] svg { color: var(--brand); opacity: 1; }
.nav__link[aria-current='page']::before {
  content: ''; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--coral-2), var(--coral));
}
.nav__count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  display: grid; place-items: center; font-size: .72rem; font-weight: 800;
  background: var(--brand-soft); color: var(--brand);
}

.sidebar__card {
  margin-top: auto; padding: var(--sp-4); border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); box-shadow: var(--shadow-xs);
  display: grid; gap: 10px;
}
.sidebar__card h3 { font-size: var(--fs-sm); }
.sidebar__card p { font-size: var(--fs-xs); color: var(--muted); }
.gate-list { display: grid; gap: 6px; list-style: none; padding: 0; }
.gate-list li { display: flex; gap: 8px; align-items: center; font-size: var(--fs-xs); font-weight: 650; color: var(--ink-2); }
.gate-list svg { width: 14px; height: 14px; color: var(--ok); flex: none; }

.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); }
.me__avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, #16203A, #3A4562); color: #fff; font-weight: 800; font-size: .8rem;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14);
}
.me__name { font-weight: 750; font-size: var(--fs-sm); line-height: 1.2; }
.me__role { font-size: .72rem; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-8);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-med) var(--ease);
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar .topbar__menu { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; font-size: var(--fs-md); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); text-decoration: none; }
.crumbs svg { width: 14px; height: 14px; color: var(--faint); flex: none; }
.crumbs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__spacer { flex: 1; }
.searchbtn {
  display: flex; align-items: center; gap: 10px; height: 40px; min-width: 260px; padding: 0 10px 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.searchbtn:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.searchbtn svg { width: 16px; height: 16px; }
.searchbtn kbd { margin-left: auto; }
kbd {
  font-family: var(--font-ui); font-size: .7rem; font-weight: 800; color: var(--muted);
  padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2);
  box-shadow: 0 1px 0 var(--line);
}

.content {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: var(--sp-6) var(--sp-8) var(--sp-12);
  display: grid; gap: var(--sp-6); align-content: start;
}
.content:focus { box-shadow: none; }
.view-enter { animation: viewIn var(--t-slow) var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-2xl); letter-spacing: -.02em; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 70ch; }
.page-head__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.footnote { font-size: var(--fs-xs); color: var(--faint); text-align: center; padding: var(--sp-4) 0 0; }

/* bottom nav (phones) */
.tabbar { display: none; }
.scrim { display: none; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  :root { --sidebar-w: 232px; }
  .content { padding: var(--sp-6) var(--sp-6) var(--sp-12); }
  .topbar { padding: 0 var(--sp-6); }
  .searchbtn { min-width: 200px; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .shell::before { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 288px; transform: translateX(-104%);
    transition: transform var(--t-med) var(--ease); box-shadow: var(--shadow-lg);
    background: var(--surface);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: var(--overlay); animation: fade var(--t-med) var(--ease); }
  .topbar { padding: 0 var(--sp-4); }
  .topbar .topbar__menu { display: inline-grid; }
  .topbar .mode-pill { display: none; }
  .searchbtn { min-width: 0; width: 40px; padding: 0; justify-content: center; }
  .searchbtn span, .searchbtn kbd { display: none; }
  .content { padding: var(--sp-4) var(--sp-4) calc(var(--sp-12) + 64px); gap: var(--sp-5); }
  .page-head h1 { font-size: 1.6rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: grid; justify-items: center; gap: 3px; padding: 6px 2px; border-radius: var(--r-sm);
    color: var(--muted); font-size: .66rem; font-weight: 750;
  }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a[aria-current='page'] { color: var(--brand); background: var(--brand-soft); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

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