:root {
  color-scheme: dark;
  --ink: #070a10;
  --ink-2: #0c111c;
  --panel: rgba(16, 23, 36, 0.82);
  --panel-solid: #111827;
  --ivory: #f4eddd;
  --paper: #d7ccba;
  --muted: #9da8b9;
  --gold: #caa75a;
  --gold-bright: #efd58d;
  --wine: #6e1c2d;
  --wine-bright: #a63a50;
  --blue: #395d89;
  --line: rgba(202, 167, 90, 0.24);
  --line-soft: rgba(255, 255, 255, 0.08);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.46);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Baskerville, Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max: 1240px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ivory);
  background:
    radial-gradient(circle at 16% -10%, rgba(110, 28, 45, 0.34), transparent 36rem),
    radial-gradient(circle at 88% 20%, rgba(57, 93, 137, 0.23), transparent 34rem),
    linear-gradient(180deg, #090d15 0%, #070a10 60%, #05070b 100%);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-user-select: none;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0.28;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.52'/%3E%3C/svg%3E");
}

img, svg { display: block; max-width: 100%; -webkit-user-drag: none; user-drag: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 4px; }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10001;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  color: #111;
  background: var(--gold-bright);
  transform: translateY(-160%);
  transition: transform 180ms ease;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 16, 0.78);
  backdrop-filter: blur(20px) saturate(130%);
}

.header-inner {
  width: min(var(--max), calc(100% - 2rem));
  min-height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { display: inline-flex; align-items: center; gap: 0.8rem; min-width: 0; }
.brand img { width: 48px; height: 48px; object-fit: contain; filter: drop-shadow(0 8px 16px rgba(0,0,0,.5)); }
.brand-name { font: 600 1.06rem/1.12 var(--serif); letter-spacing: 0.035em; }
.brand-mark { color: var(--gold-bright); font-size: 0.76em; vertical-align: top; }

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ivory);
  background: rgba(255,255,255,.04);
}

.site-nav { display: flex; align-items: center; gap: 0.2rem; }
.site-nav a {
  padding: 0.65rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  transition: color 160ms ease, background 160ms ease;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ivory); background: rgba(202,167,90,.1); }

/* ==================================================
   REGISTERS OF HÉRÉDOM™ — LANGUAGE SELECTOR
   ================================================== */
.heredom-translator { display: inline-flex; align-items: center; flex: 0 0 auto; position: relative; z-index: 10000; margin-left: .3rem; }
#heredomLanguage {
  box-sizing: border-box;
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 1.9rem 0.55rem 0.9rem;
  min-width: 0;
  max-width: 190px;
  font: 650 0.82rem/1 var(--serif);
  letter-spacing: 0.02em;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239da8b9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}
#heredomLanguage:hover, #heredomLanguage:focus { color: var(--ivory); border-color: rgba(239,213,141,.5); background-color: rgba(202,167,90,.1); outline: none; }
#heredomLanguage option { color: #0b0e14; }

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

main, section, article, header, footer { overflow-wrap: break-word; }

.heredom-translator, .heredom-translator * { unicode-bidi: isolate; }

.container { width: min(var(--max), calc(100% - 2rem)); margin-inline: auto; }
.page-main { min-height: 70vh; }

.hero {
  position: relative;
  min-height: calc(100vh - 78px);
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  align-items: center;
  gap: clamp(2rem, 6vw, 6rem);
  padding-block: clamp(4rem, 9vw, 8rem);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1rem;
  color: var(--gold-bright);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 2.8rem; height: 1px; background: var(--gold); }

h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 550; text-wrap: balance; }
h1 { max-width: 900px; font-size: clamp(3.5rem, 8.3vw, 8.2rem); line-height: 0.9; letter-spacing: -0.055em; }
h1 em { color: var(--gold-bright); font-style: italic; font-weight: 450; }
h2 { font-size: clamp(2.3rem, 5vw, 4.8rem); line-height: 1; letter-spacing: -0.04em; }
h3 { font-size: clamp(1.25rem, 2vw, 1.7rem); line-height: 1.18; }

.hero-copy > p:not(.eyebrow) { max-width: 700px; margin: 1.6rem 0 0; color: var(--paper); font: 400 clamp(1.05rem, 1.6vw, 1.28rem)/1.7 var(--serif); }
.hero-actions, .button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.75rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ivory);
  background: rgba(255,255,255,.035);
  font-size: 0.88rem;
  font-weight: 750;
  letter-spacing: 0.025em;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(239,213,141,.7); background: rgba(202,167,90,.09); }
.btn-primary { color: #140e08; border-color: var(--gold-bright); background: linear-gradient(135deg, var(--gold-bright), #bd9140); }
.btn-primary:hover { background: linear-gradient(135deg, #f8e5ad, #c79b48); }

.hero-object { min-height: 560px; display: grid; place-items: center; perspective: 1300px; }
.book-stage {
  position: relative;
  width: min(470px, 90vw);
  aspect-ratio: 0.86;
  transform: rotateY(-11deg) rotateX(4deg);
  transform-style: preserve-3d;
}
.book-stage::before {
  content: "";
  position: absolute;
  inset: 14% 4% 6%;
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: inset 0 0 70px rgba(202,167,90,.1), 0 0 90px rgba(110,28,45,.18);
  transform: translateZ(-120px);
}
.hero-book {
  position: absolute;
  width: 48%;
  aspect-ratio: 0.64;
  object-fit: cover;
  border: 1px solid rgba(239,213,141,.34);
  border-radius: 3px 11px 11px 3px;
  box-shadow: -18px 24px 46px rgba(0,0,0,.7), inset -10px 0 14px rgba(0,0,0,.25);
}
.hero-book:nth-child(1) { left: 4%; top: 14%; transform: translateZ(40px) rotateZ(-7deg); animation: drift 8s ease-in-out infinite; }
.hero-book:nth-child(2) { right: 2%; top: 4%; transform: translateZ(100px) rotateZ(7deg); animation: drift 8s ease-in-out -2.6s infinite; }
.hero-book:nth-child(3) { left: 27%; bottom: 0; transform: translateZ(160px) rotateZ(1deg); animation: drift 8s ease-in-out -5.2s infinite; }
.orbit-label { position: absolute; right: 3%; bottom: 7%; color: var(--gold-bright); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; transform: translateZ(190px); }

@keyframes drift { 0%,100% { translate: 0 0; } 50% { translate: 0 -11px; } }

.trust-strip { border-block: 1px solid var(--line); background: rgba(255,255,255,.018); }
.trust-inner { min-height: 82px; display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; }
.trust-item { padding: 1rem 1.5rem; border-right: 1px solid var(--line); text-align: center; }
.trust-item:last-child { border-right: 0; }
.trust-item strong { display: block; color: var(--gold-bright); font: 500 1.5rem/1 var(--serif); }
.trust-item span { display: block; margin-top: .35rem; color: var(--muted); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; }

.section { padding-block: clamp(5rem, 10vw, 9rem); }
.section-head { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 2rem; align-items: end; margin-bottom: 3rem; }
.section-head p { max-width: 650px; margin: 0; color: var(--muted); }
.rule { width: 100%; height: 1px; margin: 2rem 0; background: linear-gradient(90deg, var(--gold), transparent); }

.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; }
.book-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(21,29,44,.92), rgba(10,14,22,.88));
  box-shadow: 0 18px 40px rgba(0,0,0,.2);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}
.book-card:hover { transform: translateY(-7px); border-color: rgba(239,213,141,.5); box-shadow: var(--shadow); }
.book-art { position: relative; min-height: 410px; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 50% 30%, rgba(202,167,90,.15), transparent 55%); }
.book-art::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: 8%; height: 18px; border-radius: 50%; background: rgba(0,0,0,.65); filter: blur(10px); }
.book-art img { position: relative; z-index: 1; width: auto; height: 340px; max-width: 92%; object-fit: contain; border-radius: 2px 8px 8px 2px; box-shadow: -14px 20px 32px rgba(0,0,0,.62); transform: perspective(800px) rotateY(-7deg); }
.book-copy { padding: 1.55rem; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; flex: 1; }
.book-meta { margin: 0 0 .7rem; color: var(--gold-bright); font-size: .72rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.book-copy p { color: var(--muted); }
.book-links { display: flex; flex-wrap: wrap; gap: .48rem; margin-top: auto; padding-top: 1.2rem; }
.book-links a { padding: .48rem .68rem; border: 1px solid var(--line); border-radius: 999px; color: var(--paper); font-size: .75rem; font-weight: 700; }
.book-links a:hover { color: var(--gold-bright); border-color: var(--gold); }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.feature-card { min-height: 270px; padding: 1.7rem; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.feature-card .number { color: var(--gold); font: 500 2rem/1 var(--serif); }
.feature-card h3 { margin-top: 3.5rem; }
.feature-card p { color: var(--muted); }

.archive-map { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 1rem; }
.archive-panel { padding: clamp(1.5rem, 4vw, 3rem); border: 1px solid var(--line); border-radius: 24px; background: var(--panel); }
.source-list { margin: 1.4rem 0 0; padding: 0; list-style: none; }
.source-list li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .8rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--line-soft); }
.source-list li:last-child { border-bottom: 0; }
.source-list span:first-child { color: var(--gold-bright); font-family: var(--serif); }
.source-list small { color: var(--muted); }

.page-hero { padding: clamp(5rem, 11vw, 9rem) 0 4rem; border-bottom: 1px solid var(--line); }
.page-hero h1 { font-size: clamp(3.4rem, 8vw, 7.2rem); }
.page-hero p { max-width: 760px; margin-top: 1.5rem; color: var(--paper); font: 1.16rem/1.72 var(--serif); }

.prose { max-width: 860px; }
.prose h2 { margin: 3.2rem 0 1rem; font-size: clamp(2rem,4vw,3.2rem); }
.prose h3 { margin: 2rem 0 .6rem; }
.prose p, .prose li { color: var(--paper); }
.prose a { color: var(--gold-bright); text-decoration: underline; text-underline-offset: 3px; }
.prose ul { padding-left: 1.25rem; }
.notice { padding: 1.2rem 1.3rem; border-left: 3px solid var(--gold); border-radius: 0 12px 12px 0; color: var(--paper); background: rgba(202,167,90,.08); }

.support-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.support-card { padding: clamp(1.5rem, 4vw, 2.4rem); border: 1px solid var(--line); border-radius: 22px; background: var(--panel); }
.support-card p { color: var(--muted); }
.email-display { overflow-wrap: anywhere; color: var(--gold-bright); font: 500 clamp(1.25rem,3vw,2rem)/1.2 var(--serif); }

.site-footer { padding: 3rem 0; border-top: 1px solid var(--line); background: rgba(0,0,0,.22); }
.footer-grid { display: grid; grid-template-columns: 1.25fr .75fr .75fr; gap: 2rem; }
.footer-grid p { max-width: 450px; color: var(--muted); }
.footer-links { display: grid; align-content: start; gap: .6rem; }
.footer-links strong { margin-bottom: .4rem; color: var(--gold-bright); font: 500 1.15rem/1.2 var(--serif); }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--ivory); }
.copyright { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line-soft); color: #7f8999; font-size: .78rem; }

.agent-launcher {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 600;
  width: 62px;
  height: 62px;
  border: 1px solid rgba(239,213,141,.7);
  border-radius: 50%;
  color: var(--ivory);
  background: radial-gradient(circle at 35% 30%, #c79a52, #6e1c2d 55%, #151a26 100%);
  box-shadow: 0 18px 45px rgba(0,0,0,.5), 0 0 0 8px rgba(202,167,90,.07);
  cursor: pointer;
}
.agent-launcher::before { content: "✦"; font-size: 1.5rem; }
.agent-launcher span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.agent-panel {
  position: fixed;
  right: 1rem;
  bottom: 5.8rem;
  z-index: 599;
  width: min(390px, calc(100vw - 2rem));
  max-height: min(640px, calc(100vh - 8rem));
  display: none;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(239,213,141,.42);
  border-radius: 22px;
  background: rgba(10,14,22,.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.agent-panel.open { display: grid; animation: panelIn 180ms ease both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.agent-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.agent-head strong { font-family: var(--serif); font-size: 1.1rem; }
.agent-status { color: #a7d6b0; font-size: .72rem; }
.agent-close { border: 0; color: var(--muted); background: transparent; font-size: 1.3rem; cursor: pointer; }
.agent-log { min-height: 240px; padding: 1rem; overflow-y: auto; }
.message { max-width: 88%; margin: 0 0 .7rem; padding: .72rem .84rem; border: 1px solid var(--line-soft); border-radius: 14px; color: var(--paper); background: rgba(255,255,255,.035); font-size: .9rem; white-space: pre-wrap; }
.message.user { margin-left: auto; color: var(--ivory); border-color: rgba(202,167,90,.2); background: rgba(110,28,45,.25); }
.agent-form { display: grid; grid-template-columns: 1fr auto; gap: .5rem; padding: .85rem; border-top: 1px solid var(--line); }
.agent-form input { min-width: 0; padding: .72rem .8rem; border: 1px solid var(--line); border-radius: 12px; color: var(--ivory); background: rgba(255,255,255,.04); user-select: text; }
.agent-form button { padding: .7rem .85rem; border: 0; border-radius: 12px; color: #130f09; background: var(--gold-bright); font-weight: 800; cursor: pointer; }

.security-toast { position: fixed; left: 50%; bottom: 1.2rem; z-index: 10000; max-width: calc(100vw - 2rem); padding: .65rem 1rem; border: 1px solid var(--line); border-radius: 999px; color: var(--paper); background: rgba(7,10,16,.95); font-size: .78rem; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .2s ease; }
.security-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-object { min-height: 500px; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head, .archive-map { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .header-inner { min-height: 70px; }
  .brand-name { max-width: 190px; font-size: .93rem; }
  .brand img { width: 42px; height: 42px; }
  .nav-toggle { display: inline-grid; place-items: center; cursor: pointer; }
  .site-nav { position: absolute; top: calc(100% + 1px); left: 0; right: 0; display: none; padding: .7rem 1rem 1rem; border-bottom: 1px solid var(--line); background: rgba(7,10,16,.98); }
  .site-nav.open { display: grid; }
  .site-nav a { border-radius: 10px; }
  .heredom-translator { margin: .3rem 0 0; }
  #heredomLanguage { width: 100%; max-width: none; }
  .hero { padding-top: 4.5rem; }
  .hero-object { min-height: 420px; }
  .book-stage { width: min(390px, 92vw); }
  .trust-inner { grid-template-columns: repeat(2,1fr); }
  .trust-item:nth-child(2) { border-right: 0; }
  .trust-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .catalog-grid, .feature-grid, .support-grid, .footer-grid { grid-template-columns: 1fr; }
  .book-art { min-height: 360px; }
  .footer-grid { gap: 1.4rem; }
}

@media (max-width: 480px) {
  h1 { font-size: clamp(3.1rem, 18vw, 5rem); }
  .hero-object { min-height: 360px; }
  .book-stage { width: 330px; }
  .book-art img { height: 300px; }
  .agent-panel { bottom: 5.4rem; }
}

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

@media print { body { display: none !important; } }
