:root {
  color-scheme: light;
  --ink: #1f2528;
  --muted: #66747c;
  --line: #d9e0df;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #8f330f;
  --shadow: 0 18px 46px rgba(31, 37, 40, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08), transparent 42%),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 100vh;
}

.workspace {
  display: grid;
  place-items: center;
  padding: 28px;
  min-width: 0;
  overflow: auto;
}

.stage-shell {
  --stage-zoom: 1;
  width: min(calc(82vmin * var(--stage-zoom)), calc(760px * var(--stage-zoom)));
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fffdf7;
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
}

.rings,
.ring-layer {
  position: absolute;
  inset: 0;
}

.ring-layer {
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
  will-change: transform;
  pointer-events: none;
}

img.ring-layer {
  display: block;
  object-fit: contain;
  border-radius: 50%;
  user-select: none;
}

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

.crosshair::before {
  content: "";
  position: absolute;
  left: calc(50% - 1.5px);
  top: 50%;
  width: 3px;
  height: 50%;
  background: linear-gradient(rgba(143, 51, 15, 0.32), var(--warn));
  box-shadow: 0 0 0 1px rgba(143, 51, 15, 0.12);
}

.crosshair::after {
  content: "";
  position: absolute;
  left: calc(50% - 7px);
  bottom: 8px;
  width: 14px;
  height: 14px;
  background: var(--warn);
  filter: drop-shadow(0 1px 1px rgba(80, 24, 4, 0.28));
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.probe {
  position: absolute;
  left: calc(50% - 18px);
  top: calc(50% - 18px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--warn);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 6px 18px rgba(143, 51, 15, 0.22);
  cursor: crosshair;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  min-width: 0;
  overflow: auto;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.status {
  min-width: 72px;
  text-align: center;
  color: var(--accent-strong);
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  background: rgba(15, 118, 110, 0.08);
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.readout div {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
}

.readout div:last-child {
  grid-column: 1 / -1;
}

.readout span,
.field span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.readout strong {
  display: block;
  font-size: 22px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

#noteReadout {
  font-size: 16px;
  white-space: pre-line;
}

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

.controls.compact {
  margin-top: 8px;
}

.single-control {
  grid-template-columns: 1fr;
}

.zoom-controls {
  grid-template-columns: 1fr 72px 1fr;
}

.zoom-controls output {
  display: grid;
  place-items: center;
  min-height: 40px;
  color: var(--accent-strong);
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  font-variant-numeric: tabular-nums;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: rgba(15, 118, 110, 0.42);
}

button.primary,
button.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.field {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
}

.field span {
  margin: 0;
}

.field output {
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
}

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

.ring-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px;
}

.ring-row.info-row {
  grid-template-columns: 76px minmax(0, 1fr);
}

.ring-row span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ring-row strong {
  font-size: 14px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.ring-row input {
  width: 100%;
  accent-color: var(--accent);
}

.ring-row button {
  min-height: 28px;
  border-radius: 6px;
  font-size: 13px;
}

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

  .workspace {
    padding: 18px 18px 4px;
  }

  .stage-shell {
    width: min(calc(94vw * var(--stage-zoom)), calc(680px * var(--stage-zoom)));
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }
}

@media (max-width: 520px) {
  .panel {
    padding: 16px;
  }

  .controls,
  .readout {
    grid-template-columns: 1fr;
  }

  .readout div:last-child {
    grid-column: auto;
  }
}
