/* Arcanum UI — палитра GitHub Dark Dimmed */
:root {
  --bg: #22272e;           /* canvas */
  --bg-inset: #1c2128;     /* canvasInset — поля ввода, код */
  --panel: #2d333b;        /* canvasSubtle — карточки, панели */
  --border: #444c56;
  --border-muted: #373e47;
  --text: #adbac7;         /* fg */
  --text-bright: #cdd9e5;
  --muted: #768390;        /* fgMuted */
  --accent: #539bf5;
  --accent-dim: #316dca;
  --accent-subtle: #143d79;
  --danger: #e5534b;
  --ok: #57ab5a;
  --warn: #c69026;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "Cascadia Code", Consolas, "Courier New", monospace; }

/* --- nav --- */
.nav {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border-muted);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 700; font-size: 18px; color: var(--text-bright); }
.logo:hover { text-decoration: none; color: var(--accent); }
.nav-search { flex: 1; max-width: 480px; }
.nav-search input {
  width: 100%; padding: 8px 14px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
}
.nav-search input:focus { border-color: var(--accent); outline: none; }
.nav-links { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.user { color: var(--muted); }
.inline { display: inline; margin: 0; }
.badge-warn {
  background: var(--warn); color: #1c2128; border-radius: 12px;
  padding: 2px 10px; font-size: 13px; font-weight: 600;
}
.badge-warn:hover { text-decoration: none; }

/* --- layout --- */
.container { max-width: 900px; margin: 24px auto; padding: 0 20px; }
.container-wide { max-width: 1150px; }
h1 { font-size: 24px; margin: 8px 0 16px; color: var(--text-bright); font-weight: 600; }
.empty { color: var(--muted); }

/* --- flash --- */
.flash { padding: 10px 16px; border-radius: 6px; margin: 12px 0; }
.flash.ok { background: rgba(87, 171, 90, .15); border: 1px solid var(--ok); }
.flash.err { background: rgba(229, 83, 75, .12); border: 1px solid var(--danger); }

/* --- buttons --- */
.btn {
  display: inline-block; padding: 7px 18px;
  background: var(--accent-subtle); color: var(--text-bright);
  border: 1px solid var(--accent-dim); border-radius: 6px;
  cursor: pointer; font-size: 14px; line-height: 1.4;
}
.btn:hover { background: var(--accent-dim); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* --- article list --- */
.article-list { list-style: none; padding: 0; margin: 0; }
.article-list li {
  padding: 14px 18px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--border-muted); border-radius: 8px;
  transition: border-color .15s;
}
.article-list li:hover { border-color: var(--border); }
.article-link { font-size: 16px; font-weight: 600; color: var(--text-bright); }
.article-link:hover { color: var(--accent); text-decoration: none; }
.article-meta { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.date { color: var(--muted); font-size: 12.5px; margin-left: auto; }

/* --- tags --- */
.tag {
  background: var(--accent-subtle); color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 12px; padding: 1px 11px; font-size: 12.5px;
}
.tag:hover { text-decoration: none; background: var(--accent-dim); color: var(--text-bright); }
.tag-big { font-size: 15px; padding: 5px 15px; }
.tag .count { color: var(--muted); }
.tag-cloud { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- article view --- */
.article-head { display: flex; align-items: flex-start; gap: 16px; }
.article-head h1 { flex: 1; margin-top: 0; }
.article-actions { display: flex; gap: 8px; }
.meta-block { margin: 12px 0; color: var(--muted); }
.meta-block table { border-collapse: collapse; margin-top: 8px; }
.meta-block td { border: 1px solid var(--border-muted); padding: 5px 12px; }

.content { line-height: 1.7; color: var(--text); }
.content h1, .content h2, .content h3 { color: var(--text-bright); }
.content pre {
  background: var(--bg-inset); border: 1px solid var(--border-muted);
  border-radius: 6px; padding: 14px; overflow-x: auto;
}
.content code { background: var(--bg-inset); border-radius: 4px; padding: 2px 6px; font-size: 13px; }
.content pre code { background: none; padding: 0; }
.content table { border-collapse: collapse; }
.content th, .content td { border: 1px solid var(--border); padding: 7px 13px; }
.content tr:nth-child(even) { background: var(--panel); }
.content img { max-width: 100%; }
.content blockquote {
  border-left: 3px solid var(--border); margin-left: 0;
  padding-left: 16px; color: var(--muted);
}

/* --- forms --- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; color: var(--muted); margin-bottom: 6px; font-size: 13px; }
.form-row input, .form-row textarea {
  width: 100%; padding: 9px 13px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.form-row input:focus, .form-row textarea:focus {
  border-color: var(--accent); outline: none;
}
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

/* --- login / setup --- */
.login-page { display: flex; justify-content: center; padding-top: 8vh; }
.login-box {
  width: 400px; padding: 32px;
  background: var(--panel); border: 1px solid var(--border-muted); border-radius: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-box h1 { text-align: center; margin-bottom: 8px; }
.login-box h2 { font-size: 15px; margin: 14px 0 4px; color: var(--accent); }
.login-box input {
  padding: 10px 13px; background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.login-box input:focus { border-color: var(--accent); outline: none; }
.setup-box { width: 540px; }
.radio { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; }
.radio input { margin-top: 4px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }

/* --- conflicts --- */
.conflict {
  background: var(--panel); border: 1px solid var(--warn);
  border-radius: 10px; padding: 18px 22px; margin-bottom: 20px;
}
.conflict h2 { font-size: 18px; margin: 0 0 4px; color: var(--text-bright); }
.conflict h3 { font-size: 14px; color: var(--muted); }
.conflict-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.conflict-col pre {
  background: var(--bg-inset); border: 1px solid var(--border-muted); border-radius: 6px;
  padding: 12px; max-height: 340px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; font-size: 13px;
}
.conflict-actions { margin-top: 12px; display: flex; gap: 10px; }

/* --- diff (conflicts) --- */
.diff-head {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  font-size: 13px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border-muted); border-bottom: none;
  border-radius: 6px 6px 0 0; overflow: hidden;
}
.diff-head span { padding: 8px 12px; background: var(--panel); }
.diff-head span + span { border-left: 1px solid var(--border-muted); }
.diff {
  border: 1px solid var(--border-muted); border-radius: 0 0 6px 6px;
  max-height: 420px; overflow: auto;
  font: 12.5px/1.5 "Cascadia Code", Consolas, monospace;
}
.diff-row { display: grid; grid-template-columns: 1fr 1fr; }
.diff-cell {
  padding: 1px 12px; white-space: pre-wrap; word-break: break-word;
  border-left: 1px solid var(--border-muted);
}
.diff-cell:first-child { border-left: none; }
.diff-del .diff-cell:first-child { background: rgba(229, 83, 75, .14); }
.diff-ins .diff-cell:last-child { background: rgba(87, 171, 90, .16); }
.diff-mod .diff-cell:first-child { background: rgba(229, 83, 75, .10); }
.diff-mod .diff-cell:last-child { background: rgba(87, 171, 90, .12); }
.merge-block { margin-top: 12px; }
.merge-block summary { cursor: pointer; color: var(--accent); }
.merge-text {
  width: 100%; margin-top: 10px; padding: 10px 12px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}

/* --- index layout: sidebar + content --- */
.index-layout { display: flex; gap: 28px; align-items: flex-start; }
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--border-muted);
  border-radius: 8px; padding: 14px 16px;
  position: sticky; top: 72px;
  max-height: calc(100vh - 96px); overflow-y: auto;
}
.sidebar-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: 10px;
}
.index-content { flex: 1; min-width: 0; }

/* --- category tree --- */
.cat-tree { list-style: none; margin: 0; padding-left: 16px; }
.cat-tree-root { padding-left: 0; }
.cat-item { margin: 2px 0; }
.cat-item details summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px;
  padding: 2px 0; border-radius: 6px;
}
.cat-item details summary::-webkit-details-marker { display: none; }
.cat-item details summary::before {
  content: "▸"; color: var(--muted); font-size: 11px; flex-shrink: 0;
  transition: transform .12s ease;
}
.cat-item details[open] > summary::before { transform: rotate(90deg); }
.cat-link {
  color: var(--text); padding: 2px 6px; border-radius: 6px;
  display: inline-block; word-break: break-word;
}
.cat-link:hover { color: var(--accent); text-decoration: none; }
.cat-link.active {
  background: var(--accent-subtle); color: var(--accent); font-weight: 600;
}
.cat-all { font-weight: 600; }
.cat-count { color: var(--muted); font-size: 12px; margin-left: 4px; }
.cat-badge {
  background: var(--panel); border: 1px solid var(--border-muted);
  border-radius: 10px; padding: 0 8px; font-size: 12px;
  color: var(--muted); margin-right: 4px;
}
.cat-badge:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* --- breadcrumbs --- */
.breadcrumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { margin: 0 6px; color: var(--border); }

/* --- sidebar extras --- */
.sidebar-title-gap { margin-top: 18px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { margin: 4px 0; font-size: 13px; line-height: 1.35; }
.recent-list a { color: var(--text); }
.recent-list a:hover { color: var(--accent); }
.sidebar-actions { margin-top: 16px; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.cat-none { font-style: italic; }

/* --- hub (MOC) article on category page --- */
.hub-article {
  background: var(--panel); border: 1px solid var(--border-muted);
  border-radius: 8px; padding: 16px 22px; margin-bottom: 22px;
}
.hub-article h1:first-child, .hub-article h2:first-child { margin-top: 0; }

/* --- backlinks --- */
.backlinks {
  margin-top: 32px; padding-top: 16px;
  border-top: 1px solid var(--border-muted);
}
.backlinks h2 { font-size: 15px; color: var(--muted); margin: 0 0 8px; }
.backlinks ul { margin: 0; padding-left: 20px; }
.backlinks li { margin: 3px 0; }

/* --- settings --- */
.settings-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.settings-card {
  background: var(--panel); border: 1px solid var(--border-muted);
  border-radius: 10px; padding: 18px 22px;
}
.settings-card h2 { font-size: 15px; color: var(--accent); margin: 16px 0 8px; }
.settings-card h2:first-child { margin-top: 0; }
.settings-state { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.settings-state td { padding: 5px 8px; border-bottom: 1px solid var(--border-muted); }
.settings-state td:first-child { color: var(--muted); width: 45%; }
.err-text { color: var(--danger); }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 400; }

/* --- mobile --- */
@media (max-width: 800px) {
  .conflict-cols { grid-template-columns: 1fr; }
  .nav { flex-wrap: wrap; }
  .nav-search { order: 3; max-width: none; width: 100%; }
  .index-layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* Поисковые сниппеты с подсветкой совпадений */
.search-snippet { margin-top: 4px; font-size: 0.9em; color: var(--fg-dim, #9aa4b2); }
.search-snippet mark { background: #f0c67433; color: #f0c674; border-radius: 3px; padding: 0 2px; }
/* Стили select в формах (настройки → токены) */
.token-create { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.token-create select { background: var(--bg-input, #1c2128); color: inherit; border: 1px solid #30363d; border-radius: 6px; padding: 8px 10px; }
.nowrap { white-space: nowrap; }
