/* ============================================================
   ZYORA — Base reset, typography, layout shell
   Load AFTER design-tokens.css, BEFORE components.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  overflow-x: hidden;
  transition: background-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}

/* ---------- Headings ---------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  color: var(--text);
}
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-extrabold); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p  { margin: 0; color: var(--text-soft); line-height: var(--lh-relaxed); }

/* ---------- Links ---------- */
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
a:hover { opacity: 0.85; }

/* ---------- Media ---------- */
img, svg, video { max-width: 100%; display: block; }
svg { flex-shrink: 0; }

/* ---------- Forms ---------- */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; border: 0; background: transparent; padding: 0; }

/* ---------- Focus ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* ---------- Scrollbar ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; }

/* ============================================================
   App shell — the outer frame every logged-in page uses
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5) calc(var(--bottombar-h) + var(--sp-8));
}

@media (min-width: 900px) {
  .app-main {
    padding: var(--sp-8) var(--sp-6) var(--sp-12);
  }
}

/* ============================================================
   Page primitives
   ============================================================ */
.page { width: 100%; max-width: var(--content-max); margin: 0 auto; }
.page--narrow { max-width: 640px; }
.page--wide { max-width: 1120px; }

.page-hd {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.page-hd__text { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-1); }
.page-hd h1 { margin: 0; }
.page-hd p  { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }
.page-hd__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ============================================================
   Common layout helpers
   ============================================================ */
.stack   { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--sm { gap: var(--sp-2); }
.stack--lg { gap: var(--sp-6); }
.row     { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.spacer  { flex: 1; }

.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 720px) {
  .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   Text utilities
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-soft  { color: var(--text-soft); }
.text-sm    { font-size: var(--fs-sm); }
.text-xs    { font-size: var(--fs-xs); }
.text-mono  { font-family: var(--mono); }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.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;
}

.hidden { display: none !important; }

/* ============================================================
   Topbar (page header used by logged-in pages)
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 max(var(--sp-4), calc((100vw - 1120px) / 2 + var(--sp-4)));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

/* Brand mark */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: var(--fw-extrabold);
  font-size: var(--fs-md);
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand__dot {
  width: 9px; height: 9px;
  border-radius: var(--r-pill);
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 50%, transparent);
}
.brand-mini { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-extrabold); letter-spacing: -0.02em; }
.brand-dot {
  width: 9px; height: 9px; border-radius: var(--r-pill);
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 50%, transparent);
}

/* ============================================================
   Bottom navigation (mobile)
   ============================================================ */
.bottom-nav {
  position: fixed;
  z-index: var(--z-nav);
  left: 50%;
  transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 440px);
  height: var(--bottombar-h);
  padding: 5px;
  display: flex;
  gap: 2px;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  box-shadow: var(--sh-lg);
}
.bottom-nav__link {
  flex: 1 1 0;
  min-width: 0;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: var(--r-lg);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.bottom-nav__link svg { width: 19px; height: 19px; stroke-width: 1.8; }
.bottom-nav__link:active { transform: scale(0.95); }
.bottom-nav__link.is-active {
  color: var(--on-accent);
  background: var(--accent);
}

@media (min-width: 900px) {
  .bottom-nav { display: none; }
}

/* ============================================================
   Site footer
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: var(--sp-6) var(--sp-5) var(--sp-8);
  text-align: center;
}
.site-footer__inner {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}
.site-footer__tag  { font-size: var(--fs-sm); color: var(--text-soft); }
.site-footer__link {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text-soft);
  border-bottom: 1px dashed var(--border-strong);
}
.site-footer__link:hover { color: var(--text); border-color: var(--text); }
.site-footer__copy { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-2); }
.site-footer__links { display: flex; gap: var(--sp-3); flex-wrap: wrap; justify-content: center; margin-top: var(--sp-3); }
.site-footer__links a { font-size: var(--fs-xs); color: var(--text-muted); }
.site-footer__links a:hover { color: var(--text); }

/* Hide footer on chat / auth pages */
body.chat-page .site-footer { display: none !important; }

/* ============================================================
   Icons (Lucide-compatible)
   ============================================================ */
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--xs  { width: 12px; height: 12px; }
.icon--sm  { width: 14px; height: 14px; }
.icon--lg  { width: 20px; height: 20px; }
.icon--xl  { width: 24px; height: 24px; }
.icon--2xl { width: 32px; height: 32px; }
.icon--3xl { width: 48px; height: 48px; }

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}