/* Virtual Boyfriend — one stylesheet, two themes, no framework.
 * The theme is stamped on <html data-theme> by theme.js before first paint. */

:root {
  --bg: #14131a;
  --bg2: #1c1a24;
  --bg3: #24212e;
  --ink: #ece9f3;
  --ink2: #a9a3bb;
  --ink3: #7d7791;
  --line: #322e40;
  --accent: #d98a86;
  --accent2: #8fb3d9;
  --warm: #e8b7a4;
  --ok: #7fb996;
  --bad: #e08a8a;
  --care: #d9a05b;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg: #faf7f5;
  --bg2: #ffffff;
  --bg3: #f2eeea;
  --ink: #241f2b;
  --ink2: #5b5468;
  --ink3: #837c92;
  --line: #e2dbd6;
  --accent: #a8504c;
  --accent2: #3f6a99;
  --warm: #b4674f;
  --ok: #3f7d5c;
  --bad: #a83f3f;
  --care: #9a6520;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent2); }
a:hover { color: var(--accent); }

.hidden { display: none !important; }

/* `hidden` is the platform-neutral way to hide a node, but the UA rule behind it
 * lives in the weakest cascade origin at specificity 0,1,0 - so any author class
 * rule that sets `display` silently beats it and the node paints anyway. Make the
 * attribute authoritative. Keep this in step with .hidden below/above: an element
 * is shown by clearing BOTH, never by dropping the class alone. */
[hidden] { display: none !important; }


.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--ink2); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--mono); font-size: 0.8rem; }

/* --- header --- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 40;
}

.brand { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.brand strong { letter-spacing: 0.01em; }
.backlink { text-decoration: none; color: var(--ink2); }
.sep { color: var(--ink3); }

.topactions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.credits { font-family: var(--mono); font-size: 0.78rem; color: var(--ink2); }
.topup {
  font-size: 0.78rem; text-decoration: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 0.2rem 0.65rem; color: var(--accent2);
}

button {
  font-family: inherit; font-size: 0.9rem; cursor: pointer;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg3); color: var(--ink);
  padding: 0.45rem 0.85rem;
  transition: border-color 0.12s ease, background 0.12s ease;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.ghost { background: transparent; }
.ghost.small { font-size: 0.8rem; padding: 0.28rem 0.6rem; }
.ghost.tiny { font-size: 0.72rem; padding: 0.15rem 0.5rem; }

.primary {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 600;
}
:root[data-theme="light"] .primary { color: #fff; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }

.big { font-size: 0.98rem; padding: 0.6rem 1.1rem; }

/* --- layout --- */

main { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }

.hero { padding: 1.6rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; }
.hero h1 { font-size: clamp(1.6rem, 4.2vw, 2.5rem); line-height: 1.16; margin: 0 0 0.9rem; letter-spacing: -0.02em; }
.lede { font-size: 1.04rem; max-width: 68ch; margin: 0 0 0.9rem; }
.lede.small { font-size: 0.92rem; }
.herobtns { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1.1rem 0 0.7rem; }

.card {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1.3rem;
}
.card h2 { font-size: 1.18rem; margin: 0 0 0.6rem; }
.card h3 { font-size: 1rem; margin: 1.1rem 0 0.4rem; }

/* --- disclosures ---
 * Native <details>, closed on load. The bodies stay in the DOM so the published
 * register, the architecture note and the measured figures are still crawled and
 * still back the page's structured data — which is the whole reason these are
 * collapsed rather than deleted. Nothing that gates, refuses or accepts input
 * lives inside one. */

.disclose {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.7rem 1rem; margin: 0.7rem 0 0;
}
.disclose + .disclose { margin-top: 0.5rem; }
.disclose > summary {
  cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--warm);
  padding: 0.1rem 0;
}
.disclose > summary:hover { color: var(--accent); }
.disclose > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.disclose[open] > summary { margin-bottom: 0.6rem; }
.disclose p { font-size: 0.9rem; margin: 0 0 0.7rem; max-width: 74ch; }
.disclose p.small { font-size: 0.84rem; }
.disclose h3 { font-size: 0.98rem; margin: 1.1rem 0 0.4rem; }
.disclose.policy > summary { color: var(--care); }

/* --- policy and grids --- */

.policygrid, .gradegrid {
  display: grid; gap: 0.8rem; margin: 0.9rem 0;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.policycell, .gradecell {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.8rem 0.9rem; background: var(--bg3);
}
.policycell h4, .gradecell h4 { margin: 0 0 0.4rem; font-size: 0.95rem; color: var(--warm); }
.policycell p, .gradecell p { margin: 0 0 0.5rem; font-size: 0.88rem; }
.policycell.care { border-color: var(--care); }
.code {
  font-family: var(--mono); font-size: 0.7rem; color: var(--ink3);
  text-transform: uppercase; letter-spacing: 0.05em;
}

.measured { display: grid; gap: 0.7rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 0.9rem 0; }
.measurecell { border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.8rem; background: var(--bg3); }
.measurenum { display: block; font-family: var(--mono); font-size: 1.35rem; color: var(--accent); }
.measurelabel { display: block; font-size: 0.86rem; margin: 0.15rem 0; }
.measurenote { display: block; font-size: 0.78rem; color: var(--ink2); }

/* --- the builder --- */

.namerow { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; margin: 0.9rem 0; }
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 200px; }
.field label { font-size: 0.8rem; color: var(--ink2); }
input[type="text"], textarea {
  font-family: inherit; font-size: 0.95rem;
  background: var(--bg3); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 0.5rem 0.65rem; width: 100%;
}
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--accent); }
.verdict { font-size: 0.82rem; color: var(--ink2); padding-bottom: 0.5rem; max-width: 46ch; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }

.dial { margin: 1.2rem 0; }
.dial h3 { margin: 0 0 0.5rem; }
.optgrid { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.opt {
  text-align: left; display: flex; flex-direction: column; gap: 0.18rem;
  padding: 0.6rem 0.7rem; background: var(--bg3); border: 1px solid var(--line);
}
.opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg3)); }
.optlabel { font-size: 0.9rem; }
.optline { font-size: 0.79rem; color: var(--ink2); line-height: 1.45; }

.gatebox { border: 1px solid var(--care); border-radius: 10px; padding: 0.8rem 0.9rem; margin: 1.2rem 0; background: var(--bg3); }
.checkrow { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; font-size: 0.88rem; }
.checkrow input { margin-top: 0.3rem; flex: 0 0 auto; }

.startrow { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin: 1rem 0 0.5rem; }
.meter { font-size: 0.82rem; color: var(--ink2); font-family: var(--mono); }
.gate {
  border: 1px solid var(--bad); border-radius: 9px; padding: 0.6rem 0.8rem;
  font-size: 0.86rem; display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap;
}
.gateaction { font-size: 0.82rem; }

/* --- the board --- */

.board { margin-bottom: 1.4rem; }
.framebanner {
  border: 1px solid var(--line); border-left: 3px solid var(--warm);
  border-radius: 8px; padding: 0.6rem 0.85rem; margin-bottom: 0.9rem;
  font-size: 0.85rem; background: var(--bg2); color: var(--ink2);
}
.framebanner strong { color: var(--warm); margin-right: 0.4rem; }

.boardhead {
  display: flex; justify-content: space-between; gap: 0.8rem;
  flex-wrap: wrap; align-items: center; margin-bottom: 0.8rem;
}
.who { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.figname { font-size: 1.25rem; font-weight: 600; }
.pill {
  font-size: 0.72rem; font-family: var(--mono); color: var(--ink2);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.55rem;
}
.boardbtns { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.crisiswrap, .minorwrap {
  border: 2px solid var(--care); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem; background: var(--bg2);
}
.minorwrap { border-color: var(--bad); }
.crisiswrap h3, .minorwrap h3 { margin: 0 0 0.5rem; font-size: 1.05rem; color: var(--care); }
.minorwrap h3 { color: var(--bad); }
.crisiswrap p, .minorwrap p { margin: 0 0 0.8rem; font-size: 0.92rem; }
.resgrid { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-bottom: 0.6rem; }
.rescard { border: 1px solid var(--line); border-radius: 9px; padding: 0.65rem 0.75rem; background: var(--bg3); display: flex; flex-direction: column; gap: 0.2rem; }
.reswhere { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink3); }
.resname { font-size: 0.95rem; }
.reshow { font-family: var(--mono); font-size: 0.95rem; color: var(--accent); }
a.reshow { text-decoration: underline; }
.resnote { font-size: 0.78rem; color: var(--ink2); }
.crisisactions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.7rem; }

/* --- transcript --- */

.transcript { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1rem; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem; background: var(--bg2); }
.msg.you { border-left: 3px solid var(--accent2); }
.msg.him { border-left: 3px solid var(--warm); }
.msghead { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.35rem; }
.msgwho { font-weight: 600; font-size: 0.9rem; }
.msgtag, .msgcost, .msgwarn {
  font-size: 0.68rem; font-family: var(--mono); color: var(--ink3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.msgtag.care { color: var(--care); }
.msgwarn { color: var(--bad); }
.msgtext { margin: 0 0 0.45rem; font-size: 0.95rem; }
.msgtext:last-child { margin-bottom: 0; }

.auditstrip { border-top: 1px dashed var(--line); margin-top: 0.6rem; padding-top: 0.5rem; }
.auditstrip h5 { margin: 0 0 0.4rem; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--care); }
.auditfind { display: flex; flex-direction: column; gap: 0.12rem; margin-bottom: 0.5rem; }
.auditkind { font-family: var(--mono); font-size: 0.7rem; color: var(--care); }
.auditnote { font-size: 0.82rem; color: var(--ink2); }
.auditquote { font-size: 0.8rem; font-style: italic; color: var(--ink3); border-left: 2px solid var(--line); padding-left: 0.5rem; }

.warnbox { border: 1px dashed var(--line); border-radius: 9px; padding: 0.6rem 0.8rem; background: var(--bg3); }
.warnbox h5 { margin: 0 0 0.3rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink3); }
.warnbox p { margin: 0 0 0.35rem; font-size: 0.83rem; color: var(--ink2); }
.empty { font-style: italic; }

/* --- progress and composer --- */

.progress { border: 1px solid var(--line); border-radius: 9px; padding: 0.5rem 0.8rem; margin-bottom: 0.8rem; background: var(--bg3); }
.progsteps { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.progstep { font-size: 0.78rem; color: var(--ink3); }
.progstep.live { color: var(--accent); }
.progstep.done { color: var(--ok); text-decoration: line-through; }
.progfoot { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 0.35rem; }
.peek { color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

.composer { margin-bottom: 1.2rem; }
.composerrow { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }
.guardnote { border: 1px solid var(--bad); border-radius: 9px; padding: 0.7rem 0.85rem; margin-top: 0.7rem; background: var(--bg3); }
.guardnote h4 { margin: 0 0 0.35rem; font-size: 0.95rem; color: var(--bad); }
.guardnote p { margin: 0 0 0.4rem; font-size: 0.87rem; }

/* --- panels --- */

.panels { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.panel { margin-bottom: 0; }
.panel h3 { margin-top: 0; }

.proposal {
  border: 1px solid var(--accent); border-radius: 9px; padding: 0.6rem 0.75rem;
  margin-bottom: 0.7rem; display: flex; gap: 0.6rem; flex-wrap: wrap;
  align-items: center; justify-content: space-between; background: var(--bg3);
}
.proposaltext { font-size: 0.87rem; }
.proposalbtns { display: flex; gap: 0.4rem; }

.nblist { list-style: none; margin: 0.6rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.nbline {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.6rem; background: var(--bg3);
}
.nbtext { flex: 1 1 60%; font-size: 0.88rem; }
.nbsrc { font-size: 0.68rem; font-family: var(--mono); color: var(--ink3); }
.nbaddrow { display: flex; gap: 0.5rem; align-items: center; }
.nbnote { border: 1px solid var(--bad); border-radius: 8px; padding: 0.5rem 0.7rem; margin-top: 0.5rem; }
.nbnote h5 { margin: 0 0 0.25rem; font-size: 0.85rem; color: var(--bad); }
.nbnote p { margin: 0; font-size: 0.83rem; }
.nbfoot { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }

.envelope {
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.55;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 9px;
  padding: 0.7rem 0.8rem; max-height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; margin: 0.5rem 0;
}
.exportrow { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }

/* --- history --- */

.historyhead { display: flex; justify-content: space-between; gap: 0.7rem; align-items: center; flex-wrap: wrap; }
.historybtns { display: flex; gap: 0.4rem; }
.historylist { list-style: none; margin: 0.7rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.histrow {
  display: flex; justify-content: space-between; gap: 0.7rem; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 9px; padding: 0.5rem 0.7rem; background: var(--bg3);
}
.histmain { display: flex; flex-direction: column; gap: 0.1rem; }
.histname { font-size: 0.9rem; }
.histsum, .histwhen { font-size: 0.76rem; color: var(--ink2); }
.histwhen { font-family: var(--mono); color: var(--ink3); }
.histbtns { display: flex; gap: 0.4rem; align-items: center; }

/* --- footer, toast --- */

.foot {
  border-top: 1px solid var(--line); padding: 1rem 1.1rem 2rem;
  display: flex; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--ink2); max-width: 1080px; margin: 0 auto;
}
.footlinks { display: flex; gap: 0.9rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  max-width: min(620px, 92vw); z-index: 90;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.65rem 0.95rem; font-size: 0.86rem;
  background: var(--bg2); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}
.toast.err { border-color: var(--bad); }
.toast.ok { border-color: var(--ok); }

/* --- docs pages --- */

.doc { max-width: 900px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }
.doc h1 { font-size: 1.7rem; margin: 0 0 0.6rem; }
.doc h2 { font-size: 1.15rem; margin: 1.8rem 0 0.5rem; border-top: 1px solid var(--line); padding-top: 1.1rem; }
.doc h3 { font-size: 0.98rem; margin: 1.1rem 0 0.4rem; }
.doc p, .doc li { font-size: 0.92rem; }
.doc table { border-collapse: collapse; width: 100%; font-size: 0.85rem; margin: 0.8rem 0; }
.doc th, .doc td { border: 1px solid var(--line); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.doc th { background: var(--bg3); }

.codegroup { margin: 0.7rem 0 1.2rem; }
.tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.tab {
  font-family: var(--mono); font-size: 0.74rem; padding: 0.2rem 0.6rem;
  border-radius: 999px; background: transparent;
}
.tab.active { border-color: var(--accent); color: var(--accent); }
pre {
  font-family: var(--mono); font-size: 0.76rem; line-height: 1.6;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 9px;
  padding: 0.7rem 0.85rem; overflow-x: auto; white-space: pre; margin: 0;
}
code { font-family: var(--mono); font-size: 0.85em; }

.tokenbox { border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; margin: 1rem 0; background: var(--bg2); }
.tokenrow { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0.6rem 0; }
.tokenval { font-family: var(--mono); font-size: 0.78rem; word-break: break-all; color: var(--ink2); }

@media (max-width: 620px) {
  .topbar { padding: 0.6rem 0.8rem; }
  main, .foot, .doc { padding-left: 0.8rem; padding-right: 0.8rem; }
  .panels { grid-template-columns: 1fr; }
}
