/* ============================================================================================================
   Matrix57 kit — one type system, one gold, one site bar, the same focus and motion rules on every page.
   Loaded LAST on each page, so it only settles what differs; each page keeps its own layout and colours.
   Fonts: Saira Condensed (titles), IBM Plex Mono (numbers, labels, controls), IBM Plex Sans (reading text).
   Revert a page: remove its <!-- m57-kit --> head tags and its <!-- m57-bar --> block.            2026-09-26
   ============================================================================================================ */
:root {
  --m57-display: "Saira Condensed", "Arial Narrow", sans-serif;
  --m57-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --m57-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --m57-gold: #e8b341;
  --m57-gold-ink: #2a1f08;
  --m57-bar-bg: rgba(11, 14, 20, .94);
  --m57-bar-line: #232b3d;
  --m57-bar-ink: #9aa4b8;
  --m57-bar-h: 48px;
}
/* every page's own font names now mean the same three families */
:root, :root[data-theme] {
  --display: var(--m57-display);
  --mono: var(--m57-mono);
  --ui: var(--m57-ui);
  --sans: var(--m57-ui);
  --body: var(--m57-ui);
}

/* ---- the site bar: the same pages, in the same order, with the same names, on every page ---- */
.m57-bar {
  position: sticky; top: 0; z-index: 400;
  display: flex; align-items: center; gap: 14px;
  min-height: var(--m57-bar-h);
  padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
  background: var(--m57-bar-bg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--m57-bar-line);
  font-family: var(--m57-mono);
  box-sizing: border-box;
}
.m57-brand {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  color: #eef1f7; text-decoration: none;
  font-family: var(--m57-display); font-weight: 700; font-size: 18px; letter-spacing: .08em; line-height: 1;
}
.m57-brand b { color: var(--m57-gold); font-weight: 700; }
.m57-brand svg { display: block; }
.m57-links {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.m57-links::-webkit-scrollbar { display: none; }
.m57-tab {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 999px;
  color: var(--m57-bar-ink); text-decoration: none; white-space: nowrap;
  font-family: var(--m57-mono); font-size: 12.5px; letter-spacing: .02em;
  transition: color .15s ease-out, background .15s ease-out, border-color .15s ease-out;
}
.m57-tab:hover { color: #eef1f7; background: #1b2232; }
.m57-tab[aria-current="page"] { color: var(--m57-gold-ink); background: var(--m57-gold); border-color: var(--m57-gold); font-weight: 600; }
@media (pointer: coarse) {
  :root { --m57-bar-h: 56px; }
  .m57-tab { min-height: 44px; padding: 0 14px; }        /* Apple's 44pt touch target */
}
@media (max-width: 520px) { .m57-brand span { display: none; } }   /* the mark alone on phones; the links keep the room */

/* ---- focus, motion, inputs — the same everywhere ---- */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--m57-gold); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px; }   /* iOS zooms into anything smaller */
}

code, kbd, samp, pre { font-family: var(--m57-mono); }

/* ---- per page: the page's own back-links give way to the bar; fonts settle to the three families ---- */
html[data-m57-page="workbench"] a.wb-home { display: none; }
html[data-m57-page="starfind"] a[href="/dashboard"] { display: none; }
html[data-m57-page="starfind"] .bar a.logo { display: none; }                   /* the bar above already carries the mark */
html[data-m57-page="starfind"] body.gm-on .m57-bar { display: none; }           /* game mode stays full screen */
html[data-m57-page="patpat"] nav.links { display: none; }
html[data-m57-page="patpat"] { --gold: var(--m57-gold); --gold-wash: rgba(232, 179, 65, .12); }
html[data-m57-page="positional"] .brandrow, html[data-m57-page="positional"] header nav.tabs { display: none; }
html[data-m57-page="scorecard"] .top a[href="/dashboard/"], html[data-m57-page="scorecard"] .top a[href="/dashboard/workbench.html"] { display: none; }
html[data-m57-page="scorecard"] body { font-family: var(--m57-mono); }
html[data-m57-page="training"] a[href="/dashboard/index.html"][aria-label="Open dashboard"] { display: none; }
html[data-m57-page="account"] button[type="submit"], html[data-m57-page="account"] .acct-btn { background: var(--m57-gold); border-color: var(--m57-gold); color: var(--m57-gold-ink); }

/* the Trial page was written for a dark page but never set one: it showed dark-theme lines on white */
html[data-m57-page="trial"] body { background: #0b0e14; color: #dfe4f0; font-family: var(--m57-ui); font-size: 14px; line-height: 1.5; }
html[data-m57-page="trial"] h1, html[data-m57-page="trial"] h2 { font-family: var(--m57-display); letter-spacing: .02em; color: #eef1f7; }
html[data-m57-page="trial"] h1 { font-size: 26px; }
html[data-m57-page="trial"] h2 { font-size: 19px; }
html[data-m57-page="trial"] table { font-family: var(--m57-mono); font-size: 12.5px; }
html[data-m57-page="trial"] th { color: #8b93a7; font-weight: 600; }
html[data-m57-page="trial"] .wrap a { color: var(--m57-gold); }
html[data-m57-page="trial"] strong { color: #eef1f7; }
html[data-m57-page="trial"] .m57-bar { margin: -16px -16px 16px; }
html[data-m57-page="trial"] body { max-width: none; }
html[data-m57-page="trial"] .wrap { max-width: 980px; margin: 0 auto; }

/* ---- the Dashboard: with the masthead hidden (mv-solo) the sticky tabs sat 58px down, over the multiview controls ---- */
html[data-m57-page="dashboard"] body.mv-solo nav.tabs { top: 0; }

/* ============================================================================================================
   Step 2 — one control family. Three heights (compact 28 · regular 36 · large 44; every one 44 on touch, Apple's
   floor), one radius (8; pills stay pills), controls in IBM Plex Sans 500 at 13px (12 compact), gold for the one
   primary action, a gold tint for anything switched on. Each page's own controls are mapped onto it below — their
   colours stay; their size, shape and type settle. New work should use the .m57-* classes directly.
   ============================================================================================================ */
:root {
  --m57-h-compact: 28px; --m57-h: 36px; --m57-h-large: 44px; --m57-h-pill: 32px;
  --m57-r: 8px;
  --m57-ctl: 500 13px/1 var(--m57-ui);
  --m57-ctl-compact: 500 12px/1 var(--m57-ui);
  --m57-ctl-bg: #151b28; --m57-ctl-line: #2b3247; --m57-ctl-ink: #dfe4f0; --m57-ctl-dim: #9aa4b8;
  --m57-ctl-hover: #1b2232; --m57-ctl-hover-line: #3a4560;
}
@media (pointer: coarse) { :root { --m57-h-compact: 44px; --m57-h: 44px; --m57-h-pill: 44px; } }
html[data-theme="light"], html[data-m57-page="training"], html[data-m57-page="account"], html[data-m57-page="profile"] {
  --m57-ctl-bg: #ffffff; --m57-ctl-line: #d6deea; --m57-ctl-ink: #1b2333; --m57-ctl-dim: #5b6780; --m57-ctl-hover: #f1f4f9; --m57-ctl-hover-line: #b9c4d6;
}

/* the components */
.m57-btn, .m57-select, .m57-input {
  box-sizing: border-box; height: var(--m57-h); border: 1px solid var(--m57-ctl-line); border-radius: var(--m57-r);
  background: var(--m57-ctl-bg); color: var(--m57-ctl-ink); font: var(--m57-ctl); letter-spacing: .01em;
}
.m57-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s ease-out, border-color .15s ease-out, color .15s ease-out; }
.m57-btn:hover { background: var(--m57-ctl-hover); border-color: var(--m57-ctl-hover-line); }
.m57-btn--primary { background: var(--m57-gold); border-color: var(--m57-gold); color: var(--m57-gold-ink); font-weight: 600; }
.m57-btn--primary:hover { background: #f0c25a; border-color: #f0c25a; }
.m57-btn--ghost { background: transparent; border-color: transparent; color: var(--m57-ctl-dim); }
.m57-btn--compact { height: var(--m57-h-compact); padding: 0 10px; font: var(--m57-ctl-compact); }
.m57-btn--large { height: var(--m57-h-large); padding: 0 18px; font-size: 14px; }
.m57-btn.is-on, .m57-btn[aria-pressed="true"] { color: var(--m57-gold); border-color: rgba(232, 179, 65, .55); background: rgba(232, 179, 65, .10); }
.m57-select, .m57-input { padding: 0 10px; }
.m57-pill { display: inline-flex; align-items: center; height: var(--m57-h-pill); padding: 0 14px; border: 1px solid var(--m57-ctl-line); border-radius: 999px;
  background: var(--m57-ctl-bg); color: var(--m57-ctl-dim); font: var(--m57-ctl); cursor: pointer; white-space: nowrap; }
.m57-pill.is-on, .m57-pill[aria-pressed="true"] { background: var(--m57-gold); border-color: var(--m57-gold); color: var(--m57-gold-ink); font-weight: 600; }
.m57-seg { display: inline-flex; border: 1px solid var(--m57-ctl-line); border-radius: var(--m57-r); overflow: hidden; }
.m57-seg > button { height: var(--m57-h); padding: 0 12px; border: 0; border-radius: 0; background: var(--m57-ctl-bg); color: var(--m57-ctl-dim); font: var(--m57-ctl); cursor: pointer; }
.m57-seg > button + button { border-left: 1px solid var(--m57-ctl-line); }
.m57-seg > button.is-on, .m57-seg > button[aria-pressed="true"] { background: var(--m57-gold); color: var(--m57-gold-ink); font-weight: 600; }

/* ---- Dashboard: the Multiview bar (was Saira Condensed, 40-41px, radius 6) ---- */
html[data-m57-page="dashboard"] .mv-bar select, html[data-m57-page="dashboard"] .mv-bar button:not(.headtoggle) {
  height: var(--m57-h); min-height: 0; border-radius: var(--m57-r); font: var(--m57-ctl); letter-spacing: .01em; }

/* ---- Workbench: the header is the compact size (was 26-30px, radius 7-8, 9-13px type) ---- */
html[data-m57-page="workbench"] header select, html[data-m57-page="workbench"] header input[type="date"] {
  height: var(--m57-h-compact); border-radius: var(--m57-r); font: var(--m57-ctl-compact); padding-top: 0; padding-bottom: 0; }
html[data-m57-page="workbench"] header button { height: var(--m57-h-compact); font: var(--m57-ctl-compact); }
html[data-m57-page="workbench"] header > button, html[data-m57-page="workbench"] header .clock > button:not(.seg button) { border-radius: var(--m57-r); }
html[data-m57-page="workbench"] header .seg { border-radius: var(--m57-r); }
html[data-m57-page="workbench"] header .seg button { height: var(--m57-h-compact); }
html[data-m57-page="workbench"] .chip { font: var(--m57-ctl-compact); padding: 4px 10px; }
html[data-m57-page="workbench"] .anno-tool, html[data-m57-page="workbench"] .anno-act { height: 28px; font-family: var(--m57-ui); }   /* the floating tool bar stays 28 on touch too: it would stack three rows deep at 44 */
html[data-m57-page="workbench"] .anno-lb { font-size: 11px; letter-spacing: .04em; }                                                  /* was 9px — below Apple's 11pt floor */
html[data-m57-page="workbench"] #anBar select { height: 26px; font: var(--m57-ctl-compact); }

/* ---- StarFinder: the tool dock and the how-to card (was IBM Plex Mono 12.5px, 32-38px) ---- */
html[data-m57-page="starfind"] #tools button, html[data-m57-page="starfind"] #tools select, html[data-m57-page="starfind"] #tools input {
  height: var(--m57-h); min-height: var(--m57-h); padding-top: 0; padding-bottom: 0; border-radius: var(--m57-r); font: var(--m57-ctl); }
html[data-m57-page="starfind"] #hwCard button.gold { height: var(--m57-h-large); border-radius: var(--m57-r); font: 600 14px/1 var(--m57-ui); }

/* ---- PatPat: game pills, the draws-walked segment, the numbers toggle (heights 29-36, mixed radii) ---- */
html[data-m57-page="patpat"] .filters .pill { height: var(--m57-h-pill); min-height: 0; font: var(--m57-ctl); }
html[data-m57-page="patpat"] .filters .seg button { height: var(--m57-h-compact); font: var(--m57-ctl-compact); }
html[data-m57-page="patpat"] .filters .tgl { height: var(--m57-h-pill); font: var(--m57-ctl); }
html[data-m57-page="patpat"] .more { font: var(--m57-ctl-compact); }

/* ---- Positional: 44-48px everywhere on a desktop becomes the shared sizes; the phone keeps 44 ---- */
html[data-m57-page="positional"] .tbtn, html[data-m57-page="positional"] select { min-height: var(--m57-h); height: var(--m57-h); border-radius: var(--m57-r); font-size: 13px; font-weight: 500; }
html[data-m57-page="positional"] .seg button { min-height: var(--m57-h); font-size: 13px; font-weight: 500; }
html[data-m57-page="positional"] .tok { min-height: var(--m57-h-pill); font-size: 13px; }
html[data-m57-page="positional"] .btn { min-height: var(--m57-h-large); border-radius: var(--m57-r); font-size: 14px; }

/* ---- Scorecard, Training, Account ---- */
html[data-m57-page="scorecard"] .top .btn { height: var(--m57-h-compact); display: inline-flex; align-items: center; font: var(--m57-ctl-compact); }
html[data-m57-page="training"] .btn { height: var(--m57-h); min-height: 0; border-radius: var(--m57-r); font: var(--m57-ctl); letter-spacing: .01em; }
html[data-m57-page="training"] .tr-sel, html[data-m57-page="training"] .tr-datepick { height: var(--m57-h); border-radius: var(--m57-r); font: var(--m57-ctl); }
html[data-m57-page="account"] input[type="email"], html[data-m57-page="account"] input[type="password"], html[data-m57-page="account"] input[type="text"] {
  height: var(--m57-h-large); border-radius: var(--m57-r); font: 400 15px/1 var(--m57-ui); }
html[data-m57-page="account"] .acct-btn { height: var(--m57-h-large); border-radius: var(--m57-r); font: 600 15px/1 var(--m57-ui); letter-spacing: .04em; }

/* ---- Dashboard tiles: the per-tile date and rows pickers (Saira 11px, radius 6) and the icon buttons (24-30px) ---- */
html[data-m57-page="dashboard"] .mv-datesel, html[data-m57-page="dashboard"] .mv-rowsel {
  height: var(--m57-h-compact); min-height: 0; padding: 0 8px; border-radius: var(--m57-r); font: var(--m57-ctl-compact); }
html[data-m57-page="dashboard"] .mv-bug-btn, html[data-m57-page="dashboard"] .mv-expand {
  width: var(--m57-h-compact); height: var(--m57-h-compact); border-radius: var(--m57-r); }

/* ---- the guarantee: on a touch screen no text field or picker is under 16px, whatever a page says (iOS zooms in otherwise) ---- */
@media (pointer: coarse) {
  html[data-m57-page] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), html[data-m57-page] select, html[data-m57-page] textarea { font-size: 16px !important; }
}

/* ============================================================================================================
   Step 3 - one menu (Al, 2026-09-26): the Dashboard's own items, in the Dashboard's order, on every page (m57-nav.js).
   Desktop: one row across the top, the current page a gold pill, whatever doesn't fit under More. Phones and narrow
   tablets (under 900px): a tab bar at the bottom - Dashboard, Workbench, StarFinder, PatPat, More - and More opens a
   sheet with every page, grouped, in the same order. Anything a page pins to the bottom moves up above the tab bar.
   ============================================================================================================ */
:root { --m57-tabbar-h: 0px; }
.m57-nav [hidden], .m57-tabbar [hidden] { display: none !important; }
.m57-nav {
  position: sticky; top: 0; z-index: 400;
  display: flex; align-items: center; gap: 12px; min-height: 48px;
  padding: env(safe-area-inset-top, 0px) max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
  background: rgba(11, 14, 20, .96); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid #232b3d; box-sizing: border-box;
}
.m57-nav-list { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.m57-item {
  display: inline-flex; align-items: center; flex: none; height: 32px; padding: 0 11px;
  border: 1px solid transparent; border-radius: 999px; background: none; cursor: pointer;
  color: #9aa4b8; text-decoration: none; white-space: nowrap; font: 500 13px/1 var(--m57-ui); letter-spacing: .01em;
  transition: color .15s ease-out, background .15s ease-out, border-color .15s ease-out;
}
.m57-item:hover { color: #eef1f7; background: #1b2232; }
.m57-item[aria-current="page"] { color: var(--m57-gold-ink); background: var(--m57-gold); border-color: var(--m57-gold); font-weight: 600; }
.m57-sep { flex: none; width: 1px; height: 18px; margin: 0 6px; background: #2b3247; }
.m57-more-wrap { position: relative; flex: none; }
.m57-more.is-on { color: var(--m57-gold); border-color: rgba(232, 179, 65, .55); }
.m57-drop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 410; min-width: 200px; padding: 6px;
  background: #121824; border: 1px solid #2b3247; border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.m57-drop a { display: flex; align-items: center; height: 36px; padding: 0 12px; border-radius: 8px; color: #dfe4f0; text-decoration: none; font: 500 13px/1 var(--m57-ui); white-space: nowrap; }
.m57-drop a:hover { background: #1b2232; }
.m57-drop a[aria-current="page"] { color: var(--m57-gold); }
.m57-hdbtn { flex: none; width: 32px; height: 32px; border: 1px solid #2b3247; border-radius: 8px; background: transparent; color: #9aa4b8; font: 600 16px/1 var(--m57-ui); cursor: pointer; }
.m57-hdbtn:hover { color: #eef1f7; border-color: #3a4560; }
.m57-tabbar, .m57-sheet { display: none; }
html[data-m57-page="trial"] .m57-nav { margin: -16px -16px 16px; }
html[data-m57-page="starfind"] body.gm-on .m57-nav, html[data-m57-page="starfind"] body.gm-on .m57-tabbar { display: none !important; }
@media (min-width: 900px) {
  html[data-m57-page="dashboard"] nav.tabs { display: none; }          /* the row above does its job */
}
@media (max-width: 899px) {
  :root { --m57-tabbar-h: 58px; }
  .m57-nav { display: none; }
  body { padding-bottom: calc(var(--m57-tabbar-h) + env(safe-area-inset-bottom, 0px)) !important; }
  html[data-m57-page="starfind"] body.gm-on { padding-bottom: 0 !important; }
  .m57-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 420;
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
    height: calc(var(--m57-tabbar-h) + env(safe-area-inset-bottom, 0px)); padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
    background: rgba(11, 14, 20, .97); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid #232b3d; box-sizing: border-box;
  }
  .m57-tab2 {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px;
    border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
    color: #8b93a7; text-decoration: none; font: 500 10.5px/1 var(--m57-ui); letter-spacing: .01em;
  }
  .m57-tab2[aria-current="page"], .m57-tab2.is-on { color: var(--m57-gold); }
  .m57-sheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 430; }
  .m57-sheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
  .m57-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow: auto; box-sizing: border-box;
    padding: 6px 0 calc(14px + env(safe-area-inset-bottom, 0px));
    background: #10141d; border-top: 1px solid #2b3247; border-radius: 18px 18px 0 0;
  }
  .m57-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 0 18px; color: #eef1f7; font: 700 19px/1.2 var(--m57-display); letter-spacing: .03em; }
  .m57-sheet-x { width: 44px; height: 44px; border: 0; background: none; color: #9aa4b8; font: 400 26px/1 var(--m57-ui); cursor: pointer; }
  .m57-sheet-g { padding: 16px 18px 6px; color: #69778f; font: 600 11px/1 var(--m57-mono); letter-spacing: .09em; text-transform: uppercase; }
  .m57-row {
    display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 18px;
    border-top: 1px solid #1b2232; color: #dfe4f0; text-decoration: none; font: 500 16px/1.2 var(--m57-ui);
  }
  .m57-row::after { content: "\203A"; color: #5b6780; font-size: 22px; }
  .m57-row[aria-current="page"] { color: var(--m57-gold); }
  .m57-row[aria-current="page"]::after { content: "you\2019re here"; color: var(--m57-gold); font: 600 11px/1 var(--m57-mono); letter-spacing: .06em; text-transform: uppercase; }
  html.m57-sheet-open, html.m57-sheet-open body { overflow: hidden; }
  /* what a page pins to the bottom sits above the tab bar */
  html[data-m57-page="workbench"] #anBar { bottom: calc(8px + var(--m57-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  html[data-m57-page="workbench"] #anPop, html[data-m57-page="workbench"] #anTraceBar { bottom: calc(46px + var(--m57-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  html[data-m57-page="starfind"] #tools { bottom: calc(22px + var(--m57-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  html[data-m57-page="positional"] .bar { bottom: calc(var(--m57-tabbar-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: 12px; }
  html[data-m57-page="positional"] .toast { bottom: calc(92px + var(--m57-tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  /* the Dashboard keeps its own five views as tabs at the top; the other pages are in the tab bar and More */
  html[data-m57-page="dashboard"] nav.tabs a.tab { display: none; }
}
