/* Starlit portal - old-school forum look in the menu's own graphite palette (theme.hpp, default preset).
   Flat boxes, uppercase header strips with a 2 px line, label/value rows, small flat buttons. No gradients, no radius, no icons,
   no animations. Status colours only for state words. No inline styles anywhere (CSP): everything is a class here. */

:root {
  --bg: #0d0d0f;
  --bg2: #1d1e25;
  --bg3: #282932;
  --input: #101012;
  --line: #3a3a40;
  --hi: #444656;
  --fg: #d2d2d8;
  --dim: #82828c;
  --accent: #d6d6dc;
  --white: #ffffff;
  --row-even: #2a2b35;
  --ok: #5fbf6a;
  --err: #b84a4a;
  --warn: #c9a24a;
  --role-admin: #b2c9ff; /* the name of an admin, everywhere it is shown */
  --role-user: #ff79b8; /* the name of a member with an active subscription (the old pink) */
  --role-member: #d2d2d8; /* the neutral name of a member: the normal text colour */
}

* { box-sizing: border-box; }

html { background: var(--bg); color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 Monaco, Consolas, "Lucida Console", monospace;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 880px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--white); text-decoration: underline; }

/* ---- top bar ---- */
.top { padding: 16px 0 12px; }
.topin { display: flex; justify-content: space-between; align-items: baseline; gap: 12px 24px; flex-wrap: wrap; }
.brand { color: var(--white); font-weight: 700; font-size: 22px; letter-spacing: .02em; text-decoration: none; }
.brand:hover { text-decoration: none; color: var(--white); }
.nav { display: flex; gap: 6px 20px; flex-wrap: wrap; align-items: baseline; }
.nav a, .navlink { color: var(--dim); background: none; border: 0; padding: 0; margin: 0; font: inherit; cursor: pointer; text-decoration: none; }
.nav a:hover, .navlink:hover { color: var(--fg); text-decoration: none; }
.nav a.current { color: var(--accent); }
.nav a.nav-forum, .nav a.nav-forum:hover { color: var(--role-user, #ff79b8); }
.nav a.nav-forum.current { text-decoration: underline; text-underline-offset: 4px; }
.nav a.navicon { position: relative; display: inline-flex; align-self: center; }
.nav a.navicon svg { display: block; }
.nav a.navicon.linked { color: var(--fg); }
.navicon .tick { position: absolute; right: -5px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.nav a.discordlink { color: var(--fg); }
.logout { display: inline; margin: 0; }

main { padding-top: 6px; padding-bottom: 28px; }

/* ---- boxes ---- */
.box { margin: 0 0 14px; background: var(--bg2); border: 1px solid var(--line); }
.box-head {
  margin: 0;
  padding: 7px 12px;
  background: var(--bg3);
  border-bottom: 2px solid var(--hi);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.box-body > p, .box-body > form, .box-body > .actions, .box-body > .pad, .box-body > ul { margin: 0; padding: 10px 12px; }
.box-body > p + p { padding-top: 0; }
.box-body ul { padding-left: 30px; }
.box-body h3 { margin: 0; padding: 10px 12px 0; color: var(--white); font-size: 13px; }
.pad { padding: 10px 12px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cols > .box { margin-bottom: 0; }
.stack { margin-bottom: 14px; }

/* ---- tables ---- */
table { border-collapse: collapse; width: 100%; }
.rows th, .rows td { padding: 7px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.rows tr:first-child th, .rows tr:first-child td { border-top: 0; }
.rows th { width: 34%; color: var(--dim); font-weight: 400; }
.rows td { color: var(--fg); word-break: break-word; }

.scroll { overflow-x: auto; }
.grid { background: var(--input); }
.grid th { padding: 6px 12px; text-align: left; color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--line); background: var(--bg3); }
.grid td { padding: 6px 12px; border-top: 1px solid var(--line); vertical-align: top; word-break: break-word; }
.grid tbody tr:first-child td { border-top: 0; }
.grid tbody tr:nth-child(even) td { background: var(--row-even); }
.grid td.empty { color: var(--dim); text-align: center; padding: 14px 12px; }

/* ---- controls ---- */
.btn {
  display: inline-block;
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 4px 12px;
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--hi); color: var(--white); text-decoration: none; background: var(--bg3); }
.btn:disabled { color: var(--dim); cursor: not-allowed; border-color: var(--line); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; margin: 0; padding: 0; }

.field { margin: 0 0 10px; }
.field label { display: block; margin: 0 0 3px; color: var(--dim); }
.field.check label { display: flex; gap: 8px; align-items: flex-start; color: var(--fg); }
.field.check input { margin-top: 3px; flex: none; }
.hint { color: var(--dim); font-size: 12px; margin-top: 2px; }
.input {
  display: block;
  width: 100%;
  max-width: 380px;
  background: var(--input);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 5px 8px;
  font: inherit;
}
textarea.input { max-width: 100%; resize: vertical; }
.input:focus { outline: 1px solid var(--hi); border-color: var(--hi); }
input[type=checkbox] { accent-color: var(--accent); }

.narrow { max-width: 440px; margin: 28px auto 0; }

.notice { margin: 0 0 14px; padding: 8px 12px; background: var(--bg2); border: 1px solid var(--hi); color: var(--fg); }
.notice.error { border-color: var(--err); color: var(--err); }

/* ---- words and values ---- */
.dim { color: var(--dim); }
.code { font-family: Monaco, Consolas, "Lucida Console", monospace; color: var(--white); letter-spacing: .04em; overflow-wrap: anywhere; }
.st-online { color: var(--ok); }
.st-offline { color: var(--err); }
.st-updating { color: var(--warn); }
.st-bad { color: var(--err); }
/* the colour of a member's name by role (lib/html.js roleClass): admin wins over the subscriber colour; other members keep the normal text colour */
.premium, a.premium:hover { color: var(--role-user); }
.name-admin, a.name-admin:hover { color: var(--role-admin); }

.pre { white-space: pre-wrap; }
.plan-price { color: var(--white); }
.pager { padding: 8px 12px; color: var(--dim); }

.legal { padding: 10px 14px 14px; color: var(--fg); }
.legal h3 { color: var(--white); font-size: 13px; margin: 14px 0 4px; padding: 0; }
.legal p, .legal li { margin: 0 0 8px; }
.legal ul { margin: 0 0 8px; padding-left: 22px; }
.legal .placeholder { color: var(--warn); }

.foot { color: var(--dim); font-size: 12px; padding-bottom: 28px; }
.foot a { color: var(--dim); }
.foot a:hover { color: var(--fg); }

/* ---- documentation (/docs): a navigation box on the left, the page in one box on the right ---- */
.wrap.wide { max-width: 1120px; }

.docs { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; align-items: start; }
.docs > .box { margin: 0; }
.docs-nav { position: sticky; top: 8px; padding: 4px 0 6px; }
.docs-nav ul { list-style: none; margin: 0; padding: 0; }
.docs-nav .nav-group { margin: 8px 0 2px; padding: 4px 12px; color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-top: 1px solid var(--line); }
.docs-nav ul:first-child + .nav-group { margin-top: 6px; }
.docs-nav a { display: block; padding: 3px 12px 3px 10px; color: var(--fg); border-left: 2px solid transparent; }
.docs-nav a:hover { background: var(--bg3); color: var(--white); text-decoration: none; }
.docs-nav a.current { background: var(--bg3); color: var(--white); border-left-color: var(--hi); }

.box-body.doc { padding: 2px 16px 16px; overflow-wrap: break-word; }
.box-body.doc > p, .box-body.doc > ul, .box-body.doc > ol { margin: 8px 0; padding: 0; }
.box-body.doc > ul, .box-body.doc > ol { padding-left: 24px; }
.doc li { margin: 3px 0; }
.box-body.doc > .lead { margin-top: 12px; color: var(--dim); font-size: 14px; }
.box-body.doc h2 { margin: 26px 0 6px; padding: 0 0 4px; border-bottom: 1px solid var(--line); color: var(--white); font-size: 15px; scroll-margin-top: 8px; }
.box-body.doc h3 { margin: 20px 0 4px; padding: 0; color: var(--white); font-size: 13px; scroll-margin-top: 8px; }
.doc code { font: 12px Monaco, Consolas, "Lucida Console", monospace; color: var(--white); background: var(--input); padding: 0 4px; }
.doc pre.src { margin: 8px 0; padding: 8px 12px; background: var(--input); border: 1px solid var(--line); overflow-x: auto; tab-size: 2; }
.doc pre.src code { display: block; padding: 0; background: none; color: var(--fg); font: 12px/1.5 Monaco, Consolas, "Lucida Console", monospace; white-space: pre; }
.doc pre.src .c { color: var(--dim); }
.doc pre.src .s { color: var(--ok); }
.doc pre.src .n { color: var(--warn); }
.doc pre.src .k { color: var(--white); font-weight: 700; }
.doc pre.src .a { color: var(--accent); }
.doc .scroll { margin: 10px 0; border: 1px solid var(--line); }
.doc .grid code { padding: 0; background: none; }
.doc .grid td, .doc .grid th { word-break: normal; overflow-wrap: break-word; }
.doc .note { margin: 12px 0; padding: 7px 12px; background: var(--bg3); border-left: 2px solid var(--hi); }
.doc .toc { margin: 14px 0 6px; padding: 8px 12px; background: var(--input); border: 1px solid var(--line); }
.doc .toc-head { margin: 0 0 4px; color: var(--dim); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.doc .toc ul { margin: 0; padding-left: 0; list-style: none; columns: 2; column-gap: 24px; }
.doc .toc li { margin: 1px 0; break-inside: avoid; }
.doc .toc li ul { columns: 1; padding-left: 14px; }
.box-body.doc > .pager { margin: 22px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); color: var(--dim); }

/* ---- small screens: one column, nothing fancy ---- */
@media (max-width: 700px) {
  .docs { grid-template-columns: 1fr; }
  .docs-nav { position: static; }
  .doc .toc ul { columns: 1; }
  .cols { grid-template-columns: 1fr; }
  .rows th { width: 40%; }
  .nav { gap: 6px 14px; }
  .narrow { margin-top: 12px; }
  .input { max-width: 100%; }
}

/* ---- member header (layout.js .hdr): bell + alerts, avatar + account, the two dropdowns ---- */
.hdr { position: relative; align-self: center; display: flex; align-items: center; gap: 10px; margin-left: auto; }
.hdr-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
}
.hdr-btn:hover { color: var(--fg); }
.hdr-btn[aria-expanded="true"] { color: var(--white); }
.hdr-btn:focus-visible { outline: 1px solid var(--hi); outline-offset: 2px; }
.hdr-btn svg { display: block; width: 20px; height: 20px; }
.hdr-me:hover .avatar, .hdr-me[aria-expanded="true"] .avatar { opacity: .8; }
.hdr .badge { position: absolute; top: -5px; right: -7px; min-width: 16px; height: 16px; padding: 0 4px; background: var(--role-user); border: 0; color: var(--white); font-size: 10px; font-weight: 700; line-height: 16px; letter-spacing: 0; text-align: center; text-transform: none; }

.hdr .dd {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: 300px;
  max-width: calc(100vw - 32px);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-top: 2px solid var(--hi);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}
.hdr .dd[hidden] { display: none; }
.hdr .dd.dd-wide { width: 340px; }
.hdr .dd-head { margin: 0; padding: 7px 12px; background: var(--bg3); border-bottom: 1px solid var(--line); color: var(--white); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hdr .dd-list { max-height: 380px; overflow-y: auto; }
.hdr .dd-empty { padding: 14px 12px; color: var(--dim); text-align: center; }
.hdr .dd-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-top: 1px solid var(--line); }
.hdr .dd-list > .dd-item:first-child { border-top: 0; }
.hdr .dd-item:hover { background: var(--bg3); }
.hdr .dd-item.unread { box-shadow: inset 2px 0 0 var(--role-user); }
.hdr .dd-body { display: block; flex: 1 1 auto; min-width: 0; }
.hdr .dd-text { display: block; overflow-wrap: anywhere; }
.hdr .dd-time { display: block; margin-top: 2px; color: var(--dim); font-size: 11px; }
.hdr .dd-foot { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; }
.hdr .dd-who { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line); }
.hdr .dd-who > div { min-width: 0; }
.hdr .dd-who .dd-name { display: block; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.hdr .dd-group { margin-top: 2px; color: var(--dim); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.hdr .dd-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.hdr .dd-stats span { padding: 8px 4px; color: var(--dim); font-size: 11px; text-align: center; overflow-wrap: anywhere; }
.hdr .dd-stats span + span { border-left: 1px solid var(--line); }
.hdr .dd-stats b { display: block; color: var(--white); font-size: 14px; }
.hdr .dd-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.hdr .dd-links a { padding: 3px 0; font-size: 12px; }
.hdr .dd-status { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.hdr .dd-status input { flex: 1 1 auto; min-width: 0; margin: 0; padding: 4px 8px; background: var(--input); color: var(--fg); border: 1px solid var(--line); border-radius: 0; font: inherit; font-size: 12px; }
.hdr .dd-status input:focus { outline: 1px solid var(--hi); border-color: var(--hi); }
.hdr .dd-status .btn { flex: none; }
.hdr .dd .logout { display: block; margin: 0; padding: 8px 12px; }
.hdr .dd .logout .navlink { font-size: 12px; }

/* the link colour of a dropdown: the site's link colour is the nav's dim grey, so the panel sets its own */
.hdr .dd a { color: var(--fg); text-decoration: none; }
.hdr .dd a:hover { color: var(--white); text-decoration: none; }
.hdr .dd-foot a { color: var(--accent); }
.hdr .dd a.dd-name, .hdr .dd a.dd-name:hover { color: var(--role-member); }

/* ---- avatars: round, one line of border; the role colours the ring ---- */
.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg3);
  color: var(--white);
  font-weight: 700;
  line-height: 1;
  user-select: none;
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-letter { text-transform: uppercase; }
.avatar-s { width: 28px; height: 28px; }
.avatar-s .avatar-letter { font-size: 12px; }
.avatar-m { width: 48px; height: 48px; }
.avatar-m .avatar-letter { font-size: 18px; }
.avatar-xl { width: 150px; height: 150px; }
.avatar-xl .avatar-letter { font-size: 56px; }
.avatar.premium { border-color: var(--role-user); }
.avatar.name-admin { border-color: var(--role-admin); }

/* a button that looks like a link */
.linkbtn { margin: 0; padding: 0; background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: none; }
.linkbtn:hover { color: var(--white); text-decoration: underline; }

/* ---- phone: the dropdowns are full-width panels under the header (the header is the containing block) ---- */
@media (max-width: 600px) {
  .top { position: relative; }
  .hdr { position: static; }
  .hdr .dd, .hdr .dd.dd-wide { top: 100%; left: 0; right: 0; width: auto; max-width: none; max-height: 80vh; overflow-y: auto; box-shadow: none; }
  .hdr .dd-list { max-height: 60vh; }
}
