/* Explore TSPLIB95 — editorial design system */
:root {
  --bg: #faf9f6; --surface: #ffffff; --ink: #1a1a1a; --muted: #6b6b6b;
  --line: #e7e5df; --accent: #b4451f; --accent-weak: #f3e6df;
  --radius: 14px; --maxw: 1120px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #14130f; --surface: #1d1c17; --ink: #ece9e1; --muted: #9a968b;
  --line: #34322b; --accent: #e0794a; --accent-weak: #2a211a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.tnum { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.sub { color: var(--muted); }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 30px 22px 72px; }

/* Header */
.masthead { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 22px; }
.masthead h1 { font-family: var(--serif); font-weight: 600; font-size: 32px;
  letter-spacing: -0.015em; margin: 0; }
.masthead .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* Stat strip */
.stats { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 22px; }
.stat { border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
  font-size: 12.5px; color: var(--muted); background: var(--surface); letter-spacing: .02em; }
.stat b { color: var(--ink); font-family: var(--mono); }

/* Filter bar */
.filters { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px;
  align-items: end; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); }
.field input, .field select {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: 9px; padding: 9px 11px; font: inherit; width: 100%; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Buttons + toggles */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 8px 13px; cursor: pointer; font: inherit; line-height: 1;
  transition: border-color .12s, color .12s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.accent:hover { color: #fff; filter: brightness(1.06); }
[data-theme="dark"] .btn.accent { color: var(--bg); } /* dark ink on accent meets AA contrast */
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { border-color: var(--line); color: var(--ink); filter: none; }
.btn:focus-visible, a:focus-visible, .dl:focus-visible,
.toggle .track:focus-visible, thead th:focus-visible, tbody tr:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  user-select: none; font-size: 13.5px; }
.toggle .track { width: 40px; height: 22px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .15s; flex: none; }
.toggle .track[data-on="true"] { background: var(--accent); }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle .track[data-on="true"] .knob { transform: translateX(18px); }

/* Table */
.tablecard { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; padding: 13px 14px; white-space: nowrap;
  border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
thead th:hover { color: var(--ink); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--accent-weak); }
.tag { display: inline-block; font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); letter-spacing: .04em; }
.dl { font-size: 12px; padding: 4px 9px; border-radius: 7px; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); margin-right: 6px; }
.dl:hover { border-color: var(--accent); color: var(--accent); }

/* Detail panel (slide-in) */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0;
  pointer-events: none; transition: opacity .2s; z-index: 40; }
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }
.panel { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 94vw);
  background: var(--surface); border-left: 1px solid var(--line); z-index: 50;
  transform: translateX(101%); transition: transform .25s ease; display: flex;
  flex-direction: column; box-shadow: -16px 0 40px rgba(0,0,0,.08); }
.panel[data-open="true"] { transform: none; }
.panel > header { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line); }
.panel header h2 { font-family: var(--serif); margin: 0; font-size: 23px; letter-spacing: -0.01em; }
.panel .body { padding: 20px 22px; overflow: auto; }
.canvas-box { width: 100%; aspect-ratio: 1 / 1; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); display: block; }
.meta-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px;
  margin: 18px 0 0; font-size: 13px; }
.meta-grid dt { color: var(--muted); }
.meta-grid dd { margin: 0; font-family: var(--mono); word-break: break-word; }

/* Toolbar + footer */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 16px 0; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 8px; }
.foot { color: var(--muted); font-size: 12px; margin-top: 28px; }
.foot a:hover { color: var(--accent); }

::-webkit-scrollbar { height: 9px; width: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }

@media (max-width: 760px) {
  .filters { grid-template-columns: repeat(6, 1fr); }
  .field { grid-column: span 6 !important; }
  .panel { width: 100vw; }
  .masthead h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
