:root {
  color-scheme: light;
  --bg-1: #f6f0e4;
  --bg-2: #efe6d7;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text: #1f1911;
  --muted: #665e54;
  --line: rgba(31, 25, 17, 0.1);
  --accent: #a66b20;
  --accent-hover: #8e5717;
  --accent-soft: rgba(166, 107, 32, 0.08);
  --danger: #8e2f2f;
  --shadow: 0 20px 44px rgba(42, 31, 20, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", "Inter", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(166, 107, 32, 0.08), transparent 30%),
    radial-gradient(circle at 82% 14%, rgba(45, 139, 103, 0.08), transparent 24%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
}

a {
  color: inherit;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, rgba(255, 250, 241, 0.9) 90%, white);
  border-bottom: 1px solid rgba(31, 25, 17, 0.08);
}

.portal-topbar-inner {
  width: 100%;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.portal-brand {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.portal-nav {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  flex: 1;
  flex-wrap: wrap;
}

.portal-nav-link {
  text-decoration: none;
  border: 1px solid transparent;
  padding: 0;
  border-radius: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.2;
}

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

.brand-mark,
.brand-wordmark {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand-mark img,
.brand-wordmark img {
  display: block;
  height: auto;
  width: auto;
}

.brand-mark img {
  width: 32px;
  height: 32px;
}

.brand-wordmark img {
  height: 20px;
}

.brand-mark--footer img {
  width: 36px;
  height: 36px;
}

.brand-wordmark--footer img {
  height: 20px;
}

.session-chip {
  margin: 0;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  max-width: min(44vw, 320px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar-action {
  appearance: none;
  border: 1px solid rgba(31, 25, 17, 0.12);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.topbar-action:hover {
  background: rgba(255, 255, 255, 0.92);
}

.page-shell {
  min-height: 100dvh;
  padding: 24px 18px 32px;
}

.checkout-grid {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.32fr) minmax(0, 0.68fr);
  gap: 20px;
  align-items: start;
}

.checkout-panel,
.library-shell {
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.checkout-panel {
  padding: 30px;
}

.access-panel--linked h1 {
  font-size: clamp(26px, 3vw, 34px);
}

.access-panel--linked .subtitle {
  font-size: 15px;
}

.access-panel--linked .helper {
  margin-top: 8px;
  font-size: 15px;
}

.access-panel--linked #email-form {
  display: none;
}

.access-panel--linked #code-form {
  display: none;
}

.badge {
  margin: 0 0 12px;
  letter-spacing: 0.34em;
  font-size: 11px;
  color: var(--muted);
}

h1,
.summary-title {
  margin: 0;
  font-family: "Iowan Old Style", "Georgia", serif;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(34px, 5.3vw, 46px);
  line-height: 1.05;
}

.summary-title {
  font-size: clamp(28px, 3.6vw, 36px);
  line-height: 1.08;
}

.subtitle,
.summary-copy {
  margin: 10px 0 0;
  color: #3a3329;
  line-height: 1.55;
  font-size: 17px;
}

.helper {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.small {
  font-size: 14px;
}

.stack {
  margin-top: 22px;
  display: grid;
  gap: 12px;
}

.label {
  font-weight: 600;
  font-size: 14px;
}

input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(31, 25, 17, 0.12);
  padding: 13px 14px;
  font-size: 16px;
  background: #fff;
}

input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 24%, white);
  border-color: var(--accent);
}

button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  background: linear-gradient(135deg, #f5d08a, #d7a65c);
  color: #121212;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(166, 107, 32, 0.14);
}

button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #f7d89e, #d7a65c);
}

button:disabled {
  cursor: default;
  opacity: 0.6;
  transform: none;
}

.linked-state {
  margin-top: 22px;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid rgba(166, 107, 32, 0.12);
  background: rgba(255, 255, 255, 0.72);
}

.linked-state-label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 650;
}

.linked-state-email {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.linked-state-note {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.checkout-shell {
  position: relative;
  min-height: 760px;
}

.revenuecat-shell {
  position: relative;
  min-height: 760px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(166, 107, 32, 0.12);
  background:
    radial-gradient(circle at 10% 12%, rgba(215, 166, 92, 0.08), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 243, 235, 0.94));
  box-shadow: 0 20px 44px rgba(42, 31, 20, 0.1);
}

.revenuecat-shell.purchasing .revenuecat-host--paywall {
  opacity: 0;
  pointer-events: none;
}

.revenuecat-shell.purchasing .revenuecat-host--purchase {
  opacity: 1;
  pointer-events: auto;
}

.revenuecat-shell.locked .revenuecat-host {
  filter: blur(10px);
  opacity: 0.72;
  pointer-events: none;
}

.revenuecat-host {
  position: absolute;
  inset: 0;
  min-height: 760px;
  padding: 20px;
  transition: opacity 160ms ease;
}

.revenuecat-host--paywall {
  opacity: 1;
  pointer-events: auto;
}

.revenuecat-host--purchase {
  opacity: 0;
  pointer-events: none;
}

.checkout-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(247, 240, 228, 0.22);
  backdrop-filter: blur(3px);
  transition: opacity 160ms ease;
}

.revenuecat-shell.unlocked .checkout-overlay {
  opacity: 0;
  pointer-events: none;
}

.checkout-overlay-card {
  width: min(90%, 400px);
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid rgba(166, 107, 32, 0.14);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 32px rgba(42, 31, 20, 0.14);
}

.payment-status {
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.payment-status[data-tone="neutral"] {
  background: rgba(255, 255, 255, 0.78);
}

.payment-status[data-tone="success"] {
  border-color: rgba(45, 139, 103, 0.2);
  background: rgba(45, 139, 103, 0.08);
  color: #235f49;
}

.payment-status[data-tone="error"] {
  border-color: rgba(166, 107, 32, 0.22);
  background: rgba(166, 107, 32, 0.08);
  color: #7d4c10;
}

#revenuecat-checkout-shell {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(42, 31, 20, 0.06);
}

#revenuecat-checkout {
  min-height: 0;
}

.revenuecat-loading {
  margin: 0;
  min-height: 280px;
  display: grid;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--line) 75%, white);
  border-radius: 12px;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(250, 249, 246, 0.96));
}

.fallback-button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(31, 25, 17, 0.12);
  color: var(--text);
  box-shadow: none;
}

.fallback-button:hover {
  background: #fff;
}

.success-copy {
  margin: 0;
  font-family: "Iowan Old Style", "Georgia", serif;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.notice {
  margin-top: 16px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #e7cccc;
  background: #fff4f4;
  color: var(--danger);
}

.ghost-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(31, 25, 17, 0.12);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.86);
}

.ghost-link:hover {
  background: rgba(255, 255, 255, 0.96);
}

.library-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 30px;
}

.site-footer {
  margin-top: 18px;
  border-top: 1px solid rgba(31, 25, 17, 0.08);
  background: color-mix(in srgb, rgba(255, 250, 241, 0.88) 92%, white);
  backdrop-filter: blur(14px);
}

.site-footer-inner {
  display: flex;
  gap: 32px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 48px 24px 0;
}

.site-footer-brand {
  max-width: 260px;
}

.site-footer-tagline {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.site-footer-links {
  display: flex;
  gap: 56px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-group-title {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer-links-group a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}

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

.site-footer-socials {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-footer-socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}

.site-footer-socials a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.site-footer-socials svg {
  width: 20px;
  height: 20px;
}

.site-footer-bottom {
  padding: 22px 24px 18px;
}

.site-footer-bottom p {
  margin: 0;
  border-top: 1px solid rgba(31, 25, 17, 0.08);
  padding-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.library-shell .stack {
  margin-top: 22px;
}

.library-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(42, 31, 20, 0.05);
}

.product-name {
  margin: 0;
  font-weight: 650;
  font-size: 17px;
}

.product-meta {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid #dde6e3;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .checkout-grid {
    grid-template-columns: 1fr;
  }

  .access-panel {
    order: 1;
  }

  .payment-panel {
    order: 2;
  }

  .site-footer-inner {
    flex-direction: column;
  }

  .site-footer-links {
    justify-content: flex-start;
  }

  .site-footer-socials {
    margin-top: 6px;
  }
}

@media (max-width: 640px) {
  .portal-topbar-inner {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .portal-nav {
    width: 100%;
    order: 3;
    justify-content: flex-start;
    gap: 12px 16px;
  }

  .session-actions {
    margin-left: auto;
  }

  .page-shell {
    padding: 18px 14px 28px;
  }

  .checkout-panel,
  .library-shell {
    padding: 22px;
    border-radius: 20px;
  }

  .revenuecat-shell,
  .revenuecat-host {
    min-height: 620px;
  }

  .linked-state-email {
    max-width: 100%;
  }

  .site-footer-inner,
  .site-footer-bottom {
    padding-left: 16px;
    padding-right: 16px;
  }

  .site-footer-links {
    gap: 28px;
  }
}
