:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  --bg: #e8e6e0;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(42, 38, 33, 0.15);
  --text: #25211c;
  --muted: #6d665e;
  --accent: #1f7a70;
  --copper: #a85c32;
  --warning: #a06416;
  --danger: #b33f42;
  --shadow: 0 18px 52px rgba(73, 68, 60, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 38%, rgba(255, 255, 255, 0.82), rgba(232, 230, 224, 0.42) 40%, rgba(197, 192, 181, 0.72) 100%),
    var(--bg);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(220px, 430px) minmax(180px, 260px) minmax(234px, auto) 42px;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.brand,
.search-box,
.topbar select,
.icon-button,
.patch-actions,
.legend,
.toggles,
.detail-panel,
.review-panel,
.review-strip {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-weight: 750;
  white-space: nowrap;
  backdrop-filter: blur(16px);
}

.brand-mark {
  width: 14px;
  height: 14px;
  border: 2px solid var(--copper);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(168, 92, 50, 0.13);
}

.search-box input,
.topbar select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  box-shadow: var(--shadow);
  outline: none;
  backdrop-filter: blur(16px);
}

.search-box input {
  padding: 0 14px;
}

.topbar select {
  padding: 0 12px;
}

.search-box input:focus,
.topbar select:focus,
.icon-button:focus-visible {
  border-color: rgba(31, 122, 112, 0.78);
  box-shadow: 0 0 0 3px rgba(31, 122, 112, 0.14), var(--shadow);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.icon-button:hover {
  border-color: rgba(31, 122, 112, 0.42);
  color: var(--accent);
}

.patch-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.action-button {
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  white-space: nowrap;
  backdrop-filter: blur(16px);
}

.action-button:hover {
  border-color: rgba(31, 122, 112, 0.42);
  color: var(--accent);
}

.action-button.danger:hover {
  border-color: rgba(179, 63, 66, 0.32);
  color: var(--danger);
}

.legend {
  position: absolute;
  left: 18px;
  top: 76px;
  z-index: 5;
  display: grid;
  width: min(286px, calc(100vw - 36px));
  max-height: calc(100vh - 238px);
  gap: 7px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.legend-button {
  display: grid;
  grid-template-columns: 13px 44px 1fr auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.legend-button:hover,
.legend-button.active {
  border-color: rgba(31, 122, 112, 0.2);
  background: rgba(31, 122, 112, 0.08);
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.legend-code {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend-name {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-count {
  color: var(--muted);
  font-size: 12px;
}

.review-strip {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, minmax(62px, auto));
  gap: 5px 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.review-strip > div {
  min-width: 62px;
  padding: 3px 8px;
}

.metric-value {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.toggles {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  max-width: min(820px, calc(100vw - 560px));
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.toggles label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

.range-control input {
  width: 110px;
  accent-color: var(--copper);
}

.detail-panel {
  position: absolute;
  top: 76px;
  right: 18px;
  z-index: 5;
  width: min(390px, calc(100vw - 36px));
  max-height: calc(100vh - 260px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.review-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  width: min(390px, calc(100vw - 36px));
  max-height: min(310px, calc(100vh - 380px));
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.review-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.standard-review-title {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.queue-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 0 6px;
}

.source-queue-item.standard-review .queue-distance {
  color: var(--warning);
}

.source-queue-item.standard-reject .queue-distance {
  color: var(--danger);
}

.source-queue-item.standard-pass .queue-distance {
  color: var(--accent);
}

.meridian-audit-item.audit-pass .queue-distance {
  color: var(--accent);
}

.meridian-audit-item.audit-review .queue-distance {
  color: var(--warning);
}

.meridian-audit-item.audit-reject .queue-distance {
  color: var(--danger);
}

.meridian-audit-item.audit-review,
.meridian-audit-item.audit-reject {
  background: rgba(160, 100, 22, 0.06);
}

.queue-item:hover {
  background: rgba(31, 122, 112, 0.08);
}

.queue-code {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.queue-name {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-distance {
  color: var(--danger);
  font-size: 12px;
  font-weight: 750;
}

.detail-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.detail-code {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(31, 122, 112, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.detail-title h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.1;
}

.detail-title span {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pill.far {
  border-color: rgba(179, 63, 66, 0.28);
  color: var(--danger);
}

.pill.moderate {
  border-color: rgba(160, 100, 22, 0.28);
  color: var(--warning);
}

.pill.near {
  border-color: rgba(31, 122, 112, 0.24);
  color: var(--accent);
}

.pill.approved,
.status-badge.approved {
  border-color: rgba(31, 122, 112, 0.24);
  color: var(--accent);
}

.pill.rejected,
.status-badge.rejected {
  border-color: rgba(179, 63, 66, 0.28);
  color: var(--danger);
}

.pill.pending,
.status-badge.pending {
  border-color: rgba(160, 100, 22, 0.28);
  color: var(--warning);
}

.pill.changed {
  border-color: rgba(31, 122, 112, 0.2);
  background: rgba(31, 122, 112, 0.08);
  color: var(--accent);
}

.detail-section {
  padding: 14px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-section h2 {
  margin: 0 0 8px;
  color: var(--warning);
  font-size: 13px;
}

.detail-section p {
  margin: 0;
  color: #342f2a;
  font-size: 13px;
  line-height: 1.65;
}

.review-note-text {
  margin-top: 8px !important;
  color: var(--muted) !important;
}

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

.coord-grid span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.source-label-list {
  display: grid;
  gap: 8px;
}

.source-label-row {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.54);
}

.source-label-row.high {
  border-color: rgba(31, 122, 112, 0.26);
}

.source-label-row.medium {
  border-color: rgba(160, 100, 22, 0.28);
}

.source-label-row.low {
  border-color: rgba(179, 63, 66, 0.24);
}

.source-label-row.standard-pass {
  background: rgba(31, 122, 112, 0.06);
}

.source-label-row.standard-review {
  background: rgba(160, 100, 22, 0.07);
}

.source-label-row.standard-reject {
  border-color: rgba(179, 63, 66, 0.38);
  background: rgba(179, 63, 66, 0.08);
}

.source-label-row strong {
  font-size: 13px;
}

.source-label-row span,
.source-label-row small {
  color: var(--muted);
  font-size: 12px;
}

.source-label-row .standard-check.standard-pass {
  color: var(--accent);
}

.source-label-row .standard-check.standard-review {
  color: var(--warning);
}

.source-label-row .standard-check.standard-reject {
  color: var(--danger);
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.editor-head h2 {
  margin: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.review-status-row,
.editor-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.editor-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.review-status-row button,
.editor-actions button,
.nudge-buttons button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--text);
  cursor: pointer;
}

.review-status-row button:hover,
.editor-actions button:hover,
.nudge-buttons button:hover,
.review-status-row button.active {
  border-color: rgba(31, 122, 112, 0.34);
  background: rgba(31, 122, 112, 0.08);
  color: var(--accent);
}

.axis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.axis-grid label,
.note-field,
.nudge-toolbar label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.axis-grid input,
.note-field textarea,
.nudge-toolbar select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--text);
  outline: none;
}

.axis-grid input {
  height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.axis-grid small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nudge-toolbar {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.nudge-toolbar select {
  height: 34px;
  padding: 0 7px;
}

.nudge-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.note-field {
  margin-top: 10px;
}

.note-field textarea {
  resize: vertical;
  min-height: 74px;
  padding: 8px;
  line-height: 1.45;
}

.axis-grid input:focus,
.note-field textarea:focus,
.nudge-toolbar select:focus {
  border-color: rgba(31, 122, 112, 0.72);
  box-shadow: 0 0 0 3px rgba(31, 122, 112, 0.12);
}

.hover-tip {
  position: fixed;
  z-index: 20;
  display: none;
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.loading-state {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 7;
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
  min-width: 132px;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.loading-state.is-busy::before {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(191, 109, 62, 0.18);
  border-top-color: rgba(191, 109, 62, 0.88);
  border-radius: 50%;
  content: "";
  animation: loading-spin 0.76s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1060px) {
  .topbar {
    grid-template-columns: 1fr 42px;
  }

  .brand,
  .search-box,
  .topbar select,
  .patch-actions {
    grid-column: 1 / -1;
  }

  .icon-button {
    position: absolute;
    top: 0;
    right: 0;
  }

  .patch-actions {
    padding-right: 52px;
  }

  .legend {
    display: none;
  }

  .detail-panel {
    top: auto;
    right: 12px;
    bottom: 170px;
    left: 12px;
    width: auto;
    max-height: 34vh;
  }

  .review-panel {
    display: none;
  }

  .review-strip {
    display: none;
  }

  .toggles {
    right: 12px;
    left: 12px;
    justify-content: center;
    transform: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .brand {
    font-size: 14px;
  }

  .toggles {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .patch-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 72px;
  }

  .action-button {
    padding: 0 8px;
    font-size: 12px;
  }

  .axis-grid,
  .review-status-row {
    grid-template-columns: 1fr;
  }

  .nudge-toolbar {
    grid-template-columns: 1fr;
  }

  .nudge-buttons {
    grid-template-columns: repeat(3, 1fr);
  }

  .detail-title h1 {
    font-size: 24px;
  }
}
