:root {
  --tp-bg: linear-gradient(120deg, #f4f4f2 0%, #eef4fa 58%, #f5f7ec 100%);
  --tp-panel: rgba(255, 255, 255, 0.96);
  --tp-panel-soft: #eef4fb;
  --tp-line: #c7d4e5;
  --tp-text: #121212;
  --tp-muted: #4d5e74;
  --tp-brand: #ff6b00;
  --tp-button: #2e527d;
  --tp-button-text: #ffffff;
  --tp-button-ghost: #f5f8fd;
  --tp-original: #0c7a9b;
  --tp-preview: #ff8a1f;
  --tp-target: #cf4f74;
  --tp-grid: #c6d6ea;
  --tp-axis: #27486d;
  --tp-correct: #1b7c3c;
  --tp-wrong: #b24031;
  --tp-shadow: 0 14px 36px rgba(23, 44, 72, 0.14);
}

[hidden] {
  display: none !important;
}

.tp-page {
  min-height: calc(100vh - 120px);
  padding: 1rem 1rem 2rem;
  color: var(--tp-text);
  background: var(--tp-bg);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
}

.tp-header {
  margin-bottom: 1rem;
  border-bottom: 2px solid rgba(73, 111, 156, 0.22);
  padding-bottom: 0.75rem;
}

.tp-header-top {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 1.5rem;
  align-items: end;
}

.tp-header h1 {
  margin: 0;
  color: var(--tp-brand);
  font-size: clamp(1.6rem, 3.1vw, 2.4rem);
  line-height: 1.05;
}

.tp-header-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  width: 100%;
  min-width: 0;
}

.tp-subtitle {
  margin: 0.7rem 0 0;
  font-size: clamp(0.95rem, 1.5vw, 1.2rem);
  font-weight: 600;
}

.tp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 1.5rem;
  align-items: start;
}

.tp-stage {
  display: grid;
  gap: 1rem;
}

.tp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.tp-toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 3rem;
  padding: 0.55rem 0.8rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(150, 171, 201, 0.35);
}

.tp-toolbar__group label {
  min-width: 4.75rem;
  white-space: nowrap;
}

.tp-zoom-controls {
  display: inline-flex;
  gap: 0.55rem;
}

.tp-zoom-controls button,
.tp-card__actions button {
  min-height: 3rem;
}

.tp-check-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 3rem;
  padding: 0.55rem 0.8rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 0 0 1px rgba(150, 171, 201, 0.5);
}

.tp-graph-shell {
  padding: 1rem;
  border-radius: 1.6rem;
  background: var(--tp-panel);
  box-shadow: var(--tp-shadow);
}

.tp-graph-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 700px;
  overflow: auto;
  touch-action: none;
}

.tp-graph-area svg {
  max-width: 100%;
  height: auto;
}

.tp-sidebar {
  display: grid;
  gap: 1rem;
}

.tp-field {
  display: grid;
  gap: 0.35rem;
}

.tp-field span {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--tp-muted);
}

.tp-card {
  padding: 1.2rem 1.3rem;
  border-radius: 2rem;
  background: var(--tp-panel);
  box-shadow: var(--tp-shadow);
}

.tp-score-card {
  display: grid;
  gap: 0.8rem;
}

.tp-score-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

.tp-score-row p,
.tp-rule-text {
  margin: 0;
  font-size: 1rem;
}

.tp-feedback {
  min-height: 1.4rem;
  margin: 0;
  font-weight: 700;
}

.tp-feedback.ok {
  color: var(--tp-correct);
}

.tp-feedback.bad {
  color: var(--tp-wrong);
}

.tp-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tp-controls-card {
  display: grid;
  gap: 1.2rem;
}

.tp-control-section {
  display: grid;
  gap: 0.7rem;
}

.tp-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.tp-axis-col {
  display: grid;
  gap: 0.45rem;
  padding: 0.5rem;
  border-radius: 0.8rem;
  background: rgba(238, 244, 251, 0.55);
}

.tp-control-section h2 {
  margin: 0;
  font-size: clamp(1rem, 1.4vw, 1.3rem);
  line-height: 1;
}

.tp-slider-row,
.tp-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem;
  align-items: center;
  gap: 0.8rem;
}

.tp-slider-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.tp-option-row {
  grid-template-columns: auto 1fr;
  justify-content: start;
  font-size: 1rem;
}

.tp-option-row span {
  margin-left: 0.2rem;
}

select,
input[type="number"],
button {
  font: inherit;
}

select,
input[type="number"] {
  min-height: 3rem;
  border: 1px solid rgba(124, 148, 179, 0.8);
  border-radius: 0.9rem;
  background: #ffffff;
  padding: 0.55rem 0.7rem;
  color: var(--tp-text);
}

input[type="number"] {
  width: 100%;
}

input[type="range"] {
  width: 100%;
  accent-color: #7a93b8;
}

input[type="checkbox"] {
  width: 1.3rem;
  height: 1.3rem;
  accent-color: #4a84d6;
}

button {
  border: 0;
  border-radius: 1rem;
  background: var(--tp-button);
  color: var(--tp-button-text);
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(31, 61, 101, 0.22);
}

button:hover,
button:focus-visible {
  filter: brightness(1.06);
  outline: none;
}

.tp-button--ghost {
  background: var(--tp-button-ghost);
  color: var(--tp-button);
  box-shadow: inset 0 0 0 1px rgba(72, 105, 147, 0.28);
}

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

.tp-grid .axis {
  stroke: var(--tp-axis);
  stroke-width: 2.3;
}

.tp-grid .tick {
  font-size: 11px;
  fill: #486181;
}

.tp-poly-original {
  stroke: var(--tp-original);
  stroke-width: 3;
  fill: rgba(12, 122, 155, 0.2);
}

.tp-poly-preview {
  stroke: var(--tp-preview);
  stroke-width: 3;
  fill: rgba(255, 138, 31, 0.18);
}

.tp-poly-match {
  stroke: #1b7c3c;
  stroke-width: 3;
  fill: rgba(27, 124, 60, 0.2);
}

.tp-poly-target {
  stroke: var(--tp-target);
  stroke-width: 3;
  fill: rgba(207, 79, 116, 0.08);
}

.tp-poly-original__vertex,
.tp-poly-preview__vertex,
.tp-poly-match__vertex,
.tp-poly-target__vertex {
  stroke-width: 0;
}

.tp-poly-original__vertex {
  fill: var(--tp-original);
}

.tp-poly-preview__vertex {
  fill: var(--tp-preview);
}

.tp-poly-match__vertex {
  fill: #1b7c3c;
}

.tp-poly-target__vertex {
  fill: var(--tp-target);
}

.vertex-label {
  font-size: 12px;
  font-weight: 700;
  fill: #516b8f;
}

.tp-axis-origin circle {
  fill: var(--tp-axis);
}

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

  .tp-header-top {
    grid-template-columns: 1fr;
    gap: 0.9rem;
    align-items: start;
  }

  .tp-graph-area {
    min-height: 520px;
  }
}

@media (max-width: 720px) {
  .tp-header-meta {
    grid-template-columns: 1fr;
    min-width: 0;
    width: 100%;
  }

  .tp-page {
    padding: 0.8rem 0.6rem 1.4rem;
  }

  .tp-card {
    border-radius: 1.4rem;
  }

  .tp-two-col {
    grid-template-columns: 1fr;
  }

  .tp-toolbar {
    gap: 0.6rem;
  }

  .tp-toolbar__group,
  .tp-check-chip {
    width: 100%;
    justify-content: space-between;
  }

  .tp-slider-row {
    grid-template-columns: 1fr;
  }

  .tp-option-row {
    grid-template-columns: auto 1fr;
  }
}
