:root {
  --bg: #08080d;
  --bg-2: #10110f;
  --panel: rgba(18, 18, 22, 0.82);
  --panel-warm: rgba(32, 27, 23, 0.74);
  --line: rgba(226, 211, 171, 0.16);
  --line-strong: rgba(226, 211, 171, 0.3);
  --text: #efece2;
  --muted: #9e9789;
  --soft: #cfc4ad;
  --gold: #d6bc75;
  --moss: #93a492;
  --rose: #ad7077;
  --max: 1120px;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -12%, rgba(78, 63, 78, 0.46) 0, rgba(22, 20, 26, 0.8) 31%, transparent 62%),
    radial-gradient(circle at 12% 44%, rgba(113, 96, 62, 0.15), transparent 34%),
    radial-gradient(circle at 83% 52%, rgba(92, 115, 102, 0.14), transparent 36%),
    linear-gradient(180deg, #08080d 0%, #0e0d0c 54%, #090a0b 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

body.lightbox-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.88) 0 1px, transparent 1.4px),
    radial-gradient(circle at 74% 9%, rgba(255,237,198,.72) 0 1px, transparent 1.4px),
    radial-gradient(circle at 83% 43%, rgba(212,226,214,.55) 0 1px, transparent 1.4px),
    radial-gradient(circle at 28% 66%, rgba(255,255,255,.42) 0 1px, transparent 1.4px);
  background-size: 190px 190px, 260px 260px, 320px 320px, 230px 230px;
  mask-image: linear-gradient(to bottom, black, transparent 84%);
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(18px, 4vw, 44px);
  background: linear-gradient(to bottom, rgba(8, 8, 13, .96), rgba(8, 8, 13, .66));
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  text-decoration: none;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  font-size: 1rem;
  color: var(--gold);
}

.icon-button,
.analysis-toggle,
.copy,
.image-tool {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  color: var(--soft);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, background .2s ease, transform .2s ease;
}

.icon-button:hover,
.analysis-toggle:hover,
.copy:hover,
.image-tool:hover,
.icon-button:focus-visible,
.analysis-toggle:focus-visible,
.copy:focus-visible,
.image-tool:focus-visible {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(255,255,255,.07);
  outline: none;
}

main {
  position: relative;
  z-index: 1;
}

.hero,
.section,
.revelation {
  width: min(var(--max), calc(100% - 36px));
  margin: auto;
}

.hero {
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 78px 0 54px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #938a78;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
}

.hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 4.8rem;
  line-height: 1;
  letter-spacing: 0;
  margin: 0;
  max-width: 1000px;
  font-weight: 500;
}

.hero h1 em {
  font-weight: 400;
  color: #d0c2ab;
}

.lead {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.02rem;
  margin: 28px 0 34px;
}

.guide-box {
  width: min(620px, 100%);
  margin: 0 0 30px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.026);
}

.guide-box h2 {
  margin: 0 0 8px;
  font: 500 1.15rem Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

.guide-box p {
  margin: 0;
  color: #c8bfad;
}

.text-link {
  width: max-content;
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 4px;
  color: var(--soft);
  font-size: 0.95rem;
}

.text-link span {
  margin-left: 8px;
}

.section {
  padding: 82px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: end;
  margin-bottom: 34px;
}

.section-heading h2,
.seal h2,
.notes-head h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.9rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.08;
  margin: 0;
}

.section-note,
.section-intro {
  color: var(--muted);
  max-width: 430px;
  font-size: 0.94rem;
}

.artifact-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255,255,255,.025);
  box-shadow: 0 32px 90px rgba(0,0,0,.36);
}

.artifact {
  position: relative;
  max-width: 720px;
  margin: auto;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: #03050b;
}

.artifact img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
}

.star-hit {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}

.star-hit::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid transparent;
  border-radius: 50%;
  transition: border-color .25s ease, box-shadow .25s ease;
}

.star-hit:hover::before,
.star-hit:focus-visible::before,
.star-hit.found::before {
  border-color: rgba(230, 216, 168, .48);
  box-shadow: 0 0 24px rgba(214, 188, 117, .2);
}

.star-hit.found::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff8dc;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 14px 4px rgba(214, 188, 117, .52);
}

.artifact-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 4px 0;
  color: #817967;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.artifact-tools {
  display: flex;
  justify-content: center;
  padding: 14px 4px 0;
}

.echoes {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.echo-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
}

.echo-card .echo-position {
  font-size: 0.72rem;
  color: #8d846f;
  margin-bottom: 7px;
}

.echo-card code {
  font-size: 0.82rem;
  color: #e0d7c4;
  word-break: break-word;
}

.empty-state {
  grid-column: 1/-1;
  color: #817967;
  font-size: 0.9rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.hint-box {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  color: var(--muted);
}

.hint-box summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--soft);
  width: max-content;
}

.hint-steps {
  display: grid;
  gap: 8px;
  max-width: 680px;
  margin-top: 12px;
}

.hint-steps button {
  justify-self: start;
  background: none;
  border: 0;
  min-height: 44px;
  padding: 8px 0;
  color: var(--soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: 0.9rem;
}

.hint-steps p {
  margin: 0;
  border-left: 2px solid rgba(147, 164, 146, .54);
  padding: 8px 12px;
  color: #c4baaa;
  font-size: 0.92rem;
}

.analysis-status {
  margin: -16px 0 22px;
  color: #b7ad9a;
  font-size: 0.9rem;
}

.record-entry {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(30, 27, 25, .86), rgba(12, 12, 14, .94));
  border-radius: var(--radius);
  overflow: hidden;
}

.record-entry header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.record-sigil {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 1.1rem;
  color: var(--gold);
}

.record-entry header p {
  margin: 0;
  color: #8d846f;
  font-size: 0.72rem;
}

.record-entry header h3 {
  font: 500 1.35rem Georgia, serif;
  margin: 2px 0 0;
}

.lore {
  padding: 26px clamp(18px, 4vw, 44px) 34px;
  max-height: 520px;
  overflow: auto;
  scrollbar-color: #4d4335 transparent;
}

.lore p {
  position: relative;
  margin: 0 0 18px;
  color: #c9c0ae;
}

.lore.analysis p {
  padding-left: 42px;
}

.lore.analysis p::before {
  content: attr(data-p);
  position: absolute;
  left: 0;
  top: .15em;
  color: #807765;
  font-size: 0.72rem;
}

.word {
  border-radius: 4px;
  padding: 1px 0;
  cursor: default;
}

.lore.analysis .word {
  cursor: pointer;
}

.lore.analysis .word:hover,
.lore.analysis .word:focus {
  outline: 1px solid rgba(214, 188, 117, .3);
  background: rgba(255,255,255,.045);
}

.word-index {
  display: inline-block;
  color: #8a806b;
  font-size: 0.6rem;
  vertical-align: super;
  margin-left: 2px;
}

.fragment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.fragment-grid[hidden] {
  display: none;
}

.lock-panel,
.cipher-unlock {
  border: 1px dashed var(--line-strong);
  background: rgba(255,255,255,.018);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--muted);
}

.lock-panel p,
.cipher-unlock p {
  margin: 0;
}

.lock-panel p {
  color: #d2c9b6;
  font: 500 1.05rem Georgia, "Times New Roman", serif;
}

.lock-panel span {
  display: block;
  margin-top: 6px;
}

.cipher-unlock {
  display: flex;
  align-items: center;
}

.cipher-unlock form {
  width: 100%;
}

.cipher-unlock label {
  display: block;
  color: #c8bfad;
  margin-bottom: 10px;
}

.fragment-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
}

.fragment-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  color: #8d846f;
}

.copy {
  padding: 6px 10px;
  min-height: 40px;
  font-size: 0.72rem;
}

.cipher-block {
  margin: 0;
  padding: 24px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d8cfbd;
  font: 500 0.88rem/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 240px;
}

.cipher-letters {
  letter-spacing: 0.08em;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.reference-grid details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.02);
  overflow: hidden;
}

.reference-grid summary {
  padding: 17px 18px;
  cursor: pointer;
  color: #d0c7b5;
  font-size: 0.9rem;
}

.reference-body {
  border-top: 1px solid var(--line);
  padding: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.mini-example {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reference-body code,
.mini-example code {
  background: #090908;
  border: 1px solid var(--line);
  padding: 6px 8px;
  border-radius: 6px;
  color: #ded5c2;
}

.alphabet {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 4px;
}

.alphabet span {
  text-align: center;
  border: 1px solid var(--line);
  padding: 5px 2px;
  font-size: 0.7rem;
}

.seal {
  text-align: center;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.seal-symbol {
  font-size: 3rem;
  color: var(--moss);
  margin-bottom: 24px;
  text-shadow: 0 0 25px rgba(147, 164, 146, .2);
}

.seal > p:not(.eyebrow) {
  color: var(--muted);
  max-width: 520px;
}

.seal form {
  width: min(500px, 100%);
  margin-top: 26px;
  text-align: left;
}

.seal label {
  display: block;
  font-size: 0.8rem;
  color: #938a78;
  margin-bottom: 8px;
}

.seal-input-row {
  display: flex;
  gap: 8px;
}

.seal-input-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: #090908;
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 16px;
  font: 600 1rem ui-monospace, monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  outline: none;
}

.seal-input-row input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(214, 188, 117, .12);
}

.seal-input-row button {
  border: 1px solid var(--line-strong);
  background: #e4d8bd;
  color: #18140e;
  padding: 0 20px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
}

.seal-status {
  min-height: 1.4em;
  color: #b7ad9a;
  font-size: 0.88rem;
}

.revelation {
  padding: 120px 0 150px;
  border-top: 1px solid var(--line);
}

.revelation-inner {
  max-width: 760px;
  margin: auto;
}

.reveal-whisper {
  text-align: center;
  color: #9d937f;
  font: italic 1rem Georgia, serif;
  margin-bottom: 70px;
}

.memory-content h1 {
  font: 500 4.6rem/1 Georgia, serif;
  letter-spacing: 0;
  margin: 0 0 56px;
}

.memory-content h2 {
  font: 400 1rem Georgia, serif;
  color: #a79d89;
  margin-top: -42px;
  margin-bottom: 50px;
}

.memory-content p {
  font: 400 1.08rem/1.9 Georgia, "Times New Roman", serif;
  color: #d2cabd;
  margin: 0 0 22px;
}

.memory-content strong {
  color: #fff7e4;
}

.notes-panel {
  position: fixed;
  z-index: 60;
  right: 0;
  top: 0;
  width: min(430px, 92vw);
  height: 100vh;
  padding: 24px;
  background: #0d0d0d;
  border-left: 1px solid var(--line-strong);
  transform: translateX(102%);
  transition: transform .28s ease;
  display: flex;
  flex-direction: column;
}

.notes-panel.open {
  transform: translateX(0);
}

.notes-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.notes-head h2 {
  font-size: 2rem;
}

.notes-panel textarea {
  flex: 1;
  margin-top: 24px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #08080d;
  color: #d6cebd;
  padding: 16px;
  font: 400 0.92rem/1.65 ui-monospace, monospace;
  outline: none;
}

.notes-panel > p {
  font-size: 0.76rem;
  color: #857b68;
}

.scrim {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 24%, rgba(214, 188, 117, .09), transparent 42%),
    rgba(5, 5, 7, .96);
}

.image-lightbox[hidden] {
  display: none;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 32px);
  border-bottom: 1px solid var(--line);
  color: var(--soft);
  font-size: 0.82rem;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.zoom-controls button {
  min-width: 44px;
  min-height: 42px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 8px 12px;
}

.zoom-controls button:hover,
.zoom-controls button:focus-visible {
  border-color: var(--line-strong);
  background: rgba(255,255,255,.08);
  outline: none;
}

.lightbox-stage {
  flex: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.lightbox-stage.dragging {
  cursor: grabbing;
}

.lightbox-stage img {
  width: min(86vmin, 900px);
  height: auto;
  max-width: none;
  user-select: none;
  transform: translate(0, 0) scale(1);
  transform-origin: center center;
  transition: transform .08s ease;
  will-change: transform;
}

@media (max-width: 760px) {
  .topbar {
    padding: 12px 16px;
  }

  .brand {
    font-size: 0.72rem;
  }

  .hero {
    min-height: 54vh;
    padding-top: 58px;
  }

  .hero h1 {
    font-size: 2.7rem;
  }

  .section {
    padding: 64px 0;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }

  .section-heading h2,
  .seal h2 {
    font-size: 2.1rem;
  }

  .artifact-shell {
    padding: 8px;
  }

  .artifact-meta {
    font-size: 0.68rem;
    gap: 8px;
    flex-wrap: wrap;
  }

  .star-hit {
    width: 64px;
    height: 64px;
  }

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

  .fragment-grid,
  .reference-grid {
    grid-template-columns: 1fr;
  }

  .guide-box {
    padding: 16px;
  }

  .cipher-block {
    min-height: auto;
    font-size: 0.82rem;
    padding: 18px;
  }

  .copy {
    min-height: 44px;
  }

  .analysis-toggle {
    width: 100%;
    text-align: center;
  }

  .seal-input-row {
    flex-direction: column;
  }

  .seal-input-row button {
    min-height: 46px;
  }

  .lore {
    max-height: 460px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .alphabet {
    grid-template-columns: repeat(7, 1fr);
  }

  .memory-content h1 {
    font-size: 2.8rem;
  }

  .lightbox-bar {
    align-items: start;
    flex-direction: column;
  }

  .zoom-controls {
    justify-content: start;
  }

  .lightbox-stage img {
    width: min(92vmin, 720px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
