:root {
  --bg: #f4ede2;
  --bg-ink: #1d160f;
  --panel: rgba(255, 251, 245, 0.88);
  --panel-border: rgba(85, 61, 35, 0.14);
  --accent: #b54f2d;
  --accent-soft: #e8c2a8;
  --brain: #ddb693;
  --brain-dim: rgba(85, 61, 35, 0.2);
  --shadow: 0 18px 60px rgba(53, 34, 18, 0.14);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--bg-ink);
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(181, 79, 45, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(119, 90, 52, 0.12), transparent 24%),
    linear-gradient(135deg, #f7f2e9 0%, #efe5d6 48%, #f2eadf 100%);
}

html[data-embed="card"],
html[data-embed="card"] body {
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

html[data-embed="card"] .shell {
  width: 100%;
  min-height: 0;
  padding: 0;
  gap: 10px;
}

html[data-embed="card"] .app-header {
  display: none;
}

html[data-embed="card"] .stage {
  grid-template-rows: auto minmax(640px, 640px) auto auto;
  gap: 10px;
}

html[data-embed="card"] .system-control-bar {
  padding: 0;
}

html[data-embed="card"] .viewer-panel,
html[data-embed="card"] .system-overview-card {
  border-color: rgba(85, 61, 35, 0.12);
  box-shadow: none;
}

html[data-embed="card"] .viewer-panel,
html[data-embed="card"] .system-overview-card {
  border-radius: 14px;
}

html[data-embed="card"] .system-overview-card {
  padding: 14px 16px;
}
@media (max-width: 720px) {
  html[data-embed="card"] .stage {
    grid-template-rows: auto minmax(520px, 520px) auto auto;
  }
}

.shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(14px, 2vw, 24px);
}

.system-overview-card,
.viewer-panel,
.detail-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 6px 0;
}

.app-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.app-title-block {
  display: grid;
  gap: 6px;
}

.app-subtitle {
  max-width: 620px;
  color: rgba(42, 29, 18, 0.74);
  font-size: 0.98rem;
  line-height: 1.45;
}

.app-header .intro {
  max-width: 620px;
  text-align: right;
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(540px, 62vh) auto auto;
  gap: 14px;
  min-width: 0;
}

.system-control-bar {
  padding: 0 6px;
}

.system-control-bar .select-input {
  max-width: 520px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: none;
}

@media (max-width: 720px) {
  .system-control-bar {
    padding: 0;
  }

  .system-control-bar .select-input {
    max-width: none;
  }
}

.system-overview-card {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.system-overview-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.system-function-summary {
  max-width: 980px;
  line-height: 1.5;
  color: rgba(29, 22, 15, 0.86);
}

.system-overview-structures {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 36px;
}

.system-overview-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.system-overview-group-label {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: none;
  color: rgba(29, 22, 15, 0.78);
}

.system-overview-empty {
  font-size: 0.84rem;
  line-height: 1.45;
  color: rgba(42, 29, 18, 0.62);
}

.system-overview-focus {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid rgba(85, 61, 35, 0.12);
}

.system-overview-focus-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.system-overview-focus h3 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.system-overview-note,
.content-lead,
.structure-card-summary {
  font-size: 0.88rem;
  line-height: 1.5;
  color: rgba(29, 22, 15, 0.84);
}

.system-overview-system-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
  padding-top: 13px;
  border-top: 1px solid rgba(85, 61, 35, 0.16);
}

.system-overview-system-notes .system-overview-note {
  margin: 0;
}

.content-lead {
  font-weight: 650;
}

.system-overview-focus-lead,
.system-overview-focus-body,
.system-overview-focus-note {
  max-width: 980px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: rgba(29, 22, 15, 0.84);
}

.system-overview-focus-lead {
  font-weight: 650;
}

.system-overview-focus-note {
  color: rgba(42, 29, 18, 0.68);
}

.viewer-panel {
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewer {
  position: relative;
  flex: 1;
  min-height: 360px;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(236, 243, 248, 0.55), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 248, 246, 0.98));
}

.map-layer-controls {
  position: absolute;
  z-index: 4;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.map-layer-controls-left {
  top: 14px;
  left: 14px;
}

.map-layer-controls-right {
  top: 14px;
  right: 14px;
}

.map-layer-controls-bottom-left {
  bottom: 14px;
  left: 14px;
}

.map-layer-controls-bottom-right {
  right: 14px;
  bottom: 14px;
}

.map-control-button {
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(85, 61, 35, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: rgba(29, 22, 15, 0.9);
  box-shadow: 0 10px 22px rgba(40, 28, 18, 0.12);
  font: inherit;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.map-control-button:hover {
  background: rgba(255, 255, 255, 0.98);
}

.map-control-button:focus {
  outline: none;
}

.map-control-button:focus-visible {
  outline: 2px solid rgba(181, 79, 45, 0.55);
  outline-offset: 3px;
}

.map-control-button.is-active {
  background: rgba(255, 255, 255, 0.9);
  color: rgba(29, 22, 15, 0.9);
  box-shadow: 0 10px 22px rgba(40, 28, 18, 0.12);
  text-decoration: none;
}

.map-control-button.is-off {
  background: rgba(45, 40, 35, 0.12);
  color: rgba(42, 29, 18, 0.46);
  box-shadow: none;
  text-decoration: line-through;
}

.map-connector-controls {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 4;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
}

.map-hidden-panel {
  position: absolute;
  top: 84px;
  bottom: 84px;
  left: 14px;
  z-index: 5;
  width: min(230px, calc(100% - 28px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.map-hidden-panel[hidden],
.map-hidden-tray[hidden],
.map-hide-button[hidden] {
  display: none;
}

.map-hide-slot {
  min-height: 32px;
  display: flex;
  align-items: flex-start;
  pointer-events: none;
}

.map-hide-button,
.map-hidden-clear,
.map-hidden-chip {
  border: 1px solid rgba(85, 61, 35, 0.36);
  background: transparent;
  color: rgba(29, 22, 15, 0.9);
  box-shadow: none;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.75);
  pointer-events: auto;
}

.map-hide-button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.1;
}

.map-hide-button:disabled {
  cursor: default;
  opacity: 0.48;
  box-shadow: none;
}

.map-hidden-tray {
  width: max-content;
  max-width: 100%;
  max-height: min(190px, calc(100% - 50px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  overflow: hidden;
  pointer-events: auto;
}

.map-hidden-clear {
  align-self: flex-start;
  font-size: 0.7rem;
}

.map-hidden-clear:disabled {
  display: none;
}

.map-hidden-scroll {
  width: max-content;
  max-width: 100%;
  max-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  overflow: auto;
  padding: 1px 3px 3px 0;
  pointer-events: auto;
}

.map-hidden-list {
  width: max-content;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.map-hidden-chip {
  min-height: 32px;
  max-width: 100%;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.1;
}

.map-hide-button:hover,
.map-hidden-clear:hover,
.map-hidden-chip:hover {
  background: transparent;
  border-color: rgba(85, 61, 35, 0.58);
  color: rgba(29, 22, 15, 1);
}

.map-hide-button:focus-visible,
.map-hidden-clear:focus-visible,
.map-hidden-chip:focus-visible {
  outline: 2px solid rgba(181, 79, 45, 0.55);
  outline-offset: 3px;
}

.viewer-overlay {
  position: absolute;
  left: 16px;
  right: auto;
  bottom: 16px;
  max-width: min(440px, calc(100% - 32px));
  display: none;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 251, 245, 0.82);
  border: 1px solid rgba(85, 61, 35, 0.12);
  color: rgba(61, 39, 22, 0.78);
  font-size: 0.84rem;
  line-height: 1.4;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.viewer-overlay.hidden {
  display: none;
}

.viewer-overlay.error {
  display: flex;
  background: rgba(255, 242, 239, 0.9);
  border-color: rgba(130, 48, 34, 0.18);
  color: #6f2619;
}

.hover-card {
  position: absolute;
  top: 0;
  left: 0;
  width: min(320px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(85, 61, 35, 0.12);
  box-shadow: 0 18px 40px rgba(40, 28, 18, 0.16);
  pointer-events: none;
  z-index: 3;
  backdrop-filter: blur(8px);
}

.hover-card.hidden {
  display: none;
}

.hover-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.05;
}

.hover-subtitle,
.hover-meta {
  margin-top: 4px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: rgba(42, 29, 18, 0.72);
}

.hover-summary {
  margin-top: 8px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: rgba(29, 22, 15, 0.86);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  max-height: 250px;
  overflow: auto;
  align-content: start;
  padding-right: 6px;
}

.detail-card {
  border-radius: var(--radius-lg);
  padding: 14px;
  min-height: 0;
  overflow: auto;
}

.detail-card.wide {
  grid-column: 1 / -1;
}

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

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.7rem, 2.45vw, 2.35rem);
  line-height: 1.04;
}

h2 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(80, 54, 29, 0.74);
}

.intro {
  line-height: 1.5;
  color: rgba(42, 29, 18, 0.84);
}

.panel {
  background: rgba(255, 255, 255, 0.54);
  border-radius: var(--radius-md);
  border: 1px solid rgba(85, 61, 35, 0.08);
  padding: 14px;
}

.collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.collapsible-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary::after {
  content: "+";
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(181, 79, 45, 0.1);
  color: rgba(80, 54, 29, 0.84);
  font-size: 1rem;
  font-weight: 700;
}

.collapsible-panel[open] .collapsible-summary::after {
  content: "-";
}

.collapsible-title {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
}

.collapsible-subtitle {
  display: block;
  margin-top: 3px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: rgba(42, 29, 18, 0.68);
}

.collapsible-body {
  padding: 0 14px 14px;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.84rem;
  font-weight: 700;
}

.label.compact {
  margin-bottom: 0;
}

.label.control-spacer {
  margin-top: 14px;
}

.text-input,
.select-input {
  width: 100%;
  border: 1px solid rgba(85, 61, 35, 0.14);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--bg-ink);
  font: inherit;
  min-width: 0;
}

.appendix-panel {
  min-width: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.appendix-panel .collapsible-summary {
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(85, 61, 35, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.54);
  box-shadow: 0 8px 20px rgba(53, 34, 18, 0.045);
}

.appendix-panel .collapsible-body {
  padding: 0;
}

.appendix-panel .collapsible-summary::after {
  background: rgba(181, 79, 45, 0.08);
}

.appendix-panel .collapsible-title {
  font-weight: 650;
}

.appendix-panel .collapsible-subtitle {
  margin-top: 2px;
}

.appendix-panel[open] {
  min-width: 0;
}

.appendix-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
  gap: 12px;
}

.appendix-content.empty-state {
  display: block;
  color: rgba(42, 29, 18, 0.66);
}

.appendix-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: start;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(85, 61, 35, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.appendix-research-section {
  grid-column: 1 / -1;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.appendix-section-title {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(80, 54, 29, 0.72);
}

.appendix-section-heading-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.appendix-section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(181, 79, 45, 0.24);
  border-radius: 999px;
  color: rgba(111, 50, 29, 0.9);
  background: rgba(181, 79, 45, 0.14);
  box-shadow: 0 6px 14px rgba(181, 79, 45, 0.08);
  cursor: pointer;
  font: 700 0.82rem/1 var(--font-body);
  transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.appendix-section-toggle:hover,
.appendix-section-toggle.is-open {
  background: rgba(181, 79, 45, 0.22);
  box-shadow: 0 8px 18px rgba(181, 79, 45, 0.12);
  transform: translateY(-1px);
}

.appendix-section-toggle:focus-visible {
  outline: 3px solid rgba(181, 79, 45, 0.24);
  outline-offset: 2px;
}

.appendix-section-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.appendix-section-body[hidden] {
  display: none;
}

.appendix-record {
  display: grid;
  gap: 2px;
  font-size: 0.82rem;
  line-height: 1.42;
}

.appendix-record strong {
  color: rgba(29, 22, 15, 0.86);
  font-weight: 500;
}

.appendix-record span,
.appendix-note {
  color: rgba(42, 29, 18, 0.7);
}

.appendix-note {
  font-size: 0.82rem;
  line-height: 1.48;
}

.appendix-reference {
  display: grid;
  gap: 3px;
  padding-top: 8px;
  border-top: 1px solid rgba(85, 61, 35, 0.08);
  min-width: 0;
}

.appendix-reference-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.appendix-reference-source {
  padding-top: 8px;
  border-top: 1px solid rgba(85, 61, 35, 0.08);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
  color: rgba(29, 22, 15, 0.8);
}

.appendix-reference-group .appendix-reference {
  padding-top: 0;
  border-top: 0;
}

.appendix-reference-title {
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
  color: rgba(29, 22, 15, 0.88);
}

.appendix-system-citation .appendix-reference-title {
  font-weight: 500;
  line-height: 1.38;
  color: rgba(29, 22, 15, 0.88);
}

.appendix-system-citation {
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(85, 61, 35, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 18px rgba(53, 34, 18, 0.045);
}

.appendix-reference-title a {
  color: var(--accent);
  text-decoration: none;
}

.appendix-reference-title a:hover {
  text-decoration: underline;
}

.appendix-reference-authority,
.appendix-reference-supports {
  margin: 0;
  color: rgba(42, 29, 18, 0.68);
  font-size: 0.78rem;
  line-height: 1.42;
}

.appendix-citation-meta {
  gap: 5px;
}

.appendix-citation-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.appendix-citation-actions .appendix-help-button,
.appendix-citation-actions .appendix-info-button {
  flex: 0 0 auto;
}

.appendix-citation-actions .appendix-citation-meta {
  flex: 0 1 auto;
  min-width: 0;
}

.appendix-citation-meta .chip {
  font-size: 0.68rem;
  padding: 3px 7px;
  color: rgba(42, 29, 18, 0.76);
  background: rgba(85, 61, 35, 0.055);
  border-color: rgba(85, 61, 35, 0.13);
}

.appendix-help-button,
.appendix-info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  font: 700 0.82rem/1 var(--font-body);
  transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.appendix-help-button,
.appendix-info-button {
  border: 1px solid rgba(181, 79, 45, 0.24);
  color: rgba(111, 50, 29, 0.9);
  background: rgba(181, 79, 45, 0.14);
  box-shadow: 0 6px 14px rgba(181, 79, 45, 0.08);
}

.appendix-help-button:hover,
.appendix-help-button.is-open,
.appendix-info-button:hover,
.appendix-info-button.is-open {
  background: rgba(181, 79, 45, 0.22);
  box-shadow: 0 8px 18px rgba(181, 79, 45, 0.12);
  transform: translateY(-1px);
}

.appendix-info-button:disabled,
.appendix-info-button.is-disabled {
  cursor: default;
  opacity: 0.38;
  box-shadow: none;
  transform: none;
}

.appendix-info-button:disabled:hover,
.appendix-info-button.is-disabled:hover {
  background: rgba(181, 79, 45, 0.14);
  box-shadow: none;
  transform: none;
}

.appendix-help-button:focus-visible,
.appendix-info-button:focus-visible {
  outline: 3px solid rgba(181, 79, 45, 0.24);
  outline-offset: 2px;
}

.appendix-citation-text {
  margin: 0;
  color: rgba(42, 29, 18, 0.7);
  font-size: 0.78rem;
  line-height: 1.45;
}

.appendix-mini-report-body,
.appendix-science-note-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 7px;
  padding: 3px 0 2px 12px;
  border-left: 2px solid rgba(85, 61, 35, 0.12);
}

.appendix-mini-report-body[hidden],
.appendix-science-note-body[hidden] {
  display: none;
}

.appendix-mini-report-label,
.appendix-science-note-label {
  color: rgba(29, 22, 15, 0.84);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  line-height: 1.25;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(85, 61, 35, 0.24);
  text-transform: none;
  width: fit-content;
}

.appendix-mini-report-text,
.appendix-science-note-text {
  margin: 0;
  color: rgba(29, 22, 15, 0.82);
  font-size: 0.84rem;
  line-height: 1.52;
}

.range-input {
  width: 100%;
  margin-top: 10px;
  accent-color: var(--accent);
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-button {
  border: 1px solid rgba(85, 61, 35, 0.14);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--bg-ink);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.98);
}

.secondary-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.control-value {
  font-size: 0.84rem;
  font-weight: 700;
  color: rgba(80, 54, 29, 0.72);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(181, 79, 45, 0.08);
}

.metric strong {
  font-size: 1.4rem;
  font-family: var(--font-display);
}

.metric-label,
.viewer-status {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(80, 54, 29, 0.7);
}

.legend-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.94rem;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.legend-swatch.renderable {
  background: var(--accent);
}

.legend-swatch.explanation {
  background: #246a73;
}

.legend-swatch.unresolved {
  background: #8b7e73;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  color: rgba(42, 29, 18, 0.62);
  line-height: 1.55;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 0.86rem;
  background: rgba(36, 106, 115, 0.08);
  border: 1px solid rgba(36, 106, 115, 0.14);
}

.chip-button {
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.chip-button:hover {
  border-color: rgba(31, 95, 255, 0.34);
  box-shadow: 0 8px 18px rgba(31, 95, 255, 0.12);
  transform: translateY(-1px);
}

.chip-button:focus-visible {
  outline: 3px solid rgba(31, 95, 255, 0.24);
  outline-offset: 2px;
}

.chip-button.is-active {
  border-color: rgba(31, 95, 255, 0.46);
  box-shadow: inset 0 0 0 1px rgba(31, 95, 255, 0.18);
}

.chip.renderable {
  background: rgba(181, 79, 45, 0.1);
  border-color: rgba(181, 79, 45, 0.2);
}

.chip.unresolved {
  background: rgba(139, 126, 115, 0.12);
  border-color: rgba(139, 126, 115, 0.18);
}

.chip.explanation {
  background: rgba(36, 106, 115, 0.08);
  border-color: rgba(36, 106, 115, 0.14);
}

.chip.connector {
  background: rgba(93, 107, 138, 0.1);
  border-color: rgba(93, 107, 138, 0.18);
}

.structure-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(85, 61, 35, 0.08);
  background: rgba(255, 255, 255, 0.6);
}

.structure-card h3 {
  font-size: 0.94rem;
  margin-bottom: 4px;
}

.structure-meta {
  font-size: 0.8rem;
  color: rgba(42, 29, 18, 0.72);
  line-height: 1.4;
}

.structure-card-summary {
  margin-top: 8px;
  font-size: 0.82rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.summary-block {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(85, 61, 35, 0.08);
}

.summary-block strong {
  display: block;
  font-size: 1.05rem;
  font-family: var(--font-display);
  margin-top: 4px;
}

.note {
  font-size: 0.84rem;
  line-height: 1.45;
  color: rgba(42, 29, 18, 0.74);
}

.explorer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.explorer-title {
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.05;
}

.explorer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.explorer-meta .chip {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.explorer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.explorer-paragraph {
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(29, 22, 15, 0.9);
}

.explorer-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(85, 61, 35, 0.08);
}

.explorer-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.explorer-card p {
  font-size: 0.84rem;
  line-height: 1.45;
  color: rgba(42, 29, 18, 0.8);
}

.explorer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-button.subtle {
  background: rgba(255, 255, 255, 0.62);
}

.hidden-item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hidden-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(85, 61, 35, 0.08);
  background: rgba(255, 255, 255, 0.62);
}

.hidden-item-label {
  font-size: 0.9rem;
  line-height: 1.4;
  color: rgba(29, 22, 15, 0.9);
}

.hidden-item-meta {
  font-size: 0.78rem;
  line-height: 1.3;
  color: rgba(42, 29, 18, 0.66);
}

.hidden-item-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hidden-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}


@media (min-width: 1101px) {
  .collapsible-summary {
    cursor: default;
  }
}

@media (max-width: 1100px) {
  .stage {
    grid-template-rows: auto minmax(500px, 60vh) auto auto;
  }

  .details-grid {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
  }

  .detail-card.wide {
    grid-column: auto;
  }
}

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

  .app-header-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .app-header .intro {
    max-width: none;
    text-align: left;
  }

  .detail-card,
  .system-overview-card,
  .viewer-panel {
    border-radius: 22px;
  }

  .stage {
    grid-template-rows: auto minmax(420px, 62vh) auto auto;
    gap: 14px;
  }

  .system-overview-card {
    padding: 16px;
  }

  .system-overview-head {
    flex-direction: column;
    gap: 8px;
  }

  .viewer {
    min-height: 300px;
  }

  .map-layer-controls {
    gap: 6px;
  }

  .map-layer-controls-left {
    top: 10px;
    left: 10px;
  }

  .map-layer-controls-right {
    top: 10px;
    right: 10px;
  }

  .map-layer-controls-bottom-left {
    bottom: 10px;
    left: 10px;
  }

  .map-layer-controls-bottom-right {
    right: 10px;
    bottom: 10px;
  }

  .map-connector-controls {
    bottom: 10px;
  }

  .map-hidden-panel {
    top: 66px;
    right: 10px;
    bottom: 68px;
    left: 10px;
    width: auto;
    align-items: flex-start;
    justify-content: flex-end;
  }

  .map-hide-button {
    min-height: 34px;
    max-width: min(180px, calc(100vw - 28px));
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .map-hidden-tray {
    width: max-content;
    max-width: 100%;
    max-height: min(32vh, calc(100% - 48px));
  }

  .map-hidden-scroll {
    max-height: 18vh;
  }

  .map-hidden-chip {
    min-height: 34px;
    font-size: 0.72rem;
  }

  .map-control-button {
    width: 48px;
    height: 48px;
    font-size: 0.56rem;
  }
  .panel,
  .detail-card {
    padding: 12px;
  }

  .collapsible-panel {
    padding: 0;
  }

  .collapsible-summary,
  .collapsible-body {
    padding-left: 12px;
    padding-right: 12px;
  }

  .text-input,
  .select-input,
  .secondary-button {
    font-size: 16px;
  }

  .hover-card {
    width: min(280px, calc(100% - 24px));
  }

  .panel-actions {
    justify-content: stretch;
  }

  .secondary-button {
    width: 100%;
  }

  .explorer-actions,
  .hidden-item-actions {
    flex-direction: column;
  }

  .hidden-item-row {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (hover: none) and (pointer: coarse) {
  .hover-card {
    display: none !important;
  }
}
