* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #eef4f8;
  --ink: #14213d;
  --muted: #607086;
  --border: #d7e0ea;
  --satellite: #0ea5e9;
  --real: #16a34a;
  --estimate: #dc2626;
  --circle: #7c3aed;
  --error: #ef4444;
  --shadow: 0 18px 40px rgba(20, 33, 61, 0.1);
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  width: min(1480px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 20px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--satellite);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

h2 {
  margin-bottom: 12px;
  font-size: 17px;
}

.intro {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(390px, 0.78fr);
  gap: 16px;
  align-items: start;
}

.left-column,
.right-column {
  min-width: 0;
}

.right-column {
  display: grid;
  gap: 10px;
}

.canvas-panel,
.side-panel,
.data-card,
.learning-strip article {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.canvas-panel {
  padding: 12px;
}

.canvas-note {
  margin-top: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4f8 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.canvas-note-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.canvas-note .eyebrow {
  margin: 0;
  white-space: nowrap;
}

.canvas-note h2 {
  margin-bottom: 0;
}

.canvas-icon-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.canvas-icon-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 2px 10px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid #dfe7f0;
  border-radius: 8px;
}

.canvas-icon-item strong {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-icon-item small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.canvas-icon {
  grid-row: span 2;
  justify-self: center;
  position: relative;
}

.canvas-icon.dot {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border);
}

.canvas-icon.dot::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.satellite-dot {
  background: var(--satellite);
}

.real-dot {
  background: var(--real);
}

.real-dot::after {
  inset: -7px;
  border: 2px solid var(--real);
}

.estimate-dot {
  background: var(--estimate);
}

.estimate-dot::after {
  inset: -8px;
  border: 2px dashed var(--estimate);
}

.satellite-range {
  width: 32px;
  height: 32px;
  border: 2px dashed var(--circle);
  border-radius: 50%;
}

.satellite-range::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--satellite);
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px var(--border);
}

.dashed-line,
.error-line {
  width: 30px;
  height: 16px;
}

.dashed-line::after,
.error-line::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 7px;
  border-top: 2px dashed #94a3b8;
}

.error-line::after {
  border-top-style: solid;
  border-top-color: var(--error);
}

.canvas-note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.note-block {
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #dfe7f0;
  border-radius: 8px;
}

.note-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink);
}

.note-block ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.note-block li {
  color: var(--muted);
  line-height: 1.45;
}

.note-block strong {
  color: var(--ink);
}

.note-summary {
  margin: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #dfe7f0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.model-card {
  margin-top: 12px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.model-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.model-card-header .eyebrow,
.model-card h2,
.model-card h3,
.model-card p {
  margin-bottom: 0;
}

.model-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.model-flow article {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid #dfe7f0;
  border-radius: 8px;
}

.model-flow span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  background: var(--ink);
  color: #ffffff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.model-flow h3,
.model-detail h3 {
  font-size: 14px;
  color: var(--ink);
}

.model-flow p,
.model-detail p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.model-detail {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid #dfe7f0;
  border-radius: 8px;
}

.mini-formula {
  display: grid;
  gap: 6px;
  min-width: 210px;
  padding: 10px 12px;
  background: #eef4f8;
  border-radius: 8px;
}

.mini-formula strong {
  color: var(--ink);
  font-size: 12px;
}

.mini-formula code {
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #f8fbff;
  border: 1px solid #cbd8e6;
  border-radius: 8px;
}

#gpsCanvas {
  cursor: default;
}

.side-panel {
  padding: 14px;
}

.panel-section + .panel-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.legend {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}

.swatch {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
}

.swatch.satellite {
  background: var(--satellite);
  color: var(--satellite);
}

.swatch.real {
  background: var(--real);
  color: var(--real);
}

.swatch.estimate {
  background: var(--estimate);
  color: var(--estimate);
}

.swatch.circle {
  background: transparent;
  color: var(--circle);
  border-style: dashed;
}

.swatch.error {
  width: 28px;
  height: 0;
  border-width: 2px 0 0;
  border-radius: 0;
  color: var(--error);
}

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
}

.steps li {
  padding: 8px 10px;
  border-radius: 8px;
}

.steps li.active {
  background: #e8f4fd;
  color: var(--ink);
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.controls h2,
.controls .control,
.controls button {
  grid-column: span 2;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.control input[type="range"],
.control select {
  grid-column: 1 / -1;
  width: 100%;
}

.control select,
button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.check-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.controls .check-control {
  grid-column: span 1;
}

button {
  cursor: pointer;
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
}

.output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.data-card {
  padding: 16px;
}

.right-column .data-card {
  padding: 12px;
}

.data-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.data-card > p:first-of-type {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.right-column .data-card > p:first-of-type {
  font-size: 15px;
}

.data-card.wide {
  grid-column: span 2;
}

.graph-card {
  padding-bottom: 10px;
}

.graph-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.graph-header h2,
.graph-header p {
  margin-bottom: 0;
}

.graph-header p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-align: right;
}

#errorChart {
  width: 100%;
  max-height: 130px;
}

.measurement-list {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.measurement-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid var(--border);
}

.learning-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.learning-strip article {
  padding: 12px;
}

.learning-strip p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.formula {
  display: block;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

  .right-column {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .side-panel,
  .output-grid,
  .learning-strip {
    grid-column: span 2;
  }

  .canvas-icon-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-flow,
  .model-detail {
    grid-template-columns: 1fr;
  }

  .mini-formula {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 1320px);
    padding-top: 18px;
  }

  .right-column,
  .side-panel,
  .output-grid,
  .learning-strip {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .output-grid {
    grid-template-columns: 1fr;
  }

  .data-card.wide {
    grid-column: auto;
  }

  .canvas-note-header,
  .canvas-icon-card,
  .canvas-note-grid,
  .model-card-header {
    grid-template-columns: 1fr;
  }

  .canvas-note-header,
  .model-card-header {
    display: block;
  }

  .model-flow {
    grid-template-columns: 1fr;
  }

  .mini-formula code {
    white-space: normal;
  }
}
