:root {
  --site-page-width: min(1240px, calc(100% - 64px));
  --site-title-size: clamp(42px, 4.7vw, 74px);
  --site-display-size: clamp(30px, 3vw, 48px);
  --site-copy-size: 16px;
  --site-nav-size: 12px;
  --site-header-height: 76px;
  --site-header-gutter: clamp(24px, 3.2vw, 58px);
  --site-header-grid: 220px minmax(0, 1fr) 220px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: clip; }
body { font-size: var(--site-copy-size); }

.header-inner, .site-header .header-inner, .page-shell, .main-shell, .library-shell,
.about-shell, .account-shell, .daily-shell, .face-shell, .tools-shell {
  width: var(--site-page-width);
  max-width: 1240px;
}

  .hero-title, .page-title, .library-title, .about-title, .account-title,
  .daily-title, .face-title, .tools-title {
  font-size: var(--site-title-size) !important;
  line-height: 0.98 !important;
  letter-spacing: 0 !important;
}

.primary-nav a, .nav a, .account-link, .language-switcher button {
  font-size: var(--site-nav-size) !important;
}

/* Shared navigation shell. These overrides intentionally supersede each
   legacy page's local header CSS so every page uses the same geometry. */
.site-header, .topbar {
  position: fixed !important;
  inset: 0 0 auto !important;
  z-index: 100 !important;
  width: 100% !important;
  height: var(--site-header-height) !important;
  min-height: var(--site-header-height) !important;
  display: grid !important;
  grid-template-columns: var(--site-header-grid) !important;
  align-items: center !important;
  gap: 24px !important;
  margin: 0 !important;
  padding: 0 var(--site-header-gutter) !important;
  border-bottom: 1px solid rgba(200, 166, 75, 0.12) !important;
  background: linear-gradient(180deg, rgba(3, 5, 4, 0.9), rgba(3, 5, 4, 0.7)) !important;
  backdrop-filter: blur(12px) !important;
}

.site-header > .header-inner { display: contents !important; }

.site-header .brand, .site-header .brand-mark, .topbar .brand, .topbar .brand-mark {
  justify-self: start !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 11px !important;
  min-width: 0 !important;
  color: #c8a64b !important;
  text-decoration: none !important;
}

.site-header .brand-seal, .topbar .brand-seal {
  width: 36px !important;
  height: 36px !important;
  flex: 0 0 36px !important;
}

.site-header .brand-title, .topbar .brand-title {
  display: block !important;
  font-family: "Cinzel", "KaiTi", "STKaiti", serif !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.08 !important;
  letter-spacing: 1.6px !important;
  white-space: nowrap !important;
}

.site-header .brand-subtitle, .topbar .brand-subtitle {
  display: block !important;
  margin-top: 3px !important;
  color: rgba(200, 166, 75, 0.66) !important;
  font-family: "Cinzel", Georgia, serif !important;
  font-size: 8px !important;
  letter-spacing: 1.25px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

/* legal.html uses bare spans rather than the standard brand-title classes. */
.topbar .brand > span:first-child,
.site-header .brand > span:first-child:not(:has(span)) {
  color: #c8a64b !important;
  font-family: "Cinzel", "KaiTi", "STKaiti", serif !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.08 !important;
  letter-spacing: 1.6px !important;
  white-space: nowrap !important;
}

.topbar .brand > span:last-child,
.site-header .brand > span:last-child:not(:has(span)) {
  color: rgba(200, 166, 75, 0.66) !important;
  font-family: "Cinzel", Georgia, serif !important;
  font-size: 8px !important;
  letter-spacing: 1.25px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

.primary-nav, .nav {
  justify-self: center !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: clamp(16px, 2.1vw, 36px) !important;
  margin: 0 !important;
  padding: 0 !important;
  white-space: nowrap !important;
}

.primary-nav a, .nav a {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  min-height: var(--site-header-height) !important;
  margin: 0 !important;
  padding: 0 !important;
  color: rgba(238, 226, 190, 0.66) !important;
  font-family: "Cinzel", "KaiTi", "STKaiti", serif !important;
  font-size: var(--site-nav-size) !important;
  font-weight: 500 !important;
  letter-spacing: 1.25px !important;
  line-height: 1 !important;
  text-decoration: none !important;
}

.primary-nav a.active, .primary-nav a:hover, .nav a.active, .nav a:hover { color: #c8a64b !important; }

.primary-nav a.active::after, .nav a.active::after {
  left: 50% !important;
  right: auto !important;
  bottom: 9px !important;
  width: 22px !important;
  height: 2px !important;
  transform: translateX(-50%) !important;
}

.site-header .account-links, .topbar .account-links, .site-header .account-shell, .site-header .account-chip {
  justify-self: end !important;
  box-sizing: border-box !important;
  min-width: 0 !important;
}

.site-header .account-links, .topbar .account-links {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  width: 220px !important;
  gap: 0 !important;
}

.site-header .account-login, .topbar .account-login, .site-header .account-chip {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 122px !important;
  min-width: 122px !important;
  min-height: 32px !important;
  padding: 8px 12px !important;
  font-family: "Cinzel", "KaiTi", "STKaiti", serif !important;
  font-size: 11px !important;
  letter-spacing: 1px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

.site-header .account-icon, .topbar .account-icon {
  display: none !important;
}

/*
 * Every page reserves the same right-hand header slot.  The index and tools
 * pages used to expose their full account dashboard in the header, which
 * shifted the entry as authentication state changed.  The header now exposes
 * exactly one fixed-width route into the account center; account actions stay
 * on account.html.
 */
.site-header .account-shell {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  width: 220px !important;
  max-width: 220px !important;
  min-height: var(--site-header-height) !important;
}

.site-header .account-shell .account-row,
.site-header .account-shell .account-actions {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  width: 100% !important;
  gap: 0 !important;
}

.site-header .account-shell .account-status,
.site-header .account-shell .account-form,
.site-header .account-shell .account-message,
.site-header .account-shell .report-history,
.site-header .account-shell #showRegister,
.site-header .account-shell #showHistory,
.site-header .account-shell #logoutButton,
.site-header .account-shell #deleteAccountButton {
  display: none !important;
}

.site-header .account-shell .account-button {
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  width: 122px !important;
  min-width: 122px !important;
  min-height: 32px !important;
  padding: 8px 12px !important;
  font-size: 11px !important;
  line-height: 1 !important;
  letter-spacing: 1px !important;
  white-space: nowrap !important;
}

.site-header .account-shell:not(.logged-in) #showLogin,
.site-header .account-shell.logged-in #accountCenter {
  display: inline-flex !important;
}

/* The locale control belongs to the same fixed right-side header slot on every
   page.  It must not inherit placement from a page-specific navigation or
   account wrapper. */
.site-header .language-switcher,
.topbar .language-switcher {
  position: absolute !important;
  top: 50% !important;
  right: calc(var(--site-header-gutter) + 134px) !important;
  z-index: 102 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 76px !important;
  min-width: 76px !important;
  height: 30px !important;
  margin: 0 !important;
  padding: 2px !important;
  transform: translateY(-50%) !important;
  border: 1px solid rgba(212, 175, 55, 0.25) !important;
  background: rgba(0, 0, 0, 0.32) !important;
}

.site-header .language-switcher button,
.topbar .language-switcher button {
  width: 34px !important;
  min-width: 34px !important;
  height: 26px !important;
  margin: 0 !important;
  padding: 0 !important;
}

@media (max-width: 1080px) {
  :root { --site-header-grid: 170px minmax(0, 1fr) 170px; }
  .primary-nav, .nav { gap: 16px !important; }
  .primary-nav a, .nav a { letter-spacing: 0.85px !important; }
  .site-header .account-links, .topbar .account-links,
  .site-header .account-shell { width: 170px !important; max-width: 170px !important; }
}

@media (max-width: 760px) {
  :root {
    --site-page-width: min(100% - 32px, 640px);
    --site-title-size: clamp(38px, 13vw, 56px);
    --site-display-size: 30px;
    --site-copy-size: 15px;
    --site-nav-size: 11px;
    --site-header-height: 64px;
    --site-header-gutter: 16px;
    --site-header-grid: auto minmax(0, 1fr) auto;
  }

  .hero > div > h1, .page-hero h1, .library-hero h1 {
    font-size: clamp(38px, 11vw, 48px) !important;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .header-inner, .site-header .header-inner {
    width: var(--site-page-width) !important;
    min-width: 0 !important;
  }

  .primary-nav, .nav {
    min-width: 0 !important;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .primary-nav::-webkit-scrollbar, .nav::-webkit-scrollbar { display: none; }

  .site-header, .topbar { gap: 12px !important; }
  .site-header .brand-seal, .topbar .brand-seal { width: 29px !important; height: 29px !important; flex-basis: 29px !important; }
  .site-header .brand-title, .topbar .brand-title { font-size: 10px !important; }
  .site-header .brand-subtitle, .topbar .brand-subtitle { display: none !important; }
  .primary-nav, .nav { justify-content: flex-start !important; gap: 18px !important; overflow-x: auto !important; }
  .primary-nav a, .nav a { min-height: var(--site-header-height) !important; font-size: 10px !important; letter-spacing: 0.7px !important; }
  .site-header .account-login, .topbar .account-login, .site-header .account-chip, .site-header .account-shell { display: none !important; }
  .site-header .language-switcher, .topbar .language-switcher {
    right: var(--site-header-gutter) !important;
  }
  .primary-nav, .nav { padding-right: 84px !important; }

  .dashboard, .auth-layout, .library-grid, .daily-grid, .face-grid,
  .book-grid, .hero-layout, .about-grid, .account-shell {
    min-width: 0 !important;
    width: 100% !important;
  }

input, select, textarea, button { max-width: 100%; }
}

:focus-visible {
  outline: 2px solid #d4af37 !important;
  outline-offset: 3px;
}

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

  video {
    display: none !important;
  }
}
