/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafafa;
  --fg: #1a1a2e;
  --muted: #555;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --border: #e2e8f0;
  --card-bg: #fff;
  --radius: 8px;
  --max-w: 1180px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--fg); background: var(--bg); line-height: 1.7; }

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }

/* --- Header --- */
.site-header {
  background: var(--fg);
  color: #fff;
  padding: 3rem 0 2.5rem;
  text-align: center;
  position: relative;
  z-index: 30;
}
.site-header h1 { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.02em; }
.site-header .subtitle { font-size: 1.1rem; opacity: 0.8; margin-top: 0.5rem; max-width: 600px; margin-left: auto; margin-right: auto; }
.header-nav { margin-top: 1.5rem; display: flex; gap: 1.5rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.header-nav a { color: rgba(255,255,255,0.7); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.2s; }
.header-nav a:hover { color: #fff; }
.nav-dropdown {
  position: relative;
  color: rgba(255,255,255,0.7);
}
.nav-dropdown summary {
  cursor: pointer;
  list-style: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-dropdown summary::-webkit-details-marker {
  display: none;
}
.nav-dropdown summary::after {
  content: "▾";
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  transform: translateY(-0.05rem);
}
.nav-dropdown[open] summary,
.nav-dropdown summary:hover {
  color: #fff;
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  left: 50%;
  z-index: 20;
  display: none;
  width: 250px;
  padding: 0.55rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.24);
  text-align: left;
  transform: translateX(-50%);
}
.nav-dropdown[open] .nav-dropdown-menu {
  display: block;
}
.nav-dropdown-menu a {
  display: block;
  padding: 0.45rem 0.55rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--fg);
  line-height: 1.25;
}
.nav-dropdown-menu a:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.nav-dropdown-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: transparent;
}
.nav-dropdown-backdrop[hidden] {
  display: none;
}

/* --- Landing links --- */
.link-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}
.link-card {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  gap: 0.7rem;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(255, 255, 255, 0) 55%),
    var(--card-bg);
  color: var(--fg);
  text-decoration: none;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.link-card:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.42);
  box-shadow: 0 22px 58px rgba(37, 99, 235, 0.12);
}
.link-card-kicker {
  width: fit-content;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.link-card strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.2;
}
.link-card span:last-child {
  color: var(--muted);
  font-size: 0.92rem;
}

/* --- Sections --- */
section { padding: 3rem 0; }
section + section { border-top: 1px solid var(--border); }

h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--fg);
}
h3 { font-size: 1.15rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
p { margin-bottom: 1rem; color: var(--muted); }
p.section-lead { font-size: 1.05rem; margin-bottom: 2rem; }
.dataset-box { border: 1px solid #ddd; border-radius: 8px; padding: 1rem 1.25rem; margin: 0 0 2rem 0; background: #fafafa; }
.dataset-box p { margin: 0 0 0.5rem 0; }
.dataset-box-title { font-weight: 700; font-size: 1.05rem; }
.dataset-link { display: inline-block; margin: 0.25rem 1rem 0 0; font-weight: 600; text-decoration: underline; }

.overview-link-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.35rem;
  margin-top: 1.5rem;
}
.overview-link-group {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  justify-content: flex-start;
  padding: 1.3rem 1.35rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  background:
    linear-gradient(145deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0) 55%),
    var(--card-bg);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.06);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.overview-link-group:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 22px 52px rgba(37, 99, 235, 0.12);
}
.overview-link-group h3 {
  margin: 0 0 0.75rem;
  font-size: 1.12rem;
  line-height: 1.25;
}
.overview-link-group h3 a {
  color: var(--fg);
  text-decoration: none;
}
.overview-link-group h3 a:hover {
  color: var(--accent);
}
.overview-link-group p {
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  line-height: 1.55;
}
.overview-link-group ul {
  margin: auto 0 0;
  padding-left: 1rem;
}
.overview-link-group li {
  margin: 0.45rem 0;
  color: var(--muted);
  line-height: 1.45;
}
.overview-link-group li ul {
  margin-top: 0.35rem;
  padding-left: 1.15rem;
}
.overview-link-group a {
  color: var(--muted);
  text-decoration: none;
}
.overview-link-group a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.results-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: -0.5rem 0 2rem;
}
.results-nav a,
.results-nav-group > span {
  display: inline-flex;
  align-items: center;
  min-height: 2.15rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--fg);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
}
.results-nav a:hover {
  border-color: rgba(37, 99, 235, 0.42);
  color: var(--accent);
}
.results-nav-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.results-nav-group > span {
  background: var(--fg);
  color: #fff;
}

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.training-card-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-body { padding: 1rem 1.25rem; }
.card-body h4 { font-size: 1rem; font-weight: 600; margin-bottom: 0.3rem; }
.card-body p { font-size: 0.88rem; margin-bottom: 0.3rem; }

/* --- Tags --- */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  margin-right: 0.35rem;
  margin-top: 0.3rem;
}
.tag-virtuoso,
.tag-teacher,
.tag-advanced,
.tag-intermediate,
.tag-novice,
.tag-child-professional,
.tag-child-beginner,
.tag-adult-beginner,
.tag-adult-intermediate {
  background: #dcfce7;
  color: #166534;
}
.tag-concert,
.tag-sightread,
.tag-slow-demo,
.tag-demo,
.tag-practice,
.tag-showcase {
  background: #dbeafe;
  color: #1e40af;
}

/* --- YouTube embed --- */
.yt-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}
.yt-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- MIDI player --- */
.midi-example { margin-bottom: 2rem; }
.midi-single { margin-top: 0.75rem; max-width: 480px; }
.midi-quad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}
.midi-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}
.midi-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.midi-item h5 { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
audio { display: block; width: 100%; margin-top: 0.25rem; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
thead { background: var(--fg); color: #fff; }
th { padding: 0.6rem 0.8rem; text-align: left; font-weight: 600; }
td { padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--accent-light); }
.num { font-family: var(--mono); font-size: 0.85rem; }
.best { font-weight: 700; color: var(--accent); }

/* --- UMP plots --- */
.ump-comparison {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.ump-comparison > p { max-width: 760px; }
.ump-example { margin-top: 1.5rem; }
.ump-example h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.ump-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.ump-pair figure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
}
.ump-pair figcaption {
  padding: 0.55rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.ump-pair img {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Embedding Spaces overview --- */
.space-card-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.75rem;
}
.space-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.75rem;
  align-items: center;
  padding: 1.6rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.10), rgba(255, 255, 255, 0) 60%),
    var(--card-bg);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.space-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 22px 55px rgba(37, 99, 235, 0.12);
}
.space-card-kicker {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.space-card h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
  color: var(--fg);
}
.space-card p {
  margin-bottom: 0.6rem;
  font-size: 0.98rem;
  line-height: 1.6;
}
.space-card p:last-child { margin-bottom: 0; }
.space-card-prompt {
  font-size: 0.92rem;
  color: var(--fg);
}
.space-card-prompt strong { color: var(--accent); }

.space-card-cta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.space-card-launch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.95rem 1.4rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.28);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.space-card-launch:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 16px 38px rgba(37, 99, 235, 0.36);
}
@media (max-width: 800px) {
  .space-card { grid-template-columns: 1fr; }
  .space-card-cta { justify-content: flex-start; }
}

/* --- Abstract --- */
.abstract {
  background: var(--card-bg);
  border-left: 4px solid var(--accent);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 2rem;
}
.abstract p { margin: 0; font-size: 0.95rem; color: var(--fg); }

/* --- Footer --- */
/* .site-footer { padding: 2rem 0; text-align: center; border-top: 1px solid var(--border); }
.site-footer p { font-size: 0.85rem; } */

.back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: var(--fg);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.82;
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
}
.back-to-top:hover {
  opacity: 1;
  transform: translateY(-2px);
  background: var(--accent);
}

/* --- Responsive --- */
@media (max-width: 1000px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .training-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .link-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-link-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .midi-quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .training-card-grid { grid-template-columns: 1fr; }
  .link-card-grid { grid-template-columns: 1fr; }
  .overview-link-row { grid-template-columns: 1fr; }
  .midi-quad { grid-template-columns: 1fr; }
  .midi-pair { grid-template-columns: 1fr; }
  .ump-pair { grid-template-columns: 1fr; }
  .site-header h1 { font-size: 1.8rem; }
  .back-to-top { right: 0.85rem; bottom: 0.85rem; }
}
