/* Base: reset, type, buttons, app shell (top bar, bottom tabs). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
img, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.display { font-family: var(--f-display); font-weight: 400; letter-spacing: .005em; }
.h1 { font-family: var(--f-display); font-size: var(--fs-h1); line-height: var(--lh-tight); font-weight: 400; }
.h2 { font-family: var(--f-display); font-size: var(--fs-h2); line-height: var(--lh-tight); font-weight: 400; }
.h3 { font-size: var(--fs-h3); line-height: var(--lh-tight); font-weight: 800; }
.muted { color: var(--c-text-2); }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--page-max); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--safe-top) + var(--bar-h));
  padding-bottom: calc(var(--safe-bottom) + var(--nav-h) + var(--s-5));
}
.app.no-nav { padding-bottom: calc(var(--safe-bottom) + var(--s-6)); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--btn-h); padding: 0 var(--s-5);
  border: 0; border-radius: var(--r-btn);
  font-size: var(--fs-button); font-weight: 800; line-height: 1.1; text-align: center;
  cursor: pointer; user-select: none;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-main { background: var(--c-accent); color: var(--c-text-on-accent); box-shadow: 0 6px 16px color-mix(in srgb, var(--c-accent) 28%, transparent); }
.btn-main:hover { background: var(--c-accent-hover); }
.btn-gold { background: var(--c-gold); color: var(--c-text); }
.btn-gold:hover { background: color-mix(in srgb, var(--c-gold) 88%, #000); }
.btn-soft { background: var(--c-surface-2); color: var(--c-text); }
.btn-soft:hover { background: color-mix(in srgb, var(--c-surface-2) 85%, #000); }
.btn-line { background: var(--c-bg); color: var(--c-text); box-shadow: inset 0 0 0 2px var(--c-line); }
.btn-line:hover { box-shadow: inset 0 0 0 2px var(--c-text-2); }
.btn-text { background: transparent; color: var(--c-text-2); min-height: var(--tap); padding: 0 var(--s-3); }
.btn-text:hover { color: var(--c-text); }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon { width: 24px; height: 24px; flex: none; }
.icon-lg { width: 28px; height: 28px; flex: none; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; z-index: 50; left: 0; right: 0; top: 0;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--c-bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  transition: box-shadow var(--t-mid) var(--ease);
}
.topbar.scrolled { box-shadow: 0 1px 0 var(--c-line), 0 6px 18px rgba(43, 29, 23, .05); }
.topbar-in { height: var(--bar-h); display: flex; align-items: center; gap: var(--s-3); }
.topbar .spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-name { font-family: var(--f-display); font-size: 24px; line-height: 1; color: var(--c-accent); white-space: nowrap; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-text);
  cursor: pointer; transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--c-surface-2); }
.icon-btn:active { transform: scale(.94); }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 0 var(--s-4) 0 var(--s-2);
  border: 0; border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-text);
  font-size: var(--fs-body); font-weight: 800; cursor: pointer; max-width: 60vw;
}
.back-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn:hover { background: var(--c-surface-2); }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--c-bg) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--sh-bar);
}
.tabs-in { height: var(--nav-h); display: grid; grid-template-columns: repeat(4, 1fr); max-width: 640px; margin: 0 auto; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; cursor: pointer; color: var(--c-text-2);
  font-size: var(--fs-small); font-weight: 800; line-height: 1.1;
}
.tab .icon { width: 26px; height: 26px; }
.tab.on { color: var(--c-accent); }
.tab-dot { position: relative; }
.tab-dot::after { content: ""; position: absolute; top: -2px; right: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-sale); box-shadow: 0 0 0 2px var(--c-bg); }
@media (min-width: 1024px) {
  /* on a big screen tabs move into the top bar (see .topnav) */
  .tabs { display: none; }
  .app { padding-bottom: var(--s-7); }
}
.topnav { display: none; gap: var(--s-1); }
@media (min-width: 1024px) { .topnav { display: flex; } }
.topnav .tab { flex-direction: row; gap: 8px; padding: 0 var(--s-4); min-height: var(--tap); border-radius: var(--r-pill); font-size: var(--fs-body); }
.topnav .tab:hover { background: var(--c-surface); color: var(--c-text); }
.topnav .tab.on { background: var(--c-accent-soft); }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--safe-bottom) + var(--nav-h) + 16px);
  transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--c-text); color: #fff; padding: 14px 20px; border-radius: 16px;
  font-weight: 700; box-shadow: var(--sh-2); animation: toast-in var(--t-mid) var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* page transitions */
.view { animation: view-in var(--t-mid) var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
