:root {
  --bg: #f7f5fb;
  --surface: #ffffff;
  --text: #24212b;
  --muted: #6b6578;
  --border: #e2dcec;
  --accent: #7b4fd6;
  --accent-soft: #efe8fc;
  color-scheme: light;
}
/* Dark: follows the system setting unless the toggle picked light,
   or forced on when the toggle picked dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17151c;
    --surface: #211e28;
    --text: #ece8f3;
    --muted: #a59eb3;
    --border: #36313f;
    --accent: #b596ff;
    --accent-soft: #2d2540;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17151c;
  --surface: #211e28;
  --text: #ece8f3;
  --muted: #a59eb3;
  --border: #36313f;
  --accent: #b596ff;
  --accent-soft: #2d2540;
  color-scheme: dark;
}

.theme-toggle {
  position: fixed; top: 8px; right: 16px; z-index: 10;
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
  padding: 6px 14px; border-radius: 99px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
}
.theme-toggle:hover { border-color: var(--accent); }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
img { max-width: 100%; height: auto; }

/* Portal */
.portal { max-width: 960px; margin: 0 auto; padding: 48px 16px; }
.portal h1 { font-size: 2.2rem; margin: 0 0 20px; }
.lead { color: var(--muted); margin: 0 0 32px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cards-2, .cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .cards, .cards-2, .cards-4 { grid-template-columns: 1fr; } }
.portal { max-width: 1240px; }
.hub-grid { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 28px; align-items: start; }
@media (max-width: 960px) { .hub-grid { grid-template-columns: 1fr; } }
.hub-side {
  position: sticky; top: 64px; margin-top: 36px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.hub-side h2 { margin: 0 0 2px; font-size: 1.15rem; }
.hub-side .note { margin: 0 0 12px; color: var(--muted); font-size: .85rem; }
.hub-side .note:last-child { margin: 12px 0 0; }
.hub-side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hub-side li { padding: 8px 10px; border-radius: 10px; background: var(--bg); line-height: 1.5; }
.hub-side li span { font-weight: 600; margin-right: 2px; }
.hub-side li a { font-weight: 600; white-space: nowrap; }

/* Template previews */
.tpl-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 24px; }
.tpl-head h1 { margin: 0 0 6px; }
.tpl-head .note { max-width: 70ch; color: var(--muted); margin: 0 0 8px; }
.tpl-warn { color: #b45f06 !important; font-weight: 600; }
.tpl-actions { display: flex; align-items: flex-start; gap: 8px; flex: none; }
.tpl-dl { position: relative; }
.tpl-dl summary {
  list-style: none; cursor: pointer; font-weight: 700; padding: 8px 16px; border-radius: 99px;
  background: var(--accent); color: #fff; white-space: nowrap;
}
.tpl-dl summary::-webkit-details-marker { display: none; }
.tpl-dl-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
}
.tpl-dl-menu a, .tpl-dl-menu button {
  font: inherit; text-align: left; padding: 8px 12px; border-radius: 8px; border: 0; background: none;
  color: var(--text); text-decoration: none; cursor: pointer;
}
.tpl-dl-menu a:hover, .tpl-dl-menu button:hover { background: var(--accent-soft); color: var(--accent); }
.tpl-dl-menu button:disabled { opacity: .6; cursor: wait; }
.tpl-reset { font: inherit; cursor: pointer; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.tpl-reset:hover { color: var(--text); border-color: var(--accent); }
.tpl-sheet [contenteditable] { cursor: text; min-height: 1.4em; }
.tpl-sheet [contenteditable]:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.tpl-sheet [contenteditable]:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); color: var(--text); }
.tpl-sheet .tpl-cb { width: 18px; height: 18px; cursor: pointer; accent-color: #2e9a52; display: block; margin: 0 auto; }
.tpl-sheet td:has(.tpl-cb) { color: #1d1b22; }
.tpl-spark { display: flex; align-items: center; gap: 6px; }
.tpl-spark-fill { display: block; height: 12px; border-radius: 4px; min-width: 2px; transition: width .2s; }
.tpl-spark-n { font-size: .75rem; color: var(--muted); white-space: nowrap; margin-left: auto; }
.bar .bar-label { color: var(--muted); }

.hub-section { margin-top: 36px; }
.hub-section > h2 { font-size: 1.5rem; margin: 0 0 2px; padding-bottom: 6px; border-bottom: 2px solid var(--accent-soft); }
.hub-section > .lead { margin: 6px 0 16px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h2, .card h3 { margin: 0; font-size: 1.2rem; }
.card p { margin: 0; color: var(--muted); flex: 1; }
.kind {
  align-self: flex-start; font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent); background: var(--accent-soft);
  padding: 2px 8px; border-radius: 99px;
}
.detail { font-size: .85rem; color: var(--muted); }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 16px; align-items: center;
  padding: 10px 120px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar a { text-decoration: none; font-weight: 600; white-space: nowrap; }
.bar span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Document pages */
.doc-layout {
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px;
  max-width: 1200px; margin: 0 auto; padding: 24px 16px;
}
.doc-layout.no-toc { grid-template-columns: minmax(0, 1fr); max-width: 980px; }
.doc table.cheatsheet { font-size: .95rem; table-layout: auto; width: 100%; }
.doc .cheatsheet td, .doc .cheatsheet th { overflow-wrap: normal; }
.doc .cheatsheet td:first-child, .doc .cheatsheet td:nth-child(3) { white-space: nowrap; }
.doc .cheatsheet td, .doc .cheatsheet th { padding: 8px 10px; }
.toc { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 80px); overflow: auto; font-size: .9rem; }
.toc h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 2px 0; }
.toc li.lvl2 { padding-left: 12px; }
.toc a { text-decoration: none; color: var(--text); }
.toc a:hover { color: var(--accent); }
.toc a { display: block; padding: 2px 8px; margin-left: -8px; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; }
.toc a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); border-left-color: var(--accent); }
.doc {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px clamp(16px, 4vw, 48px); max-width: 860px;
}
.doc-title { margin-top: 0; }
.doc h1, .doc h2, .doc h3 { scroll-margin-top: 64px; line-height: 1.3; }
.doc img { display: block; margin: 16px auto; border-radius: 8px; }
.doc table { border-collapse: collapse; }
.doc td, .doc th { border: 1px solid var(--border); padding: 6px 8px; }

@media (max-width: 800px) {
  .doc-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; }
}

/* Spreadsheet pages */
.sheet-page { max-width: 1400px; margin: 0 auto; padding: 24px 16px; }
.sheet-page h1 { margin: 0 0 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tab {
  padding: 6px 14px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-group {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 3px 6px 3px 12px; border-radius: 99px; border: 1px dashed var(--border);
}
.tab-group-label { font-weight: 700; font-size: .9rem; color: var(--muted); letter-spacing: .03em; }
.panel h2 { font-size: 1.2rem; margin: 0 0 8px; }
.note { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }
.table-wrap { overflow: auto; max-height: 80vh; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table.sheet { border-collapse: collapse; font-size: .85rem; table-layout: fixed; min-width: 100%; }
.sheet td, .sheet th { border: 1px solid var(--border); padding: 4px 6px; vertical-align: top; overflow-wrap: anywhere; }
.sheet th { background: var(--accent-soft); text-align: left; position: sticky; top: 0; z-index: 1; }
.sheet td[data-num] { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.filled, .sheet th.filled { color: #1d1b22; }
.sheet img { display: block; max-width: 100%; max-height: 220px; margin: 0 auto 4px; }

.bar .bar-right { margin-left: auto; font-weight: 500; }
/* Section switcher ("Guardians ▾" → Economy → FastLane …) */
.sec-menu { position: relative; flex: none; }
.sec-menu-btn {
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
  padding: 3px 12px; border-radius: 99px;
  color: var(--accent); background: var(--accent-soft); border: 1px solid transparent;
}
.sec-menu-btn:hover, .sec-menu.open .sec-menu-btn { border-color: var(--accent); }
.sec-menu-panel {
  display: none; position: absolute; top: 100%; left: 0; z-index: 30;
  padding-top: 8px; /* bridges the gap so hovering down doesn't close it */
}
.sec-menu:hover .sec-menu-panel, .sec-menu.open .sec-menu-panel { display: block; }
.sec-menu-panel > ul {
  list-style: none; margin: 0; padding: 8px; min-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.2);
}
.sec-menu-group + .sec-menu-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.sec-menu-name {
  display: block; padding: 4px 10px; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.sec-menu-group.here .sec-menu-name { color: var(--accent); }
.sec-menu-group ul { list-style: none; margin: 0; padding: 0; }
.sec-menu-group a, .sec-menu-current {
  display: block; padding: 6px 10px 6px 18px; border-radius: 8px; white-space: nowrap; font-size: .92rem;
}
.sec-menu-group a { color: var(--text); text-decoration: none; }
.sec-menu-group a:hover, .sec-menu-group a:focus-visible { background: var(--accent-soft); color: var(--accent); }
.sec-menu-current { color: var(--muted); opacity: .6; cursor: default; }
@media (max-width: 700px) {
  /* Phones: the menu spans the screen under the button and titles wrap. */
  .sec-menu-panel { position: fixed; left: 16px; right: 16px; top: auto; }
  .sec-menu-panel > ul { min-width: 0; }
  .sec-menu-group a, .sec-menu-current { white-space: normal; }
}

.doc-nav {
  display: flex; flex-wrap: wrap; gap: 4px; min-width: 0;
  padding-left: 12px; border-left: 1px solid var(--border);
}
.doc-nav::-webkit-scrollbar { display: none; }
.doc-nav a, .doc-nav .doc-nav-current {
  flex: none; padding: 3px 10px; border-radius: 99px; white-space: nowrap; font-size: .9rem;
}
.doc-nav a { font-weight: 500; }
.doc-nav a:hover { background: var(--accent-soft); }
.bar .doc-nav .doc-nav-current {
  color: var(--muted); opacity: .6; cursor: default; overflow: visible;
  background: var(--bg); border: 1px solid var(--border);
}
@media (max-width: 700px) {
  /* Phones: documents get their own row under "All guides" (below the theme
     button, so that row can use the full width) and wrap instead of hiding. */
  .bar:has(.doc-nav) { flex-wrap: wrap; row-gap: 8px; }
  .doc-nav {
    flex-basis: 100%; flex-wrap: wrap; overflow: visible;
    margin-right: -104px; padding-left: 0; border-left: 0;
  }
}

/* Change-password page */
.account { max-width: 440px; margin: 0 auto; padding: 40px 16px; }
.account h1 { margin: 0 0 4px; }
.account .lead { margin-bottom: 20px; }
.account-form { display: flex; flex-direction: column; gap: 14px; }
.account-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .95rem; }
.account-form .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.account-form input {
  font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.account-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.account-form .enter { align-self: flex-start; margin: 6px 0 0; border: 0; cursor: pointer; font: inherit; font-weight: 700; letter-spacing: .04em; }
.pw-rules { list-style: none; margin: -6px 0 0; padding: 0; font-size: .85rem; color: var(--muted); }
.pw-rules li::before { content: "\2715"; display: inline-block; width: 1.4em; color: #c0504d; }
.pw-rules li.met { color: var(--text); }
.pw-rules li.met::before { content: "\2713"; color: #2e9a52; }
.account-msg { padding: 10px 14px; border-radius: 10px; border: 1px solid; }
.account-msg.good { color: #1e7a3c; background: #e6f6ea; border-color: #b6e2c2; }
.account-msg.bad { color: #a12a2a; background: #fbeaea; border-color: #f0c2c2; }

/* Designed-page tabs (text boxes placed on the sheet's grid, spacers left out) */
.sheet-layout { display: grid; grid-auto-rows: auto; gap: 6px; padding: 10px; font-size: .9rem; min-width: 900px; }
.sheet-layout .blk {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); line-height: 1.45; overflow-wrap: anywhere;
}
.sheet-layout .blk.filled { color: #1d1b22; border-color: rgba(0,0,0,.12); }
.sheet-layout .blk img { display: block; max-width: 100%; margin: 0 auto 4px; }

/* FastLane tracker */
.fl-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 0 0 10px; }
.fl-controls label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.fl-controls input, .fl-controls select, .fl-table input[type=number], .fl-results input[type=number] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.fl-controls input[type=number] { width: 6em; }
.fl-search input { width: min(320px, 70vw); }
.fl-table input[type=number], .fl-results input[type=number] { width: 5em; padding: 3px 6px; color: #1d1b22; background: rgba(255,255,255,.85); border-color: rgba(0,0,0,.25); }
.fl-table input[type=checkbox], .fl-results input[type=checkbox], .fl-mails input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.fl-clear { font: inherit; font-weight: 600; cursor: pointer; padding: 6px 14px; border-radius: 99px; border: 1px solid #b45f06; background: #fbe3cc; color: #7a3d00; }
.fl-clear:hover { background: #f6cfa6; }
.fl-legend { font-size: .85rem; color: var(--muted); margin: 0 0 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fl-swatch { padding: 1px 8px; border-radius: 6px; font-weight: 600; }
.fl-count { color: var(--muted); font-size: .9rem; }

table.fl-results { border-collapse: collapse; font-size: .85rem; min-width: 100%; }
.fl-results td, .fl-results th { border: 1px solid var(--border); padding: 4px 6px; vertical-align: top; }
.fl-results thead th { background: var(--accent-soft); text-align: left; position: sticky; top: 0; z-index: 1; }
.fl-results td[data-num] { text-align: right; font-variant-numeric: tabular-nums; }
.fl-table thead th { position: sticky; top: 0; z-index: 1; background: var(--accent-soft); text-align: left; }
/* Size columns to their content (regular sheets use fixed equal columns). */
table.fl-table, table.fl-results { table-layout: auto; }
.fl-table th, .fl-table td, .fl-results th, .fl-results td { overflow-wrap: normal; word-break: normal; }
.fl-table thead th, .fl-results thead th { min-width: 4.5em; vertical-align: bottom; }
.fl-table td:nth-child(n+7), .fl-results td:nth-child(n+7) { min-width: 8em; }

/* Row colors = the sheet's conditional formatting. */
tr.fl-g > td, .fl-swatch.fl-g { background: #00b050; color: #fff; }
tr.fl-o > td, .fl-swatch.fl-o { background: #ffc000; color: #fff; }
tr.fl-r > td, .fl-swatch.fl-r { background: #ff0000; color: #fff; }
tr.fl-k > td, .fl-swatch.fl-k { background: #000; color: #fff; }
tr.fl-a > td, .fl-swatch.fl-a { background: #e2e2e2; color: #7f7f7f; }
tr.fl-g a, tr.fl-o a, tr.fl-r a, tr.fl-k a { color: #fff; }

.fl-rewards-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; margin-bottom: 12px; }
@media (max-width: 700px) { .fl-rewards-top { grid-template-columns: 1fr; } }
.fl-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--surface); }
.fl-box h3 { margin: 0 0 6px; font-size: .95rem; }
.fl-note p { margin: 0; font-size: .9rem; }
.fl-mails { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fl-mails li { border-radius: 6px; padding: 3px 8px; }
.fl-mails label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.fl-mails li.fl-todo, tr.fl-todo > td { background: #cc4125; color: #fff; }
.fl-mails li.fl-done, tr.fl-done > td { background: #4ea72e; color: #fff; }
.fl-totals { margin-bottom: 12px; max-height: none; }
.fl-totals tbody th { text-align: left; white-space: nowrap; }
.fl-p1 { background: #cc0000; color: #fff; }
.fl-p2 { background: #e69138; color: #fff; }
.fl-p3 { background: #ffd966; color: #1d1b22; }
.fl-p4 { background: #b7e1cd; color: #1d1b22; }
.fl-p5 { background: #6aa84f; color: #fff; }

/* Hub search */
.hub-search { margin: 0 0 24px; }
.doc-col { min-width: 0; }
.doc-col .hub-search { max-width: 860px; margin-bottom: 16px; }
#hub-q {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
#hub-q:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
#hub-results {
  margin-top: 12px; max-height: 60vh; overflow: auto; padding: 4px 16px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
#hub-results[hidden] { display: none; }
.hub-note { color: var(--muted); font-size: .9rem; margin: 10px 0; }
.hub-group h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 6px; }
.hub-group h2 span { background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 0 8px; margin-left: 4px; }
.hub-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hub-group a { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.hub-group a:hover, .hub-group a:focus-visible { background: var(--accent-soft); }
.hub-sec { font-size: .75rem; font-weight: 600; color: var(--accent); }
.hub-text { font-size: .9rem; line-height: 1.45; overflow-wrap: anywhere; }
.hub-text mark { background: #ffe58a; color: #1d1b22; border-radius: 3px; padding: 0 2px; }

/* Bookmarks */
.bm-hover-btn {
  position: absolute; z-index: 6; width: 26px; height: 26px; padding: 4px;
  display: grid; place-items: center; cursor: pointer;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.bm-hover-btn[hidden] { display: none; }
.bm-hover-btn:hover { color: var(--accent); border-color: var(--accent); }
.bm-hover-btn svg, .bm-open svg, .bm-del svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bm-hover-btn.on { color: var(--accent); }
.bm-hover-btn.on svg { fill: currentColor; }

.doc .bm-on { background: var(--accent-soft); box-shadow: -10px 0 0 var(--accent-soft), -13px 0 0 var(--accent); border-radius: 0 6px 6px 0; }
.sheet tr.bm-on > :first-child { box-shadow: inset 4px 0 0 var(--accent); }
@keyframes bm-flash { from { outline-color: var(--accent); } to { outline-color: transparent; } }
.bm-flash { outline: 3px solid transparent; outline-offset: 2px; animation: bm-flash 1.6s ease-out; }

.bm-open {
  position: fixed; right: 16px; bottom: 16px; z-index: 10;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 16px; border-radius: 99px; border: 0;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.bm-open svg { width: 18px; height: 18px; }
.bm-count:not(:empty) { background: rgba(255,255,255,.25); border-radius: 99px; padding: 0 8px; font-size: .85rem; }

.bm-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 20;
  width: min(380px, 100vw); display: flex; flex-direction: column; gap: 12px;
  padding: 16px; background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0,0,0,.18);
}
.bm-drawer[hidden] { display: none; }
.bm-head { display: flex; align-items: center; justify-content: space-between; }
.bm-head h2 { margin: 0; font-size: 1.2rem; }
.bm-close { font: inherit; font-size: 1.1rem; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.bm-search {
  font: inherit; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.bm-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.bm-list { overflow: auto; flex: 1; margin: 0 -16px; padding: 0 16px; }
.bm-empty { color: var(--muted); font-size: .9rem; }
.bm-group h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }
.bm-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bm-group li { display: flex; align-items: flex-start; gap: 6px; border: 1px solid var(--border); border-radius: 10px; }
.bm-group li:hover { border-color: var(--accent); }
.bm-group li a { flex: 1; min-width: 0; padding: 8px 10px; color: var(--text); text-decoration: none; display: flex; flex-direction: column; gap: 2px; }
.bm-sec { font-size: .75rem; font-weight: 600; color: var(--accent); }
.bm-text { font-size: .88rem; line-height: 1.4; overflow-wrap: anywhere; }
.bm-del { flex: none; width: 34px; height: 34px; margin: 4px; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.bm-del:hover { color: #c0504d; background: var(--accent-soft); }

/* Join (registration) popup on the entry page */
.gate-join { margin: 14px 0 0; font-size: .9rem; color: var(--muted); }
.gate-join a { font-weight: 700; }
dialog.join {
  width: min(420px, calc(100vw - 32px)); padding: 28px 26px 20px; border-radius: 18px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
dialog.join::backdrop { background: rgba(10, 8, 16, .55); }
.join h2 { margin: 0 0 14px; font-size: 1.3rem; }
.join form { display: flex; flex-direction: column; gap: 12px; }
.join form[hidden] { display: none; }
.join label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
.join input {
  font: inherit; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.join input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.join .enter { margin: 6px 0 0; border: 0; cursor: pointer; font: inherit; font-weight: 700; letter-spacing: .06em; align-self: stretch; text-align: center; }
.join .enter:disabled { opacity: .6; cursor: wait; }
.join-close { position: absolute; top: 10px; right: 12px; font-size: 1.5rem; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; }
.join .field-err { margin: -6px 0 0; min-height: 0; color: #c0392b; font-size: .85rem; font-weight: 600; }
.join .field-err:empty { display: none; }
.join input.has-err { border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192, 57, 43, .18); }
.join input { -webkit-user-select: none; user-select: none; }
.join-typed { margin: -2px 0 0; font-size: .8rem; color: var(--muted); }
.join-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.join-status { min-height: 1.4em; margin: 12px 0 0; font-size: .92rem; }
.join-status.bad { color: #c0392b; font-weight: 600; }
.join-status.good { color: #2e9a52; font-weight: 600; font-size: 1rem; }
.join-support { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); }

/* Admin panel */
.admin { max-width: 1240px; margin: 0 auto; padding: 24px 16px; }
.admin h1 { margin: 0 0 14px; }
.admin .tabs { margin-bottom: 16px; }
.bar .bar-admin { font-weight: 700; margin-left: auto; }
.bar .bar-admin + .bar-right { margin-left: 16px; }
.badge { display: inline-block; padding: 0 7px; border-radius: 99px; background: #e5484d; color: #fff; font-size: .72rem; font-weight: 700; vertical-align: middle; }
.adm-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.adm-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; }
.adm-card b { font-size: 1.6rem; line-height: 1.2; }
.adm-card span { color: var(--muted); font-size: .85rem; }
.adm-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; }
.adm-box.alert { border-color: #e5484d; box-shadow: 0 0 0 3px rgba(229, 72, 77, .15); }
.adm-box h2 { margin: 0 0 10px; font-size: 1.15rem; }
.adm-box .table-wrap { max-height: 70vh; }
table.adm { width: 100%; border-collapse: collapse; font-size: .9rem; }
.adm th, .adm td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.adm thead th { position: sticky; top: 0; background: var(--accent-soft); z-index: 1; }
.adm td[data-num] { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm tr.is-new td { background: rgba(229, 72, 77, .07); }
.adm .manage { display: flex; flex-wrap: wrap; gap: 6px; }
.adm .manage form { display: flex; gap: 4px; align-items: center; }
.admin select, .admin input[type=text], .adm-add input {
  font: inherit; font-size: .88rem; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.admin button {
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; padding: 5px 12px; border-radius: 99px;
  border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
}
.admin button.danger { border-color: #e5484d; background: transparent; color: #e5484d; }
.adm-add { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.adm-add label { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; font-weight: 600; }
.adm-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 20px; margin: 0; }
.adm-facts dt { color: var(--muted); font-size: .8rem; }
.adm-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.ok { color: #2e9a52; font-weight: 700; }
.blocked { color: #e5484d; font-weight: 700; }

/* Entry + unauthorized pages */
body.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-back { position: absolute; top: 16px; left: 16px; font-weight: 600; text-decoration: none; }
.gate-back:hover { text-decoration: underline; }
.gate-card {
  width: 100%; max-width: 520px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 48px clamp(20px, 6vw, 48px);
}
.gate-card h1 { margin: 0 0 4px; font-size: clamp(1.6rem, 5vw, 2.2rem); line-height: 1.2; }
.gate-sub { margin: 0 0 24px; color: var(--accent); font-weight: 600; }
.enter {
  display: inline-block; margin: 16px 0 24px; padding: 12px 40px; border-radius: 99px;
  background: var(--accent); color: #fff; font-weight: 700; letter-spacing: .12em;
  text-decoration: none; transition: transform .15s, filter .15s;
}
.enter:hover { transform: translateY(-2px); filter: brightness(1.08); }
.gate-fine { margin: 0; color: var(--muted); font-size: .9rem; }
.gate-error { margin: 0 0 20px; font-size: 1.1rem; font-weight: 600; }

.tip { position: relative; display: inline-block; }
.tip-trigger {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  text-decoration: underline; cursor: help;
}
.tip-bubble {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); z-index: 2;
  width: max-content; max-width: min(280px, 80vw); margin-top: 8px;
  padding: 8px 12px; border-radius: 8px; background: var(--text); color: var(--bg);
  font-size: .85rem; line-height: 1.4; visibility: hidden; opacity: 0; transition: opacity .15s;
}
.tip-bubble::after { /* keeps the bubble open while the mouse crosses the gap */
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 10px;
}
.tip-bubble a { color: inherit; }
.tip:hover .tip-bubble, .tip:focus-within .tip-bubble, .tip.open .tip-bubble { visibility: visible; opacity: 1; }

footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; }
