:root {
  color-scheme: light;
  --ink: #1c2321;
  --muted: #66706b;
  --quiet: #8c948f;
  --paper: #edf1ee;
  --panel: rgba(250, 252, 249, 0.93);
  --panel-strong: rgba(255, 255, 252, 0.98);
  --line: rgba(28, 35, 33, 0.14);
  --line-strong: rgba(28, 35, 33, 0.24);
  --accent: #1f766f;
  --accent-strong: #104f4a;
  --warm: #a86643;
  --charcoal: #202927;
  --shadow: 0 22px 70px rgba(21, 28, 27, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell,
.viewer {
  width: 100%;
  height: 100%;
}

.viewer {
  position: relative;
  background:
    linear-gradient(180deg, rgba(247, 249, 246, 0.96), rgba(224, 231, 226, 0.9)),
    #e9ede9;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar {
  position: absolute;
  inset: 18px 18px auto 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.38rem, 2.1vw, 2.15rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.dimension-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(48vw, 680px);
}

.dimension-strip span,
.status-pill,
.panel-toggle {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.dimension-strip span {
  min-height: 30px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.78);
  color: #4f5854;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 12px 32px rgba(22, 28, 26, 0.08);
}

.control-panel {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(322px, calc(100vw - 36px));
  max-height: calc(100vh - 122px);
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  transition:
    transform 180ms ease,
    opacity 180ms ease;
  z-index: 4;
}

.control-panel.is-closed {
  transform: translateY(calc(100% + 28px));
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.panel-kicker {
  margin: 0 0 2px;
  color: var(--quiet);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  color: var(--charcoal);
  font-size: 1.06rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.panel-badge {
  flex: 0 0 auto;
  padding: 5px 7px;
  border: 1px solid rgba(31, 118, 111, 0.28);
  border-radius: 8px;
  background: rgba(31, 118, 111, 0.08);
  color: var(--accent-strong);
  font-size: 0.66rem;
  font-weight: 850;
}

.panel-toggle {
  position: absolute;
  left: 18px;
  top: 92px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.82);
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 850;
  box-shadow: 0 14px 34px rgba(22, 28, 26, 0.12);
  cursor: pointer;
  z-index: 5;
}

.panel-toggle svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.35;
}

.panel-toggle:hover,
.panel-toggle:focus-visible {
  border-color: rgba(31, 118, 111, 0.42);
  color: var(--accent);
  outline: none;
}

.panel-section + .panel-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.panel-title {
  margin-bottom: 8px;
  color: var(--quiet);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-title-small {
  margin-top: 2px;
  margin-bottom: 7px;
  font-size: 0.65rem;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid rgba(28, 35, 33, 0.1);
  border-radius: 8px;
  background: rgba(28, 35, 33, 0.06);
}

.segment-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  cursor: pointer;
}

.segment-button:hover,
.segment-button:focus-visible {
  color: var(--accent-strong);
  outline: none;
}

.segment-button.active {
  background: var(--panel-strong);
  color: var(--accent-strong);
  box-shadow: 0 8px 20px rgba(22, 28, 26, 0.1);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.tool-button {
  min-width: 0;
  min-height: 54px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid rgba(28, 35, 33, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.58);
  color: #5c6661;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.tool-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.tool-button span {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: inherit;
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 1;
}

.tool-button:hover,
.tool-button:focus-visible {
  border-color: rgba(31, 118, 111, 0.36);
  color: var(--accent-strong);
  outline: none;
  transform: translateY(-1px);
}

.tool-button.active {
  border-color: rgba(31, 118, 111, 0.52);
  background: rgba(31, 118, 111, 0.1);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(31, 118, 111, 0.08);
}

.tour-card {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(31, 118, 111, 0.22);
  border-radius: 8px;
  background: rgba(31, 118, 111, 0.08);
}

.tour-kicker,
.tour-next,
.phase-note {
  color: var(--quiet);
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: 0;
}

.tour-kicker {
  text-transform: uppercase;
}

.tour-card strong {
  color: var(--charcoal);
  font-size: 1rem;
  line-height: 1.12;
}

#tourRoomDescription {
  color: #4f5a55;
  font-size: 0.76rem;
  font-weight: 680;
  line-height: 1.28;
}

.tour-next {
  color: var(--accent-strong);
}

.tour-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 9px;
}

.tour-controls:has(#buildPlay) {
  grid-template-columns: 0.9fr 1.2fr 0.9fr;
}

.mini-button,
.phase-button,
.tour-step {
  min-width: 0;
  min-height: 34px;
  border: 1px solid rgba(28, 35, 33, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.62);
  color: #5c6661;
  font-size: 0.72rem;
  font-weight: 850;
  cursor: pointer;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
}

.mini-button svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}

.mini-button.primary,
.phase-button.active,
.tour-step.active {
  border-color: rgba(31, 118, 111, 0.48);
  background: rgba(31, 118, 111, 0.12);
  color: var(--accent-strong);
}

.mini-button:hover,
.mini-button:focus-visible,
.phase-button:hover,
.phase-button:focus-visible,
.tour-step:hover,
.tour-step:focus-visible {
  border-color: rgba(31, 118, 111, 0.38);
  color: var(--accent-strong);
  outline: none;
}

.tour-step-list,
.phase-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.phase-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 9px;
}

.phase-button {
  padding: 7px 8px;
}

.phase-note {
  min-height: 32px;
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(28, 35, 33, 0.05);
  color: #5d6964;
}

.toggle-row,
.range-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(28, 35, 33, 0.07);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 760;
}

.toggle-row:first-of-type,
.range-row:first-of-type {
  border-top: 0;
}

.toggle-row input[type="checkbox"] {
  width: 42px;
  height: 24px;
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(28, 35, 33, 0.16);
  border-radius: 999px;
  background: #d5d9d4;
  cursor: pointer;
  position: relative;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.toggle-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(28, 35, 33, 0.18);
  transition: transform 160ms ease;
}

.toggle-row input[type="checkbox"]:checked {
  border-color: rgba(31, 118, 111, 0.62);
  background: var(--accent);
}

.toggle-row input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

.range-row input[type="range"] {
  width: 126px;
  accent-color: var(--accent);
}

.source-note {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--quiet);
  font-size: 0.72rem;
  line-height: 1.34;
}

.compass-hud {
  position: absolute;
  right: 18px;
  bottom: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 178px;
  padding: 9px 11px 9px 9px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.84);
  box-shadow: 0 14px 34px rgba(22, 28, 26, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  pointer-events: none;
  z-index: 3;
}

.compass-rose {
  position: relative;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(31, 118, 111, 0.32);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(31, 118, 111, 0.16) 0 4px, transparent 5px),
    rgba(247, 250, 246, 0.72);
}

.cardinal {
  position: absolute;
  color: var(--accent-strong);
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
}

.cardinal-n {
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.cardinal-e {
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}

.cardinal-s {
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.cardinal-w {
  top: 50%;
  left: 6px;
  transform: translateY(-50%);
}

.compass-needle {
  --heading-rotation: 0deg;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 24px;
  border-radius: 999px;
  background: var(--warm);
  transform: translate(-50%, -88%) rotate(var(--heading-rotation));
  transform-origin: 50% 88%;
  box-shadow: 0 1px 4px rgba(28, 35, 33, 0.22);
  transition: transform 120ms linear;
}

.compass-needle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -5px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 8px solid var(--warm);
  transform: translateX(-50%);
}

.heading-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.heading-kicker,
.heading-copy span:last-child {
  color: var(--quiet);
  font-size: 0.63rem;
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: 0;
  text-transform: uppercase;
}

.heading-copy strong {
  color: var(--charcoal);
  font-size: 0.92rem;
  line-height: 1.08;
}

.heading-copy span:last-child {
  color: #5d6964;
  font-size: 0.66rem;
  text-transform: none;
}

.status-pill {
  position: absolute;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.84);
  color: #59625d;
  font-size: 0.76rem;
  font-weight: 850;
  box-shadow: 0 14px 34px rgba(22, 28, 26, 0.12);
  pointer-events: none;
}

body[data-time="night"] .eyebrow,
body[data-time="night"] h1 {
  color: rgba(247, 247, 240, 0.96);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.36);
}

body[data-time="night"] .dimension-strip span,
body[data-time="night"] .panel-toggle,
body[data-time="night"] .compass-hud,
body[data-time="night"] .status-pill {
  background: rgba(247, 247, 241, 0.88);
}

@media (max-width: 820px) {
  .topbar {
    inset: 12px 12px auto 12px;
    display: block;
  }

  .dimension-strip {
    justify-content: flex-start;
    max-width: calc(100vw - 24px);
    margin-top: 8px;
    gap: 6px;
  }

  .dimension-strip span {
    min-height: 26px;
    padding: 6px 8px;
    font-size: 0.67rem;
  }

  .control-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 46vh;
    padding: 12px;
  }

  .panel-toggle {
    left: 12px;
    top: 88px;
  }

  .icon-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tool-button {
    min-height: 50px;
  }

  .status-pill {
    right: 12px;
    bottom: calc(46vh + 22px);
  }

  .compass-hud {
    right: 12px;
    bottom: calc(46vh + 62px);
    min-width: 164px;
    padding: 8px 10px 8px 8px;
  }

  .compass-rose {
    width: 52px;
    height: 52px;
  }

  .compass-needle {
    height: 21px;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1.14rem;
  }

  .eyebrow {
    font-size: 0.62rem;
  }

  .panel-header {
    margin-bottom: 12px;
    padding-bottom: 11px;
  }

  .tool-button span {
    font-size: 0.62rem;
  }

  .range-row input[type="range"] {
    width: 46%;
  }

  .compass-hud {
    min-width: 0;
    max-width: calc(100vw - 24px);
  }

  .heading-copy strong {
    font-size: 0.82rem;
  }

  .heading-copy span:last-child {
    display: none;
  }
}
