:root {
  color-scheme: dark;
  --ink: #eef7ff;
  --muted: #a6b9ca;
  --surface: #101c2b;
  --surface-raised: #162638;
  --line: #324b62;
  --accent: #62f6d3;
  --warm: #f5b642;
  --danger: #ffb4ab;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 20rem; background: #08111f; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 82% 4%, #18395a 0, #08111f 42rem); line-height: 1.5; }
button, select, textarea { font: inherit; }
button, select { min-height: 2.75rem; }
button { cursor: pointer; }
:where(a, button, select, textarea):focus-visible { outline: 0.2rem solid var(--accent); outline-offset: 0.18rem; }

.skip-link { position: fixed; z-index: 20; top: 0.75rem; left: 0.75rem; padding: 0.65rem 1rem; color: #07131d; background: var(--accent); transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }
.site-header { display: flex; justify-content: space-between; gap: 3rem; align-items: end; max-width: 94rem; margin: auto; padding: 2.5rem clamp(1rem, 4vw, 4rem) 1.6rem; border-bottom: 0.0625rem solid var(--line); }
.site-header h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 3.8rem); letter-spacing: -0.055em; line-height: 0.95; }
.site-header > p { max-width: 35rem; margin: 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow, .step { margin: 0 0 0.3rem; color: var(--accent); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }

main { display: grid; grid-template-columns: minmax(19rem, 0.72fr) minmax(32rem, 1.75fr); max-width: 94rem; margin: auto; min-height: 46rem; }
.source-panel, .experience-panel { padding: clamp(1.25rem, 3vw, 2.5rem); }
.source-panel { border-right: 0.0625rem solid var(--line); background: rgb(9 20 33 / 70%); }
.section-heading, .experience-header, .label-row { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
h2, h3 { margin: 0; line-height: 1.15; }
h2 { font-size: clamp(1.35rem, 2.3vw, 2rem); }
h3 { font-size: 1.18rem; }
.local-badge { padding: 0.25rem 0.58rem; border: 0.0625rem solid #347e71; border-radius: 99rem; color: var(--accent); font-size: 0.75rem; white-space: nowrap; }
form { display: grid; gap: 0.62rem; margin-top: 1.6rem; }
label { font-weight: 700; font-size: 0.88rem; }
select, textarea { width: 100%; border: 0.0625rem solid #48647c; border-radius: 0.45rem; background: #0a1725; color: var(--ink); }
select { padding: 0.55rem 0.7rem; }
textarea { min-height: 16rem; padding: 0.85rem; resize: vertical; line-height: 1.45; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.83rem; tab-size: 2; }
.label-row { align-items: end; margin-top: 0.55rem; }
.text-button { min-height: auto; border: 0; padding: 0; color: var(--accent); background: none; text-decoration: underline; text-underline-offset: 0.2rem; }
.help, .error { margin: 0.15rem 0 0.35rem; font-size: 0.8rem; }
.help { color: var(--muted); }
.error { padding: 0.7rem; border-left: 0.2rem solid var(--danger); color: var(--danger); background: #351b23; }
.primary-button { display: flex; justify-content: space-between; align-items: center; border: 0.0625rem solid #97ffea; border-radius: 0.45rem; padding: 0.65rem 0.9rem; background: var(--accent); color: #07131d; font-weight: 850; }
.primary-button:hover { background: #a0ffe9; }

.experience-panel { min-width: 0; }
.experience-header { align-items: end; margin-bottom: 1rem; }
.scene-summary { margin: 0; color: var(--muted); font-size: 0.85rem; text-align: end; }
.viewer-shell { position: relative; overflow: hidden; border: 0.0625rem solid #48647c; border-radius: 0.75rem; background: #09111f; box-shadow: 0 1.2rem 4rem rgb(0 0 0 / 32%); }
#viewer { height: clamp(25rem, 56vh, 40rem); min-height: 25rem; }
#viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#webgl-fallback { display: grid; align-content: center; height: 100%; max-width: 44rem; margin: auto; padding: 2rem; text-align: center; background: linear-gradient(135deg, #122239, #1d3345); }
#webgl-fallback h3 { color: var(--warm); font-size: 1.5rem; }
#webgl-fallback p { color: var(--muted); }
.viewer-toolbar { position: absolute; top: 0.75rem; left: 0.75rem; display: flex; padding: 0.22rem; border: 0.0625rem solid #526b7f; border-radius: 0.5rem; background: rgb(7 16 28 / 88%); backdrop-filter: blur(0.5rem); }
.viewer-toolbar button { min-height: 2.15rem; border: 0; border-radius: 0.35rem; padding: 0.35rem 0.7rem; color: var(--ink); background: transparent; font-size: 0.78rem; }
.viewer-toolbar button[aria-pressed="true"] { color: #07131d; background: var(--accent); font-weight: 800; }
.viewer-help { position: absolute; right: 0.75rem; bottom: 0.75rem; max-width: min(32rem, calc(100% - 1.5rem)); margin: 0; padding: 0.45rem 0.65rem; border-radius: 0.35rem; color: #d5e4ef; background: rgb(7 16 28 / 82%); font-size: 0.76rem; pointer-events: none; }
#portal-tooltip { position: fixed; z-index: 10; max-width: 17rem; padding: 0.42rem 0.62rem; border: 0.0625rem solid var(--accent); border-radius: 0.35rem; color: #07131d; background: var(--accent); font-size: 0.8rem; font-weight: 800; pointer-events: none; }

.room-details { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1.25rem; margin-top: 1.25rem; }
.room-details > * { min-width: 0; padding: 1rem; border: 0.0625rem solid var(--line); border-radius: 0.55rem; background: var(--surface); }
.plaque-list { display: grid; gap: 0.75rem; margin-top: 0.85rem; }
.plaque { padding-left: 0.75rem; border-left: 0.18rem solid var(--warm); }
.plaque h4 { margin: 0; font-size: 0.98rem; }
.plaque p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }
.plaque a { color: var(--accent); overflow-wrap: anywhere; }
.portal-list { display: grid; gap: 0.5rem; margin: 0.85rem 0 0; padding: 0; list-style: none; }
.portal-list button { width: 100%; border: 0.0625rem solid #94733f; border-radius: 0.4rem; padding: 0.55rem 0.7rem; color: #fff3d5; background: #2d251a; text-align: left; }
.portal-list button:hover { border-color: var(--warm); background: #42331e; }
.portal-list button::after { content: " →"; color: var(--warm); }
.portal-list .empty { color: var(--muted); font-size: 0.86rem; }
footer { max-width: 94rem; margin: auto; padding: 1.3rem clamp(1rem, 4vw, 4rem) 2.5rem; border-top: 0.0625rem solid var(--line); color: var(--muted); font-size: 0.82rem; }
footer p { margin: 0; }

@media (max-width: 62rem) {
  .site-header { align-items: start; flex-direction: column; gap: 1rem; }
  main { grid-template-columns: 1fr; }
  .source-panel { border-right: 0; border-bottom: 0.0625rem solid var(--line); }
  textarea { min-height: 12rem; }
}
@media (max-width: 38rem) {
  .room-details { grid-template-columns: 1fr; }
  .experience-header { align-items: start; flex-direction: column; }
  .scene-summary { text-align: start; }
  #viewer { height: 29rem; }
  .viewer-help { display: none; }
  .viewer-toolbar { right: 0.75rem; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
