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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  transition: background var(--transition), color var(--transition);
}

main {
  flex: 1 0 auto;
  min-width: 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity var(--transition), color var(--transition);
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1, h2, h3, h4 {
  margin: 0;
  letter-spacing: -0.025em;
  line-height: 1.22;
  font-weight: 600;
  overflow-wrap: break-word;
}

p {
  margin: 0;
  overflow-wrap: break-word;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
  min-width: 0;
}

.container-narrow {
  max-width: 760px;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 58px;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.96rem;
  letter-spacing: -0.03em;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  color: var(--text);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.nav-link {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
}

.header-actions .toolbar-group {
  flex-wrap: nowrap;
  gap: 6px;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text);
  flex-shrink: 0;
}

.mobile-only-nav {
  display: none;
}

/* Announcement banner */
.announcement-bar {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.announcement-bar.hidden {
  display: none;
}

.announcement-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Sections (Compact Multi-Device Rhythm) */
.section {
  padding: 48px 0;
}

.section-subtle {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-header {
  max-width: 600px;
  margin-bottom: 26px;
}

.section-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.section-title {
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

/* Hero (Compact, zero overflow) */
.hero {
  padding: 50px 0 42px;
}

.hero-inner {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  margin-bottom: 18px;
  max-width: 100%;
  text-align: center;
  line-height: 1.35;
}

.hero-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  flex-shrink: 0;
}

.hero-title {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin-bottom: 14px;
}

.hero-subtitle {
  font-size: clamp(0.9rem, 1.8vw, 1.04rem);
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto 24px;
}

/* Grid helpers */
.grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.grid > * {
  min-width: 0;
}

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

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 36px 0 24px;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.footer-heading {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--text);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Skeleton & subtle fade animation */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-card {
  height: 104px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Tablet breakpoint */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-links { gap: 14px; }
}

/* Tablet & Mobile navigation drawer breakpoint (prevents nav link crowding at 768px tablet) */
@media (max-width: 900px) {
  .header-inner { height: 54px; gap: 8px; }
  .nav-links {
    display: none;
    position: absolute;
    top: 54px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
    gap: 12px;
    box-shadow: var(--shadow-md);
    z-index: 45;
  }
  .nav-links.open { display: flex; }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
}

/* Mobile grid & spacing breakpoint */
@media (max-width: 720px) {
  .container { padding: 0 14px; }
  .grid-2, .grid-3, .grid-4, .footer-grid { grid-template-columns: 1fr; }
  .section { padding: 34px 0; }
  .hero { padding: 34px 0 28px; }
  .section-header { margin-bottom: 18px; }
}

/* Narrow Phone / Split-Pane breakpoint (<= 460px): guaranteed zero horizontal overflow */
@media (max-width: 460px) {
  html { font-size: 14px; }
  .container { padding: 0 12px; }
  .header-inner { gap: 6px; height: 50px; }
  .brand { gap: 6px; font-size: 0.9rem; }
  .brand-mark { width: 22px; height: 22px; }
  #header-auth-slot .btn-ghost { display: none; }
  .mobile-only-nav { display: block; }
  .header-actions .btn-sm { padding: 5px 9px; font-size: 0.78rem; }
  .header-actions .badge { font-size: 0.7rem; padding: 2px 7px; }
  .nav-links { top: 50px; }
  .hero-badge { font-size: 0.74rem; padding: 4px 10px; }
}

/* Ultra-narrow pane (<= 320px): keep auth actions inside drawer so header never clips */
@media (max-width: 320px) {
  .container { padding: 0 10px; }
  .brand span { font-size: 0.84rem; }
  .header-actions { gap: 4px; }
  #header-auth-slot { display: none; }
  .mobile-only-nav { display: block; }
  .btn-icon, .mobile-menu-btn { width: 28px; height: 28px; }
}
