:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #10212b;
  --muted: #5b6770;
  --accent: #c3343b;
  --accent-soft: #f4d8c8;
  --border: rgba(16, 33, 43, 0.08);
  --shadow: 0 18px 40px rgba(16, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

.page {
  max-width: 1800px;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 74px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.1vw, 2.15rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-align: center;
}

.basis-block {
  margin-bottom: 10px;
}

.basis-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.basis-select {
  width: 100%;
  border: 1px solid rgba(16, 33, 43, 0.12);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 0.84rem;
}

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

.loading-indicator {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(16, 33, 43, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(16, 33, 43, 0.12);
  color: var(--text);
}

.app-switch-link {
  position: fixed !important;
  top: 18px;
  left: max(18px, calc((100vw - 1800px) / 2 + 18px));
  z-index: 80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid #0a84ff;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #0a84ff;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(16, 33, 43, 0.12);
}

.app-switch-link:hover {
  background: #0a84ff;
  color: #ffffff;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(16, 33, 43, 0.14);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.brain-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.brain-plot {
  min-height: 220px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
}

.composite-body {
  display: block;
}

.threshold-panel {
  padding: 14px 18px;
}

.threshold-block {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.threshold-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.25;
}

.threshold-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.threshold-btn {
  min-width: 54px;
  border: 1px solid #0a84ff;
  border-radius: 999px;
  background: #ffffff;
  color: #0a84ff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  padding: 7px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.threshold-btn.active {
  background: #0a84ff;
  color: #ffffff;
}

.threshold-btn:disabled {
  border-color: #d3dde7;
  color: #97a7b7;
  background: #f8fafc;
  cursor: not-allowed;
}

.value-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff3ef;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.84rem;
}

.value-input {
  width: 82px;
  padding: 6px 10px;
  border: 1px solid rgba(16, 33, 43, 0.08);
  border-radius: 999px;
  background: #fff3ef;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  font-size: 0.84rem;
  text-align: center;
}

.value-input:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.value-pill.subtle {
  background: rgba(16, 33, 43, 0.06);
  color: var(--text);
}

.slider-wrap {
  padding: 4px 2px 2px;
}

.dj-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.dj-slider:disabled {
  cursor: not-allowed;
}

.composite-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: center;
}

.effective-mix {
  color: var(--text);
  font-weight: 600;
  width: 100%;
  text-align: center;
}

.matches-panel {
  padding: 18px;
}

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

.matches-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.matches-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px;
}

.match-card {
  border: 1px solid rgba(16, 33, 43, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  padding: 10px;
  text-align: left;
}

.match-plot {
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
}

.match-title {
  margin-top: 9px;
  font-size: 0.89rem;
  font-weight: 700;
  line-height: 1.3;
}

.empty-state {
  padding: 20px 16px;
  border: 1px dashed rgba(16, 33, 43, 0.12);
  border-radius: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.6);
}

.footer {
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 2px 4px 8px;
  color: #516173;
  font-size: 0.9rem;
  text-align: left;
}

.paper-link,
.github-link {
  color: inherit;
  text-decoration: none;
}

.paper-link {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.paper-link:hover,
.github-link:hover {
  text-decoration: underline;
}

@media (max-width: 1300px) {
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .page {
    padding: 12px;
  }

  .loading-indicator {
    top: 12px;
    right: 12px;
  }

  .matches-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer {
    max-width: 100%;
    font-size: 0.78rem;
  }
}

@media (max-width: 700px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

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

  .composite-body {
    grid-template-columns: 1fr;
  }

  .threshold-panel {
    padding: 12px;
  }
}
