/* ============================================
   TRANSLATION EXPLORER — theorem.dev design system
   ============================================ */

/* Tokens are inherited from global.css when shipped into Hugo.
   This standalone block is a minimal mirror so the file works
   alone in preview. Safe to keep — it only sets defaults that
   global.css overrides when both are present. */
:root {
  --bg: #FFFFFF;
  --surface-subtle: #FCFCFC;
  --bg-surface: #F5F5F6;
  --surface: #F5F5F6;
  --surface-alt: #EAEAEC;
  --border: #E2E2E5;
  --border-strong: #CFCFD3;
  --ink: #0A0A0A;
  --text: #18181B;
  --text-muted: #52525B;
  --text-subtle: #71717A;
  --accent-soft: #DCEFFB;
  --accent-light: #7DD3FC;
  --accent: #0EA5E9;
  --accent-hover: #0284C7;
  --accent-deep: #0369A1;
  --secondary-soft: #FFE6D5;
  --secondary-light: #FB923C;
  --secondary: #F97316;
  --secondary-deep: #C2410C;
  --tertiary: #5F8A78;
  --tertiary-soft: #E0E9E4;
  --on-accent: #ffffff;

  --font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-mono-letter-spacing: 0.06em;
  --page-inset: clamp(28px, 6vw, 100px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   PAGE WRAPPER (preview only — Hugo shell on site)
   ============================================ */
.page-wrap {
  max-width: 100%;
  padding: 32px var(--page-inset) 80px;
  box-sizing: border-box;
}

/* ============================================
   EXPLORER ROOT
   ============================================ */
.explorer {
  /* Local control sizing — matched to theorem inline-control style */
  --control-btn-size: 34px;
  --explorer-radius: 0;
  --explorer-radius-lg: 0;

  /* All container/control outlines render in ink for a unified, deliberate edge */
  --border: var(--ink);
  --border-strong: var(--ink);

  max-width: 100%;
  margin: 0 auto;
  overflow: visible;
  padding-right: 8px;
  padding-bottom: 8px;
}

/* On-site Hugo shells already constrain the container */
.container:has(.explorer) {
  max-width: 100%;
  padding: 0 var(--page-inset);
  box-sizing: border-box;
  overflow-x: hidden;
}

/* ============================================
   HEADER — section bar + title
   ============================================ */
.explorer-header {
  margin-bottom: 18px;
  max-width: 1464px;
}

.explorer-header__bar {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}

.explorer-header__bar-label {
  display: inline-block;
  padding: 7px 14px;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.explorer-header__bar-line {
  flex: 1;
  height: 1px;
  background: var(--ink);
  margin-left: -1px;
}

.explorer-header h1 {
  /* Theorem DS: .s-mono-section
     mono · 600 · 15px · letter-spacing 0.08em · uppercase · ink */
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.explorer-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 4px;
  max-width: 70ch;
}

.explorer-description {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 18px;
  max-width: 70ch;
}

/* ============================================
   CONTROL BAR — tabs + search
   ============================================ */
.explorer-controls {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 100%;
  box-sizing: border-box;
}

/* Tabs: ink-shadow flat style, segmented */
.tab-switcher {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 0 var(--ink);
  border-radius: 0;
  overflow: hidden;
}

.tab-switcher .tab-btn {
  height: 100%;
  min-width: 90px;
  padding: 0 16px;
  border: none;
  border-right: 1px solid var(--ink);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-switcher .tab-btn:last-child {
  border-right: none;
}

.tab-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.tab-btn.active {
  background: var(--ink);
  color: #ffffff;
}

/* Standardized control bar — every direct child shares 36px height,
   1.5px ink border, and 3px ink box-shadow so the bar reads as one row
   of related elements. */
.explorer-controls > * {
  height: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
}

/* Search input — same ink-shadow chrome as tabs */
.search-box {
  flex: 0 1 auto;
  width: 260px;
  max-width: 100%;
  padding: 0;
  border: 1px solid var(--ink);
  background: var(--bg);
  box-shadow: 3px 3px 0 0 var(--ink);
  border-radius: 0;
}

.search-box input {
  width: 100%;
  height: 100%;
  padding: 0 12px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1;
  box-sizing: border-box;
}

.search-box input::placeholder {
  color: var(--text-subtle);
}

.search-box input:focus {
  outline: none;
}
.search-box:focus-within {
  background: var(--accent-soft);
}

/* Node count — sits inline, no chrome, just vertically centered text */
.explorer-controls .node-count {
  height: 36px;
  padding: 0 4px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   MAIN SPLIT — graph/list canvas + detail panel
   ============================================ */
.explorer-main {
  display: flex;
  gap: 16px;
  height: calc(100vh - 260px);
  min-height: 540px;
}

.explorer-content {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--ink);
  border-radius: var(--explorer-radius-lg);
  background: var(--bg);
  position: relative;
  overflow: hidden;
  transition: flex 0.3s ease;
  box-shadow: 6px 6px 0 0 var(--ink);
}

.view-container {
  display: none;
  height: 100%;
  position: relative;
}

.view-container.active {
  display: block;
}

/* ============================================
   GRAPH VIEW
   ============================================ */
#graph-view {
  position: relative;
  background: var(--surface-subtle);
  container-type: inline-size;
}

#edge-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#shadow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#cy {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* Graph controls cluster — clean flat */
.graph-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 10;
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
}

.graph-controls .zoom-group {
  display: flex;
  gap: 0;
}

.graph-controls .zoom-group button {
  border-radius: 0;
  border-right-width: 0;
}

.graph-controls .zoom-group button:first-child {
  border-radius: var(--explorer-radius) 0 0 var(--explorer-radius);
}

.graph-controls .zoom-group button:last-child {
  border-radius: 0 var(--explorer-radius) var(--explorer-radius) 0;
  border-right-width: 1px;
}

.zoom-controls {
  display: flex;
  gap: 6px;
}

.zoom-controls button {
  min-width: 36px;
  height: var(--control-btn-size);
  padding: 0 12px;
  font-weight: 500;
  font-size: 13px;
}

.graph-controls button {
  width: var(--control-btn-size);
  height: var(--control-btn-size);
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.graph-controls button:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.graph-controls button.spinning {
  animation: pulse 0.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.85); opacity: 0.7; }
}

.graph-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: var(--explorer-radius);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.04em;
  pointer-events: none;
  /* Compact pill on wide graphs (~360px sweet spot), shrinks to <100% of the
     container on narrow embeds so the hint wraps to 2-3 balanced lines instead
     of overflowing the canvas or sitting blank. */
  max-width: min(360px, calc(100% - 28px));
  white-space: normal;
  text-align: center;
  text-wrap: balance;
  z-index: 10;
}

/* ============================================
   LIST VIEW

   Layout: each row (header + data) is its own grid using the SAME shared
   `--list-grid-cols` template AND the same fixed `min-width`. That second part
   matters — without it, every row sizes its columns from its own content
   (long module names blow up column 3, badges shrink column 2), so columns
   never line up across rows. Forcing a shared minimum width makes the fr
   distribution deterministic and identical across all rows.
   ============================================ */
#list-view {
  display: none;
  flex-direction: column;
  background: var(--bg);
  /* All `auto` track sizing in the template below uses these explicit minimums.
     Sum (incl. 7×4px gaps + 2×16px padding) ≈ 738px, which is the min-width
     enforced on every row so the inner scroller can scroll horizontally below
     that without breaking column alignment. */
  --list-grid-cols:
    minmax(120px, 1.6fr)  /* Name */
    minmax(90px,  1fr)    /* Difficulty (badge) */
    minmax(120px, 1.4fr)  /* Module */
    minmax(54px,  0.55fr) /* Deps */
    minmax(72px,  0.7fr)  /* Rocq LoC */
    minmax(80px,  0.8fr)  /* Rocq Chars */
    minmax(72px,  0.7fr)  /* Iso LoC */
    minmax(80px,  0.8fr); /* Iso Chars */
  --list-min-width: 738px;
}

#list-view.active {
  display: flex;
}

/* Outer scroller: handles horizontal overflow when the container is narrower
   than --list-min-width, so the header and rows scroll together. */
.list-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: hidden;
}

.list-header,
.list-row {
  display: grid;
  grid-template-columns: var(--list-grid-cols);
  align-items: center;
  gap: 4px;
  min-width: var(--list-min-width);
  box-sizing: border-box;
}

.list-header {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

#list-content {
  flex: 1;
  overflow-y: auto;
  min-width: var(--list-min-width);
}

.list-row {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  transition: background 0.1s ease;
}

.list-row:hover {
  background: var(--accent-soft);
}

.list-cell {
  padding: 0 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-cell.sortable {
  cursor: pointer;
  transition: color 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.list-cell-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-cell.sortable:hover {
  color: var(--accent);
}

/* Sort indicator: dim by default, accent + bold for the active column. */
.sort-indicator {
  flex-shrink: 0;
  display: inline-block;
  width: 10px;
  text-align: center;
  font-size: 11px;
  line-height: 1;
  color: var(--text-subtle);
  opacity: 0.55;
  font-weight: 500;
  transition: color 0.12s ease, opacity 0.12s ease;
}

.list-cell.sortable[data-active="true"] .sort-indicator {
  color: var(--ink);
  opacity: 1;
  font-weight: 700;
}

.list-cell.sortable:hover .sort-indicator {
  color: var(--accent);
  opacity: 1;
}

.list-row .name-cell {
  color: var(--text);
  font-weight: 500;
}

.list-row .name-cell code,
.list-cell code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: var(--font-mono-letter-spacing);
}

/* Numeric cells: tabular-nums so digits line up across rows. */
.list-row .num-cell {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.list-row .num-cell.empty {
  color: var(--text-subtle);
}

/* Difficulty badges — theorem-flavored */
.difficulty-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.difficulty-easy {
  background: var(--tertiary-soft);
  color: #2f5b48;
}
.difficulty-medium {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.difficulty-hard {
  background: var(--secondary-soft);
  color: var(--secondary-deep);
}
.difficulty-extreme {
  background: var(--ink);
  color: #ffffff;
}

/* ============================================
   DETAIL PANEL
   ============================================ */
.detail-panel {
  flex: 0 0 0;
  width: 0;
  background: var(--bg);
  border: 0 solid var(--ink);
  border-radius: var(--explorer-radius-lg);
  overflow: hidden;
  transition: flex 0.3s ease, width 0.3s ease, padding 0.3s ease;
  padding: 0;
}

.detail-panel.open {
  flex: 1 1 0;
  width: 50%;
  padding: 22px;
  overflow-y: auto;
  border-width: 1px;
  box-shadow: 6px 6px 0 0 var(--ink);
  border-radius: 0;
}

.detail-header {
  position: relative;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-nav {
  display: flex;
  gap: 4px;
}

.nav-btn,
.close-btn {
  width: var(--control-btn-size);
  height: var(--control-btn-size);
  border: 1px solid var(--ink);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  border-radius: 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
  box-shadow: 2px 2px 0 0 var(--ink);
}

.close-btn {
  font-size: 16px;
  line-height: 1;
  /* Push the close button to the far right of .detail-top-row so it sits
     opposite the back/forward nav and solution dropdown. */
  margin-left: auto;
}

.nav-btn:hover:not(:disabled),
.close-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Custom solution dropdown — ink-chrome to match the button row */
.solution-dd {
  position: relative;
  flex-shrink: 0;
  max-width: 240px;
}

.solution-dd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: var(--control-btn-size);
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 2px 2px 0 0 var(--ink);
  max-width: 100%;
}

.solution-dd-trigger:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.solution-dd-trigger:focus-visible {
  outline: none;
  box-shadow: 2px 2px 0 0 var(--ink), 0 0 0 3px var(--accent-soft);
}

.solution-dd-trigger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.solution-dd-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.solution-dd-caret {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.solution-dd[data-open="true"] .solution-dd-caret {
  transform: rotate(180deg);
}

.solution-dd[data-single="true"] .solution-dd-caret {
  display: none;
}

.solution-dd[data-single="true"] .solution-dd-trigger {
  cursor: default;
  pointer-events: none;
  padding-right: 12px;
}

.solution-dd-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: 4px 4px 0 0 var(--ink);
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
}

.solution-dd-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.solution-dd-option:last-child {
  border-bottom: none;
}

.solution-dd-option:hover,
.solution-dd-option[data-active="true"] {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.solution-dd-option[aria-selected="true"] {
  background: var(--ink);
  color: var(--bg);
}

.solution-dd-option[aria-selected="true"]:hover {
  background: var(--ink);
  color: var(--bg);
}

.solution-dd-option-check {
  width: 10px;
  flex-shrink: 0;
  display: inline-flex;
  justify-content: center;
}

.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.detail-title-row h2 {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.detail-short-name {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: var(--font-mono-letter-spacing);
  margin: 0;
  word-break: break-all;
}

.detail-section {
  margin-bottom: 22px;
}

.detail-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.deps-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dep-tag {
  padding: 4px 8px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: var(--explorer-radius);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--font-mono-letter-spacing);
  cursor: pointer;
  color: var(--accent-deep);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.dep-tag:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.total-deps {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  margin-top: 8px;
}

/* Touch active feedback */
.tab-btn:active,
.graph-controls button:active,
.nav-btn:active:not(:disabled),
.close-btn:active,
.pagination-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.list-row:active,
.dep-tag:active {
  background: var(--accent-soft);
}

/* ============================================
   CODE BLOCKS
   ============================================ */
.code-display {
  width: 100%;
  min-height: 180px;
  max-height: 460px;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  letter-spacing: var(--font-mono-letter-spacing);
  background: var(--surface-subtle);
  color: var(--text);
  white-space: pre;
  margin: 0;
  box-sizing: border-box;
  resize: vertical;
}

.github-link {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  text-decoration: none;
  margin-left: 8px;
  font-weight: 500;
  text-transform: none;
  transition: color 0.12s ease;
}

.github-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Highlighted line in code blocks */
.highlight-line {
  display: inline-block;
  width: calc(100% + 1.75rem);
  background: var(--accent-soft);
  margin: 0 -14px;
  padding: 0 14px;
  border-left: 3px solid var(--accent);
}

/* Stacked source panels */
.source-split {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.source-panel {
  flex: none;
  display: flex;
  flex-direction: column;
}

.source-panel .code-display {
  height: 200px;
  min-height: 120px;
  max-height: 520px;
}

.source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.page-loading {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 99999;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: opacity 0.3s ease;
}

.page-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   PAGINATION
   ============================================ */
.list-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: nowrap;
  position: sticky;
  bottom: 0;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--explorer-radius);
  font-family: var(--font-mono);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.pagination-btn:hover:not(:disabled):not(.active) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.pagination-btn.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-btn.pagination-arrow {
  font-size: 16px;
  font-weight: 400;
  padding: 0 12px;
}

.pagination-ellipsis {
  color: var(--text-subtle);
  padding: 0 4px;
  font-size: 12px;
}

.pagination-info {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-left: 8px;
  white-space: nowrap;
}

/* ============================================
   MEDIUM WIDTHS — keep side-by-side, bump touch sizes
   ============================================ */
@media (max-width: 900px) {
  .explorer {
    --control-btn-size: 44px;
  }

  #graph-view {
    touch-action: pan-x pan-y pinch-zoom;
  }

  .pagination-btn {
    min-width: 44px;
    height: 44px;
  }
}

/* ============================================
   PHONE — stack vertically only on truly narrow viewports
   ============================================ */
@media (max-width: 600px) {
  .explorer-main {
    flex-direction: column;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .explorer-content {
    flex: none;
    min-height: 250px;
    overflow: hidden;
  }

  #list-view.active {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  #list-content {
    flex: 1;
    min-height: 280px;
    max-height: calc(60vh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .detail-panel.open {
    flex: none;
    height: auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .detail-panel.open::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border-strong);
    border-radius: 0;
    margin: 0 auto 14px;
  }

  .code-display {
    min-height: 120px;
    max-height: 320px;
    -webkit-overflow-scrolling: touch;
  }
}

@supports (height: 100dvh) {
  @media (max-width: 600px) {
    .explorer-content {
      height: 55dvh;
      max-height: 55dvh;
    }
    #list-content {
      max-height: calc(55dvh - 80px);
    }
  }
}

@media (max-width: 768px) {
  .explorer-header h1 {
    font-size: 14px;
  }

  .explorer-controls {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .tab-btn {
    height: 44px;
    min-width: 70px;
    padding: 0 12px;
    font-size: 11px;
  }

  .search-box {
    width: 100%;
    flex: 1;
    min-width: 140px;
    max-width: none;
  }

  .search-box input {
    height: 44px;
    font-size: 16px;
  }

  .graph-controls {
    top: 8px;
    right: 8px;
    padding: 6px;
  }

  .zoom-controls button {
    min-width: 44px;
    height: 44px;
  }

  .hint-desktop { display: none; }
  .hint-mobile { display: inline; }

  .code-display {
    font-size: 11.5px;
    min-height: 100px;
    max-height: 260px;
  }
}

/* Phone-only: set the canvas height now that the layout stacks */
@media (max-width: 600px) {
  .explorer-content {
    height: 55vh;
    max-height: 55vh;
  }
}

@media (max-width: 480px) {
  .explorer-header h1 {
    font-size: 13px;
  }

  /* Tighten list padding on phones; horizontal scroll keeps the 8 columns
     readable rather than collapsing data. */
  .list-header,
  .list-row {
    padding: 8px 12px;
    font-size: 12.5px;
  }

  .detail-panel.open {
    padding: 14px;
  }

  .detail-title-row h2 {
    font-size: 1rem;
  }

  .code-display {
    font-size: 11px;
    min-height: 90px;
    max-height: 220px;
    padding: 10px;
  }
}
