/* BASE — reset, layout, nav/footer chrome, buttons, chips, cards, forms, toasts.
   Uses only the token variables defined in css/tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: var(--fs-md); line-height: var(--lh);
  -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); line-height: 1.2; margin: 0 0 var(--space-3); color: var(--text); }
h1 { font-size: var(--fs-3xl); } h2 { font-size: var(--fs-2xl); } h3 { font-size: var(--fs-xl); } h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--space-4); }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.9em; }
:not(pre) > code { background: var(--code-bg); color: var(--code-text); padding: 0.1em 0.38em; border-radius: var(--radius-sm); }
pre { background: var(--code-bg); color: var(--code-text); padding: var(--space-4); border-radius: var(--radius); overflow-x: auto; line-height: 1.5; border: 1px solid var(--border); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--space-4); }
@media (min-width: 720px) { .container { padding: 0 var(--space-5); } }
.main { flex: 1 0 auto; width: 100%; }
.section { padding: var(--space-8) 0; }
.section--tight { padding: var(--space-6) 0; }
.eyebrow { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--space-3); display: inline-block; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.lead { font-size: var(--fs-lg); color: var(--text-muted); max-width: 62ch; }

/* ---------- Nav ---------- */
.nav { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.nav__inner { max-width: var(--maxw); margin: 0 auto; height: var(--nav-h); display: flex; align-items: center; gap: var(--space-5); padding: 0 var(--space-4); }
@media (min-width: 720px) { .nav__inner { padding: 0 var(--space-5); } }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand__mark { width: 24px; height: 24px; fill: var(--accent); stroke: var(--accent); stroke-width: 1.6; }
.nav__links { display: none; gap: var(--space-1); }
.nav__link { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; padding: 6px 12px; border-radius: var(--radius-pill); }
.nav__link:hover { color: var(--text); background: var(--bg-sunken); text-decoration: none; }
.nav__link.is-active { color: var(--text); background: var(--bg-sunken); }
.nav__account { margin-left: auto; display: none; align-items: center; gap: var(--space-2); }
.nav__toggle { margin-left: auto; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--bg-elev); border-radius: var(--radius); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; cursor: pointer; }
.nav__toggle span { width: 16px; height: 2px; background: var(--text); border-radius: 2px; }
.nav__drawer { border-top: 1px solid var(--border); padding: var(--space-3) var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); background: var(--bg); }
.nav__drawer[hidden] { display: none; }
.nav__drawer-link { display: block; padding: 10px 4px; color: var(--text); font-weight: 500; border: 0; background: none; text-align: left; font: inherit; cursor: pointer; }
[data-slot="drawer-account"] { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); border-top: 1px solid var(--border); padding-top: var(--space-3); }
@media (min-width: 820px) {
  .nav__links { display: flex; }
  .nav__account { display: flex; }
  .nav__toggle, .nav__drawer { display: none !important; }
}
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.avatar--initials { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: var(--fs-xs); }
.menu { position: relative; }
.menu__trigger { border: 0; background: none; padding: 2px; border-radius: 50%; cursor: pointer; }
.menu__panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-2); z-index: 60; }
.menu__head { padding: var(--space-2) var(--space-3) var(--space-3); border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); }
.menu__name { font-weight: 600; font-size: var(--fs-sm); }
.menu__sub { font-size: var(--fs-xs); color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; }
.menu__item { display: block; width: 100%; text-align: left; padding: 8px var(--space-3); border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: var(--fs-sm); background: none; border: 0; cursor: pointer; }
.menu__item:hover { background: var(--bg-sunken); text-decoration: none; }
.menu__item--accent { color: var(--accent); font-weight: 600; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: var(--space-8); background: var(--bg); }
.footer__inner { max-width: var(--maxw); margin: 0 auto; padding: var(--space-7) var(--space-4) var(--space-5); display: grid; gap: var(--space-6); }
@media (min-width: 820px) { .footer__inner { grid-template-columns: 1.2fr 2fr; padding-left: var(--space-5); padding-right: var(--space-5); } }
.footer__tag { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--space-2); max-width: 36ch; }
.footer__cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-5); }
.footer__cols h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); font-family: var(--font-mono); font-weight: 500; }
.footer__cols a { display: block; color: var(--text-muted); font-size: var(--fs-sm); padding: 3px 0; }
.footer__legal { grid-column: 1 / -1; color: var(--text-faint); font-size: var(--fs-xs); border-top: 1px solid var(--border); padding-top: var(--space-4); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); font: inherit; font-weight: 600; font-size: var(--fs-sm); line-height: 1; padding: 11px 18px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--bg-elev); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--text-faint); }
.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost:hover { background: var(--bg-sunken); }
.btn--sm { padding: 8px 12px; font-size: var(--fs-sm); }
.btn--lg { padding: 14px 22px; font-size: var(--fs-md); }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap; line-height: 1.5; }
.chip--pro { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip--streak { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.chip--free { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.chip--company { background: var(--accent-2-soft); color: var(--accent-2); border-color: transparent; }
.diff { font-size: var(--fs-xs); font-weight: 600; font-family: var(--font-mono); text-transform: lowercase; }
.diff--easy { color: var(--easy); } .diff--medium { color: var(--medium); } .diff--hard { color: var(--hard); }

/* ---------- Cards ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.card__title { font-size: var(--fs-lg); margin-bottom: var(--space-2); }
.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field label { font-size: var(--fs-sm); font-weight: 600; }
.input, .select { font: inherit; font-size: var(--fs-sm); padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg-elev); color: var(--text); width: 100%; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.form-error { color: var(--bad); font-size: var(--fs-sm); min-height: 1.2em; }
.form-ok { color: var(--ok); font-size: var(--fs-sm); }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); font-size: var(--fs-sm); box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast--ok { background: var(--ok); color: #fff; }
.toast--bad { background: var(--bad); color: #fff; }
.toast.is-out { opacity: 0; transform: translateY(6px); }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--bg-sunken), var(--border), var(--bg-sunken)); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; border-radius: var(--radius-sm); min-height: 1em; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { scroll-behavior: auto !important; } }
.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--text-muted); }
