/* ---------- Brand mark ---------- */
.brand { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); border-radius: var(--r-sm); }
.brand-mark { display: inline-flex; align-items: center; gap: 10px; }
.brand-emblem { width: 34px; height: 34px; color: var(--sea-300); flex: none; }
.brand-emblem-core { fill: var(--coral-500); }
.brand-emblem-moon { fill: var(--butter-300); }
.brand-word {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 72, "SOFT" 100;
  line-height: 1;
}
.brand:hover .brand-emblem { transform: rotate(-18deg); }
.brand-emblem { transition: transform var(--t-slow) var(--ease-spring); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  transition: background-color var(--t-med) ease, border-color var(--t-med) ease, backdrop-filter var(--t-med) ease;
  background: rgb(6 20 24 / 0.72);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
}
.page-home .site-header { position: fixed; inset: 0 0 auto; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.page-home .site-header.is-scrolled, .site-header.is-scrolled { background: rgb(6 20 24 / 0.82); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); border-bottom-color: var(--line); }
.site-header__inner {
  display: flex; align-items: center; gap: 24px;
  height: 100%;
  width: min(100% - 2 * var(--gutter), 1440px);
  margin: 0 auto;
}
.primary-nav { display: flex; gap: 4px; margin-left: 16px; }
.primary-nav a {
  position: relative;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  color: var(--text-soft);
  font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none;
  transition: color var(--t-fast);
}
.primary-nav a::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 5px; height: 2px; border-radius: 2px;
  background: var(--coral-500);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--t-med) var(--ease-out);
}
.primary-nav a:hover { color: var(--text); }
.primary-nav a:hover::after, .primary-nav a[aria-current="page"]::after { transform: scaleX(1); }
.primary-nav a[aria-current="page"] { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.balance-chip {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 16px 0 6px;
  border: 1px solid rgb(255 224 166 / 0.28);
  border-radius: var(--r-pill);
  background: rgb(255 224 166 / 0.06);
  text-decoration: none;
  font-size: var(--fs-sm);
}
.balance-chip strong { color: var(--butter-200); font-variant-numeric: tabular-nums; font-weight: 700; }
.balance-chip__label { color: var(--text-muted); }
.balance-chip__coin, .profile-balance__coin {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6dc, var(--butter-300) 35%, var(--butter-500) 70%, #a26a1c);
  box-shadow: 0 0 0 3px rgb(255 224 166 / 0.14), inset 0 -2px 3px rgb(0 0 0 / 0.25);
}

/* ---------- Flash, toast, reminder ---------- */
.flash {
  width: min(100% - 2 * var(--gutter), 760px);
  margin: 16px auto 0;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: var(--fs-sm);
}
.flash--notice { border-color: rgb(111 220 191 / 0.4); }
.flash--alert { border-color: rgb(255 106 77 / 0.5); color: var(--coral-300); }
.page-home .flash { position: fixed; top: calc(var(--header-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 90; box-shadow: var(--shadow-3); margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); z-index: 160;
  transform: translate(-50%, 0);
  padding: 12px 18px;
  border-radius: var(--r-pill);
  background: var(--text); color: var(--ink-900);
  font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--shadow-3);
  animation: toast-in var(--t-slow) var(--ease-spring);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px) scale(0.96); } }

.session-reminder {
  position: fixed; right: 20px; bottom: calc(var(--tabbar-h) + 20px); z-index: 140;
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: start;
  width: min(380px, calc(100% - 32px));
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-3);
}
.session-reminder__icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: rgb(111 220 191 / 0.12); color: var(--sea-300); grid-row: span 2; }
.session-reminder p { font-size: var(--fs-sm); color: var(--text-soft); }
.session-reminder a { color: var(--sea-200); font-size: var(--fs-sm); align-self: center; }
.session-reminder > a, .session-reminder > button { grid-column: 2; justify-self: start; }

/* ---------- Dialog sheets (auth) ---------- */
dialog { color: var(--text); }
.sheet {
  width: min(480px, calc(100% - 24px));
  max-height: min(92dvh, 900px);
  padding: 32px clamp(20px, 4vw, 36px) 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: radial-gradient(120% 60% at 50% 0%, rgb(255 106 77 / 0.12), transparent 60%), var(--surface);
  box-shadow: var(--shadow-3);
  overflow: auto;
}
.sheet::backdrop { background: rgb(2 8 10 / 0.72); backdrop-filter: blur(6px); }
.sheet[open] { animation: sheet-in var(--t-slow) var(--ease-out); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } }
.sheet__close { position: absolute; top: 14px; right: 14px; }

.auth-brand { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-perk {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: fit-content; margin: 0 auto 18px; padding: 6px 14px 6px 8px;
  border-radius: var(--r-pill); background: rgb(255 224 166 / 0.08); border: 1px solid rgb(255 224 166 / 0.22);
  font-size: var(--fs-xs); color: var(--butter-200);
}
.auth-perk__orb { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6dc, var(--butter-300) 40%, var(--butter-500)); }
.sheet h2, .auth-card h2, .auth-card h1 { text-align: center; font-size: var(--fs-2xl); margin-bottom: 18px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 20px; border-radius: var(--r-pill); background: var(--ink-950); border: 1px solid var(--line); }
.auth-tabs button, .auth-tabs a { min-height: 42px; display: grid; place-items: center; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-muted); font-weight: 600; font-size: var(--fs-sm); text-decoration: none; transition: all var(--t-fast); }
.auth-tabs .active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }
.auth-intro { text-align: center; color: var(--text-soft); margin-bottom: 14px; font-size: var(--fs-sm); }
.auth-intro strong { color: var(--butter-200); }
.auth-disclosure { margin-top: 16px; text-align: center; font-size: var(--fs-xs); color: var(--text-muted); }
.forgot-link { justify-self: end; font-size: var(--fs-sm); color: var(--sea-200); }
.stack-form input[type="submit"] { margin-top: 8px; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: clamp(40px, 6vw, 80px);
  padding: clamp(40px, 6vw, 72px) 0 32px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--ink-950), #020809);
}
.site-footer__grid, .site-footer__boundary, .site-footer__legal { width: min(100% - 2 * var(--gutter), var(--content)); margin: 0 auto; }
.site-footer__grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 40px; }
.site-footer__brand p { margin: 16px 0 20px; max-width: 36ch; color: var(--text-muted); font-size: var(--fs-sm); }
.site-footer nav { display: grid; align-content: start; gap: 10px; }
.site-footer nav h2 { font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; }
.site-footer nav a { color: var(--text-soft); text-decoration: none; font-size: var(--fs-sm); width: fit-content; }
.site-footer nav a:hover { color: var(--text); text-decoration: underline; }
.site-footer__boundary { display: flex; gap: 18px; align-items: flex-start; margin-top: 48px; padding: 20px; border-radius: var(--r-lg); border: 1px solid var(--line); background: rgb(196 246 230 / 0.03); }
.site-footer__boundary p { font-size: var(--fs-sm); color: var(--text-muted); }
.site-footer__boundary a { color: var(--sea-200); }
.age-badge { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--coral-400); color: var(--coral-300); font-weight: 700; font-size: var(--fs-sm); }
.site-footer__legal { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; margin-top: 28px; font-size: var(--fs-xs); color: var(--text-faint); }
.site-footer__legal a { color: var(--text-muted); }

/* ---------- Mobile tab bar ---------- */
.tab-bar { display: none; }
@media (max-width: 860px) {
  .primary-nav, .header-login, .balance-chip__label, .header-search { display: none; }
  .brand-word { font-size: 1.35rem; }
  .brand-emblem { width: 30px; height: 30px; }
  .tab-bar {
    position: fixed; inset: auto 0 0; z-index: 120;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    background: rgb(6 20 24 / 0.9);
    backdrop-filter: saturate(1.4) blur(18px);
    -webkit-backdrop-filter: saturate(1.4) blur(18px);
    border-top: 1px solid var(--line);
  }
  .tab-bar a {
    display: grid; justify-items: center; align-content: center; gap: 3px;
    height: var(--tabbar-h);
    color: var(--text-muted); text-decoration: none;
    font-size: 11px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-bar a .icon { width: 22px; height: 22px; }
  .tab-bar a[aria-current="page"] { color: var(--text); }
  .tab-bar a[aria-current="page"] .icon { color: var(--coral-400); }
  .tab-bar__portal { position: relative; }
  .tab-bar__orb {
    width: 50px; height: 50px; margin-top: -26px; border-radius: 50%;
    background: radial-gradient(circle at 50% 40%, var(--coral-400), var(--coral-600) 60%, #7a2413);
    box-shadow: 0 0 0 5px var(--ink-900), 0 0 0 6px rgb(255 138 110 / 0.5), 0 10px 26px -4px var(--glow);
    position: relative;
  }
  .tab-bar__orb::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 2px solid rgb(255 240 204 / 0.8); border-right-color: transparent; animation: spin 3.5s linear infinite; }
  .site-footer__grid { grid-template-columns: 1fr 1fr; }
  .site-footer__brand { grid-column: 1 / -1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Analytics consent (only when GA configured) ---------- */
.analytics-consent {
  position: fixed; z-index: 150; left: 50%; bottom: calc(var(--tabbar-h) + max(1rem, env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  width: min(720px, calc(100% - 2rem)); max-height: 75dvh; overflow: auto;
  padding: 1.4rem;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.analytics-consent h2 { font-size: var(--fs-xl); margin-bottom: 0.6rem; }
.analytics-consent p { font-size: var(--fs-sm); color: var(--text-soft); margin: 0.6rem 0; }
.analytics-consent a { color: var(--sea-200); }
.analytics-choice-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0 0.5rem; }
.analytics-choice-actions .button { flex: 1 1 180px; }
.analytics-choice-actions .button[aria-pressed="true"] { outline: 2px solid var(--sea-300); outline-offset: 2px; }
.analytics-choice-status { font-size: var(--fs-sm); color: var(--text-muted); }

@media (max-width: 560px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; gap: 28px 16px; }
  .site-footer__boundary { flex-direction: column; }
  .header-actions .button--sm { padding: 0 14px; }
}
