:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #071212;
  color: #f6f5ec;
}

/* Egypt keeps the Paleozoic interaction system, with a warmer archival palette. */
body { background: #171006; }
#viewer { background: #171006; }
.eyebrow, .story-kicker { color: #f2c45c; }
.story-card { grid-template-areas: "visual copy"; grid-template-rows: minmax(440px, auto); }
.story-copy { display: flex; flex-direction: column; justify-content: center; padding: 44px; }
.story-copy h2 { margin: 5px 40px 20px 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 5vw, 62px); font-weight: 400; line-height: 1.02; }
.story-kicker { margin: 0; font-size: 11px; font-weight: 750; letter-spacing: .17em; text-transform: uppercase; }
#story-body { margin: 0; padding-top: 20px; border-top: 1px solid rgba(242,196,92,.22); color: #eef3f5; font-size: 17px; line-height: 1.7; }
.story-visual img { width: 100%; height: 100%; max-height: 560px; object-fit: cover; }
@media (max-width: 640px) {
  .story-card { display: block; }
  .story-copy { padding: 22px 18px 28px; }
  .story-copy h2 { margin: 4px 30px 13px 0; font-size: 31px; }
  #story-body { padding-top: 13px; font-size: 14px; line-height: 1.55; }
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button { color: inherit; font: inherit; }

#viewer {
  position: fixed;
  inset: 0;
  background: #071212;
}
.pnlm-container { font-family: inherit; }
.pnlm-load-box { display: none !important; }
.pnlm-render-container { will-change: transform; }

#viewer::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.4), transparent 26%, transparent 64%, rgba(0,0,0,.7));
}

.topbar {
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-size: 13px; font-weight: 650; letter-spacing: .08em; text-decoration: none; text-transform: uppercase; pointer-events: auto; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; font-family: Georgia, serif; font-size: 18px; }
.icon-button, .arrow, .zoom-controls button { border: 1px solid rgba(255,255,255,.25); background: rgba(4,17,17,.5); backdrop-filter: blur(12px); cursor: pointer; pointer-events: auto; transition: background .2s, border-color .2s, transform .2s; }
.icon-button:hover, .arrow:hover, .zoom-controls button:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.6); }
.icon-button { width: 42px; height: 42px; border-radius: 50%; font-size: 21px; }

.scene-card { position: fixed; z-index: 2; top: 18%; left: clamp(24px, 6vw, 90px); width: min(620px, calc(100vw - 48px)); padding: 18px 20px; border: 1px solid rgba(255,255,255,.14); border-radius: 16px; background: rgba(4,17,17,.48); backdrop-filter: blur(12px); text-shadow: 0 2px 20px #000; }
.eyebrow { margin: 0 0 7px; color: #c6dfb7; font-size: 11px; font-weight: 700; letter-spacing: .19em; text-transform: uppercase; }
.scene-heading { display: flex; align-items: center; gap: 14px; }
.scene-card h1 { flex: 1; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4vw, 58px); font-weight: 400; line-height: 1; }
.scene-card.is-collapsed { width: 38px; padding: 0; border-color: transparent; background: transparent; backdrop-filter: none; }
.scene-card.is-collapsed .eyebrow { display: none; }
.scene-card.is-collapsed .scene-heading { justify-content: flex-start; }
.scene-card.is-collapsed h1 { display: none; }
.scene-toggle { display: grid; flex: 0 0 38px; width: 38px; height: 38px; padding: 0; place-items: center; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; background: rgba(4,17,17,.55); cursor: pointer; }
.scene-toggle:hover, .scene-toggle:focus-visible { border-color: rgba(255,255,255,.7); background: rgba(255,255,255,.15); outline: none; }
.scene-toggle span { font-size: 20px; transition: transform .2s; }
.scene-toggle[aria-expanded="false"] span { transform: rotate(180deg); }
#scene-details[hidden] { display: none; }
.scene-description { max-width: 58ch; margin: 14px 0 0; color: rgba(255,255,255,.88); font-size: 15px; line-height: 1.55; }
.scene-card #scene-count { margin: 12px 0 0; color: rgba(255,255,255,.72); font-size: 13px; letter-spacing: .12em; }
.support-link { display: inline-flex; margin-top: 16px; padding: 10px 14px; align-items: center; gap: 9px; border: 1px solid rgba(242,196,92,.48); border-radius: 22px; color: #f6f5ec; background: rgba(151,104,30,.25); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-decoration: none; text-transform: uppercase; transition: background .2s, border-color .2s, transform .2s; }
.support-link[hidden] { display: none; }
.support-link:hover, .support-link:focus-visible { border-color: #f2c45c; background: rgba(171,119,34,.42); outline: none; transform: translateY(-1px); }

.hint { position: fixed; z-index: 3; left: 50%; bottom: 134px; display: flex; gap: 9px; align-items: center; padding: 9px 14px; border: 1px solid rgba(255,255,255,.2); border-radius: 20px; background: rgba(4,17,17,.55); backdrop-filter: blur(12px); font-size: 11px; letter-spacing: .03em; transform: translateX(-50%); transition: opacity .6s; white-space: nowrap; pointer-events: none; }
.hint.hidden { opacity: 0; }
.mouse { font-size: 16px; }

.scene-nav { position: fixed; z-index: 4; left: 50%; bottom: 22px; display: flex; width: min(850px, calc(100vw - 32px)); align-items: center; gap: 12px; transform: translateX(-50%); }
.arrow { flex: 0 0 42px; height: 42px; border-radius: 50%; }
.scene-strip { display: flex; min-width: 0; flex: 1; gap: 8px; padding: 4px; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; }
.scene-strip::-webkit-scrollbar { display: none; }
.scene-thumb { position: relative; flex: 0 0 92px; height: 62px; padding: 0; overflow: hidden; border: 1px solid transparent; border-radius: 5px; background: #132323; cursor: pointer; opacity: .62; transition: opacity .2s, border-color .2s, transform .2s; }
.scene-thumb:hover { opacity: 1; transform: translateY(-2px); }
.scene-thumb.active { border-color: #e9efcd; opacity: 1; }
.scene-thumb img { width: 100%; height: 100%; object-fit: cover; }
.scene-thumb span { position: absolute; right: 5px; bottom: 4px; display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; background: rgba(0,0,0,.62); font-size: 9px; font-weight: 700; }

.zoom-controls { position: fixed; z-index: 3; right: 28px; bottom: 112px; display: grid; overflow: hidden; border: 1px solid rgba(255,255,255,.2); border-radius: 22px; }
.zoom-controls button { width: 40px; height: 38px; border: 0; border-radius: 0; font-size: 20px; }
.zoom-controls button + button { border-top: 1px solid rgba(255,255,255,.2); }

body.loading #viewer { opacity: .72; }

.story-hotspot-shell { z-index: 6 !important; width: 0; height: 0; pointer-events: auto; }
.story-hotspot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border: 1px solid rgba(245, 196, 92, .55);
  border-radius: 22px;
  color: #eafcff;
  background: rgba(2, 21, 31, .82);
  box-shadow: 0 5px 22px rgba(0, 0, 0, .5), 0 0 18px rgba(60, 216, 255, .12);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: border-color .2s, transform .2s, background .2s;
}
.story-hotspot span { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 50%; color: #03131b; background: #f2c45c; font-size: 18px; line-height: 1; }
.story-hotspot b { max-width: 150px; overflow: hidden; font-size: 11px; font-weight: 650; letter-spacing: .04em; text-overflow: ellipsis; white-space: nowrap; }
.story-hotspot:hover, .story-hotspot:focus-visible { border-color: #ffd777; background: rgba(5, 39, 52, .94); transform: translate(-50%, -50%) scale(1.06); outline: none; }

.story-modal[hidden] { display: none; }
.story-modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; }
.modal-scrim { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(0, 8, 14, .66); backdrop-filter: blur(8px); cursor: default; animation: popup-scrim-in .6s ease both; }
.story-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, .93fr) minmax(420px, 1.07fr);
  grid-template-areas: "visual copy" "history history" "timeline timeline";
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid rgba(127, 202, 224, .24);
  border-radius: 22px;
  color: #f5f8fa;
  background: linear-gradient(145deg, rgba(7, 35, 50, .98), rgba(2, 18, 29, .99) 58%, rgba(4, 25, 36, .99));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .65), inset 0 1px rgba(255, 255, 255, .04);
  animation: popup-card-in .65s cubic-bezier(.22, .75, .28, 1) both;
}
@keyframes popup-scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes popup-card-in { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
.story-close { position: absolute; z-index: 3; top: 20px; right: 20px; display: grid; width: 46px; height: 46px; padding: 0 0 4px; place-items: center; border: 1px solid rgba(188, 228, 240, .34); border-radius: 50%; color: #edfaff; background: rgba(0, 13, 22, .48); font-size: 34px; font-weight: 200; line-height: 1; cursor: pointer; }
.story-close:hover { border-color: #ffd777; background: rgba(54, 205, 235, .13); }
.story-visual { position: relative; grid-area: visual; min-height: 390px; overflow: hidden; border-radius: 21px 0 0 0; background: radial-gradient(circle at 50% 35%, #173c4c, #071923 68%); }
.story-visual::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, transparent 55%, rgba(2, 17, 26, .65)); }
.story-visual img { width: 100%; height: 100%; max-height: 440px; object-fit: cover; }
.story-visual img { opacity: 0; transition: opacity .35s ease; }
.story-visual.is-ready img { opacity: 1; }
.story-visual.is-loading::before { content: ""; position: absolute; z-index: 2; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px; border: 2px solid rgba(255,255,255,.2); border-top-color: #f2c45c; border-radius: 50%; animation: image-spin .8s linear infinite; }
@keyframes image-spin { to { transform: rotate(360deg); } }
.kind-pill { position: absolute; z-index: 2; display: flex; align-items: center; border: 1px solid rgba(120, 220, 241, .3); border-radius: 22px; color: #6fe7ff; background: rgba(1, 17, 26, .72); backdrop-filter: blur(8px); font-size: 13px; }
.kind-pill { top: 23px; left: 24px; gap: 8px; padding: 8px 13px; }
.story-copy { grid-area: copy; padding: 30px 30px 22px; }
.story-copy h2 { margin: 0 58px 2px 0; font-size: clamp(34px, 4vw, 52px); line-height: 1.05; letter-spacing: -.035em; }
.scientific { margin: 5px 0 20px; color: #abb8bf; font-size: 19px; font-style: italic; }
.story-group { display: flex; align-items: center; gap: 15px; margin-bottom: 18px; color: #c9d3d8; }
.story-group b { color: #cbd6db; font-size: 14px; font-weight: 450; }
.story-group b::first-letter { color: #f2c45c; }
.story-group span { width: 1px; height: 24px; background: rgba(164, 205, 218, .22); }
.story-description { margin: 0 0 20px; padding-top: 16px; border-top: 1px solid rgba(157, 202, 215, .17); color: #eef3f5; font-size: 15px; line-height: 1.55; }
.story-facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0; overflow: hidden; border: 1px solid rgba(139, 207, 225, .22); border-radius: 14px; }
.story-facts div { display: grid; grid-template-columns: minmax(105px, .8fr) 1.2fr; min-height: 58px; align-items: center; padding: 10px 13px; border-bottom: 1px solid rgba(139, 207, 225, .16); }
.story-facts div:nth-child(odd) { border-right: 1px solid rgba(139, 207, 225, .16); }
.story-facts div:nth-last-child(-n+2) { border-bottom: 0; }
.story-facts dt { display: flex; align-items: center; gap: 9px; color: #f2c45c; font-size: 11px; font-weight: 650; letter-spacing: .04em; }
.story-facts dt i { width: 22px; font-size: 20px; font-style: normal; text-align: center; }
.story-facts dd { margin: 0; color: #f0f3f4; font-size: 12px; line-height: 1.25; }
.history-panel small { display: block; color: #d6e0e4; font-size: 10px; letter-spacing: .04em; }
.history-panel { grid-area: history; display: grid; grid-template-columns: 1fr 1.25fr; gap: 24px; margin: 0 18px; padding: 16px 20px; border: 1px solid rgba(139, 207, 225, .22); border-radius: 14px; }
.history-panel > div + div { padding-left: 24px; border-left: 1px solid rgba(139, 207, 225, .16); }
.history-panel strong, .history-panel > div > span { display: block; margin-top: 5px; }
.history-panel strong { font-size: 17px; }
.history-panel > div > span { color: #b9c5ca; font-size: 13px; }
.story-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.story-tags span { padding: 4px 8px; border: 1px solid rgba(107, 218, 243, .25); border-radius: 12px; color: #9defff; background: rgba(40, 123, 143, .15); font-size: 9px; }
.story-tags span:first-child { border-color: rgba(106, 225, 120, .28); color: #9cf19f; background: rgba(54, 152, 65, .19); }
.era-track { grid-area: timeline; display: grid; grid-template-columns: repeat(7, 1fr); margin: 10px 20px 16px; padding-top: 10px; border-top: 8px solid rgba(70, 105, 120, .24); }
.era-track span { position: relative; color: #768891; font-size: 9px; text-align: center; }
.era-track span::before { content: ""; position: absolute; top: -18px; left: 0; width: 1px; height: 8px; background: rgba(132, 177, 192, .28); }
.era-track span.active { color: #f2c45c; }
.era-track span.active::after { content: ""; position: absolute; top: -18px; left: 0; width: 100%; height: 8px; background: linear-gradient(90deg, #48cde9, #74eeff); }
body.modal-open .topbar, body.modal-open .scene-card, body.modal-open .scene-nav, body.modal-open .hint, body.modal-open .zoom-controls { filter: blur(2px); pointer-events: none; }

@media (max-width: 640px) {
  .topbar { padding: 17px; }
  .brand span:last-child { display: none; }
  .scene-card { top: 12%; left: 16px; width: calc(100vw - 32px); padding: 14px 15px; border-radius: 13px; }
  .scene-card h1 { font-size: clamp(29px, 9vw, 42px); }
  .scene-description { margin-top: 10px; font-size: 13px; line-height: 1.45; }
  .scene-toggle { flex-basis: 34px; width: 34px; height: 34px; }
  .hint { bottom: 112px; }
  .hint span:not(.mouse) { display: none; }
  .scene-nav { bottom: 14px; width: calc(100vw - 20px); gap: 6px; }
  .scene-thumb { flex-basis: 72px; height: 50px; }
  .arrow { display: none; }
  .zoom-controls { right: 16px; bottom: 88px; }
  .story-hotspot b { display: none; }
  .story-hotspot { padding: 5px; }
  .story-modal { align-items: end; padding: 10px; }
  .story-card { display: block; width: 100%; max-height: calc(100vh - 20px); border-radius: 18px; }
  .story-close { top: 12px; right: 12px; width: 38px; height: 38px; font-size: 27px; }
  .story-visual { min-height: 0; height: 220px; border-radius: 17px 17px 0 0; }
  .story-visual img { max-height: none; object-position: center; }
  .kind-pill { top: 13px; left: 13px; padding: 6px 10px; font-size: 11px; }
  .story-copy { padding: 12px 12px 8px; }
  .story-copy h2 { margin-right: 0; font-size: 27px; }
  .scientific { margin: 1px 0 9px; font-size: 13px; }
  .story-group { gap: 10px; margin-bottom: 9px; }
  .story-group b { font-size: 11px; }
  .story-group span { height: 18px; }
  .story-description { margin-bottom: 10px; padding-top: 8px; font-size: 11px; line-height: 1.4; }
  .story-facts { display: block; border-radius: 10px; }
  .story-facts div { grid-template-columns: 120px 1fr; min-height: 29px; padding: 3px 9px; border-right: 0 !important; border-bottom: 1px solid rgba(139, 207, 225, .16) !important; }
  .story-facts div:last-child { border-bottom: 0 !important; }
  .story-facts dt { font-size: 9px; }
  .story-facts dt i { width: 16px; font-size: 14px; }
  .story-facts dd { text-align: right; font-size: 10px; }
  .history-panel { grid-template-columns: .8fr 1.2fr; gap: 8px; margin: 8px 12px 0; padding: 10px; border-radius: 10px; }
  .history-panel > div + div { padding-left: 8px; }
  .history-panel strong { font-size: 14px; }
  .history-panel > div > span { font-size: 10px; }
  .story-tags { gap: 3px; margin-top: 6px; }
  .story-tags span { padding: 3px 5px; font-size: 7px; }
  .era-track { margin: 9px 12px 13px; overflow: hidden; }
  .era-track span { min-width: 68px; font-size: 8px; }
}

/* Story cards intentionally use a simpler, editorial layout than organism dossiers. */
.story-card { grid-template-areas: "visual copy"; grid-template-rows: minmax(440px, auto); }
.story-copy { display: flex; flex-direction: column; justify-content: center; padding: 44px; }
.story-copy h2 { margin: 5px 40px 20px 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 5vw, 62px); font-weight: 400; line-height: 1.02; }
.story-kicker { margin: 0; color: #f2c45c; font-size: 11px; font-weight: 750; letter-spacing: .17em; text-transform: uppercase; }
#story-body { margin: 0; padding-top: 20px; border-top: 1px solid rgba(242,196,92,.22); color: #eef3f5; font-size: 17px; line-height: 1.7; }
.story-visual img { width: 100%; height: 100%; max-height: 560px; object-fit: cover; }

@media (max-width: 640px) {
  .story-copy { padding: 22px 18px 28px; }
  .story-copy h2 { margin: 4px 30px 13px 0; font-size: 31px; }
  #story-body { padding-top: 13px; font-size: 14px; line-height: 1.55; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .modal-scrim, .story-card { animation: none !important; }
}
