:root {
  color-scheme: light;
  --ink: #21332d;
  --muted: #54635c;
  --ground: #f5f5ef;
  --paper: #fffef9;
  --line: #dce1d7;
  --accent: #315747;
  --scene: #1c2825;
  font-family: system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--ground);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { opacity: .55; }
:focus-visible { outline: 3px solid #456959; outline-offset: 3px; }

.bar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(4vw, calc((100vw - 1460px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.wordmark {
  display: flex;
  gap: 11px;
  align-items: center;
  font-size: 1.06rem;
  font-weight: 750;
  letter-spacing: -.03em;
}

.wordmark-mark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-radius: 50% 50% 18% 18%;
  position: relative;
}

.wordmark-mark::after {
  content: "";
  position: absolute;
  inset: 6px 5px 0;
  background: var(--accent);
  border-radius: 50% 50% 0 0;
}

.environment, .studio-header p, .panel-heading p, .scene-info { color: var(--muted); }
.environment { font-size: .81rem; font-weight: 570; }

main {
  width: min(1460px, 92vw);
  margin-inline: auto;
  padding-block: clamp(26px, 4vw, 54px);
}

.studio-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1 {
  font-family: Charter, "Bitstream Charter", Georgia, serif;
  font-size: clamp(2.25rem, 4vw, 4.5rem);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: .99;
  margin: 0 0 11px;
}

.studio-header p { margin: 0; line-height: 1.45; }

.segments, #rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
}

.segments button, #rooms button {
  background: transparent;
  border: 0;
  border-radius: 5px;
  min-height: 42px;
  padding-inline: 12px;
  font-size: .85rem;
  font-weight: 610;
}

#rooms button[aria-pressed="true"], .segments button[aria-pressed="true"] {
  background: var(--accent);
  color: white;
}

#rooms button:hover:not([aria-pressed="true"]), .segments button:hover:not([aria-pressed="true"], :disabled) {
  background: #e7eae2;
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(288px, 320px);
  gap: 18px;
  align-items: start;
}

.visualizer {
  margin: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
}

.viewport {
  position: relative;
  isolation: isolate;
  min-height: 280px;
  height: clamp(360px, 53vh, 650px);
  overflow: hidden;
  background: var(--scene);
}

#panorama, .fallback, .fallback img {
  width: 100%;
  height: 100%;
  display: block;
}

#panorama { cursor: grab; touch-action: none; }
#panorama:active { cursor: grabbing; }
#panorama:focus-visible { outline-offset: -5px; outline-color: #fffef9; }
.fallback img { object-fit: contain; }

.scene-status {
  position: absolute;
  inset-inline: 14px auto;
  bottom: 14px;
  max-width: min(390px, 86%);
  width: fit-content;
  padding: 9px 13px;
  background: #25352def;
  border-radius: 7px;
  color: #fff;
  font-size: .85rem;
  line-height: 1.4;
  pointer-events: none;
}

.camera-buttons {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 5px;
}

.camera-buttons button {
  width: 44px;
  min-height: 44px;
  background: #fffef9f5;
  border: 1px solid #cdd6cb;
  border-radius: 6px;
  line-height: 1;
  font-size: 1.15rem;
}

figcaption {
  padding: 11px 12px 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: .84rem;
}

.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
}
.panel h2 { margin: 0; font-size: 1.16rem; }
.panel-heading p { font-size: .87rem; margin: 7px 0 22px; line-height: 1.5; }
fieldset { padding: 0; margin: 0 0 20px; border: 0; }
legend { margin-bottom: 8px; padding: 0; font-size: .95rem; font-weight: 650; }

.material {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 7px 8px;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafbf6;
  cursor: pointer;
}

.material:has(input:checked) { border-color: var(--accent); background: #e9efe6; }
.material:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.material input { accent-color: var(--accent); margin: 0 3px 0 auto; width: 16px; height: 16px; }
.material-swatch { flex: 0 0 29px; height: 29px; border: 1px solid #27392c38; border-radius: 4px; }
.material-name { font-size: .88rem; }

.scene-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: .8rem;
}
.scene-info span:first-child { color: var(--ink); font-variant-numeric: tabular-nums; }
.retry { margin-top: 12px; min-height: 44px; border: 1px solid var(--accent); border-radius: 6px; background: var(--paper); padding: 0 12px; }

@media (max-width: 850px) {
  main { width: min(94vw, 720px); }
  .studio { grid-template-columns: minmax(0, 1fr); }
  .viewport { height: clamp(270px, 52vw, 420px); }
  .panel { padding: 18px; }
}

@media (max-width: 480px) {
  .bar { min-height: 54px; }
  .studio-header { align-items: start; flex-direction: column; gap: 13px; }
  .studio-header p { font-size: .88rem; }
  .viewport { min-height: 250px; }
  figcaption { align-items: start; flex-direction: column; }
  .modes { align-self: end; }
  .camera-buttons { top: 7px; right: 7px; }
}
