:root {
  --earth-black: #120d09;
  --earth-deep: #24170f;
  --earth-brown: #4b2f1d;
  --earth-brown-2: #6b4428;
  --earth-rust: #8a5a32;
  --stone-dark: #35302a;
  --stone-mid: #665f53;
  --stone-light: #9a8973;
  --torch: #d7a14a;
  --sand: #d9c39a;
  --moss: #52623d;
  --panel-width: 260px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--sand);
  background:
    linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%),
    linear-gradient(45deg, rgba(0,0,0,.18) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.18) 75%),
    radial-gradient(circle at 45% 15%, rgba(215,161,74,.12), transparent 28rem),
    var(--earth-black);
  background-size: 18px 18px, 18px 18px, auto;
  background-position: 0 0, 9px 9px, center;
}

button,
a {
  font: inherit;
  color: inherit;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--panel-width) 1fr;
  transition: grid-template-columns 180ms ease;
}

.page-shell.panel-collapsed {
  grid-template-columns: 42px 1fr;
}

.side-panel {
  position: relative;
  min-height: 100vh;
  padding: 14px 12px;
  background:
    url("images/ui/wall-tile-placeholder.svg"),
    linear-gradient(180deg, var(--stone-dark), var(--earth-deep));
  background-size: 96px 96px, auto;
  border-right: 4px solid var(--earth-rust);
  box-shadow: inset -8px 0 0 rgba(0,0,0,.3), 8px 0 24px rgba(0,0,0,.35);
  overflow: hidden;
}

.page-shell.panel-collapsed .side-panel > *:not(.collapse-button) {
  opacity: 0;
  pointer-events: none;
}

.collapse-button {
  position: absolute;
  top: 10px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: 2px solid var(--stone-light);
  background: var(--earth-brown);
  color: var(--torch);
  cursor: pointer;
}

.page-shell.panel-collapsed .collapse-button {
  right: 6px;
  transform: rotate(180deg);
}

.logo-block {
  margin: 30px 0 16px;
  padding: 10px;
  background: rgba(18,13,9,.74);
  border: 3px solid var(--earth-rust);
  image-rendering: pixelated;
}

.project-logo {
  display: block;
  width: 100%;
  min-height: 72px;
  object-fit: contain;
  background: var(--earth-brown);
}

.top-links,
.tab-column {
  display: grid;
  gap: 9px;
}

.top-links {
  margin-bottom: 24px;
}

.stone-button,
.tab-button {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  text-align: left;
  text-decoration: none;
  border: 3px solid var(--stone-light);
  background:
    url("images/ui/button-stone-placeholder.svg"),
    linear-gradient(180deg, var(--earth-brown-2), var(--earth-brown));
  background-size: 64px 64px, auto;
  color: var(--sand);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.28);
  cursor: pointer;
}

.stone-button:hover,
.tab-button:hover,
.tab-button.active {
  color: #fff2c9;
  border-color: var(--torch);
  filter: brightness(1.12);
}

.cog-button {
  text-align: center;
}

.main-stage {
  position: relative;
  display: grid;
  gap: 18px;
  align-content: start;
  min-height: 100vh;
  padding: 22px clamp(16px, 3vw, 38px) 40px;
  background:
    url("images/ui/earth-floor-placeholder.svg"),
    linear-gradient(135deg, rgba(36,23,15,.92), rgba(75,47,29,.86));
  background-size: 128px 128px, auto;
}

.top-info-shell {
  position: sticky;
  top: 14px;
  z-index: 5;
  width: min(560px, 100%);
}

.info-chip {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px 12px;
  border: 3px solid var(--stone-light);
  background: rgba(18,13,9,.9);
  color: var(--sand);
  text-align: left;
}

.info-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--torch);
  background: var(--earth-brown);
}

.info-copy {
  display: grid;
  gap: 2px;
  line-height: 1.2;
}

.info-copy span,
.hover-tooltip span {
  opacity: .82;
}

.hover-tooltip {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: min(560px, 100%);
  min-height: 58px;
  max-height: 58px;
  padding: 8px 12px;
  display: grid;
  align-content: center;
  gap: 2px;
  border: 3px solid var(--torch);
  background: rgba(18,13,9,.96);
  box-shadow: 0 12px 22px rgba(0,0,0,.35);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
  overflow: hidden;
}

.top-info-shell:hover .hover-tooltip,
.top-info-shell:focus-within .hover-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.hero-card,
.viewer-card,
.tool-output {
  border: 4px solid var(--earth-rust);
  background: rgba(18,13,9,.72);
  box-shadow: inset 0 0 0 3px rgba(154,137,115,.28), 0 12px 28px rgba(0,0,0,.32);
}

.hero-card {
  display: grid;
  place-items: center;
  min-height: 240px;
  padding: 28px;
  text-align: center;
}

.hero-card h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 6vw, 5rem);
  letter-spacing: .06em;
  color: var(--torch);
  text-shadow: 4px 4px 0 #000;
}

.hero-card p {
  max-width: 720px;
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.45;
}

.viewer-card {
  min-height: 280px;
  padding: 14px;
}

.three-viewer {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--stone-mid);
  background:
    radial-gradient(circle at 50% 42%, rgba(215,161,74,.22), transparent 18rem),
    linear-gradient(180deg, #1f1a16, #0e0b09);
}

.viewer-grid {
  position: absolute;
  inset: 0;
  opacity: .34;
  background-image:
    linear-gradient(var(--stone-mid) 2px, transparent 2px),
    linear-gradient(90deg, var(--stone-mid) 2px, transparent 2px);
  background-size: 28px 28px;
  transform: perspective(540px) rotateX(62deg) translateY(30px) scale(1.45);
  transform-origin: center bottom;
}

.viewer-default-copy {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 18px;
  text-align: center;
  background: rgba(18,13,9,.78);
  border: 3px solid var(--torch);
}

.viewer-default-copy strong {
  font-size: 1.35rem;
  color: #ffe0a1;
}

.tool-output {
  padding: 18px 20px;
}

.tool-output h2 {
  margin: 0 0 8px;
  color: var(--torch);
}

.tool-output p {
  margin: 0;
  max-width: 850px;
  line-height: 1.55;
}

@media (max-width: 760px) {
  .page-shell,
  .page-shell.panel-collapsed {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 4px solid var(--earth-rust);
  }

  .page-shell.panel-collapsed .side-panel {
    min-height: 48px;
  }
}
