*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 8px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(22px, 5vw, 30px); font-weight: 800; }
h2 { font-size: 18px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
a { color: var(--green-700); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
mark { background: var(--orange-100); color: inherit; border-radius: 3px; padding: 0 1px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 650; font-size: 14px; margin-bottom: 8px; }
dialog { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-3); width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(7, 30, 15, .45); backdrop-filter: blur(2px); }

:focus-visible { outline: 3px solid var(--orange-500); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { 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 { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--green-800); color: #fff; padding: 10px 14px; border-radius: var(--r-sm); }
.skip:focus { top: 10px; }

.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.block { display: block; }
.pad { padding: 0 var(--gutter); }
.ok { color: var(--ok); font-weight: 650; }
.warn { color: var(--warn); font-weight: 650; }
.scroll-x { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { display: none; }

/* ---------- app shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 var(--gutter); padding-left: max(var(--gutter), env(safe-area-inset-left));
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.main {
  flex: 1; width: 100%; max-width: var(--page-max); margin: 0 auto;
  padding: 16px var(--gutter) calc(var(--nav-h) + var(--safe-b) + 28px);
  outline: none;
}
body[data-route="signin"] .main, body[data-route="signup"] .main { max-width: 480px; }
.view { display: flex; flex-direction: column; gap: 16px; animation: view-in .22s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); box-shadow: 0 -6px 20px -12px rgba(10, 40, 20, .25);
}
.bottom-nav ul { list-style: none; margin: 0 auto; padding: 0 4px; height: var(--nav-h); max-width: 640px; display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch; }
.bottom-nav a {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 650; text-align: center; line-height: 1.15;
  position: relative; padding: 0 2px; border-radius: var(--r-sm);
}
.bottom-nav .nav-ico { display: grid; place-items: center; width: 44px; height: 30px; border-radius: var(--r-pill); transition: background .15s, color .15s; }
.bottom-nav a.active { color: var(--green-800); }
.bottom-nav a.active .nav-ico { background: var(--green-100); color: var(--green-700); }
.bottom-nav a.active::after { content: ""; position: absolute; top: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--orange-500); transform: translateX(18px); }
/* Marketplace: raised orange centre action */
.bottom-nav li:nth-child(3) .nav-ico {
  width: 52px; height: 52px; margin-top: -26px; border-radius: 50%;
  background: linear-gradient(145deg, var(--orange-400), var(--orange-600)); color: #1d0f02;
  box-shadow: 0 8px 18px -6px rgba(227, 106, 12, .65), 0 0 0 5px #fff;
}
.bottom-nav li:nth-child(3) a.active .nav-ico { background: linear-gradient(145deg, var(--orange-500), var(--orange-700)); color: #fff; }
.bottom-nav li:nth-child(3) a.active::after { display: none; }
@media (max-width: 359px) { .bottom-nav a { font-size: 10px; } .bottom-nav .nav-ico { width: 38px; } }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: max-content; max-width: min(92vw, 440px); padding: 11px 16px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-3);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-success { background: var(--green-800); }
.toast-error { background: #8f1d21; }

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

/* programmatic focus on page titles after navigation: no visible ring */
[tabindex="-1"]:focus:not(:focus-visible), h1[tabindex="-1"]:focus { outline: none; }
