:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-strong: #eef3f6;
  --ink: #18232e;
  --muted: #64717f;
  --floor: #b8e3e8;
  --camera: #c7ddf2;
  --eye: #f6d7ad;
  --delta: #cde9c8;
  --hypotenuse: #d7c8f0;
  --floor-ink: #5e9da6;
  --camera-ink: #6c93b7;
  --eye-ink: #b8894f;
  --delta-ink: #78a978;
  --hypotenuse-ink: #9277bc;
  --line: var(--floor-ink);
  --axis: #2d3b49;
  --grid: #d9e1e7;
  --dimension: var(--eye-ink);
  --focus: var(--floor-ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.tool-header,
.tool-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.brand-link {
  color: var(--ink);
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--ink);
}

.tool-footer {
  flex-wrap: wrap;
  padding: 0 18px 18px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  min-height: calc(100vh - 90px);
  padding: 18px;
}

.canvas-panel,
.controls {
  background: var(--panel);
  border: 1px solid #d7e0e7;
  box-shadow: 0 16px 48px rgb(23 35 46 / 0.08);
}

.canvas-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  border-radius: 8px;
}

.plot-header {
  padding: 6px 4px 12px;
}

.plot-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1.1;
}

.plot-header p {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

svg {
  display: block;
  width: 100%;
  min-height: 360px;
}

.controls {
  align-self: start;
  border-radius: 8px;
  padding: 18px;
}

.control-row {
  display: grid;
  gap: 4px;
  margin: 0 0 14px;
}

input[type="range"] + .control-row {
  margin-top: 24px;
}

input[type="range"] + .computed-values {
  margin-top: 24px;
}

.computed-values {
  display: grid;
}

.computed-row {
  margin-bottom: 18px;
}

.toggle-list {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--hypotenuse-ink);
}

.toggle-row input:focus-visible {
  outline: 3px solid rgb(146 119 188 / 0.4);
  outline-offset: 2px;
}

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 1.55rem;
  font-weight: 750;
  line-height: 1.1;
}

label[for="length-slider"],
#length-output {
  color: var(--floor-ink);
}

label[for="camera-height-slider"],
#camera-height-output {
  color: var(--camera-ink);
}

label[for="eye-height-slider"],
#eye-height-output {
  color: var(--eye-ink);
}

#camera-distance-output,
#camera-angle-output {
  display: inline-block;
}

#camera-distance-output::before,
#camera-angle-output::before {
  color: var(--hypotenuse-ink);
}

#camera-distance-output,
#camera-angle-output {
  color: var(--hypotenuse-ink);
}

.computed-label {
  color: var(--hypotenuse-ink);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 12px;
  width: 100%;
  border: 1px solid #c9d4dc;
  border-radius: 999px;
  outline: none;
}

input[type="range"]:focus,
input[type="range"]:focus-visible {
  box-shadow:
    0 0 0 3px #ffffff,
    0 0 0 6px rgb(146 119 188 / 0.35);
}

#length-slider {
  background: var(--floor);
}

#camera-height-slider {
  background: var(--camera);
}

#eye-height-slider {
  background: var(--eye);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(24 35 46 / 0.24);
}

#length-slider::-webkit-slider-thumb {
  background: var(--floor-ink);
}

#camera-height-slider::-webkit-slider-thumb {
  background: var(--camera-ink);
}

#eye-height-slider::-webkit-slider-thumb {
  background: var(--eye-ink);
}

input[type="range"]::-moz-range-track {
  height: 12px;
  border: 1px solid #c9d4dc;
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(24 35 46 / 0.24);
}

#length-slider::-moz-range-track {
  background: var(--floor);
}

#length-slider::-moz-range-thumb {
  background: var(--floor-ink);
}

#camera-height-slider::-moz-range-track {
  background: var(--camera);
}

#camera-height-slider::-moz-range-thumb {
  background: var(--camera-ink);
}

#eye-height-slider::-moz-range-track {
  background: var(--eye);
}

#eye-height-slider::-moz-range-thumb {
  background: var(--eye-ink);
}

.grid line {
  stroke: var(--grid);
  stroke-width: 1;
}

.grid text,
.axis text,
.measurement text {
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.grid text {
  fill: var(--muted);
  font-size: 15px;
}

#x-axis,
#y-axis {
  stroke: var(--axis);
  stroke-width: 2;
}

#arrow-positive path {
  fill: var(--axis);
}

.axis text {
  fill: var(--axis);
  font-size: 18px;
  font-weight: 700;
}

#measured-line {
  stroke: var(--floor);
  stroke-linecap: round;
  stroke-dasharray: 7 7;
  stroke-width: 4;
}

#origin-point {
  fill: #ffffff;
  stroke: var(--axis);
  stroke-width: 3;
}

#end-point {
  fill: #ffffff;
  stroke: var(--floor-ink);
  stroke-width: 3;
}

#dimension-line,
#origin-witness,
#end-witness {
  stroke: var(--floor-ink);
  stroke-linecap: round;
  stroke-width: 2;
}

#dimension-line {
  stroke-dasharray: 7 6;
}

#triangle-floor-leg,
#triangle-height-leg {
  fill: none;
  stroke-linecap: round;
  stroke-width: 3;
}

#triangle-floor-leg {
  stroke: var(--floor);
  stroke-dasharray: 7 7;
}

#triangle-height-leg {
  stroke: var(--delta);
  stroke-dasharray: 7 7;
}

#triangle-floor-label,
#triangle-height-label,
#camera-distance-label {
  font-size: 16px;
  font-weight: 800;
  paint-order: stroke;
  stroke: var(--panel);
  stroke-linejoin: round;
  stroke-width: 5px;
  user-select: none;
}

#triangle-floor-label {
  fill: var(--floor-ink);
}

#triangle-height-label {
  fill: var(--delta-ink);
}

#camera-distance-line {
  stroke: var(--hypotenuse);
  stroke-dasharray: 7 7;
  stroke-linecap: round;
  stroke-width: 3;
}

#camera-distance-label {
  fill: var(--hypotenuse-ink);
}

#length-label {
  fill: var(--floor-ink);
  font-size: 20px;
  font-weight: 800;
  paint-order: stroke;
  stroke: var(--panel);
  stroke-linejoin: round;
  stroke-width: 5px;
}

#camera-body,
#camera-top {
  fill: #eef7ff;
  stroke: var(--camera);
  stroke-width: 2;
}

#camera-control {
  cursor: ns-resize;
  touch-action: none;
}

#camera-lens,
#camera-front {
  fill: var(--camera);
  stroke: var(--camera);
  stroke-linejoin: round;
  stroke-width: 2;
}

#camera-centerline {
  stroke: var(--axis);
  stroke-dasharray: 5 5;
  stroke-linecap: round;
  stroke-width: 1.5;
}

#eye-height-guide {
  stroke: var(--eye);
  stroke-dasharray: 6 6;
  stroke-linecap: round;
  stroke-width: 1.5;
  pointer-events: none;
}

#eye-control {
  cursor: grab;
  touch-action: none;
}

#eye-control:active {
  cursor: grabbing;
}

#eye-outline {
  fill: #fff4df;
  stroke: var(--eye-ink);
  stroke-width: 2;
}

#eye-pupil {
  fill: var(--eye-ink);
}

.plot-summary {
  user-select: none;
}

#summary-background {
  fill: rgb(255 255 255 / 0.86);
  stroke: #d7e0e7;
  stroke-width: 1;
}

.summary-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-value {
  font-size: 13px;
  font-weight: 800;
  text-anchor: end;
}

#summary-floor-value {
  fill: var(--floor-ink);
}

#summary-camera-value {
  fill: var(--camera-ink);
}

#summary-eye-value {
  fill: var(--eye-ink);
}

#summary-height-delta-value {
  fill: var(--delta-ink);
}

#summary-distance-value,
#summary-angle-value {
  fill: var(--hypotenuse-ink);
}

#scale-note {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 600;
  opacity: 0.78;
  user-select: none;
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .tool-header,
  .tool-footer {
    padding-right: 12px;
    padding-left: 12px;
  }

  .controls {
    order: 1;
    min-width: 0;
  }

  .control-row {
    grid-template-columns: minmax(0, 1fr) minmax(5rem, auto);
    align-items: baseline;
    column-gap: 14px;
  }

  .computed-values {
    gap: 12px;
  }

  .computed-row {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    margin-bottom: 0;
  }

  output {
    font-size: 1.35rem;
    text-align: right;
    white-space: nowrap;
  }
}
