/* Anubis Panel Kit — the one layout every app panel in the hub uses.
 * Load after hub.css (tokens, buttons, cards, fields, toast).
 *
 * Shell: a side menu (.k-side: every panel, the open one lists its pages),
 * a slim top bar (.k-top: page title · the page's buttons) and the page (.k-body).
 * Phones: the menu slides in from the side (body.k-open).
 *
 * Vanilla panels get all of this from kit.js (mountPanel). React panels render
 * the same class names. See admin-hub/TEMPLATE.md. */

.k-ic { width: 17px; height: 17px; flex: none; }

/* ---------- shell ---------- */
.k-shell { --side: 256px; min-height: 100vh; }
.k-side {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; width: var(--side);
  display: flex; flex-direction: column; gap: 8px; padding: 12px 10px 10px;
  background: var(--bg-2); border-inline-end: 1px solid var(--line);
}
.k-main { margin-inline-start: var(--side); min-width: 0; }
.k-shell:not(:has(.k-side)) .k-main { margin-inline-start: 0; } /* React panels: no side menu */


/* top bar */
.k-top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  min-height: 58px; padding: 8px 28px; background: rgba(var(--bg-rgb),.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.k-menubtn { display: none; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); }
.k-crumb { min-width: 0; line-height: 1.3; }
.k-crumb small { display: block; color: var(--faint); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-crumb h1 { font-family: var(--display); font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-top .k-actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
/* React panels' back button */
.k-top .k-backbtn { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); cursor: pointer; }
.k-top > img { width: 28px; height: 28px; border-radius: 8px; flex: none; }

.k-body { width: min(1240px, 100% - 56px); margin: 22px auto 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.k-body > * { min-width: 0; }

/* launcher home (hub overview, and the React panels' own home) */
.k-home { width: min(1100px, 100% - 32px); margin: 0 auto 48px; }
.k-hero { padding: 26px 0 6px; }
.k-hero img { width: 48px; height: 48px; border-radius: 12px; margin-bottom: 10px; }
.k-hero h1 { font-family: var(--display); font-size: 1.3rem; }
.k-hero p { color: var(--faint); margin-top: 2px; font-size: .9rem; }
.k-find { max-width: 380px; margin-top: 14px; }
.k-find input { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 14px; }
.k-find input:focus { outline: none; border-color: var(--gold); }
.k-sec-title { margin: 26px 0 10px; color: var(--faint); font-size: .76rem; font-weight: 600; }
.k-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.k-card {
  position: relative; display: flex; align-items: center; gap: 12px; text-align: start; color: var(--text); font: inherit; cursor: pointer;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .15s, background .15s;
}
.k-card:hover { border-color: rgba(var(--gold-rgb),.45); background: var(--surface-2); }
.k-card .k-art { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--gold-2); overflow: hidden; }
.k-card .k-art .k-ic, .k-card .k-art svg { width: 20px; height: 20px; }
.k-card .k-art img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.k-card .k-lbl { min-width: 0; flex: 1; }
.k-card b { display: block; font-size: .92rem; line-height: 1.4; }
.k-card small { display: block; color: var(--faint); font-size: .78rem; margin-top: 1px; line-height: 1.5; }
.k-card .k-count { position: absolute; top: 8px; inset-inline-end: 8px; }

/* ---------- building blocks ---------- */
.k-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.k-kpi { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.k-kpi b { display: block; font-family: var(--display); font-size: 1.3rem; font-weight: 700; color: var(--text); line-height: 1.2; font-variant-numeric: tabular-nums; }
.k-kpi span { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.k-kpi.live b { color: var(--text); }
.k-kpi.live span::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-inline-end: 6px; vertical-align: middle; }

.k-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.k-tile { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, background .15s; cursor: pointer; text-align: start; color: var(--text); font: inherit; }
.k-tile:hover { border-color: rgba(var(--gold-rgb),.45); background: var(--surface-2); }
.k-tile .k-ic, .k-tile svg { width: 34px; height: 34px; padding: 8px; border-radius: 9px; background: var(--gold-soft); color: var(--gold-2); flex: none; }
.k-tile b { display: block; font-size: .9rem; }
.k-tile span { color: var(--faint); font-size: .78rem; }

.k-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.k-toolbar .a-field { flex: 1; min-width: 170px; }

.k-table { overflow-x: auto; margin-inline: -4px; padding-inline: 4px; }
.k-table table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.k-table th, .k-table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.k-table th { position: sticky; top: 0; color: var(--faint); font-weight: 600; font-size: .76rem; background: var(--surface); white-space: nowrap; }
.k-table tbody tr:last-child td { border-bottom: 0; }
.k-table td { font-variant-numeric: tabular-nums; }
.k-table tr.k-row { cursor: pointer; }
.k-table tbody tr:hover { background: var(--hover); }

.k-tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 6px; background: var(--tint); color: var(--muted); margin-inline-start: 6px; white-space: nowrap; }
.k-pill { display: inline-block; font-size: .74rem; font-weight: 600; padding: 1px 9px; border-radius: 6px; background: var(--gold-soft); color: var(--gold-2); }
.k-tag.gold { background: var(--gold-soft); color: var(--gold-2); }
.k-tag.bad { background: rgba(var(--bad-rgb),.13); color: var(--bad); }
.k-tag.ok { background: rgba(var(--ok-rgb),.13); color: var(--ok); }
.k-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-inline-end: 7px; }
.k-dot.on { background: var(--ok); }
.k-note { color: var(--faint); font-size: .82rem; line-height: 1.7; }
.k-note.k-clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.k-note.k-clamp:hover { color: var(--muted); }
.k-note.k-clamp.open { display: block; }
.k-empty { color: var(--faint); text-align: center; padding: 28px 10px; font-size: .9rem; }

.k-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.k-check { flex-direction: row !important; align-items: center; gap: 10px !important; color: var(--text) !important; font-size: .9rem !important; }
.k-check input { width: 18px; height: 18px; }

.k-bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; direction: ltr; padding-top: 8px; border-bottom: 1px solid var(--line); }
.k-bars div { flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(to top, rgba(var(--gold-rgb),.18), rgba(var(--gold-rgb),.55)); position: relative; }
.k-bars div:hover { background: var(--gold-2); }
.k-bars div:hover::after { content: attr(data-t); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--raise); border: 1px solid var(--line-2); padding: 3px 9px; border-radius: 7px; font-size: .74rem; direction: rtl; z-index: 2; }

/* dialog: a sheet from the side, full height */
dialog.k-dlg { margin: 0; margin-inline-start: auto; inset-inline: auto 0; height: 100vh; max-height: 100vh; width: min(640px, 100%); max-width: 100%; padding: 0; color: var(--text); background: var(--bg-2); border: 0; border-inline-start: 1px solid var(--line-2); box-shadow: 0 0 80px var(--shadow); }
dialog.k-dlg[open] { animation: k-sheet .22s ease-out; }
@keyframes k-sheet { from { opacity: 0; transform: translateX(-24px); } }
.k-dlg .a-field textarea { resize: vertical; min-height: 64px; }
dialog.k-dlg::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.k-dlg-head { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px 0; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.k-dlg-head h2 { font-family: var(--display); font-size: 1rem; }
.k-dlg-head > :not(.k-tabs) { margin-bottom: 12px; }
.k-tabs { flex-basis: 100%; display: flex; gap: 2px; overflow-x: auto; margin-inline: -4px; scrollbar-width: none; }
.k-tabs button { flex: none; padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--faint); font-size: .84rem; font-weight: 600; white-space: nowrap; }
.k-tabs button:hover { color: var(--text); }
.k-tabs button.on { color: var(--gold-2); border-bottom-color: var(--gold); }
.k-tabpanel { display: grid; gap: 14px; }
.k-dlg-body { padding: 16px 18px 20px; display: grid; gap: 14px; }

.k-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.k-facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; overflow-wrap: anywhere; font-size: .9rem; }
.k-facts small { display: block; color: var(--faint); font-size: .74rem; }

.k-acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.k-act { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.k-act b { font-size: .9rem; }
.k-act .k-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.k-act input, .k-act select { flex: 1; min-width: 0; font: inherit; font-size: .9rem; color: var(--text); background: var(--bg); border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 10px; }

.k-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.k-chips span { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--tint); }
.k-x { border: 0; background: rgba(var(--bad-rgb),.14); color: var(--bad); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font: inherit; line-height: 1; margin-inline-start: 4px; }
.k-x:hover { background: rgba(var(--bad-rgb),.28); }
.k-code { direction: ltr; text-align: left; font-size: .74rem; max-height: 320px; overflow: auto; background: var(--bg); border: 1px solid var(--line); padding: 12px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* a page that failed to load */
.k-problem { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 34px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.k-problem-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(var(--warn-rgb),.12); color: var(--warn); margin-bottom: 6px; }
.k-problem-ic .k-ic { width: 22px; height: 22px; }
.k-problem b { font-size: 1rem; }
.k-problem p { color: var(--muted); font-size: .88rem; }
.k-problem-btns { display: flex; gap: 8px; margin-top: 8px; }
.k-problem details { width: min(640px, 100%); margin-top: 10px; color: var(--faint); font-size: .8rem; }
.k-problem summary { cursor: pointer; }
.k-problem .k-code { margin-top: 8px; }

/* ⌘K search */
dialog.k-palette { margin: 12vh auto auto; width: min(560px, 100% - 24px); padding: 0; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 30px 80px var(--shadow); overflow: hidden; }
dialog.k-palette::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.k-pal-in { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--faint); }
.k-pal-in input { flex: 1; font: inherit; font-size: 1rem; color: var(--text); background: none; border: 0; outline: none; }
.k-pal-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.k-pal-list a { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 9px; }
.k-pal-list a:hover, .k-pal-list a.on { background: var(--surface-2); }
.k-pal-list a { border-inline-start: 3px solid transparent; }
.k-pal-list a.on { border-inline-start-color: var(--gold); }
.k-pal-list .k-ic { width: 26px; height: 26px; padding: 5px; border-radius: 7px; background: var(--surface-2); color: var(--gold-2); object-fit: cover; }
.k-pal-list img.k-ic { padding: 0; }
.k-pal-list b { display: block; font-size: .9rem; font-weight: 600; }
.k-pal-list small { display: block; color: var(--faint); font-size: .76rem; }

/* loading */
.k-loading { min-height: 40vh; display: grid; place-items: center; color: var(--faint); font-size: .88rem; }
.k-spin { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--gold-soft); border-top-color: var(--gold); animation: k-spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes k-spin { to { transform: rotate(360deg); } }

/* ---------- tablets and phones ---------- */
@media (max-width: 960px) {
  .k-side { transform: translateX(100%); transition: transform .25s ease; box-shadow: none; }
  [dir="ltr"] .k-side { transform: translateX(-100%); }
  body.k-open .k-side { transform: none; box-shadow: 0 0 60px var(--shadow); }
  .k-scrim { position: fixed; inset: 0; z-index: 35; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.k-open .k-scrim { opacity: 1; pointer-events: auto; }
  .k-main { margin-inline-start: 0; }
  .k-menubtn { display: grid; }
  .k-top { padding: 8px 16px; }
  .k-body { width: min(1240px, 100% - 32px); margin-top: 16px; }
}
@media (max-width: 600px) {
  .k-top { gap: 10px; }
  .k-top .k-label { display: none; }
  .k-cards { grid-template-columns: minmax(0, 1fr); }
  .k-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .k-kpi b { font-size: 1.2rem; }
  .a-card { padding: 14px; }
}

.k-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }


/* «المساعد» (assistant.js): a small button in the bottom corner, a chat above it */
.k-ai { position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 80; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 10px; }
.k-ai-fab { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px 9px 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--raise); color: var(--text); font-weight: 600; font-size: .88rem; box-shadow: 0 8px 24px var(--shadow); }
.k-ai-fab svg { width: 18px; height: 18px; color: var(--gold-2); }
.k-ai-fab:hover { border-color: rgba(var(--gold-rgb),.5); }
.k-ai.open .k-ai-fab span { display: none; }
.k-ai.open .k-ai-fab { padding: 9px; }
.k-ai-panel { width: min(380px, calc(100vw - 32px)); height: min(540px, calc(100vh - 110px)); display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 24px 60px var(--shadow); overflow: hidden; }
.k-ai-panel[hidden] { display: none; }
.k-ai-panel header { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 2px 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.k-ai-panel header b { font-family: var(--display); font-size: .95rem; }
.k-ai-panel header small { grid-column: 1; grid-row: 2; color: var(--faint); font-size: .74rem; }
.k-ai-panel header button { grid-row: 1 / 3; border: 0; background: none; color: var(--faint); font-size: .78rem; padding: 4px 6px; border-radius: 6px; }
.k-ai-panel header .k-ai-x { font-size: 1.2rem; line-height: 1; }
.k-ai-panel header button:hover { color: var(--text); background: var(--surface-2); }
.k-ai-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.k-ai-msg { max-width: 88%; align-self: flex-start; padding: 8px 11px; border-radius: 12px; border-start-start-radius: 4px; background: var(--surface-2); font-size: .86rem; line-height: 1.7; }
.k-ai-msg.me { align-self: flex-end; background: var(--gold-soft); color: var(--gold-2); border-radius: 12px; border-start-end-radius: 4px; }
.k-ai-msg ol { margin: 6px 0 0; padding-inline-start: 18px; display: grid; gap: 3px; }
.k-ai-links { display: grid; gap: 4px; margin-top: 6px; color: var(--faint); font-size: .78rem; }
.k-ai-links a { display: block; padding: 5px 9px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line-2); color: var(--gold-2); font-size: .82rem; }
.k-ai-links a:hover { border-color: rgba(var(--gold-rgb),.45); }
.k-ai-hello { display: grid; gap: 6px; color: var(--faint); font-size: .8rem; }
.k-ai-hello button { text-align: start; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .82rem; }
.k-ai-hello button:hover { color: var(--text); border-color: var(--line-2); }
.k-ai-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.k-ai-form input { flex: 1; min-width: 0; font: inherit; font-size: .88rem; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 10px; }
.k-ai-form input:focus { outline: none; border-color: var(--gold); }
.k-ai.busy .k-ai-log::after { content: "بيفكّر…"; align-self: flex-start; color: var(--faint); font-size: .8rem; padding: 4px 10px; animation: k-ai-blink 1s infinite alternate; }
@keyframes k-ai-blink { to { opacity: .35; } }
.k-ai-focus { outline: 2px solid var(--gold) !important; outline-offset: 4px; border-radius: 8px; animation: k-ai-pulse 1.2s ease-in-out 3; }
@keyframes k-ai-pulse { 50% { outline-color: transparent; } }
@media (max-width: 600px) { .k-ai { bottom: 12px; inset-inline-end: 12px; } }

/* Light mode: a few panels paint colours inline (older code). Follow the theme. */
:root[data-theme="light"] [style*="rgba(7,15,31"], :root[data-theme="light"] [style*="rgba(255,255,255,.0"] { background: var(--surface-2) !important; }
:root[data-theme="light"] [style*="color:#5fd3a2"], :root[data-theme="light"] [style*="color: #5fd3a2"] { color: var(--ok) !important; }
:root[data-theme="light"] [style*="color:#ff8a8a"], :root[data-theme="light"] [style*="color:#ff8f8f"] { color: var(--bad) !important; }
:root[data-theme="light"] .k-top { background: rgba(var(--bg-rgb),.85); }
:root[data-theme="light"] .k-ai-fab, :root[data-theme="light"] .k-ai-panel { box-shadow: 0 10px 30px var(--shadow); }


/* ---------- side menu (kit.js mountSide) ----------
 * Top: logo · filter box · rail button. Then «المفضلة», the open panel's pages
 * in folding sections, every other panel, and the footer. One line-icon style
 * (16px, 1.75 stroke), small muted section labels, no boxes. */
.k-side .k-ic { stroke-width: 1.75; }
.k-side-top { display: flex; align-items: center; gap: 6px; }
.k-logo { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; }
.k-logo img { width: 26px; height: 26px; border-radius: 7px; }
.k-search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; height: 34px; padding-inline: 10px 3px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--faint); transition: border-color .12s;
}
.k-search:hover { border-color: var(--line-2); }
.k-search:focus-within { border-color: rgba(var(--gold-rgb),.6); color: var(--muted); }
.k-search > .k-ic { width: 15px; height: 15px; }
.k-search input { flex: 1; min-width: 0; font: inherit; font-size: .8rem; color: var(--text); background: none; border: 0; outline: none; }
.k-search input::placeholder { color: var(--faint); }
.k-search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: .6; cursor: pointer; }
.k-search button { display: grid; place-items: center; padding: 3px; border: 0; border-radius: 6px; background: none; }
.k-search kbd { font: 600 .64rem var(--body); direction: ltr; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--faint); }
.k-search button:hover kbd { color: var(--text); border-color: var(--line-3); }
.k-rail-btn { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--faint); }
.k-rail-btn:hover { background: var(--hover); color: var(--text); }
.k-rail-btn .k-ic { width: 17px; height: 17px; }

.k-nav { flex: 1; overflow-y: auto; margin-inline: -6px; padding: 2px 6px 12px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
/* small muted section labels */
.k-nav-label, .k-fold-head {
  display: flex; align-items: center; gap: 6px; margin: 16px 0 3px; padding: 3px 10px;
  color: var(--faint); font-size: .68rem; font-weight: 600; letter-spacing: .02em;
}
.k-nav-label .k-ic { width: 12px; height: 12px; }
.k-fold-head { width: 100%; border: 0; background: none; text-align: start; border-radius: 6px; transition: color .12s; }
.k-fold-head > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-fold-head .k-chev { width: 12px; height: 12px; opacity: 0; transition: transform .15s, opacity .12s; }
.k-fold-head:hover { color: var(--muted); }
.k-fold-head:hover .k-chev, .k-fold-head:focus-visible .k-chev, .k-fold-grp:not(.open) > .k-fold-head .k-chev { opacity: .8; }
.k-fold-grp.open > .k-fold-head .k-chev { transform: rotate(180deg); }
.k-fold-grp:not(.open) > .k-fold-body { display: none; }
.k-sub:not(.open) > .k-fold-head { margin-block: 2px; }
.k-sub:has(.k-nav-page.on) > .k-fold-head { color: var(--gold-2); }
.k-favs:empty { display: none; }
.k-favs > .k-nav-label:first-child, .k-nav > .k-cur:first-child .k-fold-head:first-child { margin-top: 6px; }

/* rows: a page, a panel, the footer's buttons */
.k-nav-page, .k-nav-app > a, .k-cur-head, .k-side-foot a, .k-side-foot button {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 5px 10px; border-radius: 8px;
  color: var(--muted); font-size: .82rem; font-weight: 500; background: none; border: 0; text-align: start; transition: background .12s, color .12s;
}
.k-nav-page:hover, .k-nav-app > a:hover, .k-cur-head:hover, .k-side-foot a:hover, .k-side-foot button:hover { background: var(--hover); color: var(--text); }
.k-nav-page > span, .k-nav-app > a > span:not(.k-mark), .k-cur-head > span:not(.k-mark), .k-side-foot span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-nav-page .k-ic, .k-side-foot .k-ic { width: 16px; height: 16px; color: var(--faint); transition: color .12s; }
.k-nav-page:hover .k-ic { color: var(--muted); }
.k-nav-page.on { background: var(--gold-soft); color: var(--gold-2); font-weight: 600; }
.k-nav-page.on .k-ic { color: var(--gold); }
.k-count { font-style: normal; font-size: .66rem; font-weight: 700; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--gold); color: var(--on-gold); text-align: center; line-height: 17px; }
/* pin star: on hover (always a little on touch screens), gold when pinned */
.k-star { flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-inline-end: -4px; border: 0; border-radius: 6px; background: none; color: var(--faint); opacity: 0; transition: opacity .12s, color .12s; }
.k-star .k-ic { width: 13px; height: 13px; color: inherit; }
.k-nav-page:hover .k-star, .k-star:focus-visible { opacity: 1; }
.k-star:hover { color: var(--gold-2); background: var(--tint); }
.k-star.on { opacity: 1; color: var(--gold); }
.k-star.on svg { fill: currentColor; }
@media (hover: none) { .k-star { opacity: .5; } .k-search button { display: none; } }

/* the open panel's name, then its sections */
.k-cur-head { margin-top: 10px; color: var(--text); font-weight: 600; font-size: .86rem; }
.k-mark { width: 20px; height: 20px; border-radius: 6px; flex: none; object-fit: cover; }
.k-mark-ic { display: grid; place-items: center; background: var(--surface-2); color: var(--gold-2); }
.k-mark-ic .k-ic, svg.k-mark-ic { width: 20px; height: 20px; padding: 3px; }
.k-cur .k-fold-body, .k-plain { display: grid; gap: 1px; }

/* every other panel: the name opens it, the arrow shows its pages */
.k-others { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 4px; }
.k-grp + .k-grp { margin-top: 4px; }
.k-nav-app { display: flex; align-items: center; }
.k-nav-app > a { flex: 1; min-width: 0; }
.k-nav-item.here > .k-nav-app > a { color: var(--text); font-weight: 600; }
.k-fold { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border: 0; border-radius: 7px; background: none; color: var(--faint); }
.k-fold:hover { background: var(--tint); color: var(--text); }
.k-fold .k-chev { width: 13px; height: 13px; transition: transform .15s; }
.k-nav-item.open > .k-nav-app .k-chev { transform: rotate(180deg); }
.k-nav-item:not(.open) > .k-nav-pages { display: none; }
.k-nav-pages { position: relative; margin: 0 0 6px; padding-inline-start: 20px; }
.k-nav-pages::before { content: ""; position: absolute; inset-block: 4px; inset-inline-start: 19px; width: 1px; background: var(--line); }
.k-nav-pages .k-nav-page { min-height: 28px; padding-block: 3px; padding-inline-start: 14px; font-size: .8rem; }
.k-nav-pages .k-nav-page > .k-ic { display: none; }
.k-nav-pages .k-nav-label { margin: 8px 0 1px; padding-inline-start: 14px; font-size: .64rem; }

.k-side-foot { border-top: 1px solid var(--line); padding-top: 6px; display: grid; gap: 1px; }

/* filtering: only matches show, and whatever holds one is unfolded */
.k-nav .k-miss { display: none !important; }
.k-filtering .k-favs, .k-filtering .k-nav-label { display: none; }
.k-filtering .k-fold-grp > .k-fold-body { display: grid; }
.k-filtering .k-nav-item.k-hit > .k-nav-pages { display: block; }
.k-filtering .k-nav-item:not(.k-hit) > .k-nav-pages { display: none; }
.k-filtering .k-others { border-top: 0; }
.k-nav-none { margin: 18px 10px; color: var(--faint); font-size: .8rem; line-height: 1.8; text-align: center; }
.k-nav-none button { margin-top: 6px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--gold-2); font-size: .78rem; padding: 4px 10px; }
.k-nav-none button:hover { border-color: rgba(var(--gold-rgb),.45); }

/* rail tooltip (kit.js positions it) */
.k-tip { position: fixed; z-index: 90; transform: translateY(-50%); pointer-events: none; white-space: nowrap; padding: 4px 10px; border-radius: 7px; background: var(--raise); color: var(--text); border: 1px solid var(--line-2); font-size: .78rem; font-weight: 500; box-shadow: 0 8px 24px var(--shadow); }

/* icons-only rail (wide screens only; phones keep the drawer) */
@media (min-width: 961px) {
  html.k-rail .k-shell { --side: 60px; }
  html.k-rail .k-side { padding-inline: 8px; }
  html.k-rail .k-side-top { flex-direction: column; gap: 6px; }
  html.k-rail .k-search { flex: none; width: 36px; padding: 0; justify-content: center; cursor: pointer; }
  html.k-rail .k-search input, html.k-rail .k-search button { display: none; }
  html.k-rail .k-nav { margin-inline: -8px; padding-inline: 8px; scrollbar-width: none; }
  html.k-rail .k-nav-label, html.k-rail .k-fold-head, html.k-rail .k-star, html.k-rail .k-fold,
  html.k-rail .k-nav-page > span, html.k-rail .k-nav-app span:not(.k-mark), html.k-rail .k-cur-head > span:not(.k-mark), html.k-rail .k-side-foot span,
  html.k-rail .k-nav-pages, html.k-rail .k-nav-none, html.k-rail .k-others .k-nav-home, html.k-rail .k-others .k-nav-item.here { display: none !important; }
  html.k-rail .k-nav-page, html.k-rail .k-nav-app > a, html.k-rail .k-cur-head, html.k-rail .k-side-foot a, html.k-rail .k-side-foot button { justify-content: center; padding: 8px 0; min-height: 36px; }
  html.k-rail .k-nav-page .k-count { position: absolute; top: 3px; inset-inline-end: 3px; min-width: 8px; height: 8px; padding: 0; font-size: 0; }
  html.k-rail .k-favs { padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  html.k-rail .k-sub.open + .k-sub.open { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
  html.k-rail .k-others { display: block; }
  html.k-rail .k-others > .k-fold-body { display: grid; gap: 1px; }
  html.k-rail .k-cur-head { margin-top: 4px; }
}
@media (max-width: 960px) { .k-rail-btn { display: none; } }

/* kitConfirm / kitPrompt / kitAlert (kit.js): a small centred question, not a side sheet */
dialog.k-dlg.k-ask { margin: auto; inset: 0; height: fit-content; max-height: calc(100vh - 32px); width: min(460px, calc(100% - 32px)); border: 1px solid var(--line-2); border-radius: var(--radius); overflow: auto; }
dialog.k-dlg.k-ask[open] { animation: k-pop .16s ease-out; }
@keyframes k-pop { from { opacity: 0; transform: scale(.97); } }
.k-ask-box { display: grid; gap: 12px; padding: 18px; }
.k-ask-box h2 { font-family: var(--display); font-size: 1rem; }
.k-ask-msg { white-space: pre-line; line-height: 1.8; color: var(--text); font-size: .92rem; overflow-wrap: anywhere; }
.k-ask-box h2 + .k-ask-msg { color: var(--muted); }
.k-ask-err { color: var(--bad); font-size: .82rem; }
.k-ask-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
