/* Studio Console base — reset, type, layout, top bar, tab bar. Colours come only from tokens.css. */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/ibm-plex-mono-500.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 700; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/bricolage-grotesque-700.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 800; font-style: normal; font-display: swap; src: url("/static/vendor/fonts/bricolage-grotesque-800.woff2") format("woff2"); }
/* Fallback metrics matched to Bricolage so the swap does not resize the h1 and push the page down (measured CLS 0.39). */
@font-face { font-family: "Bricolage fallback"; src: local("Arial"); size-adjust: 96%; ascent-override: 92%; descent-override: 24%; line-gap-override: 0%; }
@font-face { font-family: "Plex fallback"; src: local("Arial"); size-adjust: 104%; ascent-override: 95%; descent-override: 25%; line-gap-override: 0%; }

/* Derived from tokens, never new hues: text-safe variants of the semantic colours (AA on their grounds in
   both themes) and a control edge that meets 3:1. Use --money/--stop for icons, rules and fills; these for words. */
:root {
  --money-ink: color-mix(in oklab, var(--money) 68%, var(--ink));
  --stop-ink: color-mix(in oklab, var(--stop) 72%, var(--ink));
  --free-ink: color-mix(in oklab, var(--free) 85%, var(--ink));
  --edge: color-mix(in oklab, var(--faint) 78%, var(--ink));
  --hover: color-mix(in oklab, var(--ink) 7%, transparent);
  --press: color-mix(in oklab, var(--ink) 12%, transparent);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --gutter: var(--s4);
}
@media (min-width: 900px) { :root { --gutter: var(--s5); } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: var(--rule) transparent; scrollbar-width: thin; scroll-padding-top: calc(var(--topbar) + var(--s4)); }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; overflow-x: hidden;
  background: var(--ground); color: var(--ink); font: 400 var(--fs-body)/1.5 var(--sans); font-feature-settings: "ss01" 0;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p, figure, dl, dd, ol, ul, blockquote { margin: 0; }
ol[class], ul[class] { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
table { border-collapse: collapse; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 0; }
[hidden] { display: none !important; }
::selection { background: var(--money); color: var(--ground); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-chip); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--rule); border: 3px solid transparent; background-clip: content-box; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--faint); }

/* Type */
h1, h2, .display { font-family: var(--display); text-wrap: balance; letter-spacing: -.015em; }
h1, .h1 { font-size: var(--fs-h1); line-height: 1.04; font-weight: 800; letter-spacing: -.022em; }
h2, .h2 { font-size: var(--fs-h2); line-height: 1.12; font-weight: 700; }
h3, .h3 { font-size: var(--fs-h3); line-height: 1.3; font-weight: 600; }
h4, .h4 { font-size: var(--fs-body); line-height: 1.4; font-weight: 600; }
p { text-wrap: pretty; max-width: 68ch; }
.lead { font-size: var(--fs-lead); color: var(--muted); }
.small { font-size: var(--fs-small); }
.muted { color: var(--muted); }
.mono, code, kbd, samp { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .94em; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; } .icon-lg { width: 20px; height: 20px; stroke-width: 1.6; }

/* Layout */
main { flex: 1 0 auto; min-width: 0; }
main:focus-visible { outline: none; }
.wrap { width: 100%; max-width: calc(var(--content) + 2 * var(--gutter)); margin-inline: auto;
  padding: var(--s6) max(var(--gutter), var(--safe-r)) var(--s8) max(var(--gutter), var(--safe-l)); }
.stack { display: flex; flex-direction: column; gap: var(--s4); } .stack-lg { gap: var(--s6); } .stack-sm { gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; } .row-between { justify-content: space-between; } .row-nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 0; min-width: 0; } .push { margin-left: auto; }
.cols { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.split { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .split { grid-template-columns: minmax(0, 1fr) var(--inspector); align-items: start; } }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s3) var(--s5); padding-bottom: var(--s5); border-bottom: 1px solid var(--rule); }
.page-head p { color: var(--muted); margin-top: var(--s2); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding-bottom: var(--s2); border-bottom: 1px solid var(--rule); }

/* Full-viewport screens (viewer, gate): no page scroll; main is the canvas and owns its own scrolling regions. */
body.bleed { height: 100dvh; overflow: hidden; }
body.bleed main { flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.skip { position: fixed; z-index: 100; top: calc(var(--safe-t) + var(--s2)); left: var(--s2); padding: var(--s2) var(--s3);
  background: var(--ink); color: var(--ground); border-radius: var(--radius); font-weight: 500; text-decoration: none; transform: translateY(-300%); }
.skip:focus-visible { transform: none; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 40; flex: none; background: var(--ground); border-bottom: 1px solid var(--rule); padding-top: var(--safe-t); }
.topbar-in { height: var(--topbar); display: flex; align-items: center; gap: var(--s5);
  max-width: calc(var(--content) + 2 * var(--gutter)); margin-inline: auto; padding-inline: max(var(--gutter), var(--safe-l)) max(var(--gutter), var(--safe-r)); }
body.bleed .topbar-in { max-width: none; }
.wordmark { font: 800 1rem/1 var(--display); letter-spacing: -.01em; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; min-height: var(--control); }
.wordmark span { color: var(--muted); font-weight: 700; }
.nav { display: none; align-self: stretch; gap: var(--s1); }
.nav a { position: relative; display: inline-flex; align-items: center; gap: var(--s2); padding-inline: var(--s3); color: var(--muted); text-decoration: none; font-weight: 500; font-size: var(--fs-small); }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; inset: auto var(--s3) -1px; height: 2px; background: var(--ink); }
.nav a:focus-visible { outline-offset: -4px; }
.count { font: 500 var(--fs-micro)/1 var(--mono); font-variant-numeric: tabular-nums; min-width: 18px; padding: 3px 5px; text-align: center; border-radius: var(--radius-chip); background: var(--raised); color: var(--ink); border: 1px solid var(--rule); }
.count-money { background: var(--money-ground); border-color: var(--money); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--s1); min-width: 0; }

.presence { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--control); padding-inline: var(--s2); font-size: var(--fs-small); color: var(--muted); text-decoration: none; white-space: nowrap; min-width: 0; border-radius: var(--radius); }
.presence:hover { color: var(--ink); background: var(--hover); }
.presence .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 1.5px solid var(--faint); }
.presence[data-state="live"] .dot { background: var(--free); border-color: var(--free); }
.presence[data-state="stale"] .dot { border-color: var(--money); border-radius: 1px; }
.presence-text { overflow: hidden; text-overflow: ellipsis; }
.outbox-badge { display: inline-flex; align-items: center; gap: var(--s2); min-height: 28px; padding: 0 var(--s2); border: 1px solid var(--rule); border-radius: var(--radius); font-size: var(--fs-small); background: var(--raised); white-space: nowrap; }
.search-btn { display: inline-flex; align-items: center; gap: var(--s2); height: 30px; padding: 0 var(--s2) 0 10px; border: 1px solid var(--rule); border-radius: var(--radius); color: var(--muted); font-size: var(--fs-small); background: var(--panel); }
.search-btn:hover { color: var(--ink); border-color: var(--edge); }
.search-btn kbd { margin-left: var(--s3); }
.icon-btn { display: inline-grid; place-items: center; width: var(--control); height: var(--control); border-radius: var(--radius); color: var(--muted); flex: none; }
.icon-btn:hover { color: var(--ink); background: var(--hover); }
.icon-btn[aria-pressed="true"], .icon-btn[aria-current="page"] { color: var(--ink); background: var(--press); }
:root[data-mode="light"] .when-dark, :root:not([data-mode="light"]) .when-light { display: none; }   /* data-mode = resolved theme, set by theme.js */

/* Mobile bottom tab bar */
.tabbar { position: fixed; z-index: 40; inset: auto 0 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--ground); border-top: 1px solid var(--rule);
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l); }
.tabbar a, .tabbar button { position: relative; height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .6875rem; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabbar [aria-current="page"] { color: var(--ink); }
.tabbar [aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 50%; width: 32px; height: 2px; margin-left: -16px; background: var(--ink); }
.tabbar :focus-visible { outline-offset: -4px; }
.tabbar .count { position: absolute; top: 6px; left: calc(50% + 6px); }
body:has(.tabbar) main { padding-bottom: calc(var(--tabbar) + var(--safe-b)); }
body.bleed .tabbar { display: none; }
body.bleed:has(.tabbar) main { padding-bottom: var(--safe-b); }

@media (max-width: 899.98px) {
  .topbar .wide-only { display: none; }
  .presence { max-width: 46vw; }
}
@media (min-width: 900px) {
  .nav { display: flex; }
  .tabbar { display: none; }
  body:has(.tabbar) main, body.bleed:has(.tabbar) main { padding-bottom: 0; }
  .topbar .narrow-only { display: none; }
}

/* Bare pages (login, offline): one centred column */
.bare { min-height: 100dvh; display: grid; place-items: center; padding: var(--s6) var(--gutter); }
.bare-box { width: min(100%, 340px); display: flex; flex-direction: column; gap: var(--s5); }

@media print { .topbar, .tabbar, .toasts, .skip { display: none !important; } }

.wordmark-lg { font: 800 1.75rem/1 var(--display); letter-spacing: -.02em; } .wordmark-lg span { color: var(--muted); font-weight: 700; }
.wrap-narrow > * { max-width: 760px; }   /* reading-width column that still aligns with the top bar */
h1 .icon, h2 .icon, h3 .icon { display: inline-block; vertical-align: -.12em; width: 1em; height: 1em; }
