:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #607080;
  --line: #c9d4df;
  --panel: #ffffff;
  --page: #edf2f7;
  --circle: #2c6aa0;
  --chord-a: #0f7b6c;
  --chord-b: #ad4f3a;
  --construct: #6849a7;
  --ok: #1f7a45;
  --bad: #b3261e;
  --warn: #a15c00;
  --focus: #184fc4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  letter-spacing: 0;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
}

.interactive {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
  margin-top: 22px;
}

.stage-panel,
.control-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(37, 49, 63, 0.08);
}

.stage-panel {
  overflow: hidden;
}

.stage-title {
  min-height: 58px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.stage-title h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.stage-title span {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.92rem;
}

.geometry-stage {
  display: block;
  width: 100%;
  min-height: 420px;
  height: min(64vh, 620px);
  background: #f8fbfd;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.control-panel {
  padding: 16px;
}

.panel-block {
  margin-bottom: 16px;
}

.panel-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: 0;
}

.condition-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fbfcfe;
}

.condition-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.condition-row strong {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.condition-row.met strong {
  color: var(--ok);
}

.condition-row.broken {
  border-color: #e1a39e;
  background: #fff7f6;
}

.condition-row.broken strong {
  color: var(--bad);
}

.condition-row.disabled {
  opacity: 0.58;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

button {
  min-height: 42px;
  border: 1px solid #aebccc;
  border-radius: 6px;
  background: #f4f7fa;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 10px;
}

button:hover {
  background: #e9f0f7;
}

button:focus-visible {
  outline: 3px solid rgba(24, 79, 196, 0.28);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.status-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.status-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #edf1f5;
}

.status-list span:last-child {
  font-weight: 700;
  white-space: nowrap;
}

.status-list .ok span:last-child {
  color: var(--ok);
}

.status-list .bad span:last-child {
  color: var(--bad);
}

.message {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef5ff;
  border: 1px solid #c8dcf4;
  color: #1f456f;
}

.message.warning {
  background: #fff8ed;
  border-color: #f0cc91;
  color: #6c4100;
}

.message.success {
  background: #edf8f1;
  border-color: #b9dfc8;
  color: #155d33;
}

.measurements dl {
  margin: 0;
}

.measurements div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #edf1f5;
}

.measurements dt {
  color: var(--muted);
}

.measurements dd {
  margin: 0;
  font-weight: 700;
}

.hidden {
  display: none;
}

.svg-circle {
  fill: #eef7ff;
  stroke: var(--circle);
  stroke-width: 3;
}

.svg-diameter-grid {
  stroke: #d8e4ee;
  stroke-width: 1.2;
}

.svg-chord {
  stroke: var(--chord-a);
  stroke-width: 5;
  stroke-linecap: round;
}

.svg-chord.secondary {
  stroke: var(--chord-b);
}

.svg-construction {
  stroke: var(--construct);
  stroke-width: 3;
  stroke-linecap: round;
}

.svg-distance {
  stroke: #425466;
  stroke-width: 2.5;
  stroke-dasharray: 7 6;
}

.svg-point {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 3;
  cursor: grab;
}

.svg-point:active {
  cursor: grabbing;
}

.svg-point.center {
  fill: var(--ink);
  stroke: var(--ink);
  cursor: default;
}

.svg-point.handle {
  fill: #f8f1ff;
  stroke: var(--construct);
}

.svg-label {
  fill: var(--ink);
  font-size: 22px;
  font-weight: 700;
  pointer-events: none;
}

.svg-small-label {
  fill: #425466;
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}

.svg-right-angle {
  fill: rgba(104, 73, 167, 0.12);
  stroke: var(--construct);
  stroke-width: 2.5;
}

.svg-tick {
  stroke: #111827;
  stroke-width: 3;
  stroke-linecap: round;
}

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

  .control-panel {
    order: 2;
  }

  .geometry-stage {
    height: min(68vh, 540px);
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1500px);
    padding-top: 14px;
  }

  .stage-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .geometry-stage {
    min-height: 360px;
  }

  .condition-row {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .condition-row strong {
    grid-column: 2;
  }
}
