:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: rgba(22, 24, 29, 0.92);
  --panel-strong: #191c22;
  --line: rgba(255, 255, 255, 0.16);
  --text: #f3f5f7;
  --muted: #aeb6c2;
  --accent: #51c4a8;
  --accent-2: #f2b84b;
  --danger: #ef6f6c;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 342px;
  background: #0f1013;
}

#stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #090a0c;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

.source {
  cursor: grab;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.source:active {
  cursor: grabbing;
}

.probe {
  cursor: grab;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.58));
}

.probe:active {
  cursor: grabbing;
}

.probe-ring {
  fill: rgba(3, 8, 12, 0.34);
  stroke: #ffffff;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.probe-cross {
  stroke: var(--accent-2);
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.probe-dot {
  fill: var(--accent-2);
  stroke: rgba(255, 255, 255, 0.78);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.node-path {
  fill: none;
  stroke: rgba(255, 238, 158, 0.82);
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.wall-shape {
  fill: rgba(255, 255, 255, 0.07);
  stroke: rgba(255, 255, 255, 0.78);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.wall-shape.absorptive {
  stroke: rgba(81, 196, 168, 0.9);
}

.wall-preview {
  fill: rgba(242, 184, 75, 0.08);
  stroke: var(--accent-2);
  stroke-dasharray: 6 5;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

#overlayNote {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: min(480px, calc(100% - 28px));
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: rgba(12, 14, 18, 0.66);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  border-radius: 7px;
  pointer-events: none;
}

#panel {
  position: relative;
  z-index: 2;
  min-width: 0;
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
}

h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 730;
  letter-spacing: 0;
}

.subtle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: auto;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.tab-btn.active {
  background: rgba(81, 196, 168, 0.15);
  color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tab-content .section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
  color: #d7dde4;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

label {
  color: var(--muted);
  font-size: 12px;
}

.value {
  min-width: 54px;
  text-align: right;
  color: #eef2f5;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

select,
button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-strong);
}

select {
  width: 100%;
  padding: 0 9px;
}

input[type="number"] {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  color: var(--text);
  background: var(--panel-strong);
}

button {
  padding: 0 11px;
  cursor: pointer;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.32);
  background: #20242c;
}

button.primary {
  border-color: rgba(81, 196, 168, 0.5);
  background: #17332e;
}

button.warn {
  border-color: rgba(239, 111, 108, 0.55);
  background: #332022;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.button-row.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.info-btn {
  min-width: 25px;
  min-height: 25px;
  width: 25px;
  height: 25px;
  padding: 0;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  background: rgba(81, 196, 168, 0.1);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.035);
}

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

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

#probeScope {
  display: block;
  width: 100%;
  height: 112px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0a0c10;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

#sourceList {
  display: grid;
  gap: 8px;
}

.source-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.source-item.selected {
  border-color: rgba(81, 196, 168, 0.8);
  background: rgba(81, 196, 168, 0.08);
}

.source-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.source-name {
  font-size: 13px;
  font-weight: 720;
}

.mini {
  min-height: 27px;
  padding: 0 8px;
  font-size: 12px;
}

.status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.status.warning {
  color: #d9c893;
}

.tooltip {
  display: none;
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(242, 184, 75, 0.35);
  border-radius: 7px;
  color: #f4e6ad;
  background: rgba(40, 33, 18, 0.72);
  font-size: 12px;
  line-height: 1.4;
}

.tooltip.visible {
  display: block;
}

#presetDescription {
  min-height: 50px;
  margin-top: 4px;
}

#presetStatus {
  min-height: 34px;
}

.unsupported {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: #111317;
  color: var(--text);
  text-align: center;
  z-index: 5;
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 330px;
  }

  #panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
