:root {
  --cos: #1e6bf1;
  --sin: #e03746;
  --tan: #8c3be0;
  --sec: #6fa7ff;
  --csc: #ff9da5;
  --cot: #b689ff;
  --bg: #0b1021;
  --fg: #e8ecf5;
  --muted: #98a5c0;
  --accent: #e04f7c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

.app {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.svg-wrap {
  flex: 3 1 420px;
  display: flex;
  justify-content: center;
  position: relative;
}

.question-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(17, 23, 53, 0.95);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--fg);
  z-index: 10;
  width: min(640px, 92%);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: none;
}

.question-overlay.show {
  display: block;
}

.question-overlay .formula {
  font-size: 1.8rem;
  margin: 0.5rem 0;
  color: var(--accent);
}

.question-overlay .description {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.75rem;
  line-height: 1.4;
}

.question-overlay .usage {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
  font-style: italic;
}

svg {
  width: 100%;
  max-width: 820px;
  height: auto;
}

.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.select {
  background: #1b2342;
  color: var(--fg);
  border: 1px solid #273155;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

.select:hover {
  border-color: var(--accent);
}

.select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.45rem 0.9rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.primary:hover {
  opacity: 0.9;
}

.chip {
  display: inline-block;
  background: #1b2342;
  color: var(--fg);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid #273155;
}

.panel {
  flex: 1 1 260px;
  min-width: 240px;
  background: #111735;
  border: 1px solid #1f2740;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}

.meta {
  color: var(--muted);
  margin-bottom: 1rem;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 8px;
  background: #1b2342;
  color: var(--fg);
  font-size: 0.9rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid #1f2740;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.row-cos { color: var(--cos); }
.row-sin { color: var(--sin); }
.row-tan { color: var(--tan); }
.row-sec { color: var(--sec); }
.row-csc { color: var(--csc); }
.row-cot { color: var(--cot); }

.review {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.pill {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  margin: 0.2rem;
  border-radius: 999px;
  background: #1d2645;
  color: var(--fg);
}

.hint {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint-desktop {
  display: inline;
}

.hint-mobile {
  display: none;
}

@media (max-width: 900px) {
  .hint-desktop {
    display: none;
  }
  
  .hint-mobile {
    display: inline;
  }
}

.svg-label {
  font-family: 'Inter', system-ui, sans-serif;
  /* Use SVG user units (viewBox-relative) via script-set font-size;
     keep this small as a fallback */
  font-size: 0.06px;
  fill: #e8ecf5;
  user-select: none;
  pointer-events: none;
}

.svg-label.muted { fill: #9aa5c5; }
.svg-label.coord { fill: #e8ecf5; }
.svg-label.deg { fill: #cfd7ef; }
.svg-label.rad { fill: #9aa5c5; }
.svg-label.coord-x { fill: var(--cos); }
.svg-label.coord-y { fill: var(--sin); }
.svg-label.anchor-mid { text-anchor: middle; }
.svg-label.anchor-start { text-anchor: start; }
.svg-label.anchor-end { text-anchor: end; }

.xy-wrapper {
  font-size: 1.05rem;
  margin-top: 0.25rem;
}
.xy-x {
  color: var(--cos);
  font-weight: 600;
}
.xy-y {
  color: var(--sin);
  font-weight: 600;
}

/* Animation for angle reveal pulsing */
@keyframes angle-pulse {
  0%, 100% {
    text-shadow: 0 0 0 rgba(224, 79, 124, 0.5);
  }
  50% {
    text-shadow: 0 0 20px rgba(224, 79, 124, 1), 0 0 40px rgba(224, 79, 124, 0.6);
  }
}

.angle-reveal-pulse {
  animation: angle-pulse 1.5s ease-in-out infinite;
  font-weight: 600;
  font-size: 1.2rem;
}

/* Full circle flash glow animation */
@keyframes full-circle-flash {
  0% {
    filter: drop-shadow(0 0 0px rgba(224, 79, 124, 0));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(224, 79, 124, 1)) drop-shadow(0 0 40px rgba(224, 79, 124, 0.8));
  }
  100% {
    filter: drop-shadow(0 0 0px rgba(224, 79, 124, 0));
  }
}

svg.flash-glow {
  animation: full-circle-flash 0.5s ease-out;
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }
  .svg-wrap, .panel {
    flex: 1 1 auto;
    width: 100%;
  }
  svg {
    max-width: 100%;
  }
}