<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ACR Dashboard{% if active %} — {{ active | capitalize }}{% endif %}</title>
<style>
  :root {
    color-scheme: light dark;
    --bg: #F2EEE3;
    --surface: #FBF8F0;
    --surface-2: #E8E1D0;
    --line: #D6CCB3;
    --ink: #1E1B15;
    --ink-dim: #6B6252;
    --accent: #A8571F;
    --accent-ink: #FBF3E8;
    --wire: #3E5443;
    --ok: #2E7D4F;
    --warn: #96660A;
    --danger: #A8362A;
    --info: #3F5E82;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
    --sans: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --display-font: var(--mono);
    --radius: 4px;
    --pill-radius: 999px;
    --glow-accent: none;
    --glow-danger: none;
    --bg-texture: none;
    --bg-texture-size: auto;
    --scanline-opacity: 0;
    --canvas-glow: 0;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #14120E;
      --surface: #1B1812;
      --surface-2: #211D16;
      --line: #332E24;
      --ink: #EDE7D9;
      --ink-dim: #A39985;
      --accent: #D98A4B;
      --accent-ink: #241202;
      --wire: #6B8A72;
      --ok: #5FAE7C;
      --warn: #D9A24A;
      --danger: #D9695A;
      --info: #7FA0C7;
    }
  }

  /* --- neo-cyber theme -----------------------------------------------
     A deliberate, single dark world (not a light/dark pair) -- explicit
     user choice via the nav toggle below, not something OS dark-mode
     preference should silently trigger. `:root[data-theme="cyber"]`'s
     attribute selector outranks the plain :root inside the media query
     above regardless of source order, so this always wins once set. */
  :root[data-theme="cyber"] {
    color-scheme: dark;
    --bg: #05070E;
    --surface: #0C1220;
    --surface-2: #111A2E;
    --line: #223154;
    --ink: #E4F4FF;
    --ink-dim: #7488AE;
    --accent: #00E5FF;
    --accent-ink: #03141B;
    --wire: #8B6BFF;
    --ok: #2CFF88;
    --warn: #FFB020;
    --danger: #FF3763;
    --info: #4D82FF;
    --radius: 2px;
    --pill-radius: 3px;
    --glow-accent:
      0 0 6px color-mix(in srgb, var(--accent) 80%, transparent),
      0 0 18px color-mix(in srgb, var(--accent) 40%, transparent);
    --glow-danger: 0 0 8px color-mix(in srgb, var(--danger) 70%, transparent);
    --bg-texture:
      repeating-linear-gradient(
        0deg,
        color-mix(in srgb, var(--accent) 7%, transparent) 0px,
        transparent 1px,
        transparent 28px
      ),
      repeating-linear-gradient(
        90deg,
        color-mix(in srgb, var(--accent) 7%, transparent) 0px,
        transparent 1px,
        transparent 28px
      );
    --scanline-opacity: 0.05;
    --canvas-glow: 12;
  }
  /* "Observatory" -- a deep-space instrument-room palette: near-black sky,
     brass-and-lamplight accent, a soft pure-CSS starfield (layered radial
     gradients, no image asset -- stays offline/zero-dependency like every
     other dashboard asset) instead of Neo Cyber's scanlines. Its own
     serif --display-font (headings only; body text stays on --sans for
     legibility) is the one place typography differs at all between
     themes -- everything else here is a token substitution over the exact
     same structural CSS every other theme already shares. */
  :root[data-theme="observatory"] {
    color-scheme: dark;
    --bg: #0A0E17;
    --surface: #12192B;
    --surface-2: #1B2440;
    --line: #2C3A5E;
    --ink: #EDE6D3;
    --ink-dim: #8D96B3;
    --accent: #D8A448;
    --accent-ink: #1A1204;
    --wire: #6B8CAE;
    --ok: #6FCF97;
    --warn: #E0B85C;
    --danger: #E0645A;
    --info: #6B9BD1;
    --display-font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --radius: 3px;
    --pill-radius: 999px;
    --glow-accent:
      0 0 5px color-mix(in srgb, var(--accent) 55%, transparent),
      0 0 16px color-mix(in srgb, var(--accent) 25%, transparent);
    --glow-danger: 0 0 7px color-mix(in srgb, var(--danger) 55%, transparent);
    --bg-texture:
      radial-gradient(1.6px 1.6px at 12% 18%, color-mix(in srgb, var(--ink) 75%, transparent), transparent),
      radial-gradient(1.2px 1.2px at 32% 62%, color-mix(in srgb, var(--ink) 55%, transparent), transparent),
      radial-gradient(1.8px 1.8px at 58% 28%, color-mix(in srgb, var(--accent) 60%, transparent), transparent),
      radial-gradient(1.2px 1.2px at 74% 82%, color-mix(in srgb, var(--ink) 60%, transparent), transparent),
      radial-gradient(1.4px 1.4px at 86% 44%, color-mix(in srgb, var(--ink) 45%, transparent), transparent),
      radial-gradient(1.2px 1.2px at 6% 88%, color-mix(in srgb, var(--accent) 45%, transparent), transparent);
    --bg-texture-size: 340px 340px;
    --scanline-opacity: 0;
    --canvas-glow: 6;
  }
  * { box-sizing: border-box; }
  body {
    font-family: var(--sans);
    margin: 0;
    display: flex;
    min-height: 100vh;
    background-color: var(--bg);
    background-image: var(--bg-texture);
    background-size: var(--bg-texture-size);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    transition: background-color 0.2s ease, color 0.2s ease;
  }
  /* CRT scanline overlay -- opacity is 0 (invisible, zero cost) outside
     the cyber theme; a fixed, pointer-events:none layer so it never
     interferes with hit-testing or text selection underneath it. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background-image: repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.55) 0px,
      rgba(0, 0, 0, 0.55) 1px,
      transparent 1px,
      transparent 3px
    );
    opacity: var(--scanline-opacity);
  }
  a { color: var(--accent); }
  a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* --- theme toggle --- */
  .theme-toggle {
    margin: 0 1.25rem 0.85rem;
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .theme-toggle button {
    flex: 1;
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 0.4rem 0.3rem;
    border: none;
    background: var(--surface);
    color: var(--ink-dim);
    cursor: pointer;
  }
  .theme-toggle button + button { border-left: 1px solid var(--line); }
  .theme-toggle button[aria-pressed="true"] {
    background: color-mix(in srgb, var(--accent) 16%, var(--surface));
    color: var(--ink);
    box-shadow: var(--glow-accent);
  }

  /* --- nav --- */
  nav {
    width: 190px;
    flex-shrink: 0;
    padding: 1.25rem 0;
    background: var(--surface-2);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
  }
  .brand {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.06em;
    color: var(--ink);
    text-shadow: var(--glow-accent);
    padding: 0 1.25rem 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
  }
  .brand span { display: block; font-family: var(--sans); font-weight: 400; font-size: 11px; color: var(--ink-dim); letter-spacing: 0.02em; margin-top: 2px; }
  nav a {
    display: block;
    padding: 0.45rem 1.25rem;
    text-decoration: none;
    color: var(--ink-dim);
    font-size: 13px;
    border-left: 2px solid transparent;
  }
  nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
  nav a.active {
    color: var(--ink);
    font-weight: 700;
    border-left-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    text-shadow: var(--glow-accent);
  }
  /* Groups the 12 nav links along ACR's real subsystem boundaries (the
     same execution/knowledge/capabilities/governance/observability split
     as the repo layout itself) instead of one undifferentiated list --
     informed by 21st.dev's grouped-sidebar pattern (uiable/sidebar-1),
     adapted to this dashboard's existing mono/uppercase label type. */
  .nav-group { margin-top: 0.85rem; }
  .nav-group-label {
    display: block;
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    font-weight: 700;
    opacity: 0.65;
    padding: 0 1.25rem;
    margin-bottom: 0.2rem;
  }

  /* --- main --- */
  main { flex: 1; padding: 1.75rem 2.25rem 3rem; max-width: 1180px; }
  h1 {
    font-family: var(--display-font);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: 0.01em;
    margin: 0 0 1.1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--line);
    text-shadow: var(--glow-accent);
  }
  main > h1:not(:first-child) { margin-top: 2.25rem; }
  h2.section-label {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-dim);
    font-weight: 700;
    margin: 0 0 0.75rem;
  }
  p.lede { color: var(--ink-dim); max-width: 68ch; margin: -0.5rem 0 1.25rem; }
  code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--surface-2);
    padding: 0.1em 0.35em;
    border-radius: 3px;
  }

  /* --- metric cards --- */
  .metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.75rem; }
  .metric-card {
    border: 1px solid var(--line);
    border-left-width: 3px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    text-decoration: none;
    color: inherit;
    display: block;
  }
  a.metric-card:hover { border-color: var(--accent); box-shadow: var(--glow-accent); }
  .metric-card.pill-danger { box-shadow: var(--glow-danger); }
  /* Semantic color on the card itself (border + big number), reusing the
     same pill-* vocabulary tables use -- so a "failed" count is visible at
     a glance in the metric grid, not just once you reach the table below
     it. pill-neutral intentionally renders identically to the unmarked
     default: counts with no inherent good/bad meaning (event types,
     memory type) shouldn't carry alarm color. */
  .metric-card.pill-ok { border-left-color: var(--ok); }
  .metric-card.pill-ok .n { color: var(--ok); }
  .metric-card.pill-warn { border-left-color: var(--warn); }
  .metric-card.pill-warn .n { color: var(--warn); }
  .metric-card.pill-danger { border-left-color: var(--danger); }
  .metric-card.pill-danger .n { color: var(--danger); }
  .metric-card.pill-info { border-left-color: var(--info); }
  .metric-card.pill-info .n { color: var(--info); }
  .metric-card .n {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
    line-height: 1.1;
  }
  .metric-card .label {
    font-size: 12px;
    color: var(--ink-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
    display: block;
  }

  /* --- status pills --- */
  .pill {
    display: inline-block;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.1rem 0.5rem;
    border-radius: var(--pill-radius);
    border: 1px solid transparent;
    line-height: 1.6;
    white-space: nowrap;
  }
  .pill-ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
  .pill-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
  .pill-danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
  .pill-info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
  .pill-neutral { background: var(--surface-2); color: var(--ink-dim); border-color: var(--line); }

  /* Non-pill status text (e.g. the live-graph connection line), styled
     with the same danger vocabulary so a dropped connection reads as an
     alert instead of fading into ordinary body text. */
  .status-fail { color: var(--danger); font-weight: 700; }

  /* --- settings form --- */
  .settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; max-width: 480px; margin-bottom: 1.5rem; }
  .settings-card + .settings-card { margin-top: -0.75rem; }
  .settings-field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
  .settings-field label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
  .settings-field input[type="password"], .settings-field input[type="text"] {
    font: inherit; font-family: var(--mono); font-size: 13px; padding: 0.5rem 0.65rem;
    background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  }
  .settings-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .settings-check { display: flex; align-items: center; gap: 0.5rem; font-size: 13px; color: var(--ink-dim); margin-bottom: 1.1rem; }
  .btn-primary {
    font: inherit; font-weight: 700; font-size: 13px; padding: 0.55rem 1.1rem;
    background: var(--accent); color: var(--accent-ink); border: none; border-radius: var(--radius); cursor: pointer;
  }
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-primary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
  .settings-note { color: var(--ink-dim); font-size: 12px; margin: 0.6rem 0 0; }
  .settings-banner { background: color-mix(in srgb, var(--ok) 14%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); border-radius: var(--radius); padding: 0.6rem 0.9rem; margin-bottom: 1.1rem; font-size: 13px; max-width: 480px; }

  /* --- tables --- */
  .table-wrap { overflow-x: auto; margin-bottom: 1.75rem; border: 1px solid var(--line); border-radius: var(--radius); }
  table { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--surface); }
  th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
  th {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-dim);
    font-weight: 700;
    background: var(--surface-2);
    white-space: nowrap;
    box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--accent) 30%, transparent);
  }
  /* Applied by tables.js to every real <th> once the page loads --
     absent (and therefore invisible/inert) if JS fails to load, so a
     table is still fully readable either way. */
  th.sortable { cursor: pointer; user-select: none; }
  th.sortable:hover { color: var(--ink); }
  th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  th.sortable::after { content: "\2195"; margin-left: 0.35em; opacity: 0.35; font-weight: 400; }
  th.sortable[data-sort="asc"]::after { content: "\2191"; opacity: 1; color: var(--accent); }
  th.sortable[data-sort="desc"]::after { content: "\2193"; opacity: 1; color: var(--accent); }
  .table-filter {
    display: block;
    width: 100%;
    max-width: 260px;
    margin: 0 0 0.5rem;
    padding: 0.4rem 0.6rem;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .table-filter::placeholder { color: var(--ink-dim); }
  .table-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
  td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
  .empty { color: var(--ink-dim); font-style: italic; padding: 1rem 0.75rem; }

  /* --- charts (bars, paired bars, sparklines) -- see static/charts.js.
     Colors reference the same custom properties as everything else, so a
     theme toggle re-themes an already-rendered chart for free (no JS
     re-render needed): every fill/stroke below is a var(...) reference,
     never a hardcoded hex baked in at render time. */
  .chart-empty { color: var(--ink-dim); font-style: italic; padding: 0.5rem 0; }
  .chart-bars { display: flex; flex-direction: column; gap: 0.45rem; }
  .chart-bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; align-items: center; gap: 0.65rem; font-size: 12px; }
  .chart-bar-label { color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chart-bar-track { background: var(--surface-2); border-radius: var(--radius); height: 10px; overflow: hidden; }
  .chart-bar-fill { height: 100%; background: var(--accent); box-shadow: var(--glow-accent); }
  .chart-bar-fill.ok { background: var(--ok); }
  .chart-bar-fill.warn { background: var(--warn); }
  .chart-bar-fill.danger { background: var(--danger); box-shadow: var(--glow-danger); }
  .chart-bar-fill.info { background: var(--info); }
  .chart-bar-fill.a { background: var(--accent); }
  .chart-bar-fill.b { background: var(--wire); }
  .chart-bar-value { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); text-align: right; min-width: 3.2em; }
  .chart-paired { display: flex; flex-direction: column; gap: 0.7rem; }
  .chart-paired-group { display: flex; flex-direction: column; gap: 0.15rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--line); }
  .chart-paired-group:last-child { border-bottom: none; padding-bottom: 0; }
  .chart-legend { display: flex; gap: 1.1rem; font-size: 11px; color: var(--ink-dim); margin-bottom: 0.2rem; }
  .chart-legend-item { display: flex; align-items: center; gap: 0.35rem; }
  .chart-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
  .chart-swatch.a { background: var(--accent); }
  .chart-swatch.b { background: var(--wire); }
  .chart-sparkline-wrap { position: relative; }
  .sparkline { width: 100%; height: 48px; display: block; }
  .sparkline-area { fill: var(--accent); opacity: 0.15; }
  .sparkline-line { fill: none; stroke: var(--accent); stroke-width: 2; }
  .sparkline-dot { fill: var(--accent); }
  .chart-sparkline-label { position: absolute; top: 0; right: 0; font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
  .chart-section { margin-bottom: 1.75rem; }
  .chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; margin-bottom: 1.75rem; }
  .chart-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0.9rem 1rem; }
  .chart-card h3 { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); font-weight: 700; margin: 0 0 0.6rem; }

  /* --- legend / swatches --- */
  .legend { display: flex; flex-wrap: wrap; gap: 1.1rem; margin: 0 0 1rem; font-size: 12px; color: var(--ink-dim); }
  .legend .item { display: flex; align-items: center; gap: 0.4rem; }
  .legend .swatch { display: inline-block; width: 10px; height: 10px; flex-shrink: 0; }
  .legend .swatch.circle { border-radius: 50%; }

  @media (max-width: 720px) {
    body { flex-direction: column; }
    nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 0.5rem; align-items: center; }
    .brand, .theme-toggle { display: none; }
    nav a { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
    nav a.active { border-bottom-color: var(--accent); }
    main { padding: 1.25rem 1rem 2rem; }
  }
  @media (prefers-reduced-motion: no-preference) {
    :root[data-theme="cyber"] .brand { animation: acr-flicker 6s infinite; }
  }
  @keyframes acr-flicker {
    0%, 92%, 100% { opacity: 1; }
    93% { opacity: 0.4; }
    94% { opacity: 1; }
    95% { opacity: 0.6; }
    96% { opacity: 1; }
  }
</style>
<script>
  // Applied before first paint (head, not deferred) so switching pages
  // never flashes the wrong theme -- reads the same key the toggle below
  // writes to.
  (function () {
    var saved = localStorage.getItem("acr-theme");
    if (saved === "cyber" || saved === "observatory") document.documentElement.dataset.theme = saved;
  })();
</script>
</head>
<body>
<nav>
  <div class="brand">ACR<span>Adaptive Cognitive Runtime</span></div>
  <div class="theme-toggle" role="group" aria-label="Dashboard theme">
    <button type="button" id="theme-default" aria-pressed="true">Default</button>
    <button type="button" id="theme-cyber" aria-pressed="false">Neo Cyber</button>
    <button type="button" id="theme-observatory" aria-pressed="false">Observatory</button>
  </div>
  <a href="/" class="{{ 'active' if active == 'overview' }}">Overview</a>
  <div class="nav-group">
    <span class="nav-group-label">Execution</span>
    <a href="/tasks" class="{{ 'active' if active == 'tasks' }}">Tasks</a>
    <a href="/agents" class="{{ 'active' if active == 'agents' }}">Agents</a>
  </div>
  <div class="nav-group">
    <span class="nav-group-label">Knowledge</span>
    <a href="/memory" class="{{ 'active' if active == 'memory' }}">Memory</a>
    <a href="/skills" class="{{ 'active' if active == 'skills' }}">Skills</a>
  </div>
  <div class="nav-group">
    <span class="nav-group-label">Capabilities</span>
    <a href="/tools" class="{{ 'active' if active == 'tools' }}">Tools</a>
    <a href="/routing" class="{{ 'active' if active == 'routing' }}">Routing</a>
  </div>
  <div class="nav-group">
    <span class="nav-group-label">Governance</span>
    <a href="/security" class="{{ 'active' if active == 'security' }}">Security</a>
    <a href="/proposals" class="{{ 'active' if active == 'proposals' }}">Proposals</a>
  </div>
  <div class="nav-group">
    <span class="nav-group-label">Observability</span>
    <a href="/benchmarks" class="{{ 'active' if active == 'benchmarks' }}">Benchmarks</a>
    <a href="/events" class="{{ 'active' if active == 'events' }}">Events</a>
    <a href="/visualization" class="{{ 'active' if active == 'visualization' }}">Visualization</a>
  </div>
  <div class="nav-group">
    <span class="nav-group-label">System</span>
    <a href="/settings" class="{{ 'active' if active == 'settings' }}">Settings</a>
  </div>
</nav>
<script src="/static/charts.js"></script>
<main>
{% block content %}{% endblock %}
</main>
<script>
  (function () {
    var buttons = {
      "default": document.getElementById("theme-default"),
      "cyber": document.getElementById("theme-cyber"),
      "observatory": document.getElementById("theme-observatory"),
    };

    function sync() {
      var current = document.documentElement.dataset.theme || "default";
      Object.keys(buttons).forEach(function (theme) {
        buttons[theme].setAttribute("aria-pressed", String(theme === current));
      });
    }

    function setTheme(theme) {
      if (theme === "default") {
        delete document.documentElement.dataset.theme;
      } else {
        document.documentElement.dataset.theme = theme;
      }
      localStorage.setItem("acr-theme", theme);
      sync();
    }

    Object.keys(buttons).forEach(function (theme) {
      buttons[theme].addEventListener("click", function () { setTheme(theme); });
    });
    sync();
  })();
</script>
<script src="/static/tables.js"></script>
</body>
</html>
