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

body {
  font-family: 'Computer Modern Serif', serif;
  font-size: 15px;
  color: #111;
  background: #fcfcfc;
  line-height: 1.6;
}

/* ── Navigation ── */
nav {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

nav .nav-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: stretch;
}

.nav-link {
  font-family: 'Computer Modern Serif', serif;
  font-size: 1.05rem;
  font-weight: 400;
  color: #333;
  text-decoration: none;
  padding: 0.8rem 1rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.nav-home {
  font-weight: 700;
  color: #111;
}

.nav-link:hover {
  background: #f0f7ff;
  color: #036;
}

.nav-item {
  position: relative;
  display: flex;
}

.nav-item > .submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-top: none;
  list-style: none;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.nav-item:hover > .submenu {
  display: block;
}

.nav-item:hover > .submenu.submenu-sections {
  display: flex;
}

.submenu-col {
  list-style: none;
  padding: 0;
  margin: 0;
  min-width: 150px;
  white-space: nowrap;
}

.submenu-col:not(:last-child) {
  border-right: 2px solid #ccc;
}

.submenu li a {
  display: block;
  padding: 0.4rem 1.2rem;
  font-size: 1rem;
  color: #333;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.submenu li a:hover {
  background: #f0f7ff;
  color: #036;
}

/* ── Main content ── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
}

h1 {
  font-family: 'Computer Modern Serif', serif;
  font-size: 2.8rem;
  font-weight: 420;
  padding-top: 0.6rem;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

h2 {
  font-family: 'Computer Modern Serif', serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  color: #111;
  border-bottom: 2px solid #4a90d9;
  margin-bottom: 1.5rem;
}

h3 {
  font-family: 'Computer Modern Serif', serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.8rem;
}

p {
  font-size: 1.05rem;
  line-height: 1.6rem;
  margin-bottom: 0.4rem;
  text-align: justify;
}

a {
  color: #036;
  text-decoration: none;
  border-radius: 3px;
  transition: background 0.2s;
}

a:hover {
  background: #f0f7ff;
}

ul, ol {
  font-size: 1.05rem;
  line-height: 1.6rem;
  margin-bottom: 1rem;
  padding-left: 2rem;
}

code {
  font-family: 'Inconsolata', monospace;
  font-size: 0.9em;
  color: #600;
  background: #f5f5f5;
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

pre {
  margin: 1rem 0;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  overflow-x: auto;
}

pre code {
  display: block;
  padding: 0.2rem 1.2rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: inherit;
  background: none;
  border-radius: 0;
}

/* ── KaTeX display overrides ── */
.katex { font-size: 1em !important; white-space: nowrap; }

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

/* ── Theorem-like blocks ── */
.thm-block {
  margin: 0.5rem 0;
}

.thm-block p {
  text-align: left;
}

.thm-label {
  font-weight: 700;
  font-size: 1.05rem;
}

.proof {
  margin: 0 0 0.5rem 0;
  padding-left: 1.2rem;
  font-size: 1.05rem;
  line-height: 1.6rem;
}

/* Hide the proof summary entirely — the thm-label is the toggle */
.proof > .proof-label {
  display: none;
}

/* Clickable indicator on thm-labels that have a proof */
.thm-label.has-proof {
  cursor: pointer;
}

.thm-label.has-proof::before {
  content: '▸ ';
  color: #4a90d9;
}

.thm-label.has-proof.proof-open::before {
  content: '▾ ';
}

.proof-body {
  white-space: pre-line;
}


/* ── Language toggle ── */
html[lang="en"] .fr { display: none; }
html[lang="fr"] .en { display: none; }

.lang-toggle {
  margin-left: auto;
  display: flex;
  align-self: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
}

.lang-toggle button {
  padding: 0.35rem 0.6rem;
  font-family: 'Computer Modern Serif', serif;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  background: none;
  color: #999;
}

.lang-toggle button:not(:last-child) {
  border-right: 1px solid #ccc;
}

.lang-toggle button.active {
  background: #4a90d9;
  color: #fff;
}

.lang-toggle button:not(.active):hover {
  background: #f0f7ff;
  color: #4a90d9;
}

/* ── TSP page ── */
.tsp-section {
  margin-top: 1.2rem;
  margin-bottom: 0.8rem;
}

.tsp-map {
  width: 100%;
  height: 420px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 0.2rem;
  z-index: 0;
}

.tsp-map .leaflet-control-zoom {
  z-index: 999;
}

.tsp-status {
  font-size: 0.95rem;
  color: #555;
  min-height: 1.4em;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

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

.tsp-controls button {
  font-family: 'Computer Modern Serif', serif;
  font-size: 0.95rem;
  padding: 0.35rem 1rem;
  border: 1px solid #4a90d9;
  border-radius: 4px;
  background: #4a90d9;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s;
}

.tsp-controls button:hover {
  background: #3a7bc8;
  border-color: #3a7bc8;
}

.tsp-controls select {
  font-family: 'Computer Modern Serif', serif;
  font-size: 0.95rem;
  padding: 0.3rem 2rem 0.3rem 0.5rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555'/%3E%3C/svg%3E") no-repeat right 0.5rem center;
  appearance: none;
  cursor: pointer;
}

.tsp-controls label {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.tsp-info {
  font-size: 0.95rem;
  margin-left: 0.3rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  body { font-size: 14px; }

  nav .nav-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .nav-item > .submenu {
    position: static;
    box-shadow: none;
    border: none;
    border-left: 2px solid #e0e0e0;
    margin-left: 1rem;
  }

  .nav-item:hover > .submenu {
    display: block;
  }

  h1 { font-size: 2rem; }
}
