:root {
  color-scheme: light;
  --bg: #f2f1ee;
  --ink: #1d1f24;
  --muted: #6f727a;
  --panel: rgba(255, 255, 255, 0.9);
  --stroke: rgba(29, 31, 36, 0.08);
  --accent: #c9a56b;
  --accent-2: #6d7f92;
  --shadow: 0 24px 60px rgba(29, 31, 36, 0.12);
  --radius: 20px;
  font-family: "Sora", "Noto Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 12%, rgba(214, 206, 195, 0.6), transparent 45%),
    radial-gradient(circle at 90% 0%, rgba(202, 211, 223, 0.45), transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(230, 224, 214, 0.6), transparent 45%),
    linear-gradient(150deg, rgba(246, 245, 242, 0.95), rgba(235, 234, 231, 0.95));
  z-index: -1;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-controls input[type="range"] {
  width: 120px;
  accent-color: var(--ink);
}

.primary,
.ghost,
.toggle {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.primary {
  background: var(--ink);
  color: #fff;
  border: none;
  box-shadow: none;
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stroke);
}

.ghost.active {
  background: rgba(255, 159, 74, 0.18);
  color: #9a4a07;
  border-color: rgba(255, 159, 74, 0.6);
}

.toggle {
  background: rgba(201, 165, 107, 0.16);
  color: #6f5a3d;
  border: 1px solid rgba(201, 165, 107, 0.4);
  transition: all 0.2s ease;
}

.toggle.active {
  background: rgba(201, 165, 107, 0.35);
  color: #3f3424;
  border-color: rgba(201, 165, 107, 0.7);
}

.small {
  padding: 6px 12px;
  font-size: 12px;
}

.status {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(29, 31, 36, 0.06);
  color: var(--muted);
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr);
  gap: 24px;
  padding: 12px 7vw 60px;
  align-items: start;
}

.field-card,
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.metrics {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.metric-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 90px;
}

.metric-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-value {
  font-weight: 600;
  font-size: 16px;
}

.field {
  position: relative;
  margin-top: 16px;
  height: clamp(420px, 62vh, 660px);
  border-radius: 24px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(240, 239, 236, 0.9)),
    linear-gradient(0deg, rgba(29, 31, 36, 0.05) 0, rgba(29, 31, 36, 0.05) 1px, transparent 1px, transparent 70px),
    linear-gradient(90deg, rgba(29, 31, 36, 0.04) 0, rgba(29, 31, 36, 0.04) 1px, transparent 1px, transparent 90px);
  border: 1px solid rgba(29, 31, 36, 0.08);
  overflow: hidden;
  cursor: crosshair;
}

.field::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(29, 31, 36, 0.08) 0 20%, transparent 20% 100%),
    linear-gradient(180deg, rgba(29, 31, 36, 0.06) 0 12%, transparent 12% 100%),
    linear-gradient(135deg, rgba(29, 31, 36, 0.04) 0 30%, transparent 30% 100%),
    linear-gradient(315deg, rgba(29, 31, 36, 0.04) 0 22%, transparent 22% 100%);
  mix-blend-mode: multiply;
  opacity: 0.2;
  pointer-events: none;
}

.field-inner {
  position: absolute;
  width: 200%;
  height: 200%;
  left: -50%;
  top: -50%;
  transform-origin: 0 0;
}

.range-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  border: 1px dashed rgba(44, 46, 51, 0.28);
  opacity: 0.7;
  transform: translate(-50%, -50%);
}

.ring-clear {
  border-color: rgba(255, 159, 74, 0.45);
  border-style: dashed;
  opacity: 0.85;
}

.grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(29, 31, 36, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 31, 36, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: 0 0;
}

.source-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.field-hint {
  position: absolute;
  bottom: 16px;
  left: 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid rgba(29, 31, 36, 0.08);
}

.marker {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
}

.marker.active {
  display: block;
}

.marker.source {
  width: 16px;
  height: 16px;
  background: #4b4f55;
  border: 2px solid #4b4f55;
  box-shadow: 0 0 0 10px rgba(75, 79, 85, 0.12);
  overflow: visible;
}

.marker.source .range-ring {
  display: none;
  pointer-events: none;
}

.marker.source.show-ranges .range-ring {
  display: block;
}

.marker.source.detected {
  background: #ff9f4a;
  border-color: #ff9f4a;
  box-shadow: 0 0 0 14px rgba(255, 159, 74, 0.2);
}

.marker.source.clear {
  animation: pulse 1s infinite;
}

.marker.listener {
  width: 18px;
  height: 18px;
  background: #3fb8ff;
  box-shadow: 0 0 0 8px rgba(63, 184, 255, 0.25);
  cursor: grab;
  --heading: 0rad;
}

.marker.listener.dragging {
  cursor: grabbing;
}

.listener-heading {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: rotate(var(--heading));
  transform-origin: 50% 50%;
  pointer-events: none;
}

.listener-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #3fb8ff;
  transform: translate(-50%, -18px);
  filter: none;
}

.field-footer {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.stereo-meter {
  display: flex;
  gap: 10px;
}

.meter {
  width: 70px;
  height: 8px;
  background: rgba(29, 31, 36, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.meter span {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transform-origin: left center;
  transform: scaleX(0);
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 0 10px rgba(255, 159, 74, 0.18);
  }
  70% {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 0 0 18px rgba(255, 159, 74, 0);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 0 10px rgba(255, 159, 74, 0);
  }
}

.panel-block + .panel-block {
  margin-top: 24px;
}

.panel-title {
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
}

.input-label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.input-label input[type="file"] {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(29, 31, 36, 0.1);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.muted.small {
  font-size: 12px;
  margin-top: 12px;
}

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

.source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(29, 31, 36, 0.06);
  background: rgba(255, 255, 255, 0.7);
}

.source-item.detected {
  border-color: rgba(109, 127, 146, 0.4);
  box-shadow: 0 0 0 1px rgba(109, 127, 146, 0.2);
}

.source-item.placing {
  border-color: rgba(201, 165, 107, 0.5);
  box-shadow: 0 0 0 1px rgba(201, 165, 107, 0.2);
}

.source-info {
  display: grid;
  gap: 4px;
}

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

.source-meta {
  font-size: 12px;
  color: var(--muted);
}

.source-actions {
  display: flex;
  gap: 8px;
}

.empty {
  font-size: 13px;
  color: var(--muted);
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.zoom-controls input[type="range"] {
  accent-color: var(--ink);
}


.footer {
  padding: 0 7vw 32px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .layout {
    padding: 10px 6vw 40px;
  }

  .field {
    height: clamp(340px, 55vh, 520px);
  }
}
