/* Simple Host — the one shared stylesheet.
 *
 * Holds the design tokens, the base typography and the site chrome (header and
 * footer). Every page links it through the <!--sh:head--> marker, which the
 * server fills from partials/head.html; see chrome.go.
 *
 * Tokens keep the names the homepage has always used so a page's own styles
 * keep resolving. A page may still redefine a token in its own <style> while
 * its body waits to be restyled, and that must never reach the chrome, so the
 * token blocks below are applied to the header and footer elements as well as
 * to the root: the chrome reads its own copy, not the page's.
 *
 * No third-party font or script is loaded from here, or anywhere in the chrome:
 * a visitor's IP must never go to a third party. The body face is the system
 * sans stack; --mono is for code and keys only, and names JetBrains Mono first
 * only so pages that still load it keep their look.
 */

:root,
.sh-header,
.sh-footer {
  color-scheme: dark;
  --bg: #020617;
  --surface: #0b1222;
  --grid: #0f1830;
  --border: #1e293b;
  --border-hi: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --dim: #475569;
  --accent: #22d3ee;
  --accent-hover: #67e8f9;
  --success: #34d399;
  --error: #fb7185;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-bg: rgba(2, 6, 23, 0.75);
  --on-accent: #020617;
}

html[data-theme="light"],
html[data-theme="light"] .sh-header,
html[data-theme="light"] .sh-footer {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --grid: #e9edf4;
  --border: #e2e8f0;
  --border-hi: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --dim: #94a3b8;
  --accent: #0e7490;
  --accent-hover: #155e75;
  --success: #059669;
  --error: #e11d48;
  --header-bg: rgba(255, 255, 255, 0.82);
  --on-accent: #ffffff;
}

/* ---- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
/* Author display rules otherwise beat the UA [hidden]{display:none}. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

/* ---- Header -------------------------------------------------------------- */
/* Selectors are two classes deep on purpose: every page still carries its own
   element rules (a, p, nav a, button …) until it is restyled, and those must
   not be able to reach into the chrome. */

.sh-header {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  font-family: var(--font);
  color: var(--text);
}
.sh-header .sh-bar {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sh-header .sh-logo {
  margin: 0 auto 0 0;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.sh-header .sh-logo b { color: var(--accent); font-weight: 700; }
.sh-header .sh-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0 8px 0 0;
  padding: 0;
}
.sh-header .sh-nav a {
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}
.sh-header .sh-nav a:hover { color: var(--text); }
.sh-header .sh-nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
/* The entrance: a bordered control rather than another nav link, because it
   is the one thing a first-time visitor should press. */
.sh-header .sh-signin {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.sh-header .sh-signin:hover,
.sh-header .sh-signin[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
/* Signed in: "Your sites" plus a quiet "Sign out" beside it. On a phone they
   fold into one "Your sites" menu (.sh-acct) so the bar keeps to one line.
   The header script sets .sh-authed from localStorage before first paint. */
.sh-header .sh-signout,
.sh-header .sh-acct { display: none; }
.sh-header.sh-authed .sh-signout {
  display: inline-block;
  margin: 0;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
}
.sh-header.sh-authed .sh-signout:hover { color: var(--text); }
.sh-header .sh-acct { position: relative; }
.sh-header .sh-acct-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  cursor: pointer;
}
.sh-header .sh-acct-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.sh-header .sh-acct-btn svg { display: block; flex: none; }
.sh-header .sh-acct-menu,
.sh-header .sh-theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 160px;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.18);
}
.sh-header .sh-acct-menu[hidden],
.sh-header .sh-theme-menu[hidden] { display: none; }
.sh-header .sh-acct-menu a,
.sh-header .sh-acct-menu button,
.sh-header .sh-theme-menu button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
.sh-header .sh-acct-menu a:hover,
.sh-header .sh-acct-menu button:hover,
.sh-header .sh-theme-menu button:hover { background: var(--grid); }
.sh-header .sh-acct-menu button { color: var(--text-secondary); }
.sh-header .sh-theme {
  flex: none;
  width: 32px;
  height: 30px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  transition: none;
}
.sh-header .sh-theme:hover,
.sh-header .sh-theme[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
/* The theme menu: Match my system, Light, Dark. The chosen one carries a tick. */
.sh-header .sh-themes { position: relative; flex: none; }
.sh-header .sh-theme-menu { min-width: 180px; }
.sh-header .sh-theme-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sh-header .sh-theme-menu button[aria-checked="true"] { font-weight: 600; }
.sh-header .sh-theme-menu button[aria-checked="true"]::after { content: "\2713"; color: var(--accent); }
.sh-header .sh-theme svg { display: block; }

/* ---- Footer -------------------------------------------------------------- */

.sh-footer {
  margin: 64px 0 0;
  padding: 0;
  border-top: 1px solid var(--border);
  font-family: var(--font);
  color: var(--text-secondary);
  background: transparent;
}
.sh-footer .sh-foot {
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 24px 40px;
  font-size: 13px;
  line-height: 1.6;
}
.sh-footer .sh-foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  padding: 0;
}
.sh-footer .sh-foot-links a {
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
}
.sh-footer .sh-foot-links a:hover { color: var(--text); }
.sh-footer .sh-foot-links a[aria-current="page"] { color: var(--text); }
.sh-footer .sh-credit {
  margin: 10px 0 0;
  padding: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  opacity: 0.8;
}

/* ---- Phones -------------------------------------------------------------- */
/* Logo, two links, the entrance and the toggle stay on one line at 390px. */
@media (max-width: 640px) {
  .sh-header .sh-bar { padding: 12px 16px; gap: 10px; }
  .sh-header .sh-logo { font-size: 14px; }
  .sh-header .sh-nav { gap: 14px; margin-right: 2px; }
  .sh-header .sh-nav a { font-size: 13.5px; }
  .sh-header .sh-signin { padding: 6px 10px; font-size: 13.5px; }
  .sh-header.sh-authed #dash-link,
  .sh-header.sh-authed .sh-signout { display: none; }
  .sh-header.sh-authed .sh-acct { display: block; }
  .sh-footer { margin-top: 48px; }
  .sh-footer .sh-foot { padding: 20px 16px 32px; }
  .sh-footer .sh-foot-links { gap: 6px 16px; }
}
/* Narrow phones (iPhone mini/SE, small Androids): tighten so the signed-in
   "Your sites" menu still fits beside the toggle. */
@media (max-width: 389px) {
  .sh-header .sh-bar { gap: 8px; padding: 12px 14px; }
  .sh-header .sh-nav { gap: 10px; margin-right: 0; }
  .sh-header .sh-acct-btn { padding: 6px 8px; gap: 3px; }
}
@media (max-width: 359px) {
  .sh-header .sh-bar { gap: 8px; padding: 12px 12px; }
  .sh-header .sh-nav { gap: 10px; }
  .sh-header .sh-nav a, .sh-header .sh-signin { font-size: 13px; }
  /* Signed in, "Your sites" is wider than "Sign in" and the bar ran ~30px
     past a 320px screen. The logo already goes home, so Home steps aside. */
  .sh-header.sh-authed .sh-nav .sh-nav-home { display: none; }
}

/* "Ask about this page" box (partials/ask.html, ask.js). Page tokens only, so
   it takes on the look of whatever page it sits in. */
/* "Ask about this page": a floating button bottom-right that opens a small
   panel (a bottom sheet on phones). Page tokens only; the enterprise pages
   (data-tone="navy") use their navy document colours. */
.sh-ask { font-family: var(--font); }
.sh-ask[data-tone="navy"] { --accent: #17336b; --accent-hover: #0e2250; --on-accent: #fff; --surface: #fff; --bg: #f7f8fb; --border: #d8dde5; --border-hi: #c3cad6; --text: #0f172a; --text-secondary: #5f6b7c; }
html[data-theme="dark"] .sh-ask[data-tone="navy"] { --accent: #9db8ec; --accent-hover: #c3d4f5; --on-accent: #0c1424; --surface: #111a2b; --bg: #0c1424; --border: #2a3548; --border-hi: #3a475c; --text: #e6ebf3; --text-secondary: #8f9bad; }
body:has(.sh-ask-fab) { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
.sh-ask .sh-ask-fab { position: fixed; z-index: 60; right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px)); bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)); display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 18px 0 15px; font: inherit; font-size: 15px; font-weight: 600; line-height: 1; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); cursor: pointer; box-shadow: 0 6px 18px rgba(15, 23, 42, .18), 0 1px 3px rgba(15, 23, 42, .12); }
.sh-ask .sh-ask-fab:hover { background: var(--accent-hover); }
.sh-ask .sh-ask-fab:focus-visible, .sh-ask .sh-ask-close:focus-visible, .sh-ask .sh-ask-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sh-ask .sh-ask-fab[hidden] { display: none; }
.sh-ask .sh-ask-panel { position: fixed; z-index: 61; right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px)); bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)); width: 380px; max-height: min(560px, calc(100vh - 32px)); display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 18px 48px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .1); }
.sh-ask .sh-ask-panel[hidden] { display: none; }
.sh-ask .sh-ask-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--border); }
.sh-ask .sh-ask-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--text); }
.sh-ask .sh-ask-close { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.sh-ask .sh-ask-close:hover { background: var(--bg); color: var(--text); }
.sh-ask .sh-ask-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px; }
.sh-ask .sh-ask-log:empty { display: none; }
.sh-ask .sh-ask-turn { padding: 12px 0; border-bottom: 1px solid var(--border); }
.sh-ask .sh-ask-turn:last-child { border-bottom: 0; }
.sh-ask .sh-ask-q { margin: 0 0 6px; font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
.sh-ask .sh-ask-a { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; }
.sh-ask .sh-ask-a a { color: var(--accent); text-underline-offset: 3px; }
.sh-ask .sh-ask-a.is-loading { color: var(--text-secondary); }
.sh-ask .sh-ask-a.is-error { color: var(--error); }
.sh-ask .sh-ask-form { margin: 0; padding: 12px 16px 0; }
.sh-ask .sh-ask-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sh-ask .sh-ask-row { display: flex; gap: 8px; }
.sh-ask .sh-ask-input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 9px 12px; border: 1px solid var(--border-hi); border-radius: 8px; background: var(--bg); color: var(--text); }
.sh-ask .sh-ask-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.sh-ask .sh-ask-send { flex: none; font: inherit; font-size: 15px; font-weight: 600; padding: 9px 16px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--on-accent); cursor: pointer; }
.sh-ask .sh-ask-send:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.sh-ask .sh-ask-send:disabled { opacity: .65; cursor: default; }
.sh-ask .sh-ask-note { margin: 0; padding: 8px 16px 12px; font-size: 12px; line-height: 1.45; color: var(--text-secondary); }
@media (max-width: 560px) {
  .sh-ask .sh-ask-panel { left: 0; right: 0; bottom: 0; width: auto; max-height: min(80vh, 600px); max-height: min(80dvh, 600px); border-radius: 16px 16px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
}


/* ---- In-page dialogs (partials/dialog.html) ------------------------------ */
/* shConfirm / shPrompt / shAlert. Replaces the browser's native confirm, alert
   and prompt, which an AI browser agent cannot see or press. Two classes deep
   so a page's own button, input, h2 and p rules cannot reach in. */
.sh-dlg { width: min(440px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 32px); margin: auto; padding: 0; border: 1px solid var(--border-hi); border-radius: 14px; background: var(--surface); color: var(--text); font-family: var(--font); box-shadow: 0 18px 48px rgba(15, 23, 42, .28), 0 2px 6px rgba(15, 23, 42, .12); overflow: auto; }
.sh-dlg::backdrop { background: rgba(2, 6, 23, .55); }
.sh-dlg .sh-dlg-box { display: block; margin: 0; padding: 20px; border: 0; background: none; }
.sh-dlg .sh-dlg-title { margin: 0 0 8px; padding: 0; font-family: var(--font); font-size: 17px; font-weight: 650; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.sh-dlg .sh-dlg-body { margin: 0 0 4px; padding: 0; font-size: 14.5px; line-height: 1.55; color: var(--text-secondary); white-space: pre-line; overflow-wrap: anywhere; }
.sh-dlg .sh-dlg-field { display: block; margin: 12px 0 0; padding: 0; }
.sh-dlg .sh-dlg-label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.sh-dlg .sh-dlg-input { display: block; width: 100%; min-width: 0; margin: 0; font-family: var(--mono); font-size: 16px; padding: 9px 12px; border: 1px solid var(--border-hi); border-radius: 8px; background: var(--bg); color: var(--text); }
.sh-dlg .sh-dlg-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.sh-dlg .sh-dlg-copy { display: flex; gap: 8px; margin: 12px 0 0; }
.sh-dlg .sh-dlg-copy .sh-dlg-input { flex: 1; }
.sh-dlg .sh-dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 20px 0 0; }
.sh-dlg .sh-dlg-btn { flex: none; margin: 0; font-family: var(--font); font-size: 15px; font-weight: 600; line-height: 1.3; padding: 9px 16px; border: 1px solid var(--border-hi); border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; text-transform: none; letter-spacing: normal; }
.sh-dlg .sh-dlg-btn:hover { background: var(--bg); }
.sh-dlg .sh-dlg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sh-dlg .sh-dlg-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.sh-dlg .sh-dlg-primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.sh-dlg .sh-dlg-primary.sh-dlg-danger { border-color: var(--error); background: var(--error); color: var(--on-accent); }
.sh-dlg .sh-dlg-primary.sh-dlg-danger:hover { filter: brightness(1.08); background: var(--error); }
@media (max-width: 480px) {
  .sh-dlg .sh-dlg-box { padding: 16px; }
  .sh-dlg .sh-dlg-actions { flex-direction: column-reverse; }
  .sh-dlg .sh-dlg-actions .sh-dlg-btn { width: 100%; }
}
.sh-dlg .sh-dlg-msg { margin: 8px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--success); overflow-wrap: anywhere; }
.sh-dlg .sh-dlg-msg.sh-dlg-bad { color: var(--error); }
.sh-dlg .sh-dlg-btn:disabled { opacity: .55; cursor: default; }
