/* Fit & Calm — fonts, reset, base elements, app shell (bottom bar on phones, sidebar on laptops). */

/* Fraunces (headings) & Inter (body), self-hosted. SIL Open Font License 1.1: assets/fonts/OFL-*.txt */
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("../assets/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("../assets/fonts/fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../assets/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../assets/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/var(--lh) var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 500; font-variation-settings: 'SOFT' 100, 'WONK' 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: var(--fs-title); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p, ul, ol { margin: 0; }
ul, ol { padding: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }

.visually-hidden {
  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: 12px; top: -60px; z-index: 100;
  padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--button-bg); color: var(--on-button); font-weight: 500; text-decoration: none;
}
.skip-link:focus { top: calc(12px + var(--safe-t)); }

.icon { width: var(--icon); height: var(--icon); flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- demo banner ---------- */
body.has-demo { --demo-h: 32px; }
.demo-banner {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: var(--s-5);
  min-height: var(--demo-h); padding: 4px var(--gutter); padding-top: calc(4px + var(--safe-t));
  background: var(--button-bg); color: var(--on-button);
  font-size: var(--fs-sm); text-align: center;
}
.demo-banner a { color: inherit; font-weight: 600; }

/* ---------- app shell ---------- */
.shell { min-height: calc(100dvh - var(--demo-h)); }
.main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: calc(var(--s-6) + var(--safe-t)) var(--gutter) calc(var(--tabbar-h) + var(--safe-b) + var(--s-8));
}
body.has-demo .main { padding-top: var(--s-6); }
.main:focus { outline: none; }

/* bottom bar (phone) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 4px var(--safe-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 0; padding: 0; border: 0; background: none;
  color: var(--text-muted); font-size: var(--fs-2xs); font-weight: 500; text-decoration: none;
}
.tab .icon { width: var(--icon-nav); height: var(--icon-nav); }
.tab[aria-current="page"] { color: var(--primary-strong); font-weight: 600; }
.tab[aria-current="page"] .icon { stroke-width: 2; }
.tab span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sidebar (laptop) */
.sidebar { display: none; }

@media (min-width: 860px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .tabbar { display: none; }
  .main { padding: var(--s-8) var(--s-8) var(--s-10); }
  .sidebar {
    position: sticky; top: var(--demo-h);
    display: flex; flex-direction: column; gap: 2px;
    height: calc(100dvh - var(--demo-h)); overflow-y: auto;
    padding: var(--s-7) var(--s-4) var(--s-6);
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-3) var(--s-7); color: var(--text); text-decoration: none; }
  .brand img { width: 32px; height: 32px; border-radius: 9px; }
  .brand strong { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.1; }
  .brand small { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
  .side-link {
    display: flex; align-items: center; gap: var(--s-4);
    height: 34px; padding: 0 var(--s-4); border-radius: var(--r-sm);
    color: var(--text-muted); font-size: 13px; font-weight: 500; text-decoration: none;
  }
  .side-link[aria-current="page"] { background: var(--surface-2); color: var(--primary-strong); font-weight: 600; }
  .side-sub { height: 30px; padding-left: calc(var(--s-4) + 4px); font-size: 12.5px; }
  .side-label { margin: var(--s-6) var(--s-4) var(--s-2); font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
}
@media (hover: hover) and (min-width: 860px) {
  .side-link:not([aria-current="page"]):hover { background: var(--surface-3); color: var(--text); }
}

.app-footer {
  margin-top: var(--s-10);
  padding-top: var(--s-5);
  border-top: 1px dashed var(--line-strong);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-align: center;
}
.app-footer p + p { margin-top: 2px; }

.boot { display: grid; place-items: center; min-height: 70dvh; color: var(--text-muted); font-size: var(--fs-sm); }
.page-loading { display: flex; align-items: center; justify-content: center; gap: var(--s-4); min-height: 40dvh; color: var(--text-muted); font-size: var(--fs-sm); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary-strong); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
