/* =====================================================================
   KANBAN OS - styles.css
   Design system: dark (default) and light themes, layout, drag affordances,
   overlays, agent console, responsive behaviour.
   ===================================================================== */

:root {
  --bg: #070b11;
  --bg-2: #0b1119;
  --surface: #0f1622;
  --surface-2: #131d2b;
  --surface-3: #182435;
  --line: #1e2b3d;
  --line-soft: #17212f;
  --text: #dce7f5;
  --text-dim: #93a4ba;
  --text-mute: #64748b;
  --accent: #38e1d0;
  --accent-2: #8b6cff;
  --accent-3: #ff5c39;
  --ok: #3ddc84;
  --warn: #ffb020;
  --danger: #ff5470;
  --p-none: #5b6b80;
  --p-low: #4ea1ff;
  --p-medium: #ffb020;
  --p-high: #ff8a3d;
  --p-critical: #ff5470;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --gap: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  --shadow-soft: 0 8px 22px rgba(0, 0, 0, .35);
  --glow: 0 0 0 1px rgba(56, 225, 208, .35), 0 0 22px rgba(56, 225, 208, .18);
  --overlay: rgba(4, 8, 13, .72);
  --font: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
  --header-h: 64px;
}

html[data-theme="light"] {
  --bg: #eef2f7;
  --bg-2: #e6ebf3;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #e9eef5;
  --line: #d3dbe6;
  --line-soft: #e3e9f1;
  --text: #16202e;
  --text-dim: #4a5a6e;
  --text-mute: #7c8b9d;
  --accent: #0f9c8c;
  --accent-2: #6a4bf0;
  --accent-3: #e24a26;
  --ok: #17a45c;
  --warn: #b8770a;
  --danger: #d92b4b;
  --p-none: #7d8b9c;
  --p-low: #2a72d4;
  --p-medium: #b8770a;
  --p-high: #dd6b1f;
  --p-critical: #d92b4b;
  --shadow: 0 18px 40px rgba(24, 39, 61, .16);
  --shadow-soft: 0 6px 18px rgba(24, 39, 61, .10);
  --glow: 0 0 0 1px rgba(15, 156, 140, .35), 0 0 18px rgba(15, 156, 140, .16);
  --overlay: rgba(226, 233, 242, .78);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(139, 108, 255, .16), transparent 60%),
    radial-gradient(900px 600px at 8% 108%, rgba(56, 225, 208, .12), transparent 62%),
    var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="light"] body {
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(106, 75, 240, .10), transparent 60%),
    radial-gradient(900px 600px at 8% 108%, rgba(15, 156, 140, .10), transparent 62%),
    var(--bg);
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .01em; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.kb-visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.kb-skip-link {
  position: absolute; left: -999px; top: 0; z-index: 300;
  padding: 10px 16px; background: var(--accent); color: #04131a;
  border-radius: 0 0 var(--radius-sm) 0; font-weight: 700; text-decoration: none;
}
.kb-skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ */
/* Buttons                                                            */
/* ------------------------------------------------------------------ */

.kb-btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); border-radius: var(--radius-sm); padding: 8px 13px;
  cursor: pointer; font-weight: 600; letter-spacing: .02em;
  transition: background .16s ease, border-color .16s ease, transform .12s ease, color .16s ease;
}
.kb-btn:hover { background: var(--surface-3); border-color: #2b3d55; }
.kb-btn:active { transform: translateY(1px); }
.kb-btn:disabled { opacity: .5; cursor: not-allowed; }
.kb-btn-ghost { background: transparent; border-color: var(--line-soft); color: var(--text-dim); min-width: 38px; text-align: center; }
.kb-btn-ghost:hover { color: var(--text); }
.kb-btn-primary { background: linear-gradient(135deg, var(--accent), #21b8ad); border-color: transparent; color: #04131a; }
html[data-theme="light"] .kb-btn-primary { background: linear-gradient(135deg, var(--accent), #0b7f72); color: #fff; }
.kb-btn-primary:hover { filter: brightness(1.08); }
.kb-btn-danger { background: transparent; border-color: rgba(255, 84, 112, .45); color: var(--danger); }
.kb-btn-danger:hover { background: rgba(255, 84, 112, .12); }

.kb-icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--text-mute);
  cursor: pointer; font-size: 17px; line-height: 1; padding: 4px 7px; border-radius: 6px;
}
.kb-icon-btn:hover { color: var(--accent); background: rgba(56, 225, 208, .1); }

/* ------------------------------------------------------------------ */
/* Top bar                                                            */
/* ------------------------------------------------------------------ */

.kb-topbar {
  flex: 0 0 auto; min-height: var(--header-h); display: flex; align-items: center;
  gap: 12px; padding: 10px 18px; background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 60;
}

.kb-brand { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 0 0 auto; }
.kb-brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: conic-gradient(from 140deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  box-shadow: 0 0 18px rgba(56, 225, 208, .35);
}
.kb-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.kb-brand-text strong { font-size: 15px; letter-spacing: .12em; white-space: nowrap; }
.kb-brand-text small { color: var(--text-mute); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kb-board-picker { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 0 1 auto; }
.kb-board-select {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; color: var(--text); cursor: pointer; max-width: 190px; min-width: 80px;
}
.kb-board-select:focus { border-color: var(--accent); outline: none; box-shadow: var(--glow); }

.kb-search-wrap { flex: 1 1 auto; display: flex; gap: 8px; align-items: center; max-width: 460px; min-width: 120px; }
.kb-search {
  flex: 1 1 auto; min-width: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px; color: var(--text);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.kb-search::placeholder { color: var(--text-mute); }
.kb-search:focus { border-color: var(--accent); box-shadow: var(--glow); outline: none; }
.kb-sort {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 10px; color: var(--text-dim); cursor: pointer;
}

.kb-topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.kb-bell { position: relative; }
.kb-badge {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.kb-badge[hidden] { display: none; }

.kb-user-chip {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px;
  cursor: pointer; color: var(--text);
}
.kb-user-chip:hover { border-color: var(--accent); }
.kb-user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; }

.kb-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  background: var(--avatar-color, var(--text-mute)); color: #08121a;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
}
.kb-avatar-sm { width: 20px; height: 20px; font-size: 9px; }
.kb-avatar-xs { width: 18px; height: 18px; font-size: 8px; border: 1px solid var(--surface-2); }
.kb-avatar-empty { background: var(--surface-3); color: var(--text-mute); }
.kb-avatar-reporter { opacity: .65; }

.kb-offline {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 8px 18px; background: rgba(255, 84, 112, .16);
  border-bottom: 1px solid rgba(255, 84, 112, .4); color: var(--text); font-size: 12.5px;
}
.kb-offline[hidden] { display: none; }

/* Popovers */

.kb-popover {
  position: absolute; top: calc(var(--header-h) - 4px); right: 18px; z-index: 90;
  min-width: 300px; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.kb-popover[hidden] { display: none; }
.kb-user-menu { right: 12px; min-width: 260px; }

.kb-notifications-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px;
}
.kb-notifications-list { max-height: 340px; overflow-y: auto; }
.kb-notification {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px; cursor: pointer; color: var(--text-dim);
}
.kb-notification:hover { background: var(--surface-2); }
.kb-notification.kb-unread { background: rgba(56, 225, 208, .07); color: var(--text); }
.kb-notification-title { font-size: 12px; font-weight: 700; }
.kb-notification-text { font-size: 12px; }
.kb-notification-time { font-size: 10.5px; color: var(--text-mute); }
.kb-notifications-empty { margin: 0; padding: 16px; color: var(--text-mute); font-size: 12.5px; }

.kb-user-menu-head { padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-mute); border-bottom: 1px solid var(--line-soft); }
.kb-user-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; padding: 9px 12px; cursor: pointer; color: var(--text);
}
.kb-user-item:hover { background: var(--surface-2); }
.kb-user-item.kb-active { background: rgba(56, 225, 208, .1); }
.kb-user-item-text { display: flex; flex-direction: column; line-height: 1.2; }
.kb-user-item-text strong { font-size: 12.5px; }
.kb-user-item-text small { font-size: 11px; color: var(--text-mute); }
.kb-user-manage { border-top: 1px solid var(--line-soft); }

/* ------------------------------------------------------------------ */
/* Mobile column tabs                                                 */
/* ------------------------------------------------------------------ */

.kb-tabs {
  display: none; flex: 0 0 auto; gap: 8px; padding: 10px 14px;
  overflow-x: auto; border-bottom: 1px solid var(--line-soft); scrollbar-width: thin;
}
.kb-tab {
  flex: 0 0 auto; background: var(--surface); border: 1px solid var(--line);
  color: var(--text-dim); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600;
}
.kb-tab-count { color: var(--text-mute); font-weight: 500; }

/* ------------------------------------------------------------------ */
/* Board                                                              */
/* ------------------------------------------------------------------ */

.kb-main { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }

.kb-board {
  flex: 1 1 auto; display: flex; gap: var(--gap); padding: 16px;
  overflow-x: auto; overflow-y: hidden; align-items: stretch; scrollbar-width: thin;
}

/* The grab cursor is offered only where a plain left drag pans - the board
   background and the gap between columns. Over a column body the left button
   draws the marquee, so the cursor stays normal there. */
.kb-board.kb-pannable { cursor: grab; }
.kb-board.kb-pannable > .kb-column,
.kb-board.kb-pannable .kb-column-body,
.kb-board.kb-pannable .kb-column-empty { cursor: auto; }
.kb-board.kb-pan-ready { cursor: grab; }
.kb-board.kb-panning { scroll-snap-type: none; user-select: none; }
.kb-board.kb-panning,
.kb-board.kb-panning > .kb-column,
.kb-board.kb-panning .kb-column-body,
.kb-board.kb-panning .kb-column-empty,
.kb-board.kb-panning .kb-card { cursor: grabbing; }

.kb-board::-webkit-scrollbar,
.kb-column-body::-webkit-scrollbar,
.kb-cli-output::-webkit-scrollbar,
.kb-users-list::-webkit-scrollbar,
.kb-notifications-list::-webkit-scrollbar { width: 10px; height: 10px; }

.kb-board::-webkit-scrollbar-thumb,
.kb-column-body::-webkit-scrollbar-thumb,
.kb-cli-output::-webkit-scrollbar-thumb,
.kb-users-list::-webkit-scrollbar-thumb,
.kb-notifications-list::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 999px; border: 2px solid transparent; background-clip: content-box;
}

.kb-board-empty { color: var(--text-mute); margin: auto; }

.kb-column {
  position: relative; flex: 0 0 302px; width: 302px; max-height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-soft);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.kb-column.kb-over-limit { border-color: rgba(255, 84, 112, .5); }
.kb-column.kb-drop-active { border-color: var(--accent); }

.kb-column-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.kb-drag-handle {
  appearance: none; border: 0; background: transparent; color: var(--text-mute);
  cursor: grab; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 6px; touch-action: none;
}
.kb-drag-handle:hover, .kb-drag-handle.kb-handle-active { color: var(--accent); background: rgba(56, 225, 208, .1); }
.kb-drag-handle:active { cursor: grabbing; }
.kb-column-name {
  font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto;
}
.kb-count { font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-dim); border-radius: 999px; padding: 2px 8px; }
.kb-wip {
  font-size: 11px; font-weight: 700; color: var(--text-mute); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.kb-wip.kb-wip-over { color: var(--danger); border-color: rgba(255, 84, 112, .5); background: rgba(255, 84, 112, .1); }

.kb-column-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px;
  display: flex; flex-direction: column; gap: 9px;
}
/* The drop preview holds the place itself, so the empty hint steps aside. */
.kb-drop-active .kb-column-empty { display: none; }
.kb-column-empty {
  margin: auto 0; color: var(--text-mute); text-align: center; font-size: 12.5px;
  display: flex; flex-direction: column; gap: 4px; padding: 24px 8px;
}
.kb-column-empty span { font-size: 11.5px; opacity: .75; }
.kb-column-foot { padding: 8px 10px 10px; border-top: 1px solid var(--line-soft); }
.kb-add-btn {
  width: 100%; background: transparent; border: 1px dashed var(--line); color: var(--text-mute);
  border-radius: var(--radius-sm); padding: 7px 10px; cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.kb-add-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(56, 225, 208, .06); }

.kb-column-menu {
  position: absolute; right: 10px; top: 52px; z-index: 40; min-width: 208px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.kb-column-menu[hidden] { display: none; }
.kb-column-menu button {
  appearance: none; border: 0; background: transparent; color: var(--text-dim);
  text-align: left; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
}
.kb-column-menu button:hover { background: var(--surface-3); color: var(--text); }
.kb-column-menu .kb-danger:hover { background: rgba(255, 84, 112, .14); color: var(--danger); }

/* ------------------------------------------------------------------ */
/* Cards                                                              */
/* ------------------------------------------------------------------ */

.kb-card {
  position: relative; background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--p-none); border-radius: var(--radius);
  padding: 10px 11px; cursor: grab; display: flex; flex-direction: column; gap: 6px;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease, opacity .18s ease;
}
.kb-card:hover { transform: translateY(-1px); border-color: #2c3f58; box-shadow: var(--shadow-soft); }
.kb-card.kb-prio-low { border-left-color: var(--p-low); }
.kb-card.kb-prio-medium { border-left-color: var(--p-medium); }
.kb-card.kb-prio-high { border-left-color: var(--p-high); }
.kb-card.kb-prio-critical { border-left-color: var(--p-critical); }
.kb-card.kb-dragging, .kb-card.kb-touch-source { opacity: .38; cursor: grabbing; }
.kb-card.kb-dimmed { opacity: .28; filter: saturate(.4); }
.kb-card.kb-match { border-color: var(--accent); box-shadow: var(--glow); }
.kb-card.kb-selected { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; box-shadow: var(--glow); }
.kb-card.kb-is-done .kb-card-title { text-decoration: line-through; color: var(--text-mute); }

.kb-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kb-card-people { display: flex; gap: 3px; margin-left: auto; }
.kb-prio-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--p-none); }
.kb-prio-label.kb-prio-low { color: var(--p-low); }
.kb-prio-label.kb-prio-medium { color: var(--p-medium); }
.kb-prio-label.kb-prio-high { color: var(--p-high); }
.kb-prio-label.kb-prio-critical { color: var(--p-critical); }

.kb-done-toggle {
  appearance: none; border: 1px solid var(--line); background: transparent; color: var(--text-mute);
  border-radius: 50%; width: 22px; height: 22px; line-height: 1; cursor: pointer; font-size: 12px; flex: 0 0 auto;
}
.kb-done-toggle:hover { color: var(--ok); border-color: var(--ok); }
.kb-done-toggle[aria-pressed="true"] { color: var(--ok); border-color: var(--ok); background: rgba(61, 220, 132, .12); }

/* Hover hints drawn in CSS: unlike the native title tooltip they never
   swallow the click that triggered them. */
[data-hint] { position: relative; }
[data-hint]::after,
.kb-card-tooltip {
  z-index: 120; pointer-events: none;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 9px; font-size: 11px; font-weight: 500;
  box-shadow: var(--shadow-soft);
}
[data-hint]::after {
  content: attr(data-hint);
  position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%) translateY(-4px);
  white-space: nowrap; opacity: 0; transition: opacity .14s ease, transform .14s ease;
}
[data-hint]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.kb-card [data-hint]::after { content: none; }
.kb-card-tooltip { position: fixed; width: max-content; max-width: calc(100% - 16px); overflow-wrap: anywhere; }
.kb-column-head [data-hint]::after { top: calc(100% + 2px); }
.kb-column-filter-toggle.is-active { color:var(--accent); background:rgba(56,225,208,.14); }
.kb-column-filter[hidden] { display:none; }
.kb-column-filter { display:grid; gap:7px; flex:0 1 auto; min-height:0; max-height:45%; overflow-y:auto; padding:10px 12px; border-bottom:1px solid var(--line-soft); }
.kb-column-filter label { display:grid; gap:3px; font-size:12px; color:var(--text-dim); }
.kb-column-filter input,.kb-column-filter select { width:100%; min-width:0; min-height:34px; box-sizing:border-box; padding:6px 8px; border:1px solid var(--line); border-radius:6px; background:var(--bg); color:var(--text); font:inherit; }
.kb-column-filter-footer { display:flex; justify-content:space-between; align-items:center; gap:8px; font-size:12px; color:var(--text-mute); }
.kb-column-filter-footer button { border:0; background:transparent; color:var(--accent); padding:6px; cursor:pointer; font:inherit; }
@media(max-width:640px) { .kb-column-filter input,.kb-column-filter select { font-size:16px; min-height:40px; } }
/* Header tooltips open to the left so they never cover the next control. */
.kb-topbar [data-hint]::after {
  left: auto; right: 0; transform: translateY(-4px); max-width: 260px; white-space: normal;
  text-align: right; min-width: 0;
}
.kb-topbar [data-hint]:hover::after { transform: translateY(0); }

.kb-closed-chip {
  color: var(--ok); border: 1px solid rgba(61, 220, 132, .4);
  background: rgba(61, 220, 132, .1); border-radius: 999px; padding: 0 7px; font-weight: 700;
}
.kb-count-closed {
  display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px;
  margin-left: 4px; border-radius: 999px; background: rgba(61, 220, 132, .18);
  color: var(--ok); font-size: 9.5px; font-weight: 800; padding: 0 4px;
}

.kb-card-title { font-size: 13.5px; line-height: 1.35; word-break: break-word; }
.kb-card-desc {
  margin: 0; font-size: 12px; color: var(--text-mute); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kb-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.kb-tag {
  font-size: 10.5px; font-weight: 600; color: var(--accent-2);
  background: rgba(139, 108, 255, .12); border: 1px solid rgba(139, 108, 255, .28);
  border-radius: 999px; padding: 1px 8px;
}
.kb-card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--text-mute); }
.kb-metric { white-space: nowrap; }
.kb-overdue { color: var(--danger); font-weight: 700; }

/* Tinted cards: every foreground value comes from the computed tokens in
   core.js and is verified at 4.5:1 against the chosen background. */
.kb-card.kb-tinted {
  background: var(--kb-card-bg); border-color: var(--kb-card-line);
  border-left-color: var(--kb-card-dim); color: var(--kb-card-fg);
}
.kb-card.kb-tinted:hover { border-color: var(--kb-card-hover-line); }
.kb-card.kb-tinted.kb-prio-low { border-left-color: var(--kb-card-priority-low); }
.kb-card.kb-tinted.kb-prio-medium { border-left-color: var(--kb-card-priority-medium); }
.kb-card.kb-tinted.kb-prio-high { border-left-color: var(--kb-card-priority-high); }
.kb-card.kb-tinted.kb-prio-critical { border-left-color: var(--kb-card-priority-critical); }
.kb-card.kb-tinted.kb-match { border-color: var(--kb-card-fg); box-shadow: 0 0 0 2px var(--kb-card-line); }
.kb-card.kb-tinted .kb-card-desc,
.kb-card.kb-tinted .kb-card-meta { color: var(--kb-card-dim); }
.kb-card.kb-tinted.kb-is-done .kb-card-title { color: var(--kb-card-dim); }
.kb-card.kb-tinted .kb-prio-label { color: var(--kb-card-dim); }
.kb-card.kb-tinted .kb-prio-label.kb-prio-low { color: var(--kb-card-p-low); }
.kb-card.kb-tinted .kb-prio-label.kb-prio-medium { color: var(--kb-card-p-medium); }
.kb-card.kb-tinted .kb-prio-label.kb-prio-high { color: var(--kb-card-p-high); }
.kb-card.kb-tinted .kb-prio-label.kb-prio-critical { color: var(--kb-card-p-critical); }
.kb-card.kb-tinted .kb-tag {
  color: var(--kb-card-fg); background: var(--kb-card-tag-bg); border-color: var(--kb-card-tag-line);
}
.kb-card.kb-tinted .kb-overdue { color: var(--kb-card-danger); }
.kb-card.kb-tinted .kb-closed-chip {
  color: var(--kb-card-ok); border-color: var(--kb-card-tag-line); background: var(--kb-card-tag-bg);
}
.kb-card.kb-tinted .kb-done-toggle { color: var(--kb-card-dim); border-color: var(--kb-card-line); }
.kb-card.kb-tinted .kb-done-toggle:hover { color: var(--kb-card-ok); border-color: var(--kb-card-ok); }
.kb-card.kb-tinted .kb-done-toggle[aria-pressed="true"] {
  color: var(--kb-card-ok); border-color: var(--kb-card-ok); background: var(--kb-card-tag-bg);
}
.kb-card.kb-tinted .kb-avatar-xs { border-color: var(--kb-card-line); }
/* The drop preview is only a frame in the card flow: it keeps the place and
   the height of the dragged card without copying its content. */
.kb-card-ghost {
  position: relative; flex: 0 0 auto; box-sizing: border-box;
  border: 1px dashed var(--accent); border-radius: var(--radius);
  background: rgba(56, 225, 208, .1); opacity: .7;
  pointer-events: none;
}
.kb-ghost-count {
  position: absolute; top: -9px; right: -9px; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #04131a; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1;
}
.kb-marquee {
  position: fixed; z-index: 70; pointer-events: none;
  border: 1px solid var(--accent); background: rgba(56, 225, 208, .12); border-radius: 4px;
}
.kb-metric-prio.kb-prio-critical { color: var(--p-critical); }
.kb-metric-prio.kb-prio-high { color: var(--p-high); }
.kb-metric-prio.kb-prio-medium { color: var(--p-medium); }
.kb-metric-prio.kb-prio-low { color: var(--p-low); }

.kb-column-indicator {
  flex: 0 0 3px; align-self: stretch; border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(56, 225, 208, .7);
  animation: kb-pulse 1.1s ease-in-out infinite;
}
.kb-ghost {
  position: fixed; left: 0; top: 0; z-index: 220; pointer-events: none; opacity: .92;
  transform-origin: top left; box-shadow: 0 22px 44px rgba(0, 0, 0, .55);
  border-radius: var(--radius); rotate: -1.4deg;
}
@keyframes kb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ------------------------------------------------------------------ */
/* Search results                                                     */
/* ------------------------------------------------------------------ */

.kb-search-results {
  position: absolute; top: 12px; right: 18px; width: min(460px, calc(100% - 36px));
  max-height: min(70vh, 520px); overflow-y: auto; z-index: 30;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.kb-search-results[hidden] { display: none; }
.kb-results-head {
  display: flex; justify-content: space-between; padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft); font-size: 12px; color: var(--text-dim);
}
.kb-results-count { font-weight: 700; color: var(--accent); }
.kb-results-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.kb-result-btn {
  width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 9px; cursor: pointer; color: var(--text);
}
.kb-result-btn:hover { background: var(--surface-2); border-color: var(--line); }
.kb-result-title { font-weight: 600; flex: 1 1 190px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-result-meta { font-size: 11px; color: var(--text-mute); }
.kb-results-empty { margin: 0; padding: 14px; color: var(--text-mute); font-size: 12.5px; }

/* ------------------------------------------------------------------ */
/* Modals                                                             */
/* ------------------------------------------------------------------ */

.kb-modal {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--overlay); backdrop-filter: blur(5px);
}
.kb-modal[hidden] { display: none; }
.kb-modal-card {
  width: min(760px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden;
}
.kb-modal-card-narrow { width: min(420px, 100%); }
.kb-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
}
.kb-modal-head h2 { font-size: 15px; }
.kb-modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.kb-modal-foot {
  display: flex; align-items: center; gap: 8px; padding: 13px 18px;
  border-top: 1px solid var(--line-soft); background: var(--bg-2);
  flex-wrap: wrap;
}
.kb-spacer { flex: 1 1 auto; }
.kb-modal-foot .kb-btn { white-space: nowrap; padding: 8px 11px; }
.kb-task-position { font-size: 12px; color: var(--text-dim); white-space: nowrap; margin-right: 2px; }
.kb-modal-foot .kb-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.kb-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kb-field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.kb-field-row .kb-field { flex: 1 1 180px; }
.kb-field-flags { flex-direction: row; flex-wrap: wrap; gap: 14px; }
.kb-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.kb-field label, .kb-field-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-mute);
}
.kb-field input, .kb-field select, .kb-field textarea {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; color: var(--text); width: 100%;
}
.kb-field input:focus, .kb-field select:focus, .kb-field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--glow);
}
.kb-field textarea { resize: vertical; font-family: inherit; }

/* Card colour picker: the radio covers the swatch so pointer and keyboard
   input behave natively, and the ring shows the current choice. */
.kb-field-hint { font-size: 11.5px; color: var(--text-mute); }
.kb-color-picker { display: flex; flex-wrap: wrap; gap: 9px; }
.kb-color-option { position: relative; display: inline-flex; width: 28px; height: 28px; flex: 0 0 auto; }
.kb-color-option input {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; padding: 0;
  border: 0; background: transparent; opacity: 0; cursor: pointer;
}
.kb-color-swatch {
  width: 100%; height: 100%; border-radius: 999px; border: 2px solid var(--line-soft);
  background: var(--swatch, transparent); color: var(--swatch-ink, var(--text));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; line-height: 1; transition: transform .12s ease, box-shadow .12s ease;
}
.kb-color-default .kb-color-swatch {
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--surface-3) 6px 12px);
}
.kb-color-option:hover .kb-color-swatch { transform: scale(1.06); }
.kb-color-option input:checked + .kb-color-swatch {
  border-color: var(--text); box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 3px var(--text);
}
.kb-color-option input:checked + .kb-color-swatch::after { content: '✓'; }
.kb-color-option input:focus-visible + .kb-color-swatch { outline: 2px solid var(--accent); outline-offset: 3px; }
.kb-color-option input:disabled { cursor: not-allowed; }
.kb-color-option input:disabled + .kb-color-swatch { opacity: .45; }

.kb-subtasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.kb-subtask {
  display: flex; align-items: center; gap: 8px; background: var(--bg-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 6px 9px;
}
.kb-subtask-text { flex: 1 1 auto; font-size: 12.5px; }
.kb-subtask-done .kb-subtask-text { text-decoration: line-through; color: var(--text-mute); }
.kb-subtask-toggle, .kb-subtask-remove {
  appearance: none; border: 1px solid var(--line); background: transparent; color: var(--text-mute);
  border-radius: 6px; width: 22px; height: 22px; cursor: pointer; line-height: 1;
}
.kb-subtask-toggle[aria-pressed="true"] { color: var(--ok); border-color: var(--ok); }
.kb-subtask-remove:hover { color: var(--danger); border-color: var(--danger); }
.kb-subtasks-empty { margin: 0; color: var(--text-mute); font-size: 12px; }
.kb-subtask-add { display: flex; gap: 8px; margin-top: 8px; }
.kb-subtask-add input {
  flex: 1 1 auto; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px;
}

.kb-comments { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.kb-comments-empty { margin: 0; color: var(--text-mute); font-size: 12px; }
.kb-comment {
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.kb-comment-mine { border-color: rgba(56, 225, 208, .35); }
.kb-comment-head { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.kb-comment-head strong { font-size: 12px; }
.kb-comment-time { color: var(--text-mute); font-size: 11px; margin-left: auto; }
.kb-comment-delete {
  appearance: none; border: 0; background: transparent; color: var(--text-mute);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 3px;
}
.kb-comment-delete:hover { color: var(--danger); }
.kb-comment-text { margin: 5px 0 0; font-size: 12.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; }

.kb-members { display: flex; flex-wrap: wrap; gap: 8px; }
.kb-member {
  display: flex; align-items: center; gap: 6px; background: var(--bg-2);
  border: 1px solid var(--line-soft); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.kb-member input { width: auto; }

.kb-users-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.kb-archive-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kb-archive-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.kb-archive-row-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.kb-archive-row-text strong { font-size: 12.5px; }
.kb-archive-row-text small { font-size: 11px; color: var(--text-mute); }
.kb-archive-empty { margin: 0; padding: 18px; text-align: center; color: var(--text-mute); font-size: 12.5px; }
.kb-user-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.kb-user-row-text { display: flex; flex-direction: column; flex: 1 1 auto; line-height: 1.25; min-width: 0; }
.kb-user-row-text strong { font-size: 12.5px; }
.kb-user-row-text small { font-size: 11px; color: var(--text-mute); }
.kb-user-add { padding-top: 12px; border-top: 1px solid var(--line-soft); }
.kb-user-add-grid {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.8fr) auto;
  gap: 10px; align-items: end;
}
.kb-user-add-grid .kb-btn { height: 38px; white-space: nowrap; }
@media (max-width: 860px) {
  .kb-user-add-grid { grid-template-columns: 1fr 1fr; }
  .kb-user-add-grid .kb-btn { grid-column: 1 / -1; }
}

.kb-help-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-mute); margin-top: 6px; }
.kb-help-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kb-help-list code {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  background: rgba(56, 225, 208, .08); border: 1px solid rgba(56, 225, 208, .2);
  border-radius: 6px; padding: 3px 8px; display: inline-block;
}
.kb-help-list-commands li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.kb-help-list-commands span { font-size: 12px; color: var(--text-mute); }

/* ------------------------------------------------------------------ */
/* Agent console                                                      */
/* ------------------------------------------------------------------ */

.kb-cli-panel {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; width: min(460px, 100%);
  z-index: 180; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -22px 0 48px rgba(0, 0, 0, .35);
  transform: translateX(102%); transition: transform .24s cubic-bezier(.22, .8, .3, 1);
}
.kb-cli-panel.is-open { transform: translateX(0); }
.kb-cli-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.kb-cli-head h2 { font-size: 14px; letter-spacing: .06em; }
.kb-cli-subtitle { margin: 2px 0 0; font-size: 11.5px; color: var(--text-mute); }
.kb-cli-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.kb-cli-actions .kb-btn { padding: 5px 9px; font-size: 12px; }
.kb-cli-output {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  display: flex; flex-direction: column; gap: 4px;
}
.kb-cli-line { display: flex; gap: 9px; white-space: pre-wrap; word-break: break-word; }
.kb-cli-stamp { color: var(--text-mute); flex: 0 0 auto; }
.kb-cli-text { flex: 1 1 auto; }
.kb-cli-user .kb-cli-text { color: var(--accent); }
.kb-cli-error .kb-cli-text { color: var(--danger); }
.kb-cli-system .kb-cli-text { color: var(--text-dim); }
.kb-cli-suggest {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px;
  border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--text-mute);
}
.kb-cli-suggest[hidden] { display: none; }
.kb-cli-suggest code {
  font-family: var(--mono); color: var(--accent-2);
  background: rgba(139, 108, 255, .1); border: 1px solid rgba(139, 108, 255, .25);
  border-radius: 5px; padding: 1px 7px;
}
.kb-cli-form {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px;
  border-top: 1px solid var(--line); background: var(--bg-2);
}
.kb-cli-prompt { color: var(--accent); font-family: var(--mono); font-weight: 700; }
.kb-cli-input { flex: 1 1 auto; background: transparent; border: 0; color: var(--text); font-family: var(--mono); font-size: 12.5px; padding: 6px 0; }
.kb-cli-input:focus { outline: none; }
.kb-cli-hint { margin: 0; padding: 0 14px 12px; font-size: 11px; color: var(--text-mute); }

/* ------------------------------------------------------------------ */
/* Toasts                                                             */
/* ------------------------------------------------------------------ */

.kb-toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 250;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.kb-toast {
  pointer-events: auto; background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 12.5px; box-shadow: var(--shadow-soft);
  animation: kb-slide-in .22s ease; max-width: 340px;
}
.kb-toast-error { border-left-color: var(--danger); }
.kb-toast-success { border-left-color: var(--ok); }
.kb-toast-info { border-left-color: var(--accent-2); }
.kb-toast-out { opacity: 0; transform: translateY(6px); transition: opacity .3s ease, transform .3s ease; }
.kb-toast-action { display: flex; align-items: center; gap: 12px; }
.kb-toast-text { flex: 1 1 auto; }
.kb-toast-btn { padding: 4px 10px; font-size: 12px; white-space: nowrap; }
@keyframes kb-slide-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 767px) {
  .kb-topbar { flex-wrap: wrap; gap: 9px; padding: 9px 12px; }
  .kb-brand-text small { display: none; }
  .kb-board-picker { order: 2; }
  .kb-board-select { max-width: 130px; }
  .kb-search-wrap { order: 3; flex: 1 1 100%; max-width: none; }
  .kb-topbar-actions { order: 4; }
  .kb-user-name { display: none; }
  .kb-tabs { display: flex; }
  .kb-board { scroll-snap-type: x mandatory; padding: 12px; gap: 10px; }
  .kb-column { flex: 0 0 86vw; width: 86vw; scroll-snap-align: center; }
  .kb-search-results { top: 8px; right: 8px; left: 8px; width: auto; }
  .kb-popover { right: 8px; left: 8px; max-width: none; }
  .kb-cli-panel { width: 100%; border-left: 0; }
  .kb-toasts { right: 8px; left: 8px; bottom: 8px; }
  .kb-toast { max-width: none; }
  .kb-modal { padding: 10px; }
  .kb-field-row .kb-field { flex: 1 1 100%; }
}

@media (min-width: 768px) {
  .kb-tabs { display: none; }
}

/* Narrow desktop: shed optional chrome before the header starts to overflow. */
@media (max-width: 1460px) {
  .kb-brand-text small { display: none; }
}
@media (max-width: 1280px) {
  .kb-brand-text { display: none; }
  .kb-search-wrap { max-width: 320px; }
  .kb-board-select { max-width: 150px; }
}
@media (max-width: 1080px) {
  .kb-topbar-actions .kb-bell { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.kb-modal [hidden] { display:none !important; }
.kb-markdown { overflow-wrap:anywhere; line-height:1.6; }
.kb-markdown :first-child { margin-top:0; }.kb-markdown :last-child { margin-bottom:0; }
.kb-markdown pre { overflow:auto; padding:12px; border-radius:8px; background:var(--bg); }
.kb-markdown a { color:var(--accent,#38e1d0); }.kb-markdown table { display:block; overflow:auto; border-collapse:collapse; }.kb-markdown td,.kb-markdown th { border:1px solid var(--border); padding:6px; }
.kb-history summary { cursor:pointer; font-weight:700; padding:8px 0; }
.kb-attachment-hint,#kb-task-markdown-hint { font-size:12px; opacity:.75; }
#kb-task-attachments { list-style:none; padding:0; margin:8px 0; }
#kb-task-attachments li { display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:7px 0; border-bottom:1px solid var(--border); overflow-wrap:anywhere; }
#kb-task-attachments li span { flex:1; min-width:120px; }
.kb-attachment-upload { display:inline-flex; flex-wrap:wrap; align-items:center; gap:8px; }
#kb-task-file { max-width:100%; }
.kb-tag-suggestions { display:grid; gap:2px; max-height:180px; overflow:auto; border:1px solid var(--border); border-radius:8px; padding:4px; background:var(--surface); }
.kb-tag-suggestions button { text-align:left; color:inherit; background:transparent; border:0; border-radius:5px; padding:8px; cursor:pointer; font:inherit; }
.kb-tag-suggestions button:hover,.kb-tag-suggestions button[aria-selected=true] { background:var(--bg); }
.kb-format-toolbar { display:flex; flex-wrap:wrap; gap:5px; }
.kb-format-toolbar button { display:inline-flex; align-items:center; justify-content:center; min-width:36px; min-height:36px; padding:5px 8px; color:var(--text); background:var(--bg); border:1px solid var(--border); border-radius:6px; font:inherit; cursor:pointer; }
.kb-format-toolbar button:hover:not(:disabled),.kb-format-toolbar button:focus-visible { border-color:var(--accent,#38e1d0); }
.kb-format-toolbar button:disabled { opacity:.5; cursor:not-allowed; }
.kb-format-preview-label { display:block; margin-bottom:5px; font-size:12px; opacity:.75; }
.kb-format-preview { min-height:44px; max-height:240px; overflow:auto; padding:10px; border:1px solid var(--border); border-radius:8px; }
