:root {
  --bg: #0f1117;
  --surface: #161b22;
  --surface2: #1e2430;
  --border: #2d3548;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #34d399;
  --accent2: #60a5fa;
  --warn: #f59e0b;
  --danger: #f43f5e;
  --font: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 12px;
  --nav-w: 260px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 17px;
  overflow-x: hidden;
}

body.nav-open {
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

body.nav-open .nav-backdrop {
  display: block;
}

.mobile-header {
  display: none;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0.65rem max(1rem, env(safe-area-inset-right)) 0.65rem max(1rem, env(safe-area-inset-left));
  padding-top: max(0.65rem, env(safe-area-inset-top));
  background: rgba(15, 17, 23, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mobile-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.menu-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.menu-toggle:active {
  background: var(--border);
}

.menu-toggle-icon {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

nav.doc-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--nav-w);
  height: 100vh;
  height: 100dvh;
  padding: 1.25rem 1rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 40;
}

nav.doc-nav .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
  color: var(--text);
}

nav.doc-nav .sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

nav.doc-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

nav.doc-nav li {
  margin: 0.15rem 0;
}

nav.doc-nav a {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.6rem;
  min-height: 44px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

nav.doc-nav a:hover {
  background: var(--surface2);
  color: var(--text);
}

nav.doc-nav a:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

main {
  margin-left: var(--nav-w);
  flex: 1;
  padding: 2.5rem 3rem 4rem;
  max-width: 920px;
  min-width: 0;
}

section.slide {
  margin-bottom: 4rem;
  scroll-margin-top: 1.5rem;
}

section.slide h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
  line-height:1.2;
}

section.slide h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--accent);
}

section.slide h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

section.slide p,
section.slide li {
  color: #c9d1d9;
}

section.slide ul {
  padding-left: 1.25rem;
}

section.slide li {
  margin: 0.35rem 0;
}

.callout {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  font-size: 0.95rem;
}

.callout.warn {
  border-left-color: var(--warn);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.table-scroll table {
  margin: 0;
}

.table-scroll table.metrics {
  min-width: 100%;
}

@media (max-width: 600px) {
  .table-scroll table.metrics {
    min-width: 28rem;
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
  }

  nav.doc-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: min(18rem, 88vw);
    height: 100vh;
    height: 100dvh;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-left: max(1rem, env(safe-area-inset-left));
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }

  body.nav-open nav.doc-nav {
    transform: translateX(0);
  }

  main {
    margin-left: 0;
    width: 100%;
    max-width: none;
    padding: 1rem max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
    padding-bottom: max(3rem, env(safe-area-inset-bottom));
  }

  section.slide {
    scroll-margin-top: calc(3.75rem + env(safe-area-inset-top));
    margin-bottom: 2.75rem;
  }

  section.slide h1 {
    font-size: 1.55rem;
  }

  section.slide h2 {
    font-size: 1.2rem;
  }

  body {
    font-size: 16px;
  }

  .callout {
    font-size: 0.88rem;
    padding: 0.85rem 1rem;
    word-break: break-word;
  }

  #tuned-params {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    align-items: baseline;
  }

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

  select.model-select {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
    box-sizing: border-box;
  }

  .chart-card {
    padding: 1rem;
    margin: 1.1rem 0;
  }

  .chart-wrap {
    height: 260px;
  }

  .chart-wrap.tall {
    height: 300px;
  }

  .chart-wrap.short {
    height: 220px;
  }
}

@media (max-width: 480px) {
  main {
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
  }

  .chart-wrap {
    height: 220px;
  }

  .chart-wrap.tall {
    height: 260px;
  }

  .chart-wrap.short {
    height: 200px;
  }

  table.metrics,
  table.team-table {
    font-size: 0.82rem;
  }

  table.metrics th,
  table.metrics td,
  .team-table th,
  .team-table td {
    padding: 0.45rem 0.5rem;
  }
}

@media (min-width: 901px) {
  body.nav-open {
    overflow: visible;
    touch-action: auto;
  }

  body.nav-open .nav-backdrop {
    display: none !important;
  }

  nav.doc-nav {
    transform: none !important;
  }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.chart-card h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-wrap.tall {
  height: 400px;
}

.chart-wrap.short {
  height: 260px;
}

table.metrics {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0;
}

table.metrics th,
table.metrics td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
}

table.metrics th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
}

table.metrics td.num {
  font-family: var(--font-mono);
  text-align: right;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--accent);
  margin-right: 0.35rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface2);
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
}

.team-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.team-table th,
.team-table td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
}

.team-table th {
  background: var(--surface2);
}

footer.site {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

select.model-select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-family: var(--font);
  margin-bottom: 1rem;
}
