@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&family=Source+Serif+4:wght@400;600&display=swap");

:root {
  --wilson-ink: #1d1b1f;
  --wilson-ink-soft: #4d4a52;
  --wilson-accent: #c05b2c;
  --wilson-accent-2: #0f6f76;
  --wilson-card: rgba(255, 255, 255, 0.82);
  --wilson-card-strong: rgba(255, 255, 255, 0.96);
  --wilson-border: rgba(29, 27, 31, 0.12);
  --wilson-shadow: 0 18px 40px rgba(30, 20, 10, 0.12);
  --wilson-radius: 18px;
}

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

body {
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  background: radial-gradient(
    circle at top left,
    #f7f0e9 0%,
    #e7eef0 45%,
    #f2f4f7 100%
  );
  color: var(--wilson-ink);
  line-height: 1.6;
  min-height: 100vh;
}

.wilson-loop-app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 22px 60px;
}

.wilson-loop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.wilson-loop-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--wilson-accent-2);
  font-weight: 600;
}

.wilson-loop-header h1 {
  font-size: clamp(2.1rem, 3vw, 3rem);
  font-weight: 700;
  margin-top: 6px;
}

.wilson-loop-subtitle {
  font-size: 1.05rem;
  color: var(--wilson-ink-soft);
  margin-top: 6px;
}

.wilson-loop-formula {
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 1.1rem;
  color: var(--wilson-accent);
  background: rgba(255, 255, 255, 0.8);
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid rgba(192, 91, 44, 0.2);
  box-shadow: 0 8px 20px rgba(192, 91, 44, 0.18);
  white-space: nowrap;
}

.wilson-loop-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 24px;
}

.wilson-loop-card {
  background: var(--wilson-card);
  border-radius: var(--wilson-radius);
  border: 1px solid var(--wilson-border);
  box-shadow: var(--wilson-shadow);
  padding: 20px;
  backdrop-filter: blur(6px);
}

.wilson-loop-canvas-card {
  position: relative;
  background: var(--wilson-card-strong);
  padding: 16px;
}

#wilsonCanvas {
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    rgba(248, 244, 237, 0.9),
    rgba(240, 246, 249, 0.9)
  );
  border: 1px solid rgba(29, 27, 31, 0.12);
  touch-action: none;
}

.wilson-loop-tip {
  position: absolute;
  bottom: 18px;
  right: 18px;
  font-size: 0.85rem;
  padding: 8px 12px;
  background: rgba(15, 111, 118, 0.12);
  color: var(--wilson-accent-2);
  border-radius: 999px;
  border: 1px solid rgba(15, 111, 118, 0.25);
}

.wilson-loop-side {
  display: grid;
  gap: 20px;
}

.wilson-loop-card h2 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.wilson-loop-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.wilson-loop-control label {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--wilson-ink-soft);
}

.wilson-loop-control input[type="range"] {
  width: 100%;
  accent-color: var(--wilson-accent);
}

.wilson-loop-control select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--wilson-border);
  background: #fff;
  font-weight: 600;
  color: var(--wilson-ink);
}

.wilson-loop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wilson-loop-actions button {
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

#resampleButton {
  background: var(--wilson-accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(192, 91, 44, 0.25);
}

#resetLoopButton {
  background: rgba(15, 111, 118, 0.12);
  color: var(--wilson-accent-2);
  border: 1px solid rgba(15, 111, 118, 0.3);
}

.wilson-loop-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(29, 27, 31, 0.12);
}

.wilson-loop-metrics {
  display: grid;
  gap: 12px;
}

.wilson-loop-metric {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(29, 27, 31, 0.08);
  font-size: 0.95rem;
}

.wilson-loop-metric strong {
  font-weight: 700;
  color: var(--wilson-accent-2);
  text-align: right;
}

.wilson-loop-legend {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--wilson-ink-soft);
}

.wilson-loop-legend-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.wilson-loop-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.wilson-loop-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(29, 27, 31, 0.15);
}

.wilson-loop-swatch-u1 {
  background: conic-gradient(
    from 90deg,
    #2f6fab,
    #31a36f,
    #f5b642,
    #d34b4b,
    #2f6fab
  );
}

.wilson-loop-swatch-su2 {
  background: linear-gradient(135deg, #ff7b7b, #6cc6ff, #87e39f);
}

.wilson-loop-notes {
  margin-top: 24px;
  padding: 22px 24px;
  background: var(--wilson-card-strong);
}

.wilson-loop-list {
  margin: 12px 0 18px 20px;
}

.wilson-loop-list li {
  margin-bottom: 8px;
}

.wilson-loop-notes h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  color: var(--wilson-accent);
}

@media (max-width: 960px) {
  .wilson-loop-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .wilson-loop-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .wilson-loop-actions {
    grid-template-columns: 1fr;
  }

  .wilson-loop-metric {
    flex-direction: column;
    align-items: flex-start;
  }
}
