/* Styled after arenchvz.com: plain white page, black Verdana, classic blue links that fade on
   hover, bold headings with a rule underneath, no cards, shadows or rounded buttons.
   Light is the default; the "Dark mode" link in the nav switches to the site's dark palette. */
:root {
  --paper: #ffffff;       /* page background (the site's --bg) */
  --card: #ffffff;        /* behind canvases and overlays */
  --ink: #000000;         /* the site's --text */
  --muted: #666666;
  --rule: #bbbbbb;
  --accent: #0000ee;      /* the site's --link; also the color of i-hat */
  --visited: #551a8b;     /* the browser's classic purple for clicked links; marks the view you're on */
  --j: #cc3300;           /* j-hat */
  --k: #008040;           /* k-hat */
  --v: #8000a0;           /* v and Av */
  --eig: #b07800;         /* eigenvector lines */
  --good: #007a33;
  --bad: #cc0000;
  --grid: rgba(0, 0, 238, 0.22);
  --grid-faint: rgba(0, 0, 0, 0.07);
  --shade: rgba(0, 0, 238, 0.08);
  --font-body: Verdana, sans-serif;
  --font-mono: Menlo, Consolas, "Courier New", monospace;
  --font-math: Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #121212; --card: #121212; --ink: #eeeeee; --muted: #999999; --rule: #444444;
  --accent: #6699ff; --visited: #d0adf0; --j: #ff7a50; --k: #4cd08a; --v: #c08cff; --eig: #f0b937; --good: #5cc98f; --bad: #ff6b6b;
  --grid: rgba(102, 153, 255, 0.28); --grid-faint: rgba(238, 238, 238, 0.07); --shade: rgba(102, 153, 255, 0.14);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.45;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: 0.6; }
code { font-family: var(--font-mono); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* headings: plain bold Verdana like the rest of the site, with a line underneath */
h2 {
  font-size: 18px; font-weight: bold; margin: 0 0 10px;
  border-bottom: 1px solid var(--ink); padding-bottom: 2px;
}

/* ---------------- header: title, then a plain row of nav links */
.top { margin-bottom: 18px; }
.title { color: var(--ink); }
.title:hover { opacity: 1; }
.title h1 { font-size: 1.5em; font-weight: bold; margin: 0.83em 0 0.5em; }   /* sized like the site's h2 title */
.tabs, .tabs-inner { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 15px; }
.nav_link {
  color: var(--accent); background: none; border: none; padding: 0; font: inherit; cursor: pointer;
}
.nav_link:hover { opacity: 0.6; }
/* the site's own nav row (Home, Blog, ...) sits above the visualizer's view tabs */
.site_nav { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 15px; margin-bottom: 14px; }
/* the page and the view you're on are purple, like a link you've already clicked */
.site_nav .nav_link[aria-current="page"],
.tabs-inner .nav_link[aria-selected="true"] { color: var(--visited); }
/* the C++ library status line stays hidden unless the library fails to load.
   (it's hidden, not deleted, because app.js writes into it) */
.engine { display: none; margin: 10px 0 0; font-size: 14px; }
.engine.err { display: block; color: var(--bad); }

/* ---------------- shared bits */
.card { margin: 0; padding: 0; }
.small { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--ink); margin-bottom: 10px; padding-bottom: 2px; }
.row-between h2 { border: 0; padding: 0; margin: 0; }

/* buttons look like the site's links: blue text, fade on hover */
.chip, .btn {
  font: inherit; font-size: 16px; color: var(--accent); background: none;
  border: none; padding: 0; cursor: pointer; text-align: left;
}
.chip:hover, .btn:hover { opacity: 0.6; }
.btn:disabled { color: var(--muted); cursor: default; opacity: 1; }
.btn.primary { font-weight: bold; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; }

/* Tools | Examples switch: the current one reads as plain text, the other as a link */
.seg { display: inline-flex; gap: 12px; }
.seg button {
  font: inherit; font-size: 18px; font-weight: bold;
  color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer;
}
.seg button:hover { opacity: 0.6; }
.seg button[aria-selected="true"] { color: var(--ink); }
.seg button[aria-selected="true"]:hover { opacity: 1; }

input[type="range"] { width: 100%; accent-color: var(--accent); margin: 8px 0 0; }
input[type="checkbox"] { accent-color: var(--accent); }

/* ---------------- transform views (2D and 3D) */
#view-transform, #view-space { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.stage { position: relative; }
#plane, #space-canvas {
  display: block; width: 100%; aspect-ratio: 1 / 1; max-height: calc(100vh - 190px);
  touch-action: none; cursor: move; border: 1px solid var(--rule);
}
#space-canvas { cursor: grab; }
#space-canvas.dragging { cursor: grabbing; }
.view-reset {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  background: var(--card); padding: 2px 6px; font-size: 15px;
}
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; padding-top: 8px; font-size: 14px; color: var(--muted); }
.sw { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: 4px; }
.sw-i { background: var(--accent); } .sw-j { background: var(--j); } .sw-k { background: var(--k); } .sw-v { background: var(--v); }
.sw-e { background: repeating-linear-gradient(90deg, var(--eig) 0 4px, transparent 4px 7px); }
.hint { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.panel { display: grid; gap: 26px; }

.matrix-edit {
  display: inline-grid; gap: 6px; padding: 6px 10px; margin: 4px 0 10px;
  border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); border-radius: 6px;
}
.matrix-edit.one { grid-template-columns: 76px; margin: 0; }
.matrix-edit.two { grid-template-columns: repeat(2, 80px); }
.matrix-edit.three { grid-template-columns: repeat(3, 70px); }
.matrix-edit input {
  width: 100%; font: 16px var(--font-mono); text-align: center; padding: 5px 4px;
  border: 1px solid var(--muted); border-radius: 0; background: var(--paper); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.matrix-edit input.c-i { border-bottom: 3px solid var(--accent); }
.matrix-edit input.c-j { border-bottom: 3px solid var(--j); }
.matrix-edit input.c-k { border-bottom: 3px solid var(--k); }
.matrix-edit input.c-v { border-bottom: 3px solid var(--v); }
.matrix-edit input.aug { border-left: 2px dashed var(--muted); }
.matrix-edit input[aria-invalid="true"] { border-color: var(--bad); }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 12px; font-size: 16px; }
.v-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; }
.v-edit .v-name { font-size: 20px; color: var(--v); }
.v-edit .small { flex-basis: 100%; margin: 0; }

.readout { display: grid; gap: 10px; font-size: 16px; }
.readout h2 { margin-bottom: 0; }
.verdict { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pill { font-size: 15px; }
.pill::before { content: "\25B6\FE0E  "; font-size: 0.75em; }  /* the site's ▶ marker */
.pill.good { color: var(--good); } .pill.bad { color: var(--bad); } .pill.info { color: var(--ink); } .pill.warn { color: var(--eig); }
.kv { display: grid; grid-template-columns: 116px 1fr; gap: 6px 10px; align-items: baseline; margin: 0; }
.kv dt { color: var(--muted); font-size: 15px; }
.kv dd { margin: 0; font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.math { font-family: var(--font-math); font-style: italic; }
.mini { display: inline-grid; gap: 0 12px; padding: 0 8px; border-left: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink); border-radius: 4px; text-align: right; }

/* ---------------- row reduction */
#view-elimination { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr) minmax(200px, 270px); gap: 28px; align-items: start; }
.size-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 16px; margin-bottom: 12px; }
.size-row select { font: inherit; padding: 1px 4px; background: var(--paper); color: var(--ink); border: 1px solid var(--muted); border-radius: 0; }
#elim-grid { max-width: 100%; overflow-x: auto; }
#elim-grid input { min-width: 0; font-size: 15px; }
#elim-grid.dense { gap: 4px; padding: 6px 6px; }
#elim-grid.dense input { font-size: 13px; padding: 5px 0; }
#elim-grid input.fixed { color: var(--muted); background: transparent; border-style: dashed; cursor: default; }
.check:has(input:disabled) { color: var(--muted); }
.inv-note { flex-basis: 100%; font-size: 14px; color: var(--muted); }
.inv-note .btn { font-size: 14px; }
.big-matrix table.dense { font-size: 15px; }
.big-matrix table.dense td { padding: 6px 7px; }
.status { display: flex; gap: 14px; }
.op { font: 20px var(--font-mono); margin: 6px 0 14px; min-height: 30px; }
.big-matrix { overflow-x: auto; padding: 4px 0 8px; }
.big-matrix table { border-collapse: separate; border-spacing: 0; font: 18px var(--font-mono); font-variant-numeric: tabular-nums; }
.big-matrix td { padding: 7px 12px; text-align: right; position: relative; transition: background-color 0.25s; }
.big-matrix td.rl { color: var(--muted); font-size: 14px; padding-right: 10px; }
.big-matrix td.first { border-left: 2px solid var(--ink); border-radius: 6px 0 0 6px; }
.big-matrix td.lastc { border-right: 2px solid var(--ink); border-radius: 0 6px 6px 0; }
.big-matrix td.aug { border-left: 1.5px dashed var(--muted); }
.big-matrix tr.target td:not(.rl) { background: var(--shade); }
.big-matrix tr.source td.rl { color: var(--accent); font-weight: bold; }
.big-matrix td.pivot span { outline: 2px solid var(--eig); border-radius: 50%; padding: 1px 6px; }
.big-matrix td.changed { color: var(--accent); }
.stepper { display: flex; gap: 14px; align-items: center; }
.stepper input[type="range"] { margin: 0; flex: 1; min-width: 60px; }
.result { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 16px; display: grid; gap: 6px; }
.result p { margin: 0; }
.elim-list { position: relative; margin: 0; padding: 0 0 0 3.4em; font: 15px var(--font-mono); max-height: calc(100vh - 190px); overflow-y: auto; }
.elim-list li { padding: 2px 4px; cursor: pointer; color: var(--accent); }
.elim-list li:hover { opacity: 0.6; }
.elim-list li[aria-current="step"] { color: var(--ink); font-weight: bold; background: var(--shade); }
.elim-list li[aria-current="step"]:hover { opacity: 1; }

.foot { margin-top: 40px; font-size: 14px; color: var(--muted); }

@media (max-width: 1100px) {
  #view-elimination { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
  .elim-list { grid-column: 1 / -1; max-height: 220px; }
}
@media (max-width: 860px) {
  #view-transform, #view-space, #view-elimination { grid-template-columns: minmax(0, 1fr); }
  #plane, #space-canvas { max-height: none; }
}
@media (max-width: 600px) {
  body { font-size: 16px; padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
