/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, monospace;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --sidebar: 252px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

:root, :root[data-theme="dark"] {
  --bg: #090909;
  --bg-2: #0d0d0d;
  --surface: #121212;
  --surface-2: #181818;
  --surface-3: #202020;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --text: #f3f1ec;
  --text-2: rgba(243, 241, 236, .62);
  --text-3: rgba(243, 241, 236, .38);
  --accent: #d8c29a;
  --accent-soft: rgba(216, 194, 154, .12);
  --accent-ink: #0b0b0b;
  --good: #82d3a5;
  --good-soft: rgba(130, 211, 165, .12);
  --warn: #e9bb6f;
  --warn-soft: rgba(233, 187, 111, .12);
  --bad: #ec8b7f;
  --bad-soft: rgba(236, 139, 127, .12);
  --info: #a4b8ff;
  --info-soft: rgba(164, 184, 255, .12);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 20px 50px -20px rgba(0,0,0,.6);
  --glow: radial-gradient(600px 300px at 15% -10%, rgba(216,194,154,.08), transparent 70%);
  --logo-filter: none;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f4f0;
  --bg-2: #efede8;
  --surface: #ffffff;
  --surface-2: #f6f5f1;
  --surface-3: #ecebe6;
  --line: rgba(12, 12, 12, .07);
  --line-2: rgba(12, 12, 12, .13);
  --text: #0c0c0c;
  --text-2: rgba(12, 12, 12, .6);
  --text-3: rgba(12, 12, 12, .4);
  --accent: #96773d;
  --accent-soft: rgba(150, 119, 61, .1);
  --accent-ink: #ffffff;
  --good: #24945a;
  --good-soft: rgba(36, 148, 90, .1);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, .1);
  --bad: #c4513f;
  --bad-soft: rgba(196, 81, 63, .1);
  --info: #4561d6;
  --info-soft: rgba(69, 97, 214, .1);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 16px 40px -24px rgba(0,0,0,.18);
  --glow: radial-gradient(600px 300px at 15% -10%, rgba(150,119,61,.07), transparent 70%);
  --logo-filter: invert(1);
  color-scheme: light;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14.5px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background .4s var(--ease), color .4s var(--ease);
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { display: block; max-width: 100%; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ─── Type ───────────────────────────────────────────────── */
.display { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; line-height: 1.05; }
.display em { font-style: italic; color: var(--text-2); }
.h1 { font-size: clamp(34px, 4.6vw, 52px); }
.h2 { font-size: clamp(26px, 3vw, 34px); }
.h3 { font-size: 22px; }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mono { font-family: var(--mono); }

/* ─── Shell ──────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px 16px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 18px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; filter: var(--logo-filter); }
.brand b { font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
.brand small { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 16px 12px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 450;
  transition: color .2s, background .2s;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav a.active::before {
  content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 2px;
  border-radius: 2px; background: var(--accent);
  animation: grow .4s var(--ease);
}
.nav .badge { margin-left: auto; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.me .avatar { width: 32px; height: 32px; font-size: 12px; }
.me div { min-width: 0; flex: 1; }
.me b { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { font-size: 11.5px; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; background-image: var(--glow); background-repeat: no-repeat; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .crumb { font-size: 13px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.topbar .crumb b { color: var(--text); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .mobile-brand { display: none; }

.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px clamp(16px, 4vw, 44px) 90px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin: 18px 0 30px; }
.page-head p { margin-top: 10px; max-width: 560px; }

/* ─── Mobile ─────────────────────────────────────────────── */
.tabbar { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar .mobile-brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
  .topbar .mobile-brand img { width: 26px; height: 26px; border-radius: 7px; filter: var(--logo-filter); }
  .topbar .crumb, .topbar .kbd { display: none; }
  .page { padding-bottom: 120px; }
  .tabbar {
    position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px; border-radius: 20px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid var(--line-2); box-shadow: var(--shadow);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 0 6px; border-radius: 14px; font-size: 10.5px; color: var(--text-3);
    transition: color .2s, background .2s;
  }
  .tabbar svg { width: 20px; height: 20px; }
  .tabbar .active { color: var(--text); background: var(--surface-3); }
  .tabbar .dot { position: absolute; top: 6px; right: calc(50% - 16px); }
}

/* ─── Login ──────────────────────────────────────────────── */
.login {
  position: relative; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: 24px 16px; overflow: hidden; background: #070707; color: #f3f1ec;
}
.login .lines { position: absolute; inset: -20%; transform: rotate(-12deg); opacity: .5; pointer-events: none; }
.login .lines i {
  position: absolute; left: -40%; height: 1px; width: 60%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: streak var(--d, 6s) linear infinite; animation-delay: var(--delay, 0s);
}
.login-card { position: relative; width: 100%; max-width: 400px; text-align: center; animation: rise .9s var(--ease) both; }
.login-card .logo { width: 64px; height: 64px; margin: 0 auto 28px; border-radius: 16px; box-shadow: 0 0 0 1px rgba(255,255,255,.1), 0 20px 60px -10px rgba(216,194,154,.25); }
.login-card h1 { font-size: 46px; }
.login-card p { color: rgba(243,241,236,.55); margin: 12px 0 30px; }
.login-field { position: relative; }
.login-field input {
  width: 100%; height: 56px; padding: 0 60px 0 20px; border-radius: 16px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12); color: #f3f1ec;
  font: 500 16px var(--mono); letter-spacing: .14em; text-transform: uppercase; text-align: center;
  transition: border-color .25s, background .25s, box-shadow .25s;
}
.login-field input::placeholder { color: rgba(243,241,236,.3); letter-spacing: .08em; }
.login-field input:focus { outline: none; border-color: rgba(216,194,154,.6); background: rgba(255,255,255,.06); box-shadow: 0 0 0 5px rgba(216,194,154,.08); }
.login-field button {
  position: absolute; right: 7px; top: 7px; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; background: #f3f1ec; color: #0b0b0b;
  transition: transform .25s var(--ease-spring), opacity .2s;
}
.login-field button:hover { transform: translateX(2px); }
.login-field button svg { width: 18px; height: 18px; }
.login-error { min-height: 22px; margin-top: 14px; font-size: 13px; color: #ec8b7f; }
.login.shake .login-field { animation: shake .45s; }
.login-foot { margin-top: 34px; font-size: 12px; color: rgba(243,241,236,.35); }
.login.leaving .login-card { animation: leave .5s var(--ease) forwards; }

/* ─── Motion ─────────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes leave { to { opacity: 0; transform: translateY(-10px) scale(.98); filter: blur(4px); } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes streak { from { transform: translateX(0); } to { transform: translateX(260%); } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ripple { from { transform: scale(.8); opacity: .6; } to { transform: scale(2.4); opacity: 0; } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

.view { animation: fade .35s var(--ease); }
.reveal { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
