:root {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    sans-serif;
  color: #172033;
  background: #eef2f5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px 14px;
  background: #ffffff;
  border-bottom: 1px solid #d8e0e8;
}

.eyebrow {
  margin: 0 0 4px;
  color: #64748b;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: 0;
}

.view-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: #eef2f7;
  border: 1px solid #d6dee7;
  border-radius: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tab,
.ghost {
  border: 0;
  cursor: pointer;
  border-radius: 6px;
}

.tab {
  padding: 9px 12px;
  background: transparent;
  color: #475569;
}

.tab.is-active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: #dbe3ea;
  border-bottom: 1px solid #dbe3ea;
}

.summary-strip div {
  background: #ffffff;
  padding: 12px 18px;
}

.summary-strip span {
  display: block;
  font-size: 24px;
  font-weight: 750;
}

.summary-strip small {
  display: block;
  color: #64748b;
  margin-top: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  min-height: 0;
}

.filters,
.detail-panel {
  min-height: 0;
  overflow: auto;
  background: #ffffff;
  border-right: 1px solid #d8e0e8;
  padding: 18px;
}

.detail-panel {
  border-right: 0;
  border-left: 1px solid #d8e0e8;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  color: #475569;
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
}

input[type="range"] {
  padding: 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: #24324a;
}

.toggle input {
  width: 16px;
  min-height: 16px;
}

.ghost {
  width: 100%;
  min-height: 38px;
  margin: 10px 0 16px;
  background: #edf6f3;
  color: #0f766e;
}

.legend {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #475569;
}

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

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.visual-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #f8fafc;
}

.axis-copy {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 12px;
  z-index: 2;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: #475569;
  font-size: 12px;
  pointer-events: none;
}

.axis-copy span {
  padding: 4px 8px;
  border: 1px solid rgba(100, 116, 139, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
}

.view-host {
  position: absolute;
  inset: 0;
  display: none;
}

.view-host.is-active {
  display: block;
}

#mapCanvas,
#threeMount,
#threeMount canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.prompt-host {
  overflow: auto;
  padding: 64px 28px 28px;
  background: #fbfcfd;
}

.prompt-host pre {
  white-space: pre-wrap;
  margin: 0;
  color: #1f2937;
  line-height: 1.7;
  font-size: 14px;
}

.detail-head {
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

.detail-head p {
  color: #0f766e;
  font-size: 13px;
  margin-bottom: 6px;
}

.detail-head h2 {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.score-pill {
  border: 1px solid #dbe3ea;
  border-radius: 8px;
  padding: 10px;
  background: #fafafa;
}

.score-pill span,
.score-pill small {
  display: block;
  color: #64748b;
  font-size: 12px;
}

.score-pill strong {
  display: block;
  margin: 4px 0;
  font-size: 24px;
  line-height: 1;
}

.meta-list {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px 10px;
  margin: 0;
  font-size: 13px;
}

.meta-list dt {
  color: #64748b;
}

.meta-list dd {
  margin: 0;
  color: #172033;
  word-break: break-word;
}

.flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0;
}

.flag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
}

.flag.risk {
  background: #fee2e2;
  color: #b91c1c;
}

.flag.core {
  background: #dcfce7;
  color: #166534;
}

.flag.review {
  background: #fef3c7;
  color: #92400e;
}

.reason-block {
  padding: 12px 0;
  border-top: 1px solid #e2e8f0;
}

.reason-block h3 {
  font-size: 13px;
  color: #475569;
  margin-bottom: 6px;
}

.reason-block p {
  font-size: 13px;
  line-height: 1.65;
  color: #1f2937;
  word-break: break-word;
}

.empty,
.error-state p {
  color: #64748b;
  line-height: 1.7;
}

.error-state {
  max-width: 720px;
  margin: 80px auto;
  padding: 28px;
  background: #ffffff;
  border: 1px solid #dbe3ea;
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid #d8e0e8;
    max-height: 42vh;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .filters {
    border-right: 0;
    border-bottom: 1px solid #d8e0e8;
    max-height: 42vh;
  }

  .visual-panel {
    min-height: 68vh;
  }
}
