/* vDan Knowledge Base. Standalone-safe: tokens are redefined here so the file also works outside the theme. */
:root {
  --ff: 'DM Sans', system-ui, sans-serif; --fm: 'DM Mono', ui-monospace, Consolas, monospace; --fd: 'Outfit', 'DM Sans', sans-serif;
  --bg: #0e0f11; --bg2: #16181b; --bg4: #1f2226; --border: #26292e; --border2: #33363c;
  --text1: #ececee; --text2: #a3a6ad; --text3: #8a8e96; --text4: #7f838b;
  --ac: #2563eb; --ac-soft: rgba(110,161,255,.14); --ac-text: #8fb6ff; --blue-hl: #6ea1ff; --purple: #bc8cff;
  --green-t: #56d364; --green-s: rgba(63,185,80,.12); --amber-t: #ffa657; --amber-s: rgba(240,136,62,.12); --red-t: #ff7b72; --red-s: rgba(248,81,73,.12);
  --radius: 10px; --radius-sm: 6px; --shadow-md: 0 4px 16px rgba(0,0,0,.4);
}
:root[data-theme="light"] {
  --bg: #fff; --bg2: #f6f6f7; --bg4: #ececee; --border: #e4e4e7; --border2: #d4d4d8;
  --text1: #18181b; --text2: #4b4b53; --text3: #5f5f68; --text4: #6b6b73;
  --ac-soft: rgba(31,95,214,.10); --ac-text: #1f5fd6; --blue-hl: #1f5fd6; --purple: #6639ba;
  --green-t: #116329; --green-s: rgba(26,127,55,.12); --amber-t: #7d4e00; --amber-s: rgba(191,135,0,.14); --red-t: #a40e26; --red-s: rgba(207,34,46,.10);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
}
.kb-page .content-layout { display: block; }
.kb-root { font-family: var(--ff); color: var(--text1); }
.kb-standalone body { margin: 0; background: var(--bg); color: var(--text1); font-family: var(--ff); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
.kb-standalone .kb-root { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.kb-standalone a { color: var(--ac-text); text-decoration: none; }

/* Loader */
.kb-loader { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.kb-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border2); border-top-color: var(--ac); animation: kb-spin .9s linear infinite; }
@keyframes kb-spin { to { transform: rotate(360deg); } }
.kb-loader h2 { font-family: var(--fd); margin: 8px 0 0; font-size: 1.1rem; }
.kb-loader p { font-family: var(--fm); font-size: 11px; color: var(--text3); margin: 0; }
.kb-progress { width: 220px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.kb-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ac), var(--purple)); transition: width .2s; }
.kb-error { border: 1px solid var(--red-t); background: var(--red-s); color: var(--text1); padding: 14px 16px; border-radius: var(--radius); font-size: 14px; }
.kb-hidden { display: none !important; }

/* Top bar */
.kb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 18px 0 14px; border-bottom: 1px solid var(--border); }
.kb-head h1 { font-family: var(--fd); font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
.kb-head h1 span { color: var(--text3); font-weight: 500; }
.kb-sync { font-family: var(--fm); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); display: inline-flex; align-items: center; gap: 6px; }
.kb-sync::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green-t); }
.kb-btn { height: 30px; padding: 0 10px; border: 1px solid var(--border2); background: var(--bg2); color: var(--text1); border-radius: var(--radius-sm); font-family: var(--fm); font-size: 11px; cursor: pointer; text-decoration: none !important; display: inline-flex; align-items: center; gap: 6px; }
.kb-btn:hover { border-color: var(--blue-hl); color: var(--blue-hl); }
.kb-head-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Stats row */
.kb-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.kb-stat { border: 1px solid var(--border); background: var(--bg2); border-radius: var(--radius); padding: 10px 14px; }
.kb-stat b { display: block; font-family: var(--fd); font-size: 1.4rem; font-weight: 800; line-height: 1.1; }
.kb-stat small { font-family: var(--fm); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text3); }
@media (max-width: 760px) { .kb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Search + tabs */
.kb-search { position: relative; margin: 6px 0 12px; }
.kb-search input { width: 100%; height: 44px; padding: 0 70px 0 14px; border: 1px solid var(--border2); background: var(--bg2); color: var(--text1); border-radius: var(--radius); font-family: var(--fm); font-size: 13px; outline: none; box-sizing: border-box; }
.kb-search input:focus { border-color: var(--blue-hl); }
.kb-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--fm); font-size: 10px; color: var(--text4); border: 1px solid var(--border2); border-radius: 4px; padding: 2px 6px; }
.kb-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.kb-tab { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 12px; color: var(--text2); font-family: var(--ff); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.kb-tab.is-active { color: var(--text1); border-bottom-color: var(--blue-hl); }
.kb-tab small { font-family: var(--fm); font-size: 10px; color: var(--text4); margin-left: 4px; }

/* Layout: filters + list */
.kb-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .kb-body { grid-template-columns: 1fr; } }
.kb-filters { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 80px; }
.kb-fgroup h4 { margin: 0 0 6px; font-family: var(--fm); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text3); }
.kb-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.kb-chip { height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border2); background: var(--bg); color: var(--text2); font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-family: var(--ff); }
.kb-chip small { font-family: var(--fm); font-size: 10px; opacity: .6; }
.kb-chip:hover { border-color: var(--blue-hl); color: var(--text1); }
.kb-chip.is-active { background: var(--text1); color: var(--bg); border-color: var(--text1); }
.kb-chip.is-fix.is-active { background: var(--red-t); border-color: var(--red-t); color: #fff; }

.kb-list { display: flex; flex-direction: column; gap: 6px; }
.kb-count { font-family: var(--fm); font-size: 11px; color: var(--text3); margin: 0 0 8px; }
.kb-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); padding: 12px 14px; cursor: pointer; }
.kb-item:hover, .kb-item.is-focus { border-color: var(--blue-hl); }
.kb-item.is-focus { box-shadow: 0 0 0 2px var(--ac-soft); }
.kb-item.is-read { opacity: .7; }
.kb-item-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--fm); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); margin-bottom: 4px; }
.kb-item-cat { color: var(--ac-text); font-weight: 700; }
.kb-item-new { color: var(--green-t); }
.kb-item-fix { color: var(--red-t); }
.kb-item-title { font-family: var(--fd); font-size: 1.02rem; font-weight: 700; margin: 0; line-height: 1.3; }
.kb-item-ex { font-size: 13.5px; color: var(--text2); margin: 6px 0 0; }
.kb-item-ex mark, .kb-item-title mark { background: var(--amber-s); color: var(--amber-t); border-radius: 3px; padding: 0 2px; }
.kb-item-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.kb-pill { height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; display: inline-flex; align-items: center; border: 1px solid var(--border2); color: var(--text3); font-family: var(--fm); }
.kb-pill.is-ver { color: var(--purple); border-color: transparent; background: rgba(188,140,255,.12); }
.kb-pill.is-cmd { color: var(--green-t); background: var(--green-s); border-color: transparent; }
.kb-expand { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border2); }
.kb-expand h5 { margin: 0 0 6px; font-family: var(--fm); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--text3); }
.kb-expand pre { margin: 0 0 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--fm); font-size: 12px; white-space: pre-wrap; word-break: break-word; color: var(--text1); }
.kb-expand .kb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kb-expand .kb-btn.is-primary { background: var(--ac); border-color: var(--ac); color: #fff; }
.kb-empty { padding: 40px; text-align: center; border: 1px dashed var(--border2); border-radius: var(--radius); color: var(--text3); }

/* Commands tab */
.kb-cmd-group { margin-bottom: 18px; }
.kb-cmd-group h3 { font-family: var(--fm); font-size: 12px; letter-spacing: .08em; margin: 0 0 8px; color: var(--text1); display: flex; align-items: center; gap: 8px; }
.kb-cmd-group h3 small { color: var(--text4); font-weight: 400; }
.kb-cmd { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; border: 1px solid var(--border); background: var(--bg2); border-radius: var(--radius-sm); padding: 6px 10px; margin-bottom: 4px; }
.kb-cmd code { font-family: var(--fm); font-size: 12px; color: var(--text1); background: none; border: 0; padding: 0; white-space: pre-wrap; word-break: break-all; }
.kb-cmd a { font-family: var(--fm); font-size: 10px; color: var(--text3); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.kb-cmd:hover { border-color: var(--blue-hl); }
.kb-cmd.is-copied { border-color: var(--green-t); }

/* Analytics */
.kb-ana { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .kb-ana { grid-template-columns: 1fr; } }
.kb-card { border: 1px solid var(--border); background: var(--bg2); border-radius: var(--radius); padding: 14px 16px; }
.kb-card h3 { margin: 0 0 10px; font-family: var(--fm); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text3); }
.kb-bar { display: grid; grid-template-columns: 110px minmax(0, 1fr) 36px; gap: 8px; align-items: center; font-size: 12.5px; margin-bottom: 5px; }
.kb-bar span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-bar i { display: block; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--ac), var(--purple)); }
.kb-bar b { font-family: var(--fm); font-size: 11px; font-weight: 500; color: var(--text3); text-align: right; }

/* Footer + help */
.kb-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); font-family: var(--fm); font-size: 11px; color: var(--text4); display: flex; flex-wrap: wrap; gap: 8px 16px; }
.kb-foot a { color: var(--text2); }
.kb-help { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 500; }
.kb-help.is-open { display: flex; }
.kb-help-box { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 18px 22px; width: min(520px, 92vw); box-shadow: var(--shadow-md); }
.kb-help-box h3 { margin: 0 0 12px; font-family: var(--fd); }
.kb-help-box table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-help-box td { padding: 5px 0; border-bottom: 1px solid var(--border); }
.kb-help-box kbd { font-family: var(--fm); font-size: 11px; border: 1px solid var(--border2); border-radius: 4px; padding: 1px 6px; background: var(--bg); }
