:root {
  color-scheme: light dark;
  --bg: #101214;
  --panel: #181b1f;
  --panel-2: #20242a;
  --text: #eef1f3;
  --muted: #a9b1b8;
  --line: #343a42;
  --accent: #6fd0a8;
  --warn: #e2b15d;
  --err: #e67676;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

html,
body.viewer-page {
  width: 100%;
  height: 100%;
}

body.viewer-page {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #15181c;
}

.viewer-page .site-header {
  height: 56px;
  min-height: 0;
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  gap: 12px;
  font-size: 14px;
}

.app-shell {
  --viewer-row-share: 7fr;
  --info-panel-row-share: 3fr;
  --info-panel-divider-size: 9px;

  display: grid;
  grid-template-rows:
    minmax(0, var(--viewer-row-share)) var(--info-panel-divider-size)
    minmax(0, var(--info-panel-row-share));
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  height: calc(100dvh - 56px);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.toolbar,
.status-bar {
  display: flex;
  flex-wrap: wrap;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  border-left: 1px solid var(--line);
  padding-left: 8px;
}

.toolbar-group:first-child {
  border-left: 0;
  padding-left: 0;
}

.toolbar-group-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolbar-disclosure {
  display: block;
  position: relative;
}

.toolbar-disclosure summary {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 13px;
}

.toolbar-disclosure-controls {
  display: flex;
  position: absolute;
  z-index: 4;
  top: calc(100% + 6px);
  left: 8px;
  flex-wrap: wrap;
  width: max-content;
  max-width: min(520px, calc(100vw - 28px));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
  box-shadow: 0 8px 28px rgb(0 0 0 / 35%);
}

.map-overlay-controls,
.map-control-group {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  gap: 6px;
}

.status-bar {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.status-bar span + span::before {
  content: "/";
  margin-right: 8px;
  color: #68717a;
}

button,
select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  color: var(--text);
  background: var(--panel-2);
  font: inherit;
}

button[aria-pressed="true"] {
  border-color: #4fa483;
  background: #18352b;
}

.canvas-host {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0b0d0f;
}

#world-canvas,
#pov-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background: #0b0d0f;
}

#world-canvas[hidden],
#pov-canvas[hidden] {
  display: none;
}

.info-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
}

.info-panel-resizer {
  position: relative;
  z-index: 2;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: row-resize;
  touch-action: none;
}

.info-panel-resizer::before {
  position: absolute;
  inset: -8px 0;
  content: "";
}

.info-panel-resizer::after {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--line);
  content: "";
  transform: translateY(-50%);
}

.info-panel-resizer:is(:hover, :focus-visible, [data-dragging="true"])::after {
  height: 3px;
  background: var(--accent);
}

.info-panel-resizer:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -2px;
}

.panel-columns {
  --panel-divider-size: 9px;

  display: grid;
  grid-template-columns:
    minmax(0, var(--panel-explorer-share, 1fr)) var(--panel-divider-size)
    minmax(0, var(--panel-inspection-share, 1fr)) var(--panel-divider-size)
    minmax(0, var(--panel-world-share, 1fr)) var(--panel-divider-size)
    minmax(0, var(--panel-ecology-share, 1fr)) var(--panel-divider-size)
    minmax(0, var(--panel-system-share, 1fr));
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.panel-column {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 10px 12px 16px;
}

.panel-resizer {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.panel-resizer::before {
  position: absolute;
  inset: 0 -8px 0 0;
  content: "";
}

.panel-resizer::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--line);
  content: "";
  transform: translateX(-50%);
}

.panel-resizer:is(:hover, :focus-visible, [data-dragging="true"])::after {
  width: 3px;
  background: var(--accent);
}

.panel-resizer:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -2px;
}

body.panel-resizing {
  cursor: col-resize;
  user-select: none;
}

body.info-panel-resizing {
  cursor: row-resize;
  user-select: none;
}

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

.panel-section h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-section dl {
  display: grid;
  grid-template-columns: minmax(0, 36%) minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
  font-size: 13px;
}

[data-panel-column="inspection"] [data-panel-section="hover"] dl {
  grid-template-columns:
    minmax(0, 0.8fr) minmax(0, 1.2fr)
    minmax(0, 0.8fr) minmax(0, 1.2fr);
  column-gap: 8px;
}

[data-panel-column="inspection"] [data-panel-section="hover"] .panel-field dt,
[data-panel-column="inspection"] [data-panel-section="hover"] .panel-field dd {
  grid-column: auto;
}

.panel-field {
  display: contents;
}

.panel-field[hidden] {
  display: none;
}

.panel-field dt {
  grid-column: 1;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.panel-field dd {
  grid-column: 2;
  margin: 0;
  overflow-wrap: anywhere;
}

.panel-field[data-span="wide"] dd {
  grid-column: 1 / -1;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}

.panel-field[data-severity="warning"] dd {
  color: var(--warn);
}

.panel-field[data-severity="error"] dd {
  color: var(--err);
}

.platform-diagnostics {
  min-width: 0;
  border-top: 1px solid var(--line);
  background: #121519;
}

.platform-diagnostics summary {
  min-height: 30px;
  padding: 6px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

pre {
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d0f12;
  color: var(--muted);
}

/* The browser-only log is outside the shared information document and never
   grows the dock: newest entries win and app.js prunes the bounded tail. */
.platform-diagnostics pre[data-platform-field="diagnostics"] {
  max-height: 120px;
  overflow-x: hidden;
  overflow-y: auto;
  border-width: 1px 0 0;
  border-radius: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 12px;
}

.doc-page {
  width: min(960px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
  line-height: 1.6;
}

.doc-page h1,
.doc-page h2,
.doc-page h3 {
  line-height: 1.2;
}

.doc-page h1 {
  margin: 0 0 18px;
  font-size: 32px;
}

.doc-page h2 {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 22px;
}

.doc-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.doc-page th,
.doc-page td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.doc-page th {
  background: var(--panel-2);
}

.ok {
  color: var(--accent);
}

.warn {
  color: var(--warn);
}

.err {
  color: var(--err);
}

@media (max-width: 760px) {
  html,
  body.viewer-page {
    height: auto;
    min-height: 100%;
  }

  body.viewer-page {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 14px;
  }

  .viewer-page .site-header {
    height: auto;
  }

  .app-shell {
    grid-template-rows: auto auto;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .viewer {
    grid-template-rows: auto minmax(280px, min(70vw, 420px)) auto;
    min-height: 0;
    overflow: visible;
  }

  .toolbar,
  .status-bar {
    flex-wrap: wrap;
  }

  .toolbar-disclosure-controls {
    position: static;
    width: auto;
    max-width: 100%;
    margin-top: 6px;
    box-shadow: none;
  }

  .info-panel {
    display: block;
    border-top: 1px solid var(--line);
    max-height: none;
    overflow: visible;
  }

  .info-panel-resizer {
    display: none;
  }

  .panel-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }

  .panel-column {
    min-width: 0;
    overflow: visible;
    border-top: 1px solid var(--line);
    border-left: 0;
    scrollbar-gutter: auto;
  }

  .panel-column:first-child {
    border-top: 0;
  }

  .panel-resizer {
    display: none;
  }

  .panel-section dl {
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
  }
}
