*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #c4b5fd;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.subtitle {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* ── Three-column layout ── */
.layout {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 980px;
}

.side-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 220px;
  flex-shrink: 0;
}

.center-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Main canvas ── */
#canvas {
  display: block;
  border-radius: 14px;
  background: #1e293b;
  cursor: crosshair;
  touch-action: none;
}

/* ── Function graphs ── */
.graphs-row {
  display: flex;
  gap: 10px;
}

.graphs-row canvas {
  display: block;
  border-radius: 10px;
  background: #1e293b;
}

/* ── Cards ── */
.card {
  background: #1e293b;
  border-radius: 14px;
  padding: 18px 20px;
}

.card h2 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #64748b;
  margin-bottom: 14px;
}

/* ── Angle display ── */
.angle-display {
  font-size: 2.4rem;
  font-weight: 700;
  color: #c4b5fd;
  line-height: 1;
  margin-bottom: 4px;
}

.angle-alt {
  font-size: 0.85rem;
  color: #64748b;
}

input.angle-display {
  background: transparent;
  border: none;
  border-bottom: 2px solid #c4b5fd;
  outline: none;
  width: 100%;
  padding: 0 0 2px 0;
  caret-color: #c4b5fd;
}

input.angle-display:focus {
  border-bottom-color: #a78bfa;
}

/* ── Trig value rows ── */
.trig-row {
  margin-bottom: 14px;
}

.trig-row:last-child { margin-bottom: 0; }

.trig-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}

.trig-name {
  font-size: 1rem;
  font-weight: 600;
}

.trig-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trig-formula {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 6px;
}

.bar-track {
  height: 8px;
  background: #0f172a;
  border-radius: 4px;
  overflow: visible;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.05s, margin-left 0.05s;
  position: absolute;
  top: 0;
}

.sin-color  { color: #f87171; }
.cos-color  { color: #60a5fa; }
.tan-color  { color: #fbbf24; }
.hyp-color  { color: #34d399; }

.bar-sin  { background: #f87171; }
.bar-cos  { background: #60a5fa; }
.bar-tan  { background: #fbbf24; }

/* ── Controls ── */
.control-row {
  margin-bottom: 14px;
}

.control-row:last-child { margin-bottom: 0; }

.control-row label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.control-row label span {
  color: #e2e8f0;
  font-weight: 600;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #0f172a;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c4b5fd;
  cursor: pointer;
  border: 2px solid #0f172a;
}

/* ── Toggle buttons ── */
.toggle-group {
  display: flex;
  background: #0f172a;
  border-radius: 8px;
  padding: 3px;
}

.toggle-group button {
  flex: 1;
  padding: 7px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  background: transparent;
  color: #64748b;
  transition: background 0.15s, color 0.15s;
}

.toggle-group button.active {
  background: #c4b5fd;
  color: #1e293b;
}

/* ── Legend ── */
.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #94a3b8;
}

.legend-dot {
  width: 12px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

.undef-note {
  font-size: 0.75rem;
  color: #f87171;
  font-style: italic;
  display: none;
}
