:root {
  --bg: #f6f0e5;
  --bg-soft: #efe4d0;
  --surface: rgba(255, 250, 243, 0.88);
  --line: rgba(84, 55, 28, 0.17);
  --text: #2e2218;
  --muted: #705f50;
  --primary: #1f3d63;
  --primary-contrast: #f2f7ff;
  --accent: #c86c2e;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-soft: 0 16px 42px rgba(44, 30, 17, 0.14);
  --max-width: 1160px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -8%, rgba(200, 108, 46, 0.24), transparent 32%),
    radial-gradient(circle at 82% 15%, rgba(31, 61, 99, 0.25), transparent 30%),
    linear-gradient(152deg, var(--bg) 0%, var(--bg-soft) 58%, #e5d7bf 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(40, 24, 12, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 24, 12, 0.09) 1px, transparent 1px);
  background-size: 46px 46px;
  z-index: -1;
}

.container {
  width: min(var(--max-width), calc(100% - 34px));
  margin: 0 auto;
}

.site-header {
  margin: 14px 0 32px;
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(255, 252, 246, 0.86);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary-contrast);
  font-weight: 700;
  font-size: 0.9rem;
  background: linear-gradient(140deg, #1f3d63, #355984);
}

.brand h1 {
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand p {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
}

.header-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
}

.links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 auto;
  min-width: 0;
}

.links a {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease;
}

.links a:hover {
  background: rgba(31, 61, 99, 0.1);
  color: var(--primary);
}

.links a.is-active {
  background: linear-gradient(180deg, rgba(31, 61, 99, 0.18), rgba(31, 61, 99, 0.1));
  color: #173658;
  border: 1px solid rgba(31, 61, 99, 0.18);
  box-shadow: inset 0 -2px 0 0 var(--primary), 0 10px 22px rgba(31, 61, 99, 0.16);
  font-weight: 600;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  padding: 10px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 10px 24px rgba(41, 29, 17, 0.12);
}

.btn-primary {
  border-color: transparent;
  color: var(--primary-contrast);
  background: linear-gradient(132deg, #1f3d63, #2a4f7b);
}

.page-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 28px;
  margin-bottom: 22px;
}

.page-card h2 {
  font-family: "Fraunces", serif;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin-bottom: 10px;
}

.page-intro {
  color: var(--muted);
  max-width: 70ch;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
  padding: 14px;
}

.card h3 {
  color: var(--primary);
  margin-bottom: 6px;
  font-size: 1rem;
}

.card p {
  color: var(--muted);
  font-size: 0.88rem;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 24px 0 34px;
}

.mobile-menu-toggle {
  display: none;
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  border-radius: 8px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.mobile-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 200ms ease;
}

.mobile-menu-toggle.is-open span:nth-child(1) {
  transform: rotate(45deg) translateY(8px);
}

.mobile-menu-toggle.is-open span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.is-open span:nth-child(3) {
  transform: rotate(-45deg) translateY(-8px);
}

.mobile-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  z-index: 75;
}

.mobile-menu-backdrop.is-open {
  display: block;
}

/* Auth dropdown/popover */
.auth-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.auth-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  width: min(360px, calc(100vw - 28px));
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(248, 241, 231, 0.96));
  border: 1px solid rgba(84, 55, 28, 0.14);
  border-radius: 22px;
  box-shadow: 0 22px 56px rgba(44, 30, 17, 0.18);
  z-index: 200;
  padding: 18px;
  animation: fadeUp 240ms ease both;
  overflow: hidden;
}

.auth-dropdown::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 22px;
  width: 16px;
  height: 16px;
  background: rgba(255, 252, 247, 0.98);
  border-top: 1px solid rgba(84, 55, 28, 0.14);
  border-left: 1px solid rgba(84, 55, 28, 0.14);
  transform: rotate(45deg);
}

.auth-dropdown.is-open {
  display: block;
}

.auth-dropdown-tabs {
  display: flex;
  gap: 6px;
  margin: 0 28px 16px 0;
  padding: 4px;
  border: 1px solid rgba(84, 55, 28, 0.12);
  border-radius: 999px;
  background: rgba(31, 61, 99, 0.06);
}

.auth-dropdown-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  flex: 1 1 0;
  transition: all 160ms ease;
}

.auth-dropdown-tab:hover {
  color: var(--primary);
}

.auth-dropdown-tab.is-active {
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary);
  border-color: rgba(84, 55, 28, 0.1);
  box-shadow: 0 8px 16px rgba(31, 61, 99, 0.08);
}

.auth-dropdown-content {
  display: none;
}

.auth-dropdown-content.is-active {
  display: block;
  padding: 2px 2px 0;
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.auth-form-group label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.auth-form-group input {
  border: 1px solid rgba(84, 55, 28, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 11px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 160ms ease;
}

.auth-form-group input:focus {
  outline: none;
  border-color: rgba(31, 61, 99, 0.52);
  box-shadow: 0 0 0 3px rgba(31, 61, 99, 0.12);
}

.auth-dropdown-error {
  color: #c83d3d;
  font-size: 0.8rem;
  margin-bottom: 10px;
  display: none;
}

.auth-dropdown-error.show {
  display: block;
}

.auth-dropdown-button {
  width: 100%;
  margin-bottom: 10px;
  min-height: 44px;
  box-shadow: 0 12px 24px rgba(31, 61, 99, 0.14);
}

.auth-dropdown-divider {
  border: none;
  border-top: 1px solid rgba(84, 55, 28, 0.12);
  margin: 14px 0 12px;
}

.auth-dropdown-social {
  display: grid;
  gap: 8px;
}

.auth-dropdown-social button {
  appearance: none;
  border: 1px solid rgba(84, 55, 28, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  padding: 11px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-dropdown-social button:hover {
  background: rgba(31, 61, 99, 0.08);
  border-color: rgba(31, 61, 99, 0.24);
  transform: translateY(-1px);
}

.auth-dropdown-close {
  appearance: none;
  border: 1px solid rgba(84, 55, 28, 0.1);
  background: rgba(255, 255, 255, 0.84);
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  border-radius: 999px;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.auth-dropdown-close:hover {
  color: var(--text);
  background: rgba(31, 61, 99, 0.08);
  border-color: rgba(31, 61, 99, 0.18);
}

@media (max-width: 980px) {
  .site-header {
    border-radius: var(--radius-lg);
  }

  .header-side {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .links {
    margin: 0;
  }
}

@media (max-width: 820px) {
  .site-header {
    position: static;
  }

  .header-side {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .auth-dropdown-wrapper {
    width: 100%;
  }

  .auth-dropdown {
    left: 0;
    right: auto;
  }

  .auth-dropdown::before {
    left: 24px;
    right: auto;
  }

  .links {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .links a {
    text-align: center;
    padding: 8px 10px;
  }

  .header-side .btn {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .container {
    width: min(var(--max-width), calc(100% - 22px));
  }

  .site-header {
    position: static;
    border-radius: var(--radius-lg);
    flex-direction: column;
    align-items: stretch;
  }

  .header-side {
    justify-content: flex-start;
    flex: 0 0 auto;
    width: 100%;
  }

  .links {
    width: 100%;
    margin: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .links a {
    flex: initial;
    text-align: center;
  }

  .page-card {
    padding: 20px 14px;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: 0;
  }

  .container {
    width: min(var(--max-width), calc(100% - 16px));
  }

  .site-header {
    gap: 8px;
    padding: 10px 12px;
    justify-content: flex-start;
    align-items: center;
    border-radius: var(--radius-lg);
  }

  .mobile-menu-toggle {
    display: flex;
    order: -1;
    flex-shrink: 0;
  }

  .brand {
    justify-content: center;
    flex: 1;
    order: 0;
  }

  .brand h1 {
    font-size: 0.85rem;
  }

  .brand p {
    display: none;
  }

  .header-side {
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    order: 1;
  }

  .header-side .btn {
    width: auto;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .links {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 76;
    flex-direction: column;
    background: var(--surface);
    border-radius: 0;
    box-shadow: none;
    padding: 80px 20px 20px;
    gap: 8px;
    margin: 0;
    display: none;
  }

  .links.is-open {
    display: flex;
  }

  .links a {
    font-size: 0.95rem;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: left;
  }

  .page-card {
    border-radius: 18px;
    padding: 18px 12px;
  }

  .card {
    padding: 12px;
  }

  .auth-dropdown {
    position: fixed;
    top: 86px;
    left: 14px;
    right: 14px;
    width: auto;
    max-width: none;
  }

  .auth-dropdown::before {
    display: none;
  }
}

@media (max-width: 420px) {
  .links a {
    font-size: 0.9rem;
    padding: 11px 14px;
  }
}
