:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Apple SD Gothic Neo", sans-serif;
  color: #edf4ef;
  background: #101613;
  font-synthesis: none;
  --ink: #edf4ef;
  --muted: #8c9b93;
  --panel: #171e1a;
  --panel-deep: #0d1210;
  --line: rgba(229, 240, 233, 0.14);
  --lime: #a8ef7c;
  --cyan: #60d7d2;
  --orange: #ff875f;
  --danger: #ff7c69;
}

* { box-sizing: border-box; }

html, body { min-width: 320px; min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(96, 215, 210, 0.09), transparent 30rem),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #101613;
  background-size: auto, 32px 32px, 32px 32px, auto;
}

button, a { font: inherit; }

.page-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: 76px;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  color: var(--ink);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(168, 239, 124, .5);
  border-radius: 50%;
  color: var(--lime);
  font-family: Georgia, serif;
  font-size: 1rem;
}

.header-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.eyebrow,
.section-kicker,
.viewer-heading > span,
.section-heading > span {
  color: var(--lime);
  font-size: .62rem;
  font-weight: 900;
  letter-spacing: .15em;
}

.header-title strong {
  font-family: Georgia, "Nanum Myeongjo", serif;
  font-size: 1.05rem;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5e6b64;
}

.status-badge.connecting .status-dot {
  background: var(--orange);
  box-shadow: 0 0 0 5px rgba(255, 135, 95, .1);
}

.status-badge.live { color: var(--ink); }
.status-badge.live .status-dot {
  background: var(--lime);
  box-shadow: 0 0 0 5px rgba(168, 239, 124, .1);
  animation: pulse 1.6s ease-out infinite;
}

.status-badge.error { color: var(--danger); }
.status-badge.error .status-dot { background: var(--danger); }

.button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--lime);
  border-radius: 6px;
  cursor: pointer;
  font-size: .76rem;
  font-weight: 900;
  transition: transform 140ms ease, background 140ms ease;
}

.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--lime); color: #111811; }
.button.stop { border-color: var(--orange); background: transparent; color: var(--orange); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, .7fr);
  min-height: calc(100vh - 77px);
}

.viewer-panel {
  position: relative;
  min-height: 680px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at center, rgba(50, 77, 65, .18), transparent 55%),
    var(--panel-deep);
}

#pointcloud-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#pointcloud-canvas.dragging { cursor: grabbing; }

.viewer-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, .35);
}

.viewer-heading {
  position: absolute;
  top: 22px;
  left: 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  pointer-events: none;
}

.viewer-heading strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px;
  text-align: center;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.empty-state.hidden { opacity: 0; }

.scan-ring {
  position: relative;
  width: 92px;
  height: 92px;
  margin-bottom: 26px;
  border: 1px solid rgba(168, 239, 124, .28);
  border-radius: 50%;
}

.scan-ring::before,
.scan-ring::after {
  position: absolute;
  content: "";
}

.scan-ring::before {
  inset: 16px;
  border: 1px solid rgba(96, 215, 210, .5);
  border-radius: 50%;
}

.scan-ring::after {
  top: 50%;
  left: 50%;
  width: 1px;
  height: 42%;
  background: linear-gradient(var(--lime), transparent);
  transform-origin: top center;
  animation: radar 2.8s linear infinite;
}

.empty-state strong {
  font-family: Georgia, "Nanum Myeongjo", serif;
  font-size: clamp(1.35rem, 2.3vw, 2.1rem);
  font-weight: 500;
}

.empty-state p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.viewer-footer {
  position: absolute;
  right: 22px;
  bottom: 18px;
  left: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: .66rem;
  pointer-events: none;
}

.legend { display: flex; gap: 14px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; }
.legend .low { background: var(--orange); }
.legend .high { background: var(--cyan); }

.info-panel {
  min-width: 0;
  background: rgba(23, 30, 26, .84);
}

.info-section {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 15px;
  padding: 34px 28px 30px;
  border-bottom: 1px solid var(--line);
}

.section-number {
  color: var(--orange);
  font-family: Georgia, serif;
  font-size: 1rem;
  font-style: italic;
}

.info-section h1 {
  margin: 8px 0 12px;
  font-family: Georgia, "Nanum Myeongjo", serif;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -.045em;
}

.info-section p,
.read-only-note p {
  margin: 0;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.65;
}

code {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric-grid > div {
  min-width: 0;
  padding: 17px 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-grid > div:nth-child(even) { border-right: 0; }
.metric-grid > .wide { grid-column: 1 / -1; border-right: 0; }
.metric-grid > div:last-child { border-bottom: 0; }

.metric-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .61rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.metric-grid strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .72rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bounds-section {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 17px;
}

.text-button {
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .66rem;
}

.axis-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.axis {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .61rem;
  font-weight: 900;
}

.axis.x { color: var(--orange); }
.axis.y { color: var(--lime); }
.axis.z { color: var(--cyan); }

.axis-row strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .7rem;
  font-weight: 700;
}

.read-only-note {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 13px;
  margin: 24px 28px;
  padding: 16px;
  border: 1px solid rgba(168, 239, 124, .18);
  background: rgba(168, 239, 124, .045);
}

.lock-icon { color: var(--lime); font-size: 1.1rem; }
.read-only-note strong { display: block; margin-bottom: 6px; font-size: .72rem; }

.error-message {
  margin: 0 28px 24px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 124, 105, .35);
  background: rgba(255, 124, 105, .08);
  color: var(--danger);
  font-size: .7rem;
  line-height: 1.45;
}

@keyframes radar {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(168, 239, 124, 0); }
  100% { box-shadow: 0 0 0 0 rgba(168, 239, 124, 0); }
}

@media (max-width: 980px) {
  .page-shell { width: min(100% - 20px, 1500px); }
  .topbar {
    grid-template-columns: auto 1fr;
    padding: 12px 0;
  }
  .header-title { display: none; }
  main { grid-template-columns: 1fr; }
  .viewer-panel { min-height: min(64vh, 620px); border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .brand > span:last-child,
  .status-badge { display: none; }
  .viewer-panel { min-height: 58vh; }
  .viewer-footer > span:last-child { display: none; }
  .info-section { padding: 28px 18px 24px; }
  .bounds-section { padding: 22px 18px; }
  .read-only-note { margin: 20px 18px; }
}
