/* ==========================================================================
   app.css — Ophis Web
   --------------------------------------------------------------------------
   The base stylesheet: no framework, and nothing fetched from the network.
   almanac.css, loaded after it, restyles it as the light default theme and
   embeds the fonts. Layout is a three-column grid that folds to two, then one.

   Sections:  tokens · reset · chrome · layout · panels · controls ·
              dates · operations · filters · output · detail · chart ·
              tooltip / toast / modal · responsive · print
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #0a0c11;
  --bg-2: #0e1118;
  --panel: #12151d;
  --panel-2: #171b25;
  --raised: #1d2230;
  --line: rgba(255, 255, 255, .085);
  --line-strong: rgba(255, 255, 255, .16);
  --ink: #e8e4d8;
  --ink-2: #c9c6bb;
  --dim: #868c9c;
  --gold: #d8a943;
  --gold-2: #f3d27a;
  --cyan: #54b8c9;
  --red: #e0584a;
  --green: #7faa5a;
  --violet: #a68ada;
  --chart-line: rgba(255, 255, 255, .10);
  --chart-axis: rgba(255, 255, 255, .34);
  --moon: #cbd5e1;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f2ec;
  --bg-2: #efece4;
  --panel: #ffffff;
  --panel-2: #faf8f4;
  --raised: #f0ece2;
  --line: rgba(20, 18, 12, .12);
  --line-strong: rgba(20, 18, 12, .22);
  --ink: #1b1a17;
  --ink-2: #3c3a34;
  --dim: #6f6c63;
  --gold: #a9761a;
  --gold-2: #8a5f12;
  --cyan: #14708a;
  --red: #b3372a;
  --green: #4d7a2c;
  --violet: #6b4fa8;
  --chart-line: rgba(20, 18, 12, .10);
  --chart-axis: rgba(20, 18, 12, .45);
  --moon: #4a5568;
  --shadow: 0 10px 28px rgba(40, 35, 20, .14);
  color-scheme: light;
}

/* ----------------------------------------------------------------- reset */
* { box-sizing: border-box; }
/* body grows with the page: a body pinned to the screen height would carry
   the sticky bars off the top once the page scrolls past one screen. */
html { height: 100%; }
/* app.js measures how much of the top of the page the sticky bars cover
   (--bars-cover), so a field reached by keyboard, or a panel scrolled into
   view, lands below them. A control in a sticky bar is on screen already, so
   focusing one must not scroll the page. */
html { scroll-padding-top: var(--bars-cover, 0px); }
html:has(.topbar:focus-within) { scroll-padding-top: 0; }
@media not all and (max-width: 900px) {
  html:has(.statusbar:focus-within) { scroll-padding-top: 0; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0 0 .6em; }
sub { font-size: .72em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--dim); }
.warn-text { color: var(--red); }
.fineprint { color: var(--dim); font-size: 12.5px; font-style: italic; }
/* Read by screen readers, not drawn. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
::selection { background: var(--gold); color: #100c02; }

/* ---------------------------------------------------------------- chrome */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

/* The brand is the page's h1, set in the bar's own type rather than a heading's. */
.brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; font: inherit; }
.brand-mark { color: var(--gold); font-size: 21px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-text b { letter-spacing: .22em; font-size: 14px; color: var(--gold-2); }
.brand-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; color: var(--dim); text-transform: uppercase; }

.event-bar { display: flex; gap: 6px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
/* The tab list may hold only tabs, so the + button follows it. display: contents
   takes away the list's box, not its role, so they share one row, as before. */
.event-tabs { display: contents; }
.event-tab {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  max-width: 230px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.event-tab:hover { border-color: var(--line-strong); color: var(--ink); }
.event-tab.active { border-color: var(--gold); color: var(--gold-2); background: color-mix(in srgb, var(--gold) 12%, var(--panel)); }
.event-tab-ord { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; color: var(--dim); }
.event-tab.active .event-tab-ord { color: var(--gold); }
.event-tab.add { padding: 6px 12px; font-size: 15px; line-height: 1; color: var(--dim); }

.toolbar { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 6px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .02em;
  color: var(--dim);
  position: sticky;
  top: 49px;
  z-index: 35;
}
.status-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-item b { color: var(--ink); font-weight: 600; }
.status-item.shifted { color: var(--cyan); }
.status-item input[type="date"] { font-size: 11px; padding: 2px 6px; }

.appfoot {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px;
  margin-top: auto;
}

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr) minmax(290px, 330px);
  gap: 14px;
  padding: 14px;
  align-items: start;
  flex: 1 1 auto;
}
.rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; position: sticky; top: 92px; max-height: calc(100vh - 106px); overflow-y: auto; padding-right: 2px; }
.center { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.rail::-webkit-scrollbar, .table-scroll::-webkit-scrollbar, .event-bar::-webkit-scrollbar { width: 8px; height: 8px; }
.rail::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb, .event-bar::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 8px;
}

/* ---------------------------------------------------------------- panels */
.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px 13px;
}
.panel:empty { display: none; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h2 {
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.panel-head .count {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--raised);
  color: var(--dim);
}
.panel-head .count.warn { color: var(--red); }
.panel-hint { color: var(--dim); font-size: 11.5px; margin: 0 0 9px; line-height: 1.45; }
.panel-note { color: var(--dim); font-size: 11px; font-family: var(--mono); }
.empty { color: var(--dim); font-size: 12.5px; font-style: italic; padding: 6px 2px; }

/* -------------------------------------------------------------- controls */
.btn {
  border: 1px solid var(--line-strong);
  background: var(--raised);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--gold); color: var(--gold-2); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 3px 8px; font-size: 11px; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--gold-2); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #120d02; font-weight: 600; }
.btn.primary:hover { background: var(--gold-2); color: #120d02; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }

.icon-btn {
  font-size: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  border-radius: var(--radius-sm);
  width: 26px;
  height: 26px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.icon-btn:hover { color: var(--gold-2); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

input, select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 8px;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
input:disabled { color: var(--dim); }
textarea { resize: vertical; }
input[type="date"], input[type="time"] { font-family: var(--mono); font-size: 12px; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
:root[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(.75); }

.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; min-width: 0; }
.field label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1 1 0; }

/* Checkbox styled as a small tick box. */
.tick { position: relative; display: inline-flex; width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; }
.tick input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tick span {
  width: 16px; height: 16px; border-radius: 4px;
  border: 1px solid var(--line-strong); background: var(--bg-2);
  display: block; pointer-events: none;
}
.tick input:checked + span { background: var(--gold); border-color: var(--gold); }
.tick input:checked + span::after {
  content: ""; position: absolute; left: 5px; top: 2px;
  width: 4px; height: 8px; border: solid #120d02; border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.tick input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }

.row-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  min-width: 22px;
  flex: 0 0 auto;
  text-align: right;
}
.row-label.alpha { color: var(--gold-2); }
.row-label.beta { color: var(--dim); }
.row-label.small { min-width: 18px; font-size: 10px; }

/* ----------------------------------------------------------------- dates */
.date-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.date-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 34px 16px 22px 22px;
  align-items: center;
  gap: 5px;
}
.date-rows.with-time .date-row { grid-template-columns: 26px minmax(0, 1fr) 68px 30px 16px 22px 22px; }
.date-row.off { opacity: .45; }
.date-row .weekday { font-family: var(--mono); font-size: 10px; color: var(--dim); text-align: center; }
.date-row .sunset {
  grid-column: 2 / -1;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--cyan);
  opacity: .8;
  margin-top: -2px;
}

/* ------------------------------------------------------------ operations */
.operation-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.operation-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 58px 16px 22px;
  align-items: center;
  gap: 5px;
}
.operation-row.off { opacity: .45; }
.operation-input { font-family: var(--mono); font-size: 11.5px; }
.operation-row.broken .operation-input { border-color: var(--red); }
.weight-input { font-family: var(--mono); font-size: 11px; text-align: center; padding: 5px 4px; }
.operation-preview, .operation-error {
  grid-column: 2 / -1;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  margin-top: -3px;
}
.operation-error { color: var(--red); }

/* --------------------------------------------------------------- filters */
.filter-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.filter-row { display: grid; grid-template-columns: 20px 16px minmax(0, 1fr); align-items: center; gap: 7px; }
.filter-row .filter-label { font-size: 12px; color: var(--dim); }
.filter-row.on .filter-label { color: var(--ink-2); }
.filter-value { width: 62px; display: inline-block; padding: 2px 5px; font-family: var(--mono); font-size: 11px; }

/* ------------------------------------------------------------ mini table */
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 500;
  padding: 3px 5px;
  border-bottom: 1px solid var(--line);
}
.mini-table td { padding: 3px 5px; border-bottom: 1px solid var(--line); }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-table tr[data-action] { cursor: pointer; }
.mini-table tr[data-action]:hover { background: var(--panel-2); }
.mini-table tr.selected { background: color-mix(in srgb, var(--gold) 14%, transparent); }
.mini-table .num, .num { text-align: right; font-family: var(--mono); }
.mini-table .lbl, .lbl { font-family: var(--mono); color: var(--ink-2); }
.arrow { color: var(--dim); }

/* ---------------------------------------------------------------- output */
.panel-output { padding-bottom: 6px; }
.table-scroll { overflow-x: auto; max-height: 62vh; overflow-y: auto; border-radius: var(--radius-sm); }
.output-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.output-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-strong);
  padding: 7px 9px;
  text-align: left;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
  white-space: nowrap;
}
.output-table thead th.sortable { cursor: pointer; user-select: none; }
.output-table thead th.sortable:hover { color: var(--gold-2); }
.output-table thead th.active { color: var(--gold); }
.sort-caret { opacity: 0; margin-left: 5px; font-size: 9px; }
.output-table thead th.active .sort-caret { opacity: 1; }
.output-table thead th.ord { width: 34px; }

.output-table tbody td { padding: 6px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.output-table tbody tr:last-child td { border-bottom: 0; }
.z-row { cursor: pointer; }
.z-row:hover td { background: var(--panel-2); }
.z-row.selected td { background: color-mix(in srgb, var(--gold) 13%, transparent); }
.z-row .ord { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.z-date { font-family: var(--mono); font-size: 13px; color: var(--ink); display: block; white-space: nowrap; }
.z-date-end, .z-meta { font-family: var(--mono); font-size: 10px; color: var(--dim); display: block; white-space: nowrap; }
.col-hits { color: var(--ink-2); }
.col-ops { width: 46%; }
.col-msrf { white-space: nowrap; }

.score {
  display: inline-block;
  min-width: 42px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.score.heat-0 { color: var(--dim); background: var(--raised); }
.score.heat-1 { color: var(--ink-2); background: color-mix(in srgb, var(--gold) 8%, var(--raised)); }
.score.heat-2 { color: var(--gold-2); background: color-mix(in srgb, var(--gold) 16%, var(--raised)); }
.score.heat-3 { color: var(--gold-2); background: color-mix(in srgb, var(--gold) 26%, var(--raised)); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.score.heat-4 { color: #150f02; background: var(--gold); font-weight: 700; }

.pill-wrap { display: flex; flex-wrap: wrap; gap: 4px; max-height: 66px; overflow-y: auto; }
.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: nowrap;
  cursor: help;
}
.pill.op.alpha { color: var(--gold-2); border-color: color-mix(in srgb, var(--gold) 48%, transparent); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.pill.op.beta { color: var(--dim); }
.pill.op.selected { outline: 1px solid var(--gold); background: color-mix(in srgb, var(--gold) 22%, transparent); }
.pill .pill-sub { font-size: 9.5px; }
.pill.msrf { margin-right: 3px; font-weight: 600; }
.pill.msrf.msrf-normal { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, transparent); background: color-mix(in srgb, var(--cyan) 10%, transparent); }
.pill.msrf.msrf-important { color: var(--gold-2); border-color: color-mix(in srgb, var(--gold) 55%, transparent); background: color-mix(in srgb, var(--gold) 14%, transparent); }
.pill.msrf.msrf-vortex { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 55%, transparent); background: color-mix(in srgb, var(--violet) 14%, transparent); }
.alpha { color: var(--gold-2); }
.beta { color: var(--dim); }
.msrf-normal { color: var(--cyan); }
.msrf-important { color: var(--gold-2); }
.msrf-vortex { color: var(--violet); }

.errors { border: 1px solid color-mix(in srgb, var(--red) 55%, transparent); background: color-mix(in srgb, var(--red) 9%, transparent); border-radius: var(--radius-sm); padding: 10px 12px; }
.errors h3 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--red); margin-bottom: 6px; }
.errors ul, .errors-list { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.errors li, .errors-list li { margin-bottom: 3px; }

/* ---------------------------------------------------------------- detail */
.panel-detail { display: none; }
.panel-detail.open { display: block; }
.detail-summary { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.detail-summary div { display: flex; flex-direction: column; }
.detail-summary .k { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.detail-summary .v { font-family: var(--mono); font-size: 16px; color: var(--gold-2); }
.detail-scroll { overflow-x: auto; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.detail-table th {
  text-align: left; font-family: var(--mono); font-size: 9px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--dim); font-weight: 500; padding: 4px 6px; border-bottom: 1px solid var(--line-strong);
}
.detail-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.detail-table tr { cursor: pointer; }
.detail-table tr:hover td { background: var(--panel-2); }
.detail-table tr.selected td { background: color-mix(in srgb, var(--gold) 14%, transparent); }
.detail-note { margin-top: 9px; font-size: 12px; color: var(--ink-2); }

/* ----------------------------------------------------------------- chart */
.panel-chart { padding-bottom: 8px; }
.chart-wrap { position: relative; height: 300px; }
#chart-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.chart-options { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 11px; color: var(--dim); cursor: pointer; user-select: none;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
/* The checkbox itself cannot be seen, so the chip shows its keyboard focus. */
.chip:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.chip:hover { border-color: var(--line-strong); color: var(--ink-2); }
.chip.on { border-color: var(--gold); color: var(--gold-2); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.chip.disabled { opacity: .4; cursor: not-allowed; }
.chip-glyph { font-size: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 10.5px; color: var(--dim); font-family: var(--mono); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.swatch.x { background: var(--gold); border-radius: 2px; }
.swatch.low { background: rgb(150, 160, 175); }
.swatch.three { background: rgb(253, 218, 13); }
.swatch.four { background: rgb(0, 150, 255); }
.swatch.five { background: rgb(210, 43, 43); }
.swatch.ring { background: transparent; border: 1.5px solid var(--dim); }

/* ---------------------------------------------------- tooltip / toast / modal */
.tooltip {
  position: fixed;
  z-index: 100;
  max-width: 460px;
  padding: 8px 10px;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .09s ease;
}
.tooltip.show { opacity: 1; }
.tip-table { border-collapse: collapse; font-size: 11.5px; }
.tip-table th {
  text-align: right; padding: 2px 8px 2px 0; color: var(--dim);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 500; white-space: nowrap;
  vertical-align: top;
}
.tip-table td { padding: 2px 0; color: var(--ink); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(14px);
  z-index: 110;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: color-mix(in srgb, var(--green) 60%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--red) 60%, transparent); }

.modal { display: none; position: fixed; inset: 0; z-index: 120; }
.modal.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal-card {
  position: relative;
  margin: 6vh auto;
  max-width: 720px;
  width: calc(100% - 32px);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal-card header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.modal-card header h2 { flex: 1; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.modal-body { padding: 14px; overflow-y: auto; font-size: 13px; color: var(--ink-2); }
.modal-body h3 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 14px 0 6px; }
.modal-card footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 6px; }
.doc-table td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-table td:first-child { white-space: nowrap; color: var(--ink); }
.doc-list { margin: 0 0 8px; padding-left: 20px; }
.doc-list li { margin-bottom: 4px; }

body.dropping::after {
  content: "Drop a .oph file to open it";
  position: fixed;
  inset: 12px;
  z-index: 115;
  border: 2px dashed var(--gold);
  border-radius: 14px;
  background: color-mix(in srgb, var(--gold) 8%, rgba(0, 0, 0, .35));
  color: var(--gold-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  letter-spacing: .1em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 1320px) {
  .layout { grid-template-columns: minmax(280px, 320px) minmax(0, 1fr); }
  .rail-right { grid-column: 1 / -1; position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .rail-right .panel { flex: 1 1 320px; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .rail { position: static; max-height: none; }
  .rail-left { order: 2; }
  .center { order: 1; }
  .rail-right { order: 3; }
  .topbar { flex-wrap: wrap; }
  .event-bar { order: 3; width: 100%; }
  .statusbar { position: static; }
  .chart-wrap { height: 240px; }
  .col-ops { width: auto; }
}

@media (max-width: 560px) {
  .brand-sub { display: none; }
  .date-rows.with-time .date-row { grid-template-columns: 24px minmax(0, 1fr) 62px 16px 22px 22px; }
  .date-rows.with-time .date-row .weekday { display: none; }
  .table-scroll { max-height: none; }
}

/* On a short screen, such as a phone on its side or a page zoomed far in,
   the bars would fill much of it; there they scroll away with the page. */
@media (max-height: 500px) {
  .topbar, .statusbar { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ----------------------------------------------------------------- print */
@media print {
  .topbar, .toolbar, .rail-right, .chart-options, .chart-legend, .appfoot, .tooltip, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { display: block; padding: 0; }
  .panel { border: 1px solid #ccc; break-inside: avoid; margin-bottom: 10px; }
  .table-scroll { max-height: none; overflow: visible; }
}
