/* ============ Wiki: nested pages with a Notion-like block editor (wiki.js) ============ */
#wiki {
  position: fixed; z-index: 5;
  left: max(var(--li), 12px); right: 12px; top: 12px; bottom: 12px;
  display: flex; overflow: hidden;
  border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  transition: left .45s var(--ease);
  animation: ganttIn .35s var(--ease);
}
#wiki[hidden] { display: none; }
/* the map, its toolbar and pills step aside: the wiki has its own controls */
body.wiki-mode #canvas, body.wiki-mode #hint, body.wiki-mode #toolbar, body.wiki-mode #filterPill,
body.wiki-mode #searchBar, body.wiki-mode #feedbackBtn, body.wiki-mode #modeHint { display: none !important; }
body.wiki-mode #viewSwitch { box-shadow: none; background: var(--surface-2); border-color: transparent; }

/* ---------- sidebar: tree, search, tags ---------- */
.wk-side {
  flex: none; width: 272px; display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 45%, var(--surface));
}
.wk-side-head { display: flex; align-items: center; justify-content: space-between; height: 54px; padding: 0 12px 0 16px; flex: none; }
body.sb-collapsed .wk-side-head { padding-left: 60px; }
.wk-side-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.wk-side-title svg.i { width: 17px; height: 17px; }
.wk-search {
  display: flex; align-items: center; gap: 7px; margin: 0 12px 8px; padding: 0 8px 0 10px; height: 34px; flex: none;
  border-radius: 30px; background: var(--surface); border: 1px solid var(--border); color: var(--text-3);
  transition: border-color .15s, box-shadow .15s;
}
.wk-search:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--hover); }
.wk-search svg.i { width: 15px; height: 15px; flex: none; }
.wk-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 13px; color: var(--text); }
.wk-search input::placeholder { color: var(--text-3); }
.wk-search-x { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--text-3); }
.wk-search-x:hover { background: var(--hover); color: var(--text); }
.wk-search-x svg.i { width: 12px; height: 12px; }
.wk-modes { display: flex; align-items: center; gap: 6px; margin: 0 12px 8px; flex: none; }
.wk-modes .vseg { flex: 1; }
.wk-modes .vseg button, .wk-modes .vseg .seg-thumb { width: calc((272px - 24px - 32px - 6px - 8px) / 2); }
.wk-tagbar { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 12px 6px; flex: none; max-height: 92px; overflow: auto; }
.wk-tagbar[hidden] { display: none; }
.wk-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px 0 7px; max-width: 100%;
  border-radius: 30px; font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
  transition: background-color .12s, color .12s, border-color .12s, transform .2s var(--spring);
}
.wk-chip:active { transform: scale(.94); }
.wk-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--t); flex: none; }
.wk-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-chip b { font-weight: 500; color: var(--text-3); font-size: 11px; }
.wk-chip:hover { color: var(--text); border-color: var(--border-strong); }
.wk-chip.on { color: var(--text); background: color-mix(in srgb, var(--t) 16%, var(--surface)); border-color: color-mix(in srgb, var(--t) 55%, transparent); }
.wk-chip.none { opacity: .55; }

.wk-tree { flex: 1; min-height: 0; overflow: auto; padding: 2px 8px 16px; overscroll-behavior: contain; }
.wk-tree-empty { padding: 18px 12px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.wk-tree-empty.sm { padding: 6px 10px 8px 34px; text-align: left; }
.wk-row {
  position: relative; display: flex; align-items: center; gap: 4px; min-height: 30px; padding: 3px 4px 3px calc(4px + var(--d) * 16px);
  border-radius: 8px; cursor: pointer; color: var(--text-2); font-size: 13.5px; user-select: none; -webkit-user-select: none;
  transition: background-color .1s;
}
.wk-row:hover { background: var(--hover); color: var(--text); }
.wk-row.on { background: var(--active); color: var(--text); font-weight: 550; }
.wk-row.dragging { opacity: .35; }
.wk-caret { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 6px; color: var(--text-3); }
.wk-caret svg.i { width: 13px; height: 13px; transition: transform .2s var(--ease); }
.wk-caret.open svg.i { transform: rotate(90deg); }
.wk-caret:not(.leaf):hover { background: var(--active); color: var(--text); }
.wk-caret.leaf svg.i { opacity: 0; }
.wk-ricon { display: grid; place-items: center; width: 20px; height: 20px; flex: none; font-size: 15px; line-height: 1; color: var(--text-3); }
.wk-ricon svg.i { width: 15px; height: 15px; }
.wk-rtext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wk-rname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-rtext small { font-size: 11px; color: var(--text-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-snip mark { background: color-mix(in srgb, #F2B33D 40%, transparent); color: inherit; border-radius: 3px; }
.wk-rdots { display: flex; gap: 3px; flex: none; }
.wk-rdots i { width: 6px; height: 6px; border-radius: 50%; background: var(--t); }
.wk-rbtn { display: none; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 6px; color: var(--text-3); }
.wk-rbtn svg.i { width: 14px; height: 14px; }
.wk-rbtn:hover { background: var(--active); color: var(--text); }
.wk-row:hover .wk-rbtn { display: grid; }
.wk-row:hover .wk-rdots { display: none; }
@media (pointer: coarse) { .wk-rbtn[data-a="more"] { display: grid; } .wk-rdots { display: none; } }
/* drop places while a page is dragged */
.wk-row.drop-in { background: color-mix(in srgb, var(--accent) 10%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.wk-row.drop-before::before, .wk-row.drop-after::after {
  content: ''; position: absolute; left: calc(8px + var(--d) * 16px); right: 4px; height: 2px; border-radius: 2px; background: var(--accent);
}
.wk-row.drop-before::before { top: -1px; }
.wk-row.drop-after::after { bottom: -1px; }
body.wk-tree-dragging, body.wk-tree-dragging * { cursor: grabbing !important; }
.wk-drag-ghost {
  position: fixed; left: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; pointer-events: none !important;
  border-radius: 30px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13px;
}
.wk-drag-ghost svg.i { width: 15px; height: 15px; color: var(--text-3); }
/* grouped by tags */
.wk-group { margin-bottom: 4px; border-radius: 10px; transition: background-color .12s, box-shadow .12s; }
.wk-group.drop-group { background: color-mix(in srgb, var(--accent) 6%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.wk-ghead {
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 4px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; user-select: none;
}
.wk-ghead:hover { background: var(--hover); }
.wk-ghead i { width: 8px; height: 8px; border-radius: 50%; background: var(--t); flex: none; }
.wk-gname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-ghead b { font-weight: 500; color: var(--text-3); }
.wk-group.folded .wk-caret svg.i { transform: none; }
.wk-gbody .wk-row { padding-left: 10px; }

/* ---------- main column ---------- */
.wk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.wk-top {
  display: flex; align-items: center; gap: 4px; flex: none; height: 54px;
  padding: 0 calc(max(var(--ri), 12px) + 366px - 12px) 0 14px; border-bottom: 1px solid var(--border);
}
.wk-tree-btn { display: none; }
.wk-crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow: hidden; white-space: nowrap; }
.wk-crumb {
  display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 220px; height: 28px; padding: 0 7px; border-radius: 7px;
  font-size: 13px; color: var(--text-2);
}
.wk-crumb span:last-child { overflow: hidden; text-overflow: ellipsis; }
.wk-crumb svg.i { width: 15px; height: 15px; }
button.wk-crumb:hover { background: var(--hover); color: var(--text); }
.wk-crumb.cur { color: var(--text); font-weight: 550; }
.wk-crumb-ic { font-size: 14px; }
.wk-sep { color: var(--text-3); font-size: 12px; }
.wk-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; margin-right: 6px; }
@container (max-width: 820px) { .wk-meta { display: none; } }
.wk-top .g-btn { height: 28px; }
.wk-top [hidden] { display: none !important; }

.wk-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scroll-padding: 80px 0; }
.wk-page {
  position: relative; max-width: 760px; margin: 0 auto; padding: 44px 64px 30vh;
  font-size: 16px; line-height: 1.6; color: var(--text);
}

/* empty wiki */
.wk-empty { max-width: 440px; margin: 12vh auto 0; text-align: center; }
.wk-empty-ic {
  display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
}
.wk-empty-ic svg.i { width: 28px; height: 28px; }
.wk-empty h2 { margin: 0 0 8px; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.wk-empty p { margin: 0 0 22px; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }
.wk-empty .btn { display: inline-flex; align-items: center; gap: 6px; }

/* page head: icon, title, tags */
.wk-cover-tools { display: flex; gap: 4px; height: 28px; margin-bottom: 6px; opacity: 0; transition: opacity .15s; }
.wk-page:hover .wk-cover-tools, .wk-cover-tools:focus-within { opacity: 1; }
.wk-ghost-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border-radius: 7px;
  font-size: 13px; color: var(--text-3);
}
.wk-ghost-btn:hover { background: var(--hover); color: var(--text-2); }
.wk-ghost-btn svg.i { width: 14px; height: 14px; }
.wk-icon {
  display: block; font-size: 58px; line-height: 1; width: 78px; height: 78px; margin: -4px 0 10px -6px; border-radius: 12px;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  transition: background-color .12s, transform .25s var(--spring);
}
.wk-icon:not(:disabled):hover { background: var(--hover); }
.wk-icon:not(:disabled):active { transform: scale(.93); }
.wk-icon:disabled { cursor: default; }
.wk-title {
  margin: 0 0 10px; font-size: 38px; line-height: 1.2; font-weight: 700; letter-spacing: -.025em;
  outline: none; overflow-wrap: anywhere; cursor: text;
}
.wk-title:empty::before { content: attr(data-ph); color: var(--text-3); opacity: .7; }
.wk-props {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 30px;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
}
.wk-prop-label { display: inline-flex; align-items: center; gap: 6px; width: 92px; font-size: 13px; color: var(--text-3); }
.wk-prop-label svg.i { width: 14px; height: 14px; }
.wk-prop-none { font-size: 13px; color: var(--text-3); }
.wk-tag {
  display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 4px 0 9px; border-radius: 30px; font-size: 12.5px;
  color: var(--text); background: color-mix(in srgb, var(--t) 16%, transparent);
}
.wk-tag button { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--text-3); }
.wk-tag button:hover { background: color-mix(in srgb, var(--t) 30%, transparent); color: var(--text); }
.wk-tag button svg.i { width: 11px; height: 11px; }
#wiki .wk-tag:not(:has(button)) { padding-right: 9px; }
.wk-tag-add {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 30px;
  font-size: 12.5px; color: var(--text-3); border: 1px dashed var(--border-strong);
}
.wk-tag-add:hover { color: var(--text); border-color: var(--text-3); }
.wk-tag-add svg.i { width: 12px; height: 12px; }
.wk-page.drop-target { box-shadow: none; }
.wk-page.drop-target .wk-props { border-bottom-color: var(--dt); box-shadow: 0 1px 0 var(--dt); }

/* ---------- blocks ---------- */
.wk-doc { position: relative; }
.wk-block { position: relative; display: flex; align-items: flex-start; margin-left: calc(var(--ind, 0) * 26px); padding: 2px 0; border-radius: 4px; }
.wk-text { flex: 1; min-width: 0; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; caret-color: var(--text); }
.wk-text:empty::before { content: attr(data-ph); color: var(--text-3); opacity: 0; pointer-events: none; }
.wk-text:focus:empty::before, .wk-block[data-type^="h"] .wk-text:empty::before, .wk-block[data-type="todo"] .wk-text:empty::before,
.wk-block:not([data-type="p"]) .wk-text:focus:empty::before { opacity: .75; }
.wk-doc > .wk-block:only-child[data-type="p"] .wk-text:empty::before { content: 'Начните писать или нажмите «/» для команд'; opacity: .75; }
.wk-doc.ro .wk-text:empty::before { content: none; }
.wk-text code, .wk-text .wk-inline-code {
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace; font-size: .86em;
  padding: .12em .38em; border-radius: 5px; background: var(--surface-2); color: #E5484D;
}
:root[data-theme="dark"] .wk-text code { color: #FF8A8F; }
.wk-text mark { background: color-mix(in srgb, #F2B33D 42%, transparent); color: inherit; border-radius: 3px; padding: 0 .1em; }
.wk-text strong, .wk-text b { font-weight: 650; }
.wk-a { color: inherit; text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; cursor: pointer; }
.wk-a:hover { text-decoration-color: var(--text); }
.wk-pagelink {
  display: inline-flex; align-items: baseline; gap: 4px; padding: 0 2px; border-radius: 4px; cursor: pointer;
  color: inherit; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; font-weight: 550;
}
.wk-pagelink svg.i { width: .9em; height: .9em; align-self: center; color: var(--text-3); }
.wk-pagelink:hover { background: var(--hover); }
.wk-pagelink.broken { color: var(--text-3); text-decoration: line-through; }
.wk-pl-ic { font-size: .95em; }

.wk-block[data-type="h1"] { margin-top: 1.5em; padding: 3px 0; }
.wk-block[data-type="h2"] { margin-top: 1.15em; padding: 3px 0; }
.wk-block[data-type="h3"] { margin-top: .9em; padding: 2px 0; }
.wk-doc > .wk-block:first-child { margin-top: 0; }
.wk-block[data-type="h1"] .wk-text { font-size: 1.85em; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
.wk-block[data-type="h2"] .wk-text { font-size: 1.45em; line-height: 1.3; font-weight: 680; letter-spacing: -.015em; }
.wk-block[data-type="h3"] .wk-text { font-size: 1.2em; line-height: 1.35; font-weight: 650; }

.wk-mark { flex: none; display: flex; align-items: center; justify-content: center; min-width: 24px; height: 1.6em; margin-right: 4px; color: var(--text); user-select: none; -webkit-user-select: none; }
.wk-block[data-type="ul"] .wk-mark { font-size: 1.2em; line-height: 1; height: calc(1.6em / 1.2); }
.wk-block[data-type="ol"] .wk-mark { justify-content: flex-end; padding-right: 2px; min-width: 24px; font-variant-numeric: tabular-nums; }
.wk-check {
  width: 18px; min-width: 18px; height: 18px; margin: calc((1.6em - 18px) / 2) 8px 0 3px; border-radius: 5px;
  border: 1.6px solid var(--text-2); color: transparent; cursor: pointer; transition: background-color .15s, border-color .15s, transform .2s var(--spring);
}
.wk-check svg.i { width: 13px; height: 13px; stroke-width: 3; }
.wk-check:active { transform: scale(.85); }
.wk-block[data-checked="1"] .wk-check { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.wk-block[data-checked="1"] .wk-text { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.wk-doc.ro .wk-check { cursor: default; }

.wk-block[data-type="quote"] { padding: 2px 0 2px 16px; margin: 4px 0; }
.wk-block[data-type="quote"]::before { content: ''; position: absolute; left: 1px; top: 4px; bottom: 4px; width: 3px; border-radius: 3px; background: var(--text); }
.wk-block[data-type="quote"] .wk-text { font-size: 1.05em; }
.wk-block[data-type="callout"] { margin: 6px 0; padding: 14px 16px 14px 12px; border-radius: 10px; background: var(--surface-2); }
.wk-callout-ic { min-width: 28px; height: 1.6em; margin-right: 8px; border-radius: 6px; font-size: 1.15em; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
.wk-callout-ic:hover { background: var(--active); }

.wk-block[data-type="divider"] { padding: 10px 0; cursor: default; }
.wk-block[data-type="divider"] hr { width: 100%; margin: 0; border: 0; border-top: 1px solid var(--border-strong); }

.wk-block[data-type="code"] { display: block; margin: 6px 0; border-radius: 10px; background: var(--surface-2); }
.wk-code-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 0 12px; }
.wk-lang { width: 120px; border: 0; outline: 0; background: none; font-size: 12px; color: var(--text-3); padding: 2px 0; }
.wk-lang:focus { color: var(--text); }
.wk-code-copy { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px; color: var(--text-3); opacity: 0; transition: opacity .15s; }
.wk-block[data-type="code"]:hover .wk-code-copy { opacity: 1; }
.wk-code-copy:hover { background: var(--active); color: var(--text); }
.wk-code-copy svg.i { width: 13px; height: 13px; }
.wk-pre {
  margin: 0; padding: 6px 16px 14px; overflow-x: auto; white-space: pre; tab-size: 2;
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace; font-size: 13.5px; line-height: 1.6;
}

.wk-block[data-type="image"] { display: block; margin: 8px 0; }
.wk-block[data-type="image"] figure { margin: 0; }
.wk-block[data-type="image"] img { display: block; max-width: 100%; max-height: 70vh; border-radius: 8px; margin: 0 auto; }
.wk-block[data-type="image"].broken figure::before { content: 'Картинка недоступна'; display: block; padding: 28px; border-radius: 8px; background: var(--surface-2); color: var(--text-3); text-align: center; font-size: 13px; }
.wk-block[data-type="image"] figcaption { margin-top: 6px; font-size: 13px; color: var(--text-2); text-align: center; }
.wk-block[data-type="image"] figcaption:empty::before { opacity: 0; }
.wk-block[data-type="image"]:hover figcaption:empty::before, .wk-block[data-type="image"] figcaption:focus:empty::before { opacity: .7; }

.wk-block[data-type="table"] { display: block; margin: 8px 0; padding: 0 0 26px; }
.wk-doc.ro .wk-block[data-type="table"] { padding-bottom: 0; }
.wk-table-scroll { overflow-x: auto; padding-right: 26px; }
.wk-block table { border-collapse: collapse; min-width: 50%; font-size: 14.5px; }
.wk-block th, .wk-block td { border: 1px solid var(--border-strong); padding: 0; vertical-align: top; min-width: 110px; }
.wk-block th { background: var(--surface-2); font-weight: 600; text-align: left; }
.wk-cell { padding: 6px 10px; min-height: 1.6em; line-height: 1.5; }
.wk-tadd {
  position: absolute; display: grid; place-items: center; border-radius: 6px; color: var(--text-3); background: var(--surface-2);
  opacity: 0; transition: opacity .15s, background-color .12s;
}
.wk-tadd svg.i { width: 14px; height: 14px; }
.wk-tadd:hover { background: var(--active); color: var(--text); }
.wk-tadd.col { top: 0; right: 0; width: 20px; bottom: 26px; }
.wk-tadd.row { left: 0; right: 26px; bottom: 2px; height: 20px; }
.wk-block[data-type="table"]:hover .wk-tadd { opacity: 1; }

/* the handle left of the hovered block */
.wk-handle {
  position: absolute; left: 0; top: 0; z-index: 3; display: flex; gap: 1px;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.wk-handle.show { opacity: 1; pointer-events: auto; }
.wk-page.typing .wk-handle { opacity: 0; pointer-events: none; }
.wk-handle button { display: grid; place-items: center; width: 22px; height: 24px; border-radius: 5px; color: var(--text-3); }
.wk-handle button:hover { background: var(--hover); color: var(--text-2); }
.wk-handle button svg.i { width: 16px; height: 16px; }
.wk-handle [data-h="grip"] { cursor: grab; width: 18px; }
.wk-dropline { position: absolute; left: 0; top: 0; height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 55%, #3FA9F5); opacity: 0; pointer-events: none; z-index: 3; }
.wk-dropline.show { opacity: 1; }
.wk-dragged { opacity: .35; }
body.wk-block-dragging, body.wk-block-dragging * { cursor: grabbing !important; user-select: none; }

.wk-tail { min-height: 60px; cursor: text; }
.wk-doc.ro + .wk-tail { cursor: default; min-height: 24px; }

/* raw Markdown */
.wk-source {
  display: block; width: 100%; min-height: 50vh; resize: none; border: 0; outline: 0; padding: 14px 16px; border-radius: 10px;
  background: var(--surface-2); color: var(--text); overflow: hidden;
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace; font-size: 13.5px; line-height: 1.65; tab-size: 2;
}

/* sub-pages under the page */
.wk-kids { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.wk-kids-title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 0 0 6px 4px; }
.wk-kid {
  display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 8px; border-radius: 8px; text-align: left;
  font-size: 14.5px; color: var(--text); transition: background-color .1s;
}
.wk-kid:hover { background: var(--hover); }
.wk-kid-name { font-weight: 550; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.wk-kid-tag { font-size: 11.5px; color: var(--text-2); padding: 1px 7px; border-radius: 30px; background: color-mix(in srgb, var(--t) 16%, transparent); }
.wk-kid.add { color: var(--text-3); font-size: 13.5px; }
.wk-kid.add svg.i { width: 15px; height: 15px; margin: 0 2px 0 3px; }
.wk-kid.add:hover { color: var(--text-2); }

/* ---------- popups: "/" menu, formatting bar, tag picker ---------- */
.wk-pal { width: 300px; max-height: min(360px, 50vh); overflow: auto; padding: 5px; }
.wk-pal .menu-title { padding: 6px 10px 4px; font-size: 11.5px; color: var(--text-3); }
.wk-pal-item { gap: 10px; padding: 5px 8px; }
.wk-pal-item.on { background: var(--hover); }
.wk-tile {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px; font-weight: 650; color: var(--text-2);
}
.wk-tile svg.i { width: 18px; height: 18px; }
.wk-pal-empty { padding: 10px 12px; font-size: 13px; color: var(--text-3); }
.wk-fmt {
  position: fixed; z-index: 85; display: flex; align-items: center; gap: 1px; padding: 4px; border-radius: 30px;
  background: var(--tip-bg); color: var(--tip-fg); box-shadow: var(--shadow-lg); animation: popIn .14s var(--ease);
}
.wk-fmt button { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 30px; color: inherit; opacity: .78; }
.wk-fmt button:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.wk-fmt button.on { opacity: 1; background: rgba(255, 255, 255, .2); }
.wk-fmt svg.i { width: 16px; height: 16px; }
.wk-fmt-turn { font-size: 12.5px; padding: 0 8px 0 12px !important; }
.wk-fmt-turn svg.i { width: 12px; height: 12px; transform: rotate(90deg); }
.wk-fmt-sep { width: 1px; height: 18px; margin: 0 3px; background: currentColor; opacity: .2; }
.wk-fmt.link-mode { padding: 4px 6px 4px 12px; gap: 8px; }
.wk-fmt input { width: 260px; height: 30px; border: 0; outline: 0; background: none; color: inherit; font-size: 13px; }
.wk-fmt input::placeholder { color: inherit; opacity: .55; }
.wk-fmt [data-tip]::after { display: none !important; }
.wk-tagpick { width: 260px; padding: 6px; }
.wk-tp-in { width: 100%; height: 32px; padding: 0 10px; margin-bottom: 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); outline: 0; font-size: 13px; }
.wk-tp-in:focus { border-color: var(--border-strong); }
.wk-tp-list { max-height: 260px; overflow: auto; }
.wk-tp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--t); flex: none; margin: 0 3px; }
.wk-icon-remove { display: flex; align-items: center; gap: 6px; width: calc(100% - 16px); margin: 0 8px 8px; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); }
.wk-icon-remove:hover { color: var(--danger); }
.wk-icon-remove svg.i { width: 14px; height: 14px; }
.modal .wk-img-url { width: 100%; height: 38px; margin-top: 14px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); outline: 0; }
.modal .wk-img-url:focus { border-color: var(--text-3); }
.modal-actions .g-flex { flex: 1; }
.modal-actions .btn svg.i { width: 15px; height: 15px; margin-right: 5px; vertical-align: -3px; }

.wk-scrim { display: none; }

/* ---------- narrower screens ---------- */
@media (max-width: 1180px) {
  .wk-top .g-btn span { display: none; }
  .wk-meta { display: none; }
}
@media (max-width: 980px) {
  .wk-side { width: 236px; }
  .wk-modes .vseg button, .wk-modes .vseg .seg-thumb { width: calc((236px - 24px - 32px - 6px - 8px) / 2); }
  .wk-page { padding-left: 48px; padding-right: 32px; }
}
@media (max-width: 640px) {
  #wiki { left: 8px; right: 8px; top: calc(58px + env(safe-area-inset-top)); bottom: calc(8px + env(safe-area-inset-bottom)); }
  .wk-top { padding: 0 8px; }
  .wk-tree-btn { display: grid; }
  .wk-side {
    position: absolute; left: 0; top: 0; bottom: 0; z-index: 6; width: min(300px, 86%);
    transform: translateX(-102%); transition: transform .3s var(--ease); background: var(--surface); box-shadow: var(--shadow-lg);
  }
  #wiki.tree-open .wk-side { transform: none; }
  .wk-scrim { display: block; position: absolute; inset: 0; z-index: 5; background: rgba(10, 12, 18, .28); opacity: 0; pointer-events: none; transition: opacity .3s; }
  #wiki.tree-open .wk-scrim { opacity: 1; pointer-events: auto; }
  .wk-side-head, body.sb-collapsed .wk-side-head { padding-left: 16px; }
  .wk-modes .vseg button, .wk-modes .vseg .seg-thumb { width: calc((min(300px, 86vw) - 24px - 32px - 6px - 8px) / 2); }
  .wk-page { padding: 24px 18px 40vh 30px; font-size: 16px; }
  .wk-title { font-size: 30px; }
  .wk-handle { display: none; }
  .wk-prop-label { width: auto; }
  .wk-search input, .wk-tp-in, .wk-fmt input, .modal .wk-img-url { font-size: 16px; }
}
