:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5f6673;
  --border: #dfe2e8;
  --accent: #2458d6;
  --accent-text: #ffffff;
  --up: #137a3a;
  --down: #b3261e;
  --warn-bg: #fff4d6;
  --error-bg: #fde7e6;
  --success-bg: #e3f5e9;
  --info-bg: #e6eefc;
  --radius: 10px;
  --gap: 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --border: #2d323b;
    --accent: #6b93f2;
    --accent-text: #0d1117;
    --up: #56c47f;
    --down: #f2807a;
    --warn-bg: #3a3017;
    --error-bg: #3d1d1b;
    --success-bg: #173222;
    --info-bg: #19263f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  flex: 1;
}

.top nav a, .subnav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 2px solid transparent;
}

.top nav a[aria-current="page"], .subnav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.top nav.tabs a { font-weight: 600; }

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.signout {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.who {
  color: var(--muted);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

h1 { font-size: 1.6rem; margin: 0 0 0.25rem; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.page-head { margin-bottom: var(--gap); }
.sub { color: var(--muted); font-size: 0.9rem; font-weight: normal; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0 0; }
.empty { color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: var(--gap);
}

.panel.narrow { max-width: 28rem; margin-left: auto; margin-right: auto; }
.panel.danger { border-color: var(--down); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin-bottom: var(--gap);
}

.stats div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.stats span { display: block; color: var(--muted); font-size: 0.85rem; }
.stats strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.panel .stats div { background: var(--bg); }

.up { color: var(--up); }
.down { color: var(--down); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.me td { background: var(--info-bg); }
td .detail { display: block; margin-top: 0.15rem; }
td.action { width: 1%; text-align: right; }
.symbol { white-space: nowrap; }
/* Two classes, to outrank the .btn and .btn-quiet padding set further down. */
.btn-quiet.btn-small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.table-wrap + form { display: block; margin-top: 0.75rem; }

.notice {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  margin: 0 0 var(--gap);
}

.notice-error { background: var(--error-bg); }
.notice-success { background: var(--success-bg); }
.notice-warn { background: var(--warn-bg); }
.notice-info { background: var(--info-bg); }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--text);
}

.stack { display: grid; gap: 0.75rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.form-grid h2, .form-grid .hint { grid-column: 1 / -1; }
.form-grid > .btn { grid-column: 1 / -1; justify-self: start; }

/* One field per row, for a form whose fields differ in size. */
.form-long > * { max-width: 40rem; }
.form-long h2 { margin-bottom: 0; }
input.short { max-width: 12rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.actions .hint { margin: 0; }

label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
label small { font-weight: normal; color: var(--muted); }

input, select, textarea {
  font: inherit;
  font-weight: normal;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  width: 100%;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:user-invalid, textarea:user-invalid { border-color: var(--down); }

.btn, .btn-quiet {
  font: inherit;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.btn {
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  font-weight: 600;
}

.btn-danger { background: var(--down); border-color: var(--down); }

.btn-quiet {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}

.inline { display: inline; }

.search { display: flex; gap: 0.5rem; margin-bottom: var(--gap); }
.search input { flex: 1; }
.search .btn { width: auto; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.cards li { display: grid; gap: 0.15rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.cards li:last-child { border-bottom: none; }

.plain { margin: 0; padding-left: 1.2rem; }
.steps { margin: 0 0 1rem; padding-left: 1.3rem; display: grid; gap: 0.35rem; }

code { font-size: 0.9em; overflow-wrap: anywhere; }
.steps code, .hint code { white-space: nowrap; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 40rem) {
  .signout { width: 100%; justify-content: space-between; }
}

/* Reacts cheat sheet */
.react-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: 0.75rem;
}

.react {
  display: grid;
  grid-template-rows: auto 1fr;
  /* A video or audio player's own minimum width must not widen the column. */
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.react-media {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  /* Holds the box to its ratio: an image of another shape can't stretch it. */
  overflow: hidden;
  background: var(--bg);
}

.react-media img, .react-media video {
  width: 100%;
  height: 100%;
  min-width: 0;
  object-fit: contain;
}

.react-media audio { width: 92%; min-width: 0; }

.react-command {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
}

/* One click selects the whole command, for copying by hand without the script. */
.command { user-select: all; overflow-wrap: anywhere; min-width: 0; }

/* The Copy button needs the script, which marks the page once it runs. */
.copy { display: none; flex-shrink: 0; }
.js .copy { display: inline-block; }

/* Docs: the command guide */
.guide-toc { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem 1.5rem; }
.guide-toc h2 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.guide-toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.guide-toc a { text-decoration: none; }
.guide-group { margin: 1.75rem 0 0.75rem; font-size: 1.3rem; }
.guide-command { scroll-margin-top: 1rem; }
.guide-command h3 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.guide-command h3 code { font-size: 1.05em; }
.guide-command h4 { font-size: 0.9rem; margin: 1rem 0 0.4rem; color: var(--muted); }
.guide-command p { margin: 0 0 0.6rem; max-width: 46rem; }
.guide-usage td:first-child { width: 45%; }
.guide-plain { margin: 0; display: grid; gap: 0.5rem; }
.guide-plain dt { font-weight: 600; }
.guide-plain dd { margin: 0; color: var(--muted); }
.guide-examples { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.guide-examples li { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.guide-examples pre {
  margin: 0;
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.guide-notes { margin-top: 0.75rem; color: var(--muted); font-size: 0.9rem; }

/* Stock tab: an amber-phosphor homage to the 1980s market terminal. */
.fkey { display: none; }

body.terminal {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --text: #ffb000;
  --muted: #b07a00;
  --data: #f2f2e6;
  --border: #4a3300;
  --accent: #ffd400;
  --accent-text: #000000;
  --up: #3cff6e;
  --down: #ff4136;
  --go: #20b84a;
  --warn-bg: #000000;
  --error-bg: #000000;
  --success-bg: #000000;
  --info-bg: #1c1400;
  --radius: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  font-size: 15px;
  text-shadow: 0 0 2px rgba(255, 176, 0, 0.45);
  background:
    radial-gradient(ellipse at center, #120c00 0%, #000 75%) fixed;
}

/* Scanlines over the whole screen; never in the way of a click. */
body.terminal::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
}

.terminal h1, .terminal h2, .terminal th, .terminal label,
.terminal .top nav a, .terminal .subnav a, .terminal .stats span,
.terminal .btn, .terminal .btn-quiet, .terminal .badge {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.terminal a { color: var(--accent); text-decoration: none; }
.terminal a:hover { background: var(--accent); color: #000; text-shadow: none; }

.terminal .top {
  background: #000;
  border-bottom: 1px solid var(--text);
}

.terminal .brand {
  background: var(--text);
  color: #000;
  padding: 0 0.4rem;
  text-shadow: none;
}

.terminal .brand::after {
  content: "\2588";
  color: var(--text);
  background: #000;
  margin-left: 0.4rem;
  animation: terminal-blink 1s steps(1) infinite;
}

@keyframes terminal-blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .terminal .brand::after { animation: none; }
}

.terminal .top nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }

.terminal .subnav {
  background: #000;
  border-bottom: 1px dashed var(--border);
  gap: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.terminal .subnav a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem 0.1rem 0.1rem;
}

.terminal .fkey {
  display: inline-block;
  min-width: 2.6em;
  text-align: center;
  padding: 0 0.25rem;
  background: #e8c200;
  color: #000;
  font-weight: 700;
  text-shadow: none;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
}

.terminal .subnav a[aria-current="page"] {
  color: #000;
  background: var(--text);
  border-color: var(--text);
  text-shadow: none;
}

.terminal .subnav a:hover { color: #000; }

.terminal h1 {
  color: var(--data);
  font-size: 1.35rem;
  border-bottom: 1px dashed var(--text);
  padding-bottom: 0.25rem;
}

.terminal .sub, .terminal .hint, .terminal .empty, .terminal label small { color: var(--muted); }

.terminal .panel {
  border: 1px solid var(--text);
  padding: 0.85rem;
}

/* A panel's title is a reverse-video strip across its top edge. */
.terminal .panel > h2:first-child {
  margin: -0.85rem -0.85rem 0.75rem;
  padding: 0.15rem 0.85rem;
  background: var(--text);
  color: #000;
  font-size: 0.95rem;
  text-shadow: none;
}

.terminal .panel > h2:first-child .sub { color: #3a2600; }

.terminal .stats div {
  background: #000;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
}

.terminal .stats span { color: var(--muted); font-size: 0.75rem; }
.terminal .stats strong { color: var(--data); }
.terminal .panel .stats div { background: #000; }

.terminal .up { color: var(--up); text-shadow: 0 0 3px rgba(60, 255, 110, 0.5); }
.terminal .down { color: var(--down); text-shadow: 0 0 3px rgba(255, 65, 54, 0.5); }

.terminal th {
  color: var(--text);
  font-size: 0.75rem;
  border-bottom: 1px solid var(--text);
}

.terminal td {
  color: var(--data);
  border-bottom: 1px dotted var(--border);
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.terminal tbody tr:hover td { background: #1c1400; }
.terminal tr.me td { background: #2a1d00; }

.terminal .notice { background: #000; border: 1px solid; border-left-width: 6px; }
.terminal .notice-error { color: var(--down); }
.terminal .notice-success { color: var(--up); }
.terminal .notice-warn { color: var(--accent); }
.terminal .notice-info { color: var(--text); }

.terminal .badge { background: var(--text); color: #000; text-shadow: none; }

.terminal input, .terminal select, .terminal textarea {
  background: #000;
  color: var(--data);
  border: 1px solid var(--text);
  border-radius: 0;
  caret-color: var(--text);
}

.terminal input::placeholder { color: var(--muted); opacity: 0.7; }

.terminal input:focus-visible, .terminal select:focus-visible, .terminal textarea:focus-visible,
.terminal button:focus-visible, .terminal a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Buttons are keyboard keys: green GO, red for anything destructive. */
.terminal .btn {
  background: var(--go);
  border: 1px solid #0d6b28;
  color: #000;
  border-radius: 2px;
  text-shadow: none;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35);
}

.terminal .btn:active { box-shadow: none; transform: translateY(1px); }
.terminal .btn-danger { background: #d42a1f; border-color: #7a140e; }

.terminal .btn-quiet {
  border: 1px solid var(--text);
  color: var(--text);
  border-radius: 0;
}

.terminal .btn-quiet:hover { background: var(--text); color: #000; text-shadow: none; }

.terminal .panel.danger { border-color: var(--down); }
.terminal .panel.danger > h2:first-child { background: var(--down); }

.terminal code { color: var(--accent); }
