:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --ink: #1c2026;
  --muted: #64717d;
  --line: #d8dee3;
  --accent: #0b6f70;
  --accent-weak: #dceeee;
  --geodesic: #d63f2f;
  --domain: #20242a;
  --pair-a: #0b7285;
  --pair-b: #b05c00;
  --pair-c: #6d5bd0;
  --pair-d: #247a38;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.hyperbolic-app {
  display: grid;
  grid-template-columns: minmax(286px, 340px) minmax(0, 1fr);
  min-height: 100vh;
}

.control-rail {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 20px;
  overflow-y: auto;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.back-link,
.data-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.back-link:hover,
.data-link:hover {
  text-decoration: underline;
}

.brand-block h1 {
  margin: 0 0 8px;
  font-size: 23px;
  line-height: 1.12;
  letter-spacing: 0;
}

.brand-block p,
#surfaceSubtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.switch-stack {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.switch-stack label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.details {
  display: grid;
  grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
  gap: 8px 12px;
  margin: 18px 0 0;
  font-size: 13px;
}

.details dt {
  color: var(--muted);
}

.details dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.pair-a {
  background: var(--pair-a);
}

.pair-b {
  background: var(--pair-b);
}

.pair-c {
  background: var(--pair-c);
}

.pair-d {
  background: var(--pair-d);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.top-strip {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.top-strip h2 {
  margin: 0 0 4px;
  font-size: 23px;
  line-height: 1.2;
  letter-spacing: 0;
}

.data-link {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px 12px;
  white-space: nowrap;
}

.scene-panel {
  position: relative;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

#surfaceCanvas {
  display: block;
  width: 100%;
  height: min(68vh, 690px);
  min-height: 520px;
  touch-action: none;
  cursor: grab;
}

#surfaceCanvas.is-panning {
  cursor: grabbing;
}

.scene-tools {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(216, 222, 227, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 24px rgba(26, 34, 42, 0.08);
}

.scene-tools button {
  min-width: 32px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

.scene-tools button:hover {
  border-color: #aebbc3;
  background: #f7f9fa;
}

.error-box {
  position: absolute;
  inset: auto 18px 18px 18px;
  border: 1px solid #e4a29a;
  border-radius: 6px;
  background: #fff6f4;
  color: #8d251b;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
}

.is-hidden {
  display: none !important;
}

.lower-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.92fr) minmax(320px, 1.08fr);
  gap: 16px;
  margin-top: 16px;
}

.list-panel,
.details-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

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

.panel-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
}

.geodesic-table-wrap {
  max-height: 342px;
  overflow: auto;
}

.geodesic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.geodesic-table th,
.geodesic-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

.geodesic-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 750;
}

.geodesic-table tr {
  cursor: pointer;
}

.geodesic-table tbody tr:hover,
.geodesic-table tbody tr.is-selected {
  background: var(--accent-weak);
}

.selected-details {
  margin: 14px;
}

.json-view {
  max-height: 206px;
  overflow: auto;
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 14px;
  background: #fbfcfc;
  color: #2d3339;
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 960px) {
  .hyperbolic-app,
  .lower-layout {
    grid-template-columns: 1fr;
  }

  .control-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .scene-panel {
    min-height: 400px;
  }

  #surfaceCanvas {
    height: 62vh;
    min-height: 380px;
  }
}

@media (max-width: 620px) {
  .workspace,
  .control-rail {
    padding: 16px;
  }

  .top-strip {
    display: grid;
  }

  .data-link {
    justify-self: start;
  }
}
