:root {
  color-scheme: light;
  --ink: #18322c;
  --muted: #66736f;
  --paper: #f4f0e6;
  --card: #fffdf8;
  --line: #d8d3c7;
  --green: #1e6959;
  --green-dark: #144c41;
  --amber: #e99a24;
  --amber-soft: #fff1d5;
  --red: #be4a3c;
  --shadow: 0 14px 35px rgba(44, 55, 49, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 30px clamp(22px, 4vw, 64px) 24px;
  border-bottom: 1px solid rgba(24, 50, 44, .14);
}

.eyebrow, .section-label {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .15em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-family: Georgia, serif; font-size: clamp(30px, 4vw, 48px); font-weight: 500; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; letter-spacing: -.02em; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 15px; }

.header-key { display: flex; gap: 20px; padding-bottom: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.header-key span { display: flex; align-items: center; gap: 7px; }
.key-swatch { width: 18px; height: 4px; border-radius: 3px; }
.key-swatch.beam { background: var(--amber); }
.key-swatch.footprint { background: var(--green); }
.key-swatch.target { width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

.app-shell { display: grid; grid-template-columns: 288px minmax(0, 1fr); gap: 25px; padding: 26px clamp(22px, 4vw, 64px); }
.control-panel, .viz-card, .metric { background: var(--card); border: 1px solid rgba(24, 50, 44, .12); box-shadow: var(--shadow); }
.control-panel { border-radius: 13px; padding: 23px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.text-button { padding: 5px 0; border: 0; background: none; color: var(--green); font-size: 12px; font-weight: 750; }
.text-button:hover { color: var(--amber); }
.controls { display: grid; gap: 22px; padding: 22px 0; }
.control { display: grid; gap: 9px; }
.control > span, .control small { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.control b { font-size: 13px; }
.control output { color: var(--green); font-size: 13px; font-weight: 750; }
.control small { color: #8a918e; font-size: 10px; }
.number-field { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.number-field input { width: 70px; padding: 6px 4px 6px 8px; border: 0; outline: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 750; text-align: right; }
.number-field:focus-within { border-color: var(--green); box-shadow: 0 0 0 2px rgba(30, 105, 89, .1); }
.number-field i { padding-right: 8px; color: var(--muted); font-size: 11px; font-style: normal; }

input[type="range"] { width: 100%; height: 4px; margin: 5px 0; border-radius: 99px; appearance: none; background: linear-gradient(90deg, var(--green) var(--fill, 50%), #d9ded9 var(--fill, 50%)); }
input[type="range"]::-webkit-slider-thumb { width: 15px; height: 15px; border: 3px solid var(--card); border-radius: 50%; appearance: none; background: var(--green); box-shadow: 0 0 0 1px rgba(24, 50, 44, .25); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 3px solid var(--card); border-radius: 50%; background: var(--green); box-shadow: 0 0 0 1px rgba(24, 50, 44, .25); }
.conventions { padding: 14px; border-left: 3px solid var(--amber); background: var(--amber-soft); color: #706246; font-size: 11px; line-height: 1.45; }
.conventions p { margin-bottom: 4px; }
.conventions p:last-child { margin-bottom: 0; }

.workspace { min-width: 0; }
.status-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 13px; }
.metric { min-width: 0; min-height: 102px; border-radius: 11px; padding: 16px 17px; }
.metric-title { overflow: hidden; margin-bottom: 9px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .09em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.metric strong { display: block; overflow: hidden; margin-bottom: 5px; font-family: Georgia, serif; font-size: 22px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.metric > span { display: block; overflow: hidden; color: #87908d; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #a8aeac; }
.target-card.visible { border-color: rgba(30, 105, 89, .45); background: #f3faf6; }
.target-card.visible .status-dot { background: #39a071; box-shadow: 0 0 0 4px rgba(57, 160, 113, .13); }
.target-card.visible strong { color: var(--green); }

.viz-card { overflow: hidden; border-radius: 13px; }
.viz-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; min-height: 61px; padding: 11px 17px; border-bottom: 1px solid var(--line); }
.viz-toolbar p { margin: 0; color: var(--muted); font-size: 11px; }
.transport { display: flex; align-items: center; gap: 8px; }
.primary-button, .icon-button { border: 0; border-radius: 7px; font-weight: 700; }
.primary-button { display: flex; align-items: center; gap: 8px; min-width: 93px; padding: 9px 14px; background: var(--green); color: white; font-size: 12px; }
.primary-button:hover { background: var(--green-dark); }
.icon-button { width: 34px; height: 34px; background: #edf0ec; color: var(--green); font-size: 19px; }
.icon-button:hover { background: #e2e7e1; }
.view-button { height: 34px; padding: 0 10px; border: 0; border-radius: 7px; background: #edf0ec; color: var(--green); font-size: 11px; font-weight: 750; }
.view-button:hover { background: #e2e7e1; }
.view-button:disabled { cursor: default; opacity: .45; }
.speed-control { display: flex; align-items: center; gap: 6px; margin-left: 5px; color: var(--muted); font-size: 11px; }
select { padding: 7px 24px 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); font-size: 11px; }
.display-options { display: flex; align-items: center; gap: 12px; }
.display-options label { display: flex; align-items: center; gap: 5px; color: var(--muted); cursor: pointer; font-size: 11px; white-space: nowrap; }
.display-options input { width: 14px; height: 14px; margin: 0; accent-color: var(--green); }
.drag-symbol { display: inline-block; margin-right: 3px; color: var(--green); font-size: 16px; }

#visualization { display: block; width: 100%; height: auto; min-height: 410px; touch-action: none; user-select: none; }
.grid-line { stroke: #526d65; stroke-width: 1; stroke-opacity: .09; stroke-dasharray: 3 7; }
.grid-label { fill: #81908b; font-size: 10px; }
.sensor-ray { stroke: var(--amber); stroke-width: 2; stroke-dasharray: 6 5; }
.center-ray { stroke: #d78816; stroke-width: 1.5; stroke-opacity: .8; }
.ground-line { stroke: #726c5d; stroke-width: 2; }
.footprint-line { stroke: var(--green); stroke-width: 9; stroke-linecap: butt; }
.slant-measure-line { stroke: #315f56; stroke-width: 1.5; stroke-dasharray: 5 5; }
.ground-drop-line { stroke: #687873; stroke-width: 1.25; stroke-dasharray: 2 5; }
.ground-measure-line { stroke: #7b6646; stroke-width: 1.25; }
.range-label { pointer-events: none; }
.range-label rect { fill: rgba(255, 253, 248, .94); stroke: rgba(49, 95, 86, .28); stroke-width: 1; }
.range-label text { fill: #24483f; font-size: 10px; font-weight: 750; letter-spacing: .02em; }
.ground-range-label rect { stroke: rgba(123, 102, 70, .3); }
.ground-range-label text { fill: #6d593d; }
.rotor-line { stroke: #17362f; stroke-width: 3; }
.rotor { fill: #45645c; opacity: .65; }
.drone-body { fill: #254a41; stroke: #17362f; stroke-width: 2; stroke-linejoin: round; }
.sensor { fill: var(--amber); stroke: #fff8eb; stroke-width: 2; }
.direction-arrow { fill: var(--green); }
.target-group { cursor: ew-resize; outline: none; }
.target-hit-area { fill: transparent; }
.target-ring { fill: var(--card); stroke: var(--red); stroke-width: 3; }
.target-core { fill: var(--red); }
.target-tick { stroke: var(--red); stroke-width: 2; }
.target-group.visible .target-ring { fill: #eaf7ef; stroke: var(--green); animation: pulse 1.6s ease-out infinite; }
.target-group.visible .target-core, .target-group.visible .target-tick { fill: var(--green); stroke: var(--green); }
@keyframes pulse { 0% { stroke-width: 5; } 100% { stroke-width: 2; } }
.measure-line { stroke: #65766f; stroke-width: 1; stroke-dasharray: 3 3; }
.measure-label, .axis-labels text { fill: #64736e; font-size: 11px; }
#targetLabel { fill: var(--red); font-size: 10px; font-weight: 750; letter-spacing: .08em; }
#offscreenNotice rect { fill: rgba(24, 50, 44, .86); }
#offscreenNotice text { fill: white; font-size: 11px; }

.time-strip { display: grid; grid-template-columns: 105px 1fr 92px; align-items: center; gap: 13px; padding: 13px 19px 16px; color: var(--muted); font-size: 10px; }
.timeline-scrubber { width: 100%; height: 16px; margin: 0; appearance: none; background: transparent; }
.timeline-scrubber::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--green) var(--timeline-fill, 0%), #e0e2dc var(--timeline-fill, 0%));
}
.timeline-scrubber::-moz-range-track {
  height: 5px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--green) var(--timeline-fill, 0%), #e0e2dc var(--timeline-fill, 0%));
}
.timeline-scrubber::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -5px;
  border: 3px solid var(--card);
  border-radius: 50%;
  appearance: none;
  background: var(--green);
  box-shadow: 0 0 0 1px rgba(24, 50, 44, .25);
}
.timeline-scrubber::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 3px solid var(--card);
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 1px rgba(24, 50, 44, .25);
}
.time-strip span:last-child { text-align: right; }
footer { padding: 0 64px 24px; color: #7e8884; font-size: 10px; text-align: right; }

@media (max-width: 1350px) {
  .status-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conventions { max-width: 560px; }
}

@media (max-width: 700px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .header-key { flex-wrap: wrap; padding-bottom: 0; }
  .status-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viz-toolbar { align-items: flex-start; flex-direction: column; }
  .viz-toolbar p { display: none; }
  .time-strip { grid-template-columns: 82px 1fr 75px; }
  #visualization { min-height: 330px; }
  footer { padding-inline: 22px; }
}

@media (max-width: 470px) {
  .controls { grid-template-columns: 1fr; }
  .status-row { grid-template-columns: 1fr 1fr; }
  .metric { padding: 13px; }
  .metric strong { font-size: 18px; }
  .speed-control { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .target-group.visible .target-ring { animation: none; }
}
