/* XC Wiki — dark-first knowledge base theme */
:root, [data-theme="dark"] {
  --bg: #0B0E14;
  --bg2: #0D1119;
  --card: #131826;
  --card2: #161C2E;
  --border: #1E2639;
  --text: #FFFFFF;
  --muted: #8B93A7;
  --muted2: #5C6579;
  --accent: #2E7CF6;
  --accent2: #3B82F6;
  --purple: #7C5CFF;
  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --hero-grad: linear-gradient(135deg, #101A33 0%, #0E1B3D 55%, #141B3A 100%);
  --input: #0F1422;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 14px;
}
[data-theme="light"] {
  --bg: #F4F6FB;
  --bg2: #FFFFFF;
  --card: #FFFFFF;
  --card2: #F8FAFD;
  --border: #E2E8F2;
  --text: #0F172A;
  --muted: #5B6478;
  --muted2: #8A93A8;
  --input: #F1F4FA;
  --hero-grad: linear-gradient(135deg, #1B2B5C 0%, #24407E 60%, #2B3F7E 100%);
  --shadow: 0 10px 26px rgba(15,23,42,.10);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.55;
  background-image: radial-gradient(rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 26px 26px;
}
[data-theme="light"] body { background-image: radial-gradient(rgba(15,23,42,.05) 1px, transparent 1px); }
.hidden { display: none !important; }
.container { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .5em; line-height: 1.25; }
p { margin: 0 0 1em; }
.link-btn { background: none; border: 0; color: var(--accent2); cursor: pointer; font-size: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- preview banner ---------- */
.preview-banner {
  background: linear-gradient(90deg, #4C2E9E, #5B3BB8);
  color: #fff; text-align: center; font-size: .85rem; padding: .55em 1em;
  display: flex; gap: 1em; align-items: center; justify-content: center; flex-wrap: wrap;
}
.preview-banner .link-btn { color: #fff; font-weight: 700; text-decoration: underline; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: rgba(11,14,20,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
[data-theme="light"] .topbar { background: rgba(255,255,255,.92); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .8rem; color: #fff; background: linear-gradient(135deg, #2E7CF6, #7C5CFF);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .92rem; }
.brand-text small { color: var(--muted); font-size: .72rem; }
.search-trigger {
  flex: 1; max-width: 460px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  background: var(--input); border: 1px solid var(--border); color: var(--muted);
  border-radius: 9px; padding: 7px 12px; cursor: pointer; font-size: .85rem;
}
.search-trigger:hover { border-color: var(--accent); }
.search-trigger .search-ph { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-trigger kbd {
  font-family: inherit; font-size: .68rem; background: var(--card2); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 7px; color: var(--muted);
}
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.theme-toggle { display: flex; background: var(--input); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.theme-toggle button {
  background: transparent; border: 0; color: var(--muted); font-size: .75rem; padding: 6px 10px; cursor: pointer;
}
.theme-toggle button.active { background: var(--accent); color: #fff; }
.user-chip {
  display: flex; align-items: center; gap: 8px; background: var(--input); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 6px 10px; cursor: pointer; font-size: .82rem;
}
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 9px;
  padding: .55em 1.1em; font-weight: 600; cursor: pointer; font-size: .88rem; display: inline-block;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--red); }
.btn.small { padding: .35em .8em; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  background: var(--input); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: .9rem;
}
.nav-toggle { display: none; }

/* ---------- main nav ---------- */
.mainnav {
  display: flex; gap: 4px; padding: 8px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg2); position: sticky; top: 55px; z-index: 40;
}
.mainnav a, .mainnav .nav-drop > button {
  color: var(--muted); font-size: .85rem; padding: 7px 12px; border-radius: 8px; background: none; border: 0; cursor: pointer;
}
.mainnav a:hover, .mainnav .nav-drop > button:hover { color: var(--text); background: var(--card); text-decoration: none; }
.mainnav a.active { color: #fff; background: var(--accent); }
.nav-drop { position: relative; }
.nav-drop-menu {
  display: none; position: absolute; top: 100%; left: 0; min-width: 200px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: var(--shadow); z-index: 60;
}
.nav-drop:hover .nav-drop-menu { display: block; }
.nav-drop-menu a { display: block; }

/* ---------- hero ---------- */
.hero {
  background: var(--hero-grad); border: 1px solid var(--border); border-radius: 18px;
  padding: 34px 34px 28px; margin: 26px 0 20px; position: relative; overflow: hidden;
}
.hero h1 { font-size: 1.9rem; margin-bottom: .25em; }
.hero h1 .hl { color: var(--accent2); }
.hero p.desc { color: var(--muted); max-width: 560px; font-size: .92rem; }
.hero-search { display: flex; gap: 8px; max-width: 520px; margin-top: 16px; }
.hero-search input {
  flex: 1; background: rgba(255,255,255,.06); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 14px; font-size: .92rem;
}
[data-theme="light"] .hero-search input { background: rgba(255,255,255,.85); }
.hero-search input:focus { outline: 2px solid var(--accent); }
.pop-searches { margin-top: 12px; font-size: .78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  background: rgba(255,255,255,.07); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 3px 12px; font-size: .76rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.hero-cards { position: absolute; right: 40px; top: 50%; transform: translateY(-50%); display: flex; gap: 10px; }
.hero-card {
  width: 74px; height: 100px; border-radius: 12px; border: 1.5px solid var(--accent2);
  background: rgba(46,124,246,.10); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--accent2); box-shadow: 0 0 24px rgba(46,124,246,.25);
}
.hero-card:nth-child(2) { transform: rotate(8deg) translateY(-8px); border-color: var(--purple); color: var(--purple); background: rgba(124,92,255,.10); }
.hero-card:nth-child(3) { transform: rotate(-8deg) translateY(6px); }

/* ---------- category cards ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 18px 0; }
.cat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 12px; color: var(--text); display: flex; flex-direction: column; gap: 4px;
  transition: transform .15s, border-color .15s; position: relative;
}
.cat-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.cat-card .ci { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.cat-card strong { font-size: .82rem; }
.cat-card small { color: var(--muted); font-size: .7rem; }
.cat-card .arr { position: absolute; right: 10px; top: 14px; color: var(--muted2); }

/* ---------- sections ---------- */
.section { margin: 26px 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.section-head h2 { font-size: 1.05rem; }
.section-head p.sub { color: var(--muted); font-size: .82rem; margin: 0 0 10px; }
.svc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.svc-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; gap: 12px; align-items: center; color: var(--text); transition: border-color .15s;
}
.svc-card:hover { border-color: var(--accent); text-decoration: none; }
.svc-card .si { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.svc-card strong { display: block; font-size: .9rem; }
.svc-card small { color: var(--muted); font-size: .78rem; }
.svc-card .arr { margin-left: auto; color: var(--muted2); }

/* continue reading */
.continue-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.continue-card .cr-title { font-weight: 700; font-size: .92rem; }
.continue-card .cr-step { color: var(--muted); font-size: .75rem; margin: 2px 0 8px; }
.progress { height: 5px; background: var(--input); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent2); border-radius: 99px; transition: width .3s; }

/* article lists */
.art-list { display: flex; flex-direction: column; }
.art-row { padding: 10px 2px; border-bottom: 1px solid var(--border); }
.art-row:last-child { border-bottom: 0; }
.art-row a.t { color: var(--text); font-weight: 600; font-size: .88rem; }
.art-row a.t:hover { color: var(--accent2); }
.art-row .meta { color: var(--muted); font-size: .74rem; margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.panel h3 { font-size: .95rem; display: flex; justify-content: space-between; align-items: center; }
.panel h3 a { font-size: .75rem; font-weight: 600; }

/* browse by service */
.browse-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 10px; }
.browse-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 6px;
  text-align: center; color: var(--text); font-size: .72rem; display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.browse-item:hover { border-color: var(--accent); text-decoration: none; }
.browse-item .bi { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; }

/* ---------- article page ---------- */
.crumbs { font-size: .8rem; color: var(--muted); margin: 18px 0 8px; }
.crumbs a { color: var(--muted); }
.reading-bar { position: fixed; top: 0; left: 0; height: 3px; background: var(--accent2); z-index: 100; width: 0; }
.article-layout { display: grid; grid-template-columns: 1fr 240px; gap: 26px; margin-top: 6px; }
.article-body { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px 34px; min-width: 0; }
.article-body h1 { font-size: 1.7rem; }
.article-meta { color: var(--muted); font-size: .8rem; margin-bottom: 18px; display: flex; gap: 12px; flex-wrap: wrap; }
.md { color: var(--text); }
.md h2 { font-size: 1.3rem; margin-top: 1.6em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 1.1rem; margin-top: 1.4em; }
.md code { background: var(--input); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: .85em; }
.md pre { background: #0A0D15; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
[data-theme="light"] .md pre { background: #0F172A; }
.md pre code { background: none; border: 0; padding: 0; color: #DCE6F5; }
.md blockquote { border-left: 3px solid var(--accent); margin: 1em 0; padding: .4em 1em; background: var(--card2); border-radius: 0 8px 8px 0; }
.md table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .88rem; }
.md th, .md td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md th { background: var(--card2); }
.md img { max-width: 100%; border-radius: 8px; }
.md ul.task-list { list-style: none; padding-left: 4px; }
.toc { position: sticky; top: 130px; align-self: start; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; font-size: .82rem; max-height: 70vh; overflow-y: auto; }
.toc strong { display: block; margin-bottom: 8px; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.toc a { display: block; color: var(--muted); padding: 3px 0; }
.toc a:hover, .toc a.active { color: var(--accent2); }
.toc a.l3 { padding-left: 12px; } .toc a.l4 { padding-left: 24px; }
.feedback-box { margin-top: 26px; padding: 18px; background: var(--card2); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }
.feedback-box .fb-btns { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.tag { background: var(--input); border: 1px solid var(--border); border-radius: 999px; padding: 2px 12px; font-size: .76rem; color: var(--muted); }
a.tag:hover { color: var(--text); border-color: var(--accent); }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.prevnext a { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
.prevnext a small { display: block; color: var(--muted); font-size: .72rem; }

/* ---------- search modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 70vh; display: flex; flex-direction: column; }
.search-box { overflow: hidden; }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-input-row input { flex: 1; background: none; border: 0; color: var(--text); font-size: 1rem; }
.search-input-row input:focus { outline: none; }
.search-results { overflow-y: auto; padding: 8px; }
.sr-item { display: block; padding: 10px 12px; border-radius: 9px; color: var(--text); }
.sr-item:hover { background: var(--card2); text-decoration: none; }
.sr-item .t { font-weight: 600; font-size: .9rem; }
.sr-item .t mark, .sr-item .s mark { background: rgba(46,124,246,.35); color: inherit; border-radius: 3px; }
.sr-item .s { color: var(--muted); font-size: .78rem; }
.sr-cat { font-size: .72rem; color: var(--muted2); text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px 4px; }

/* ---------- admin ---------- */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; margin: 20px 0 40px; align-items: start; }
.admin-nav { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; position: sticky; top: 120px; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a { color: var(--muted); font-size: .86rem; padding: 8px 12px; border-radius: 8px; }
.admin-nav a:hover, .admin-nav a.active { color: var(--text); background: var(--card2); text-decoration: none; }
.admin-nav a.active { color: #fff; background: var(--accent); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 1.7rem; font-weight: 800; }
.stat .l { color: var(--muted); font-size: .78rem; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th { background: var(--card2); color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--card2); }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.pill.published { background: rgba(16,185,129,.15); color: var(--green); }
.pill.draft { background: rgba(245,158,11,.15); color: var(--amber); }
.pill.archived { background: rgba(139,147,167,.15); color: var(--muted); }
.pill.scheduled { background: rgba(46,124,246,.15); color: var(--accent2); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type="text"], .toolbar select { width: auto; }
input, select, textarea {
  background: var(--input); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 9px 12px; font-size: .9rem; width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
label.fld { display: block; margin: .9em 0; }
label.fld > span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: .6em 0; font-size: .88rem; }
.check-row input { width: auto; }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-split textarea { min-height: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; resize: vertical; }
.md-preview { background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 16px; min-height: 420px; max-height: 640px; overflow-y: auto; }
.diff-old { background: rgba(239,68,68,.12); }
.diff-new { background: rgba(16,185,129,.12); }
.diff-line { font-family: ui-monospace, monospace; font-size: .8rem; padding: 2px 8px; white-space: pre-wrap; word-break: break-word; }
.ver-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }

/* setup / login */
.auth-wrap { max-width: 420px; margin: 8vh auto; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.4rem; text-align: center; }
.auth-card p.sub { color: var(--muted); text-align: center; font-size: .85rem; }

/* toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card2); border: 1px solid var(--border); border-left: 4px solid var(--accent); color: var(--text); border-radius: 10px; padding: 12px 16px; font-size: .86rem; box-shadow: var(--shadow); max-width: 340px; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }

/* footer */
.footer { border-top: 1px solid var(--border); margin-top: 50px; padding: 20px 0; color: var(--muted); font-size: .8rem; }
.footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* empty state */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .browse-grid { grid-template-columns: repeat(5, 1fr); }
  .article-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav { position: static; flex-direction: row; overflow-x: auto; }
  .hero-cards { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-split { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .search-trigger .search-ph, .search-trigger kbd { display: none; }
  .search-trigger { flex: 0; }
  .topbar { flex-wrap: wrap; }
  .mainnav { display: none; position: fixed; top: 0; left: 0; right: 0; flex-direction: column; background: var(--bg2); padding: 70px 20px 20px; z-index: 45; border-bottom: 1px solid var(--border); }
  .mainnav.open { display: flex; }
  .nav-toggle { display: block; margin-left: auto; background: var(--input); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .svc-grid, .two-col, .prevnext { grid-template-columns: 1fr; }
  .browse-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 1.5rem; }
  .article-body { padding: 20px; }
  .form-row, .form-row3 { grid-template-columns: 1fr; }
  .theme-toggle button:not(.active) { display: none; }
}

/* ---------- WYSIWYG editor ---------- */
.wysi { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.wysi-tabs { display: flex; gap: 4px; padding: 8px 10px 0; background: var(--bg2); }
.wysi-tabs .wt { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: .82rem; font-weight: 600; padding: 8px 14px; cursor: pointer; }
.wysi-tabs .wt.active { color: var(--text); border-bottom-color: var(--accent); }
.wysi-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; background: var(--bg2); border-top: 1px solid var(--border); }
.wt-group { display: flex; gap: 2px; padding: 2px 8px 2px 2px; border-right: 1px solid var(--border); align-items: center; }
.wt-group:last-child { border-right: 0; }
.wt-group button { background: none; border: 1px solid transparent; border-radius: 6px; color: var(--text); font-size: .82rem; min-width: 30px; height: 30px; padding: 0 6px; cursor: pointer; }
.wt-group button:hover { background: var(--input); border-color: var(--border); }
.wt-color { position: relative; font-weight: 800; font-size: .9rem; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 6px; cursor: pointer; border-bottom: 3px solid var(--red); }
.wt-color.hl { border-bottom-color: #fef08a; }
.wt-color input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.wysi-pane { min-height: 320px; }
.wysi-edit { min-height: 320px; max-height: 560px; overflow: auto; padding: 16px 18px; outline: none; }
.wysi-edit:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.wysi-edit h1, .wysi-edit h2, .wysi-edit h3 { margin: .6em 0 .4em; }
.wysi-edit blockquote { border-left: 3px solid var(--accent); margin: 1em 0; padding: .4em 1em; color: var(--muted); background: var(--bg2); border-radius: 0 8px 8px 0; }
.wysi-edit pre { background: #0F172A; color: #E2E8F0; padding: 12px; border-radius: 8px; overflow: auto; }
.wysi-edit table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.wysi-edit table th, .wysi-edit table td { border: 1px solid var(--border); padding: 8px 10px; }
.wysi-edit table th { background: var(--bg2); }
.wysi-edit img { max-width: 100%; border-radius: 8px; }
.wysi-edit hr { border: 0; border-top: 2px solid var(--border); margin: 1.2em 0; }
.wysi-preview { padding: 16px 18px; min-height: 320px; }
.wysi-status { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; font-size: .72rem; color: var(--muted2); background: var(--bg2); border-top: 1px solid var(--border); }
.html-wrap { position: relative; min-height: 320px; max-height: 560px; }
.html-hl, .html-src { margin: 0; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; line-height: 1.6; tab-size: 2; }
.html-hl { position: absolute; inset: 0; overflow: auto; white-space: pre; pointer-events: none; color: var(--text); }
.html-src { position: absolute; inset: 0; width: 100%; height: 100%; background: transparent; color: transparent; caret-color: var(--text); border: 0; outline: none; resize: none; white-space: pre; overflow: auto; }
.tok-tag { color: var(--accent2); font-weight: 700; }
.tok-attr { color: var(--amber); }
.tok-str { color: var(--green); }

/* ---------- article body (reader + preview) ---------- */
.md table, .wysi-preview table { border-collapse: collapse; width: 100%; margin: 1em 0; display: block; overflow-x: auto; }
.md table th, .md table td, .wysi-preview table th, .wysi-preview table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md table th, .wysi-preview table th { background: var(--bg2); }
.md img, .wysi-preview img { max-width: 100%; border-radius: 8px; }
.md blockquote, .wysi-preview blockquote { border-left: 3px solid var(--accent); margin: 1em 0; padding: .4em 1em; color: var(--muted); background: var(--bg2); border-radius: 0 8px 8px 0; }
.md hr, .wysi-preview hr { border: 0; border-top: 2px solid var(--border); margin: 1.2em 0; }
.md figure, .wysi-preview figure { margin: 1em 0; text-align: center; }
.md figcaption, .wysi-preview figcaption { font-size: .8rem; color: var(--muted); }

/* ---------- misc new components ---------- */
.lock { font-size: .8em; }
.chip-pick { display: inline-flex; align-items: center; gap: 6px; background: var(--input); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: .8rem; cursor: pointer; }
.chip-pick input { accent-color: var(--accent); }
.pw-once { background: #fef9c3; color: #713f12; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 14px; font-size: .85rem; }
.pw-once code { font-size: 1rem; font-weight: 700; user-select: all; }
[data-theme="dark"] .pw-once { background: #422006; color: #fde68a; border-color: #92400e; }
.guide { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: .82rem; }
.guide summary { cursor: pointer; font-weight: 700; }
.guide ol { margin: 8px 0 4px; padding-left: 20px; }
.guide li { margin-bottom: 6px; }
.guide code { background: var(--input); padding: 2px 6px; border-radius: 6px; font-size: .75rem; word-break: break-all; }

/* ---------- branding live preview ---------- */
.brand-preview { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.bp-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg2); }
.bp-mark { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: .75rem; }
.bp-bar small { color: var(--muted); }
.bp-hero { padding: 22px 18px; }
.bp-hero h3 { margin: 0 0 6px; }
.bp-hero p { color: var(--muted); font-size: .82rem; margin: 0 0 10px; }
.bp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.bp-chips span { background: var(--input); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: .72rem; }
.bp-foot { padding: 10px 14px; font-size: .72rem; color: var(--muted2); border-top: 1px solid var(--border); }

/* ---------- media library / attachments / misc ---------- */
.drop-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 20px; text-align: center; transition: border-color .15s, background .15s; }
.drop-zone.over { border-color: var(--accent); background: rgba(46,124,246,.06); }
.attach-box { margin-top: 26px; padding: 18px; background: var(--card2); border: 1px solid var(--border); border-radius: var(--radius); }
.attach-box h3 { margin-top: 0; font-size: .95rem; }
.attach-item { margin: 10px 0; }
.attach-item img { max-width: 100%; border-radius: 8px; }
.attach-item figure, .attach-item { text-align: left; }
.attach-name { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.footer .footer-admin { color: var(--muted2); opacity: .55; font-size: .92em; }
.footer .footer-admin:hover { opacity: 1; }
.md video, .md audio, .wysi-preview video, .wysi-preview audio, .wysi-edit video, .wysi-edit audio { max-width: 100%; margin: .6em 0; }
/* category covers (BookStack-style): cover band on cards, banner on the category page */
.cat-card .ci-cover { width: 100%; height: 64px; object-fit: cover; border-radius: 8px; display: block; }
.cat-banner { width: 100%; max-height: 160px; object-fit: cover; border-radius: 12px; display: block; margin: 10px 0 4px; border: 1px solid var(--border); }

@media (max-width: 640px) {
  .wysi-toolbar { gap: 2px; }
  .wt-group button { min-width: 26px; height: 28px; }
}

/* Private wiki: before sign-in, only the sign-in/setup screens show — the
   top bar, main navigation and search stay hidden until a session exists
   (the .auth-locked class on <body> is lifted by syncChrome in app.js). */
body.auth-locked .topbar,
body.auth-locked .mainnav,
body.auth-locked #search-modal { display: none !important; }
