:root {
  color-scheme: dark;
  --bg: #071116;
  --bg-soft: rgba(16, 31, 39, 0.9);
  --panel: rgba(8, 18, 25, 0.92);
  --panel-strong: rgba(13, 26, 34, 0.96);
  --line: rgba(184, 222, 255, 0.16);
  --line-strong: rgba(184, 222, 255, 0.32);
  --text: #e8f4fb;
  --text-dim: #a1c0d2;
  --accent: #89d8ff;
  --accent-strong: #f87f7f;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.38);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(72, 161, 204, 0.15), transparent 30%),
    radial-gradient(circle at bottom right, rgba(240, 89, 89, 0.15), transparent 32%),
    linear-gradient(135deg, #04090d, #08141a 50%, #061015);
  color: var(--text);
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  height: 100vh;
  gap: 1rem;
  padding: 1rem;
}

.panel,
.viewer-panel {
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border-radius: 28px;
  background: linear-gradient(180deg, var(--panel), rgba(7, 17, 22, 0.88));
  overflow: hidden;
}

.panel-block {
  padding: 0.95rem 1rem;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(18, 33, 41, 0.72), rgba(10, 19, 25, 0.78));
  border: 1px solid rgba(184, 222, 255, 0.08);
}

.panel-block.grow {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.viewer-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.85rem;
}

.viewer-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.35rem;
}

.viewer-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 34px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, rgba(92, 156, 192, 0.24), transparent 26%),
    radial-gradient(circle at 80% 10%, rgba(232, 108, 108, 0.18), transparent 18%),
    linear-gradient(180deg, rgba(6, 15, 20, 0.96), rgba(4, 11, 16, 0.98));
}

.viewer {
  position: absolute;
  inset: 0;
}

.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8fc6e6;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.85rem, 3vw, 2.45rem);
  line-height: 1.05;
}

h2 {
  font-size: 0.98rem;
}

.lead {
  margin-top: 0.55rem;
  color: var(--text-dim);
  line-height: 1.55;
}

.lead.compact {
  margin-top: 0.45rem;
  font-size: 0.95rem;
}

.microcopy {
  margin-top: 0.75rem;
  color: #9eb7c7;
  font-size: 0.88rem;
  line-height: 1.45;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.segmented-control,
.chip-grid,
.toggle-grid,
.legend,
.selected-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.segmented-control button,
.chip-grid button,
.toggle-button,
.ghost-button,
.structure-item {
  border: 1px solid transparent;
  border-radius: 999px;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.segmented-control button,
.chip-grid button,
.toggle-button,
.ghost-button {
  padding: 0.68rem 0.95rem;
  background: rgba(22, 37, 46, 0.88);
  color: var(--text);
  cursor: pointer;
}

.segmented-control button:hover,
.chip-grid button:hover,
.toggle-button:hover,
.ghost-button:hover,
.structure-item:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.segmented-control button.active,
.toggle-button.active {
  background: linear-gradient(180deg, rgba(137, 216, 255, 0.24), rgba(52, 114, 146, 0.3));
  border-color: rgba(137, 216, 255, 0.42);
  box-shadow: 0 10px 24px rgba(43, 126, 165, 0.18);
}

.chip-grid button.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.05);
  color: #dbeaf3;
}

.search-label {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.search-input {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(184, 222, 255, 0.12);
  background: rgba(7, 15, 21, 0.72);
  color: var(--text);
  padding: 0.8rem 0.95rem;
  margin-bottom: 0.8rem;
  outline: none;
}

.search-input:focus {
  border-color: rgba(137, 216, 255, 0.52);
  box-shadow: 0 0 0 3px rgba(137, 216, 255, 0.12);
}

.structure-list {
  display: grid;
  gap: 0.55rem;
  overflow: auto;
  padding-right: 0.25rem;
}

.structure-item {
  display: grid;
  gap: 0.4rem;
  width: 100%;
  padding: 0.9rem 1rem;
  text-align: left;
  cursor: pointer;
  background: rgba(13, 24, 32, 0.84);
}

.structure-item.selected {
  background: linear-gradient(180deg, rgba(248, 127, 127, 0.16), rgba(137, 216, 255, 0.18));
  border-color: rgba(248, 127, 127, 0.34);
}

.structure-item small,
.legend-item,
.selected-meta span {
  color: var(--text-dim);
}

.structure-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.98rem;
}

.group-pill,
.group-dot,
.legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.group-pill {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.group-dot,
.legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  flex: 0 0 auto;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.8rem;
}

.selected-panel {
  background:
    radial-gradient(circle at top right, rgba(137, 216, 255, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(22, 32, 40, 0.92), rgba(11, 21, 27, 0.94));
}

.selected-meta span {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.84rem;
}

.callout {
  position: absolute;
  max-width: 260px;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  background: rgba(6, 12, 18, 0.94);
  border: 1px solid rgba(184, 222, 255, 0.2);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  transform: translate(-50%, -120%);
}

.callout strong {
  display: block;
  margin-bottom: 0.3rem;
}

.callout span {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.4;
}

.viewer-status {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  background: rgba(6, 12, 18, 0.72);
  border: 1px solid rgba(184, 222, 255, 0.12);
  color: #c4dcea;
  font-size: 0.9rem;
  max-width: min(90%, 360px);
}

.hidden {
  display: none;
}

.noscript-warning {
  position: fixed;
  inset: auto 1rem 1rem 1rem;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(76, 16, 16, 0.96);
  color: #ffe8e8;
  z-index: 50;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .panel {
    max-height: none;
  }

  .viewer-shell {
    min-height: 72vh;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .panel,
  .viewer-panel {
    border-radius: 24px;
  }

  .panel {
    padding: 0.75rem;
  }

  .panel-block {
    padding: 0.85rem;
  }

  .viewer-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .viewer-shell {
    min-height: 66vh;
  }
}
