:root {
  --bg: #f5f4f1;          /* warm off-white page */
  --surface: #ffffff;     /* cards */
  --surface-2: #f2f1ed;   /* inset / nested */
  --ink: #1c1c1e;         /* soft black — primary text */
  --ink-2: #3a3a3e;
  --muted: #77767b;       /* grey text */
  --line: #e6e4df;        /* hairline borders */
  --brand: #ef5b25;       /* orange */
  --brand-strong: #d94c17;
  --brand-tint: #fef1ea;  /* soft orange wash */
  --ok: #1c8a53;
  --ok-tint: #e8f5ee;
  --err: #c53a2b;
  --err-tint: #fcecea;
  --radius: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
::selection { background: var(--brand-tint); }
.hidden { display: none !important; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 0;
  font-size: .85em;
}

/* --- top bar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px 22px;
  flex-wrap: wrap;
  padding: 13px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 12px; height: 12px;
  border-radius: 0;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.brand-sub { color: var(--muted); font-size: 13px; font-weight: 400; }

/* signed-in cluster — two columns (text + Log out), pushed to the far right */
.signed-in { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.signed-in-text { color: var(--muted); font-size: 13px; font-weight: 400; }
#co-email { color: var(--ink-2); }
#co-company:not(:empty)::before { content: " · "; }
.linklike {
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--muted); font-size: 13px; font-weight: 400; cursor: pointer;
}
.linklike:hover { color: var(--brand); background: none; text-decoration: underline; }
.linklike:active { color: var(--brand-strong); }

/* directory nav — orange text links, no button chrome */
.topnav { display: flex; align-items: center; gap: 22px; }
.navlink {
  position: relative;
  background: none; border: 0; padding: 2px 0 6px; margin: 0; cursor: pointer;
  color: var(--brand); font-size: 16px; font-weight: 500; letter-spacing: -.01em;
  transition: color .12s;
}
.navlink:hover { color: var(--brand-strong); background: none; }
.navlink:active { color: var(--brand-strong); }
.navlink.active { color: var(--brand-strong); }
/* orange arrow centered under the selected page */
.navlink.active::after {
  content: "";
  position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid var(--brand-strong);
}
.navlink:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

/* --- layout --- */
#app { width: 100%; max-width: 680px; margin: 0 auto; padding: 32px 20px 48px; flex: 1; }

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card { padding: 32px; border-radius: 0; box-shadow: 0 1px 2px rgba(20,20,20,.05), 0 14px 36px rgba(20,20,20,.06); }
.panel { padding: 22px 24px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(20,20,20,.04); }
.auth-card { max-width: 420px; margin: 6vh auto 0; }

/* --- type --- */
h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: var(--ink); }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; }

/* --- tabs (segmented control) --- */
.tabs { display: flex; gap: 6px; margin: 20px 0 18px; background: var(--surface-2); padding: 5px; border-radius: 0; }
.tab { flex: 1; background: transparent; color: var(--muted); border: 0; padding: 9px; border-radius: 0; cursor: pointer; font-size: 14px; font-weight: 600; transition: .15s; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(210,70,20,.4); }

/* --- forms --- */
form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 13px;
  border-radius: 0;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #a9a8ac; }
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

/* signup consent checkboxes */
.agree-rows { display: flex; flex-direction: column; gap: 9px; margin: 2px 0; }
.agree-row { flex-direction: row; align-items: flex-start; gap: 9px; font-size: 13px; font-weight: 400; color: var(--ink-2); cursor: pointer; }
.agree-row input { flex: none; width: 16px; height: 16px; margin-top: 1px; padding: 0; accent-color: var(--brand); cursor: pointer; }
.agree-row a { color: var(--brand); }

/* --- buttons --- */
button {
  font-family: inherit;
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 11px 16px;
  border-radius: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, transform .05s, border-color .15s;
}
button:hover { background: var(--brand-strong); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
#auth-submit { margin-top: 2px; padding: 12px; }
button.ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
button.ghost:hover { background: var(--surface-2); border-color: #d8d6d0; }
button.small { padding: 8px 12px; font-size: 13px; }

.error { color: var(--err); min-height: 18px; font-size: 13px; margin: 12px 0 0; }

/* --- verify banner --- */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--brand-tint); border: 1px solid #f6d3c1; color: #8a3c17;
  padding: 14px 16px; border-radius: 0; margin-bottom: 16px; font-size: 14px;
}
.banner-icon { font-size: 16px; }
.banner-body { flex: 1; min-width: 180px; }
.banner strong { color: #7a3413; }

/* --- license list --- */
.list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
.list li {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 14px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 0; font-size: 13px;
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
#change-plan-picker { margin-top: 14px; }
button:disabled { opacity: .5; cursor: default; }
button.ghost:disabled:hover { background: var(--surface); border-color: var(--line); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 0;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.badge.active { background: var(--ok-tint); border-color: #bfe3cd; color: var(--ok); }
.badge.revoked { background: var(--err-tint); border-color: #f2c5bf; color: var(--err); }

.key { font-family: ui-monospace, Menlo, monospace; word-break: break-all; }
.key.copyable { cursor: pointer; padding: 4px 8px; border-radius: 0; background: var(--surface); border: 1px solid var(--line); transition: border-color .15s; }
.key.copyable:hover { border-color: var(--brand); }
.key.copied { color: var(--ok); border-color: var(--ok); }
.icon-btn { background: transparent; border: 0; cursor: pointer; font-size: 15px; padding: 2px 4px; line-height: 1; color: var(--muted); }
.icon-btn:hover { color: var(--ink); background: transparent; }
.key-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.key-actions button { padding: 5px 10px; font-size: 12px; }

/* --- plans / pricing --- */
#plan-picker { margin-top: 14px; }
.plans { display: flex; gap: 12px; flex-wrap: wrap; }
.plans-col { flex-direction: column; flex-wrap: nowrap; }
.plan {
  flex: 1; min-width: 160px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 0; padding: 18px;
  transition: border-color .15s, box-shadow .15s;
}
.plan:hover { border-color: var(--brand); box-shadow: 0 6px 22px rgba(20,20,20,.07); }
.plan h3 { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
.plan .plan-desc { margin: 2px 0 10px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.plan .price { font-size: 22px; font-weight: 700; color: var(--ink); margin: 4px 0 14px; }
.plan button { width: 100%; }

/* --- onboarding steps --- */
.steps { margin: 8px 0 12px; padding-left: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding: 7px 0 7px 34px; counter-increment: step; font-size: 14px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand-tint); color: var(--brand);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* --- Stripe checkout modal --- */
.modal { position: fixed; inset: 0; background: rgba(20,18,16,.55); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto; z-index: 50; }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 20px; width: 100%; max-width: 540px; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal.center { align-items: center; padding: 16px; }
.modal-card.confirm { max-width: 400px; padding: 24px; }
.modal-card.confirm h3 { margin: 0 0 8px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.modal-card.confirm .muted { margin: 0; font-size: 14px; line-height: 1.5; }
.confirm-actions { justify-content: flex-end; margin-top: 20px; }
.confirm-input-row { margin-top: 16px; }
button.danger { background: var(--err); }
button.danger:hover { background: #a72e21; }

/* account / auth extras */
a.linkish { color: var(--brand); text-decoration: none; }
a.linkish:hover { color: var(--brand-strong); text-decoration: underline; }
.forgot { margin: 12px 0 0; }
.mfa-secret { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.mfa-secret .key { letter-spacing: .04em; }

/* games */
.game-name { font-size: 15px; font-weight: 600; color: var(--ink); }
/* over-plan-limit titles: greyed + struck, still listed and removable */
.game-inactive { background: var(--surface-2); }
.game-inactive .game-name { color: var(--muted); font-weight: 500; text-decoration: line-through; }
.game-add { display: flex; gap: 8px; margin-top: 12px; }
.game-add input { flex: 1; }
.warn-text {
  background: #fdf4e7; border: 1px solid #f0d8b4; color: #8a5a12;
  padding: 10px 12px; border-radius: 0; font-size: 13px; line-height: 1.45; margin: 0 0 14px;
}
@media (prefers-reduced-motion: no-preference) {
  .modal-card.confirm { animation: pop .14s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
}

/* --- footer --- */
.footer { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; text-align: center; color: var(--muted); font-size: 12px; padding: 20px; border-top: 1px solid var(--line); }
.dot-sep { opacity: .5; }
.footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.footer a:hover { color: var(--ink); }

@media (max-width: 520px) {
  .card { padding: 24px; }
  #app { padding: 22px 14px 36px; }
  .plans { flex-direction: column; }
  .topbar { padding: 14px 16px; }
}

/* One-time purchases (support packages) list. */
.purchase-list { display: flex; flex-direction: column; gap: 8px; }
.purchase-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 12px; border: 1px solid var(--line, #e6e4df); border-radius: 0; }
.purchase-name { font-weight: 600; }
.purchase-meta { color: var(--muted, #77767b); font-size: 13px; white-space: nowrap; }

/* Downloads tab (self-host release tarballs). */
.downloads-list { display: flex; flex-direction: column; gap: 14px; }
.dl-card { border: 1px solid var(--line); background: var(--surface); padding: 16px 18px; }
.dl-head { display: flex; align-items: baseline; gap: 10px; }
.dl-head h3 { margin: 0; font-size: 16px; }
.dl-version { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--brand-strong); background: var(--brand-tint); border: 1px solid #f6d3c2; padding: 2px 8px; }
.dl-blurb { margin: 6px 0 12px; font-size: 13px; }
.dl-artifacts { display: flex; flex-direction: column; gap: 8px; }
.dl-artifact { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dl-btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; background: var(--brand); color: #fff; border: 1px solid var(--brand-strong); padding: 7px 12px; font-size: 13px; font-weight: 600; transition: background .15s; }
.dl-btn:hover { background: var(--brand-strong); }
.dl-plat { font-weight: 500; opacity: .9; font-size: 12px; }
.dl-meta { color: var(--muted); font-size: 13px; }
.dl-sha { font-size: 12px; color: var(--muted); cursor: pointer; padding: 3px 7px; background: var(--surface-2); border: 1px solid var(--line); transition: border-color .15s; }
.dl-sha:hover { border-color: var(--brand); }
.dl-archive { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.dl-archive summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.dl-archive-ver { margin: 12px 0 0; }
.dl-archive-tag { display: inline-block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }

/* Docs tab. */
.doc-view .panel { line-height: 1.55; }
.doc-view h2 { margin: 2px 0 10px; }
.doc-view p { margin: 0 0 10px; color: var(--ink-2); }
.doc-lead { font-size: 15px; color: var(--ink) !important; }
.doc-tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--brand-strong); background: var(--brand-tint);
  padding: 3px 9px; border-radius: 0; margin-bottom: 4px;
}
.doc-list { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.doc-list li { color: var(--ink-2); }
.doc-option { border-left: 3px solid var(--line); padding: 2px 0 2px 14px; margin: 14px 0 0; }
.doc-option h3 { margin: 0 0 4px; font-size: 15px; }
.doc-option p { margin: 0; }
.doc-view code {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 0;
  padding: 1px 6px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============ Docs: header dropdown + directory + article ============ */
.docsnav { position: relative; display: inline-block; margin-left: 14px; }
.docs-btn { background: transparent; border: 0; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px 8px; }
.docs-btn:hover { color: var(--brand-strong); }
.docs-caret { font-size: 10px; color: var(--muted); }
.docs-menu { position: absolute; top: 100%; left: 0; z-index: 60; display: none; min-width: 250px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 14px 36px rgba(20,20,20,.14); padding: 8px; max-height: 72vh; overflow: auto; }
.docsnav:hover .docs-menu, .docs-menu:hover { display: block; }
.docs-menu-group { padding: 4px 0; }
.docs-menu-head { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 8px; }
.docs-menu-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--ink-2); font: inherit; font-size: 13px; padding: 6px 8px; cursor: pointer; }
.docs-menu-item:hover { background: var(--surface-2); color: var(--brand-strong); }

.docs-page { max-width: 940px; margin: 0 auto; padding: 8px 16px 56px; }
.docs-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 20px; }
.docs-directory { display: flex; flex-direction: column; gap: 26px; }
.docs-group-title { margin: 0 0 10px; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.docs-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 12px; }
.docs-card { text-align: left; background: var(--surface); border: 1px solid var(--line); padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 5px; }
.docs-card:hover { border-color: var(--brand); }
.docs-card strong { font-size: 15px; color: var(--ink); }
.docs-card span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.docs-article { line-height: 1.6; }
.docs-article h2 { margin: 8px 0 14px; }
.docs-article h3 { margin: 22px 0 6px; font-size: 16px; }
.docs-article p { margin: 0 0 12px; color: var(--ink-2); }
.docs-back { margin-bottom: 14px; }
.docs-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-strong); background: var(--brand-tint); padding: 3px 9px; margin-bottom: 6px; }
.docs-list { margin: 6px 0 12px; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; color: var(--ink-2); }
.docs-code { background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; white-space: pre; margin: 0 0 14px; }
.docs-note { background: var(--brand-tint); border-left: 3px solid var(--brand); padding: 10px 14px; font-size: 13px; color: var(--ink-2); margin: 0 0 14px; }
.docs-article code, .docs-list code, .docs-note code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* Docs: API reference tables */
.docs-table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13px; }
.docs-table td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; color: var(--ink-2); line-height: 1.55; }
.docs-table td:first-child { color: var(--ink); white-space: nowrap; }
.docs-table td:last-child { white-space: normal; }
.docs-table code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* One-time purchase fulfillment status */
.purchase-status { font-weight: 700; }
.purchase-status.done { color: #3a9d5d; }
