/* =============================================================
 * Dev Portal — стиль SMUI Nord, JetBrains Mono.
 * Использует HSL-токены из tokens.css.
 * ============================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--font-mono); font-weight: 600; }

::selection { background: hsl(var(--primary) / 0.2); color: hsl(var(--primary)); }

/* Background — radial glow + grid */
body.app-bg {
  background:
    radial-gradient(ellipse 70% 50% at 50% -5%,
      hsl(var(--primary) / 0.07) 0%, transparent 100%),
    linear-gradient(to right,  hsl(var(--border) / 0.15) 1px, transparent 1px),
    linear-gradient(to bottom, hsl(var(--border) / 0.15) 1px, transparent 1px),
    hsl(var(--background));
  background-size: auto, 24px 24px, 24px 24px, auto;
}

.hidden { display: none !important; }

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  height: 44px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-kg {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 800;
  letter-spacing: .14em;
  text-decoration: none;
  color: hsl(var(--background));
  background: hsl(var(--foreground) / 0.65);
  padding: 8px 11px;
  flex-shrink: 0;
  transition: opacity .15s;
}
.navbar-kg:hover { opacity: .8; }

.navbar-spacer { flex: 1; }

.navbar-center { display: flex; gap: 4px; align-items: center; }

/* Theme toggle */
.theme-toggle {
  width: 30px; height: 30px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  border-color: hsl(var(--smui-border-hover));
}
.theme-toggle .ic-sun  { display: none; }
.theme-toggle .ic-moon { display: block; }
html:not(.dark) .theme-toggle .ic-sun  { display: block; }
html:not(.dark) .theme-toggle .ic-moon { display: none; }

/* Nav tabs */
.btn-nav {
  display: inline-flex; gap: 6px; align-items: center;
  height: 30px; padding: 0 12px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-nav:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  border-color: hsl(var(--smui-border-hover));
}
.btn-nav.active {
  background: hsl(var(--primary) / 0.12);
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}

/* Auth group (username + logout) */
.auth-group {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  height: 30px; padding: 2px 10px;
  cursor: pointer;
  font-family: var(--font-mono);
  line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.auth-group:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--smui-border-hover));
}
.auth-username {
  font-size: 10px; font-weight: 600;
  color: hsl(var(--foreground));
  letter-spacing: .03em;
}
.auth-logout-label {
  font-size: 8px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  letter-spacing: .08em;
  text-transform: uppercase;
}
.auth-group:hover .auth-logout-label { color: hsl(var(--foreground)); }

/* CPU widget */
.widget {
  font-family: var(--font-mono);
  font-size: 10px;
  color: hsl(var(--muted-foreground));
  padding: 0 8px;
  height: 30px;
  display: inline-flex; align-items: center;
  border: 1px solid hsl(var(--border));
  white-space: nowrap;
}

/* ── Dashboard layout ─────────────────────────────────────── */
.dashboard {
  padding: 24px 32px;
  flex: 1;
  width: 100%;
  overflow-y: auto;
}

.section-block { margin-bottom: 36px; max-width: 972px; margin-left: auto; margin-right: auto; }
.section-block:last-child { margin-bottom: 0; }

.section-head {
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: 8px 16px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid hsl(var(--border));
}
.section-head-left { display: flex; align-items: baseline; gap: 14px; }
.section-label {
  font-family: var(--font-mono);
  font-size: 14px; font-weight: 600;
  letter-spacing: .02em;
  color: hsl(var(--foreground));
  text-transform: uppercase;
}

.dashboard-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  height: 30px; padding: 0 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: .03em;
  cursor: pointer;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--muted-foreground));
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--smui-border-hover));
}
.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.btn-primary:hover {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  opacity: .85;
  border-color: hsl(var(--primary));
}
.btn-ghost { background: transparent; }
.btn-danger {
  border-color: hsl(var(--destructive) / 0.5);
  color: hsl(var(--destructive));
}
.btn-danger:hover {
  background: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive));
  color: hsl(var(--destructive));
}
.btn-sm { height: 26px; padding: 0 10px; font-size: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Login overlay ────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
}
.login-overlay.hidden { display: none; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: hsl(var(--background) / 0.75);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 400; padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  padding: 0;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid hsl(var(--border));
}
.modal-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: hsl(var(--popover-foreground));
}
.modal-close {
  width: 24px; height: 24px; border: none;
  background: transparent; color: hsl(var(--muted-foreground));
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.modal-body { padding: 14px 18px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid hsl(var(--border));
}

/* ── Form elements ────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  font-size: 11px; font-family: var(--font-mono);
  color: hsl(var(--muted-foreground));
  text-transform: uppercase; letter-spacing: 1.5px;
}
.form-input {
  height: 32px; padding: 0 10px;
  border: 1px solid hsl(var(--input));
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  font-size: 13px; font-family: var(--font-mono);
  width: 100%; outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: hsl(var(--primary)); }
.form-input::placeholder { color: hsl(var(--muted-foreground)); opacity: .6; }
.form-select {
  height: 32px; padding: 0 10px;
  border: 1px solid hsl(var(--input));
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  font-size: 12px; font-family: var(--font-mono);
  width: 100%; outline: none;
  transition: border-color .15s;
  cursor: pointer;
}
.form-select:focus { border-color: hsl(var(--primary)); }
.form-error {
  font-size: 11px;
  color: hsl(var(--destructive));
  font-family: var(--font-mono);
  padding: 6px 10px;
  border: 1px solid hsl(var(--destructive) / 0.4);
  background: hsl(var(--destructive) / 0.08);
  margin-bottom: 12px;
}
.form-error.hidden { display: none; }

/* ── Projects table ──────────────────────────────────────── */
.projects-table-wrap { overflow-x: auto; border: 1px solid hsl(var(--border)); background: hsl(var(--card)); }
.projects-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 11px; }
.projects-table thead th {
  text-align: left;
  font-weight: 500; font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}
.projects-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  vertical-align: middle;
}
.projects-table tbody tr:last-child td { border-bottom: none; }
.projects-table tbody tr:hover { background: hsl(var(--background)); }
.projects-table .td-name { font-weight: 600; }
.projects-table .td-actions { text-align: right; white-space: nowrap; }
.projects-table .td-actions .actions { display: inline-flex; gap: 6px; justify-content: flex-end; align-items: center; }
.projects-table .th-actions { text-align: right; }

/* Status pill */
.pill {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
/* Claude project chat button */
.btn-claude {
  border-color: hsl(var(--primary) / 0.5);
  color: hsl(var(--primary));
}
.btn-claude:hover {
  background: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}

.pill-new    { color: hsl(var(--muted-foreground)); }
.pill-work   { color: hsl(var(--smui-yellow));  border-color: hsl(var(--smui-yellow) / 0.6); }
.pill-prod   { color: hsl(var(--smui-green));   border-color: hsl(var(--smui-green) / 0.6); }
.pill-arch   { color: hsl(var(--muted-foreground)); opacity: 0.6; }

/* Status select in table */
.status-select {
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 6px; height: 24px;
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  cursor: pointer; outline: none;
}
.status-select:focus { border-color: hsl(var(--primary)); }

/* Create project inline form */
.create-form-row {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--primary) / 0.4);
  margin-bottom: 12px;
}
.create-form-row .form-group { flex: 1; margin-bottom: 0; }

/* ── Explorer panel ──────────────────────────────────────── */
.explorer-wrap {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  margin-bottom: 16px;
}
.explorer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid hsl(var(--border));
}
.explorer-title {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: hsl(var(--foreground)); letter-spacing: .03em;
  text-transform: uppercase;
}
.explorer-body { display: flex; min-height: 0; }
.explorer-tree {
  width: 260px; flex-shrink: 0;
  border-right: 1px solid hsl(var(--border));
  padding: 8px 0;
  font-size: 11px; font-family: var(--font-mono);
  overflow-y: auto; max-height: 380px;
}
.explorer-tree-item {
  display: flex; gap: 4px; align-items: center;
  padding: 3px 12px;
  cursor: pointer;
  color: hsl(var(--foreground));
  user-select: none;
}
.explorer-tree-item:hover { background: hsl(var(--background)); }
.explorer-tree-file { padding-left: 24px; color: hsl(var(--muted-foreground)); }
.explorer-tree-file.active { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); }
.explorer-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.explorer-view-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 10px; font-family: var(--font-mono);
  color: hsl(var(--muted-foreground));
}
.explorer-view-pre {
  flex: 1; margin: 0; padding: 12px;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.55;
  color: hsl(var(--foreground));
  white-space: pre;
  background: hsl(var(--background));
  overflow: auto; max-height: 340px;
}
.tree-children { padding-left: 14px; }
.tree-children.hidden { display: none; }

/* ── Chat layout ─────────────────────────────────────────── */
.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 44px - 48px - 32px);
  min-height: 400px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
}
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 0;
}
.chat-input-row {
  display: flex; gap: 6px; align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid hsl(var(--border));
  flex-shrink: 0;
}
.chat-textarea {
  flex: 1; min-height: 32px; max-height: 120px;
  padding: 7px 10px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  font-family: var(--font-mono); font-size: 11px;
  resize: none; outline: none;
}
.chat-textarea:focus { border-color: hsl(var(--primary)); }
.chat-send {
  width: 32px; height: 32px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: var(--font-mono); font-size: 14px;
}
.chat-send:hover { opacity: .88; }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* Chat bubbles */
.chat-bubble {
  padding: 8px 10px;
  border: 1px solid hsl(var(--border));
  font-size: 11px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-width: 92%;
  font-family: var(--font-mono);
}
.chat-bubble-user {
  align-self: flex-end;
  background: hsl(var(--primary) / 0.12);
  border-color: hsl(var(--primary) / 0.3);
  color: hsl(var(--foreground));
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}
.chat-bubble-thinking {
  align-self: flex-start;
  font-style: italic; color: hsl(var(--muted-foreground));
  border-color: hsl(var(--border));
}
.chat-bubble-error {
  align-self: stretch;
  background: hsl(0 70% 50% / 0.12);
  border-color: hsl(0 70% 50% / 0.4);
  color: hsl(0 70% 60%);
}
.chat-bubble-system {
  align-self: center;
  background: transparent; border: none;
  font-style: italic; color: hsl(var(--muted-foreground));
  font-size: 10.5px;
}

/* ── Stats ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  padding: 16px;
}
.stat-label {
  font-size: 10px; font-family: var(--font-mono);
  color: hsl(var(--muted-foreground));
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 28px; font-weight: 700;
  font-family: var(--font-mono);
  color: hsl(var(--primary));
  line-height: 1;
}
.stat-sub {
  font-size: 10px; color: hsl(var(--muted-foreground));
  font-family: var(--font-mono);
  margin-top: 4px;
}

.stats-table-wrap { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 11px; }
.stats-table thead th {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.stats-table tbody td { padding: 8px 12px; border-bottom: 1px solid hsl(var(--border)); color: hsl(var(--foreground)); }
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table tbody tr:hover td { background: hsl(var(--accent)); }

/* ── Settings ────────────────────────────────────────────── */
.settings-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  margin-bottom: 16px;
}
.settings-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: hsl(var(--foreground));
}
.settings-card-body { padding: 16px; }

.users-list {
  display: flex; flex-direction: column;
  border: 1px solid hsl(var(--border));
}
.user-row {
  display: flex; align-items: center;
  padding: 8px 12px;
  background: hsl(var(--card)); gap: 8px;
  border-bottom: 1px solid hsl(var(--border));
}
.user-row:last-child { border-bottom: none; }
.user-row-name { flex: 1; font-size: 12px; font-family: var(--font-mono); color: hsl(var(--foreground)); }
.user-row-role {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 9px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
.user-row-role.role-admin {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.08);
}
.user-row-empty {
  padding: 20px; text-align: center;
  font-size: 11px; font-family: var(--font-mono);
  color: hsl(var(--muted-foreground));
}

/* ── Floating project chat window ───────────────────────── */
#floating-project-chat {
  position: fixed;
  width: 380px;
  height: 480px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 8px 32px hsl(0 0% 0% / 0.25), 0 2px 8px hsl(0 0% 0% / 0.15);
  display: flex;
  flex-direction: column;
  z-index: 300;
  overflow: hidden;
}

.pc-float-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 14px;
  height: 38px;
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
}
.pc-float-header:active { cursor: grabbing; }

.pc-float-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px;
  color: hsl(var(--foreground));
  min-width: 0;
}
.pc-float-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: hsl(var(--primary));
  flex-shrink: 0;
}

.pc-float-btn {
  width: 22px; height: 22px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-family: var(--font-mono); font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.pc-float-btn:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
  border-color: hsl(var(--smui-border-hover));
}

.pc-float-messages {
  flex: 1; overflow-y: auto;
  padding: 10px;
  display: flex; flex-direction: column; gap: 7px;
  min-height: 0;
  background: hsl(var(--background));
}

.pc-float-input-row {
  display: flex; gap: 6px; align-items: flex-end;
  padding: 8px 10px;
  border-top: 1px solid hsl(var(--border));
  flex-shrink: 0;
  background: hsl(var(--card));
}

@media (max-width: 480px) {
  #floating-project-chat { width: calc(100vw - 16px); right: 8px !important; }
}

/* ── Utility ─────────────────────────────────────────────── */
.muted { color: hsl(var(--muted-foreground)); font-size: 11px; font-family: var(--font-mono); }
.empty {
  font-family: var(--font-mono); font-size: 11px;
  color: hsl(var(--muted-foreground));
  padding: 20px; text-align: center;
  border: 1px dashed hsl(var(--border));
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .navbar { padding: 0 10px; gap: 4px; }
  .dashboard { padding: 16px 12px 32px; }
  .btn-nav .btn-nav-text { display: none; }
  .btn-nav { width: 30px; padding: 0; justify-content: center; }
  .widget { display: none; }
  .explorer-tree { width: 100%; border-right: none; border-bottom: 1px solid hsl(var(--border)); }
  .explorer-body { flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════
   PROJECTS — новый UI
   ══════════════════════════════════════════════════════════ */

/* Верхняя панель */
.proj-section { padding: 0 !important; overflow: visible; }
.proj-top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid hsl(var(--border));
}
.proj-top-left { display: flex; align-items: center; gap: 10px; }
.proj-count { font-family: var(--font-mono); font-size: 11px; }
.proj-top-actions { display: flex; gap: 6px; }
.muted-sm { font-family: var(--font-mono); font-size: 11px; color: hsl(var(--muted-foreground)); }

/* Inline форма создания */
.create-inline-form {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 20px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--accent) / .3);
}
.create-inline-form .form-input { height: 32px; font-size: 12px; padding: 0 10px; }

/* Таблица проектов */
.projects-table-wrap { overflow-x: auto; }
.projects-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 11px; }
.projects-table th {
  padding: 8px 12px; text-align: left;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.projects-table td {
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border) / .5);
  vertical-align: middle;
}
.projects-table tr:hover td { background: hsl(var(--accent) / .4); }
.proj-type-badge {
  font-size: 9px; font-weight: 700; letter-spacing: .1em;
  padding: 2px 6px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
.proj-name-cell { font-weight: 600; color: hsl(var(--foreground)); }
.th-actions { text-align: right; }
.td-actions { white-space: nowrap; }

/* Кнопки действий в строке */
.proj-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.pact-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 26px; min-width: 26px; padding: 0 6px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  transition: background .12s, color .12s, border-color .12s;
}
.pact-btn:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); border-color: hsl(var(--primary) / .5); }
.pact-delete { border-color: hsl(var(--destructive) / .4); }
.pact-delete:hover { background: hsl(var(--destructive) / .15); color: hsl(var(--destructive)); border-color: hsl(var(--destructive)); }
.pact-claude { background: hsl(var(--primary) / .1); border-color: hsl(var(--primary) / .4); color: hsl(var(--primary)); }
.pact-claude:hover { background: hsl(var(--primary) / .2); border-color: hsl(var(--primary)); }

/* Пустое состояние */
.empty-state {
  padding: 48px 20px; text-align: center;
  font-family: var(--font-mono); font-size: 12px; color: hsl(var(--muted-foreground));
}
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: .3; }

/* Кнопки */
.btn-accent { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: #fff !important; }
.btn-accent:hover { opacity: .88; }
.btn-outline { background: transparent; }

/* ═══════════════════════════════════════════════════════════
   ФАЙЛОВЫЙ МЕНЕДЖЕР (modal overlay)
   ══════════════════════════════════════════════════════════ */
.expl-modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.expl-modal.hidden { display: none !important; }
.expl-panel {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  width: 100%; max-width: 900px; height: 75vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.expl-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  flex-shrink: 0;
}
.expl-breadcrumbs { display: flex; align-items: center; gap: 0; font-family: var(--font-mono); font-size: 11px; flex-wrap: wrap; }
.bc-item { padding: 2px 5px; cursor: pointer; color: hsl(var(--muted-foreground)); }
.bc-item:hover { color: hsl(var(--foreground)); }
.bc-active { color: hsl(var(--foreground)); cursor: default; }
.bc-root { color: hsl(var(--primary)); }
.bc-sep { color: hsl(var(--border)); padding: 0 2px; }
.expl-body { display: flex; flex: 1; overflow: hidden; }
.expl-sidebar {
  width: 240px; flex-shrink: 0;
  border-right: 1px solid hsl(var(--border));
  overflow-y: auto;
  background: hsl(var(--background));
}
.expl-content {
  flex: 1; overflow: auto;
  background: hsl(var(--background));
  position: relative;
}
.expl-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px;
  color: hsl(var(--muted-foreground));
}
.expl-entry {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  font-family: var(--font-mono); font-size: 11px;
  border-bottom: 1px solid hsl(var(--border) / .3);
  cursor: default;
  position: relative;
}
.expl-entry:hover { background: hsl(var(--accent)); }
.expl-entry:hover .expl-entry-actions { opacity: 1; }
.expl-entry-name { flex: 1; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expl-dir .expl-entry-name { color: hsl(var(--primary) / .85); font-weight: 600; }
.expl-file .expl-entry-name:hover { text-decoration: underline; color: hsl(var(--primary)); }
.expl-icon { font-size: 9px; width: 14px; flex-shrink: 0; color: hsl(var(--muted-foreground)); }
.expl-file-icon {
  font-size: 8px; font-weight: 700; letter-spacing: -.5px;
  color: hsl(var(--muted-foreground)); background: hsl(var(--accent));
  padding: 0 2px; border: 1px solid hsl(var(--border));
  min-width: 22px; text-align: center;
}
.expl-entry-size { font-size: 9px; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.expl-entry-actions { opacity: 0; transition: opacity .1s; margin-left: 4px; }
.expl-del-btn { cursor: pointer; font-size: 10px; opacity: .7; }
.expl-del-btn:hover { opacity: 1; color: hsl(var(--destructive)); }
.expl-children { padding-left: 14px; border-left: 1px solid hsl(var(--border) / .4); margin-left: 12px; }
.expl-children.hidden { display: none; }

/* Просмотр файла */
.expl-file-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  flex-shrink: 0;
}
.expl-file-title { font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.expl-code {
  margin: 0; padding: 14px;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.6;
  color: hsl(var(--foreground));
  white-space: pre; overflow: auto;
  tab-size: 2;
}
.expl-img-wrap { padding: 20px; display: flex; justify-content: center; }

/* ═══════════════════════════════════════════════════════════
   МОДАЛЬНОЕ ОКНО ШАБЛОНОВ
   ══════════════════════════════════════════════════════════ */
.tmpl-modal {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.tmpl-modal.hidden { display: none !important; }
.tmpl-panel {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  width: 100%; max-width: 640px;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.45);
}
.tmpl-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}
.tmpl-body { padding: 20px; }
.tmpl-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: hsl(var(--muted-foreground)); margin-bottom: 12px;
}
.tmpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.tmpl-card {
  padding: 14px;
  border: 1px solid hsl(var(--border));
  cursor: pointer;
  transition: border-color .12s, background .12s;
  background: hsl(var(--background));
}
.tmpl-card:hover { border-color: hsl(var(--primary) / .5); background: hsl(var(--accent)); }
.tmpl-card.selected { border-color: hsl(var(--primary)); background: hsl(var(--primary) / .08); }
.tmpl-card-name { font-family: var(--font-mono); font-size: 11px; font-weight: 700; margin-bottom: 6px; }
.tmpl-card-desc { font-family: var(--font-mono); font-size: 10px; color: hsl(var(--muted-foreground)); line-height: 1.4; margin-bottom: 8px; }
.tmpl-card-dir { font-size: 10px; opacity: .5; }
.tmpl-name-row { margin-top: 4px; }
.tmpl-name-row .form-input { width: 100%; }
.tmpl-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}

/* ── KB / Course / Notes styles (from vibe-portal) ── */
.course-head { max-width: 760px; margin: 0 auto 28px; }
.course-badge {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin-bottom: 14px;
}
.course-h1 {
  font-family: var(--font-mono);
  font-size: 30px; font-weight: 700;
  letter-spacing: -.01em;
  color: hsl(var(--foreground));
  margin-bottom: 14px;
}
.course-h1 em {
  font-style: normal;
  color: hsl(var(--primary));
}
.course-lead {
  font-size: 14px; line-height: 1.6;
  color: hsl(var(--muted-foreground));
  max-width: 64ch;
}
.course-lead a { color: hsl(var(--primary)); text-decoration: underline; text-underline-offset: 2px; }
.course-modules {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 760px; margin: 0 auto;
}
.course-module {
  display: grid; grid-template-columns: 60px 1fr auto;
  align-items: stretch;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  text-decoration: none;
  transition: border-color .15s;
}
.course-module:hover { border-color: hsl(var(--primary)); }
.course-module--recommended {
  border-color: hsl(var(--smui-green) / 0.5);
}
.course-module--recommended:hover { border-color: hsl(var(--smui-green)); }
.course-module--recommended .course-module-no {
  background: hsl(var(--smui-green) / 0.15);
  color: hsl(var(--smui-green));
  border-right-color: hsl(var(--smui-green) / 0.3);
}
.course-module--recommended .course-module-cta {
  color: hsl(var(--smui-green));
}
.course-module-no {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  letter-spacing: .04em;
  border-right: 1px solid hsl(var(--border));
}
.course-module-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.course-module-title {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  color: hsl(var(--foreground));
}
.course-module-desc {
  font-size: 12px; line-height: 1.5;
  color: hsl(var(--muted-foreground));
}
.course-module-cta {
  display: flex; align-items: center;
  padding: 0 18px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .04em;
  color: hsl(var(--primary));
  border-left: 1px solid hsl(var(--border));
}

/* ── Skills: диаграмма уровней установки ───────────────── */
.skills-scope-diagram {
  display: grid;
  grid-template-columns: 1fr 48px 1fr;
  gap: 0;
  align-items: center;
  max-width: 720px;
  margin: 12px 0 0;
}
.skills-scope-card {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--smui-surface-1));
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.skills-scope-global { border-color: hsl(var(--primary) / 0.4); }
.skills-scope-project { border-color: hsl(var(--smui-green) / 0.5); }
.skills-scope-badge {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .08em; color: hsl(var(--muted-foreground));
}
.skills-scope-path {
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  color: hsl(var(--foreground));
}
.skills-scope-tree pre {
  margin: 0; font-size: 11px; line-height: 1.6;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--smui-surface-0)); padding: 10px 12px;
  border: 1px solid hsl(var(--border));
  overflow-x: auto;
}
.skills-scope-props {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 3px;
}
.skills-scope-props li {
  font-size: 11px; color: hsl(var(--muted-foreground)); line-height: 1.4;
}
.skills-scope-props li strong { color: hsl(var(--foreground)); }
.skills-scope-note {
  font-size: 11px; color: hsl(var(--muted-foreground));
  border-top: 1px solid hsl(var(--border)); padding-top: 8px;
  font-style: italic;
}
.skills-scope-note--highlight {
  color: hsl(var(--smui-green));
  border-top-color: hsl(var(--smui-green) / 0.3);
}
.skills-scope-arrow {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 0 4px;
}
.skills-scope-arrow-line {
  width: 100%; height: 1px; background: hsl(var(--border));
  position: relative;
}
.skills-scope-arrow-line::after {
  content: '→'; position: absolute; right: -6px; top: -9px;
  font-size: 14px; color: hsl(var(--muted-foreground));
}
.skills-scope-arrow-label {
  font-size: 9px; font-family: var(--font-mono);
  color: hsl(var(--muted-foreground)); text-align: center;
  line-height: 1.4; letter-spacing: .03em; text-transform: uppercase;
}
@media (max-width: 640px) {
  .skills-scope-diagram {
    grid-template-columns: 1fr;
  }
  .skills-scope-arrow { flex-direction: row; padding: 8px 0; }
  .skills-scope-arrow-line { width: 40px; }
  .skills-scope-arrow-line::after { content: '↓'; right: auto; left: 50%; top: -9px; }
}

/* ── Skills: команда vs скилл vs агент ─────────────────── */
/* Диаграмма потока */
.sca-flow {
  display: grid;
  grid-template-columns: 52px 1fr 52px 1fr;
  gap: 6px 0;
  align-items: center;
  max-width: 680px;
  margin: 0 0 20px;
  background: hsl(var(--smui-surface-0));
  border: 1px solid hsl(var(--border));
  padding: 14px 16px;
}
.sca-flow-actor {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.sca-flow-actor-icon { font-size: 20px; line-height: 1; }
.sca-flow-actor-label {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  color: hsl(var(--muted-foreground)); letter-spacing: .06em; text-transform: uppercase;
}
.sca-flow-msg {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  font-size: 11px; font-family: var(--font-mono);
  color: hsl(var(--muted-foreground));
}
.sca-flow-msg code { font-size: 11px; }
.sca-flow-msg-arrow { opacity: .4; white-space: nowrap; }
.sca-flow-msg--cmd   { border-left: 2px solid hsl(var(--primary) / .5); }
.sca-flow-msg--skill { border-left: 2px solid hsl(var(--smui-green) / .5); }
.sca-flow-msg--agent { border-left: 2px solid hsl(39 80% 55% / .5); }
.sca-flow-result {
  grid-column: 4;
  font-size: 11px; line-height: 1.5;
  color: hsl(var(--muted-foreground));
  padding: 4px 8px;
  border-left: 1px dashed hsl(var(--border));
}
.sca-flow-result em { font-style: normal; color: hsl(var(--foreground)); }
.sca-flow-tag {
  display: inline-block;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  letter-spacing: .08em; padding: 1px 5px;
  margin-right: 6px; vertical-align: middle;
}
.sca-flow-result--cmd   .sca-flow-tag { background: hsl(var(--primary) / .15);   color: hsl(var(--primary)); }
.sca-flow-result--skill .sca-flow-tag { background: hsl(var(--smui-green) / .15); color: hsl(var(--smui-green)); }
.sca-flow-result--agent .sca-flow-tag { background: hsl(39 80% 55% / .15);        color: hsl(39 80% 60%); }

/* Три карточки */
.sca-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-width: 760px; margin: 0;
}
.sca-card {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--smui-surface-1));
  padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.sca-card--cmd   { border-top: 2px solid hsl(var(--primary)); }
.sca-card--skill { border-top: 2px solid hsl(var(--smui-green)); }
.sca-card--agent { border-top: 2px solid hsl(39 80% 55%); }
.sca-card-header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.sca-card-icon { font-size: 16px; }
.sca-card-name {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .08em; color: hsl(var(--foreground));
}
.sca-card-path {
  font-size: 10px; color: hsl(var(--muted-foreground));
  background: hsl(var(--smui-surface-0)); padding: 1px 5px;
  border: 1px solid hsl(var(--border));
}
.sca-card-who {
  font-size: 11px; color: hsl(var(--foreground));
  background: hsl(var(--smui-surface-0)); padding: 6px 8px;
  border-left: 2px solid hsl(var(--border));
}
.sca-card--cmd   .sca-card-who { border-color: hsl(var(--primary)); }
.sca-card--skill .sca-card-who { border-color: hsl(var(--smui-green)); }
.sca-card--agent .sca-card-who { border-color: hsl(39 80% 55%); }
.sca-card-who code { font-size: 10px; }
.sca-card-what {
  font-size: 11px; line-height: 1.6; color: hsl(var(--muted-foreground));
}
.sca-card-when {
  font-size: 10px; line-height: 1.5; color: hsl(var(--muted-foreground));
  border-top: 1px solid hsl(var(--border)); padding-top: 7px;
  font-style: italic;
}
@media (max-width: 640px) {
  .sca-cards { grid-template-columns: 1fr; }
  .sca-flow  { grid-template-columns: 44px 1fr 44px; }
  .sca-flow-result { grid-column: 1 / -1; border-left: none; border-top: 1px dashed hsl(var(--border)); }
}

/* ── MATERIALS view: sub-tabs + якорные чипы + page-* ──── */
.materials-subnav {
  display: flex; gap: 6px; flex-wrap: wrap;
  max-width: 972px; margin: 0 auto 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid hsl(var(--border));
}
.materials-tab {
  display: inline-flex; gap: 6px; align-items: center;
  height: 30px; padding: 0 12px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
}
.materials-tab:hover { color: hsl(var(--foreground)); border-color: hsl(var(--smui-border-hover)); }
.materials-tab.active {
  background: hsl(var(--primary) / 0.12);
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}
.materials-tab-icon { font-size: 11px; }

.materials-page {
  max-width: 760px; margin: 0 auto;
}
.materials-page.hidden { display: none; }
.page-meta {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin-bottom: 12px;
}
.page-h1 {
  font-family: var(--font-mono);
  font-size: 32px; font-weight: 700;
  letter-spacing: -.01em;
  color: hsl(var(--foreground));
  margin-bottom: 14px;
}
.page-h1 em { font-style: normal; color: hsl(var(--primary)); }
.page-lead {
  font-size: 14px; line-height: 1.6;
  color: hsl(var(--muted-foreground));
  margin-bottom: 24px;
  max-width: 64ch;
}

.anchor-chips {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 32px;
}
.anchor-chip {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 4px 11px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .04em;
  text-decoration: none;
  transition: color .15s, border-color .15s;
}
.anchor-chip::before {
  content: '●'; font-size: 7px;
  color: hsl(var(--primary)); opacity: .7;
}
.anchor-chip:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--primary) / 0.45);
}

.page-sect {
  background: hsl(var(--card));
  border-left: 3px solid hsl(var(--primary));
  border-top: 1px solid hsl(var(--border));
  border-right: 1px solid hsl(var(--border));
  border-bottom: 1px solid hsl(var(--border));
  padding: 18px 22px;
  margin-bottom: 14px;
  scroll-margin-top: 56px;
}
.page-sect-no {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: hsl(var(--foreground));
  margin-bottom: 8px;
}
.page-sect p, .page-list li {
  font-size: 13px; line-height: 1.6;
  color: hsl(var(--foreground));
}
.page-sect p { margin-bottom: 8px; }
.page-list { padding-left: 22px; }
.page-list li { margin: 4px 0; }
.page-list li::marker { color: hsl(var(--primary)); }
.page-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-mono); font-size: 12px;
}
.page-table thead th {
  text-align: left;
  font-weight: 600; font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  padding: 7px 12px;
  border-bottom: 1px solid hsl(var(--border));
}
.page-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  vertical-align: top;
}
.page-table tbody tr:last-child td { border-bottom: none; }
.page-table td:first-child { white-space: nowrap; width: 1%; }

.page-faq {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  margin-bottom: 8px;
}
.page-faq summary {
  padding: 11px 16px;
  cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: hsl(var(--foreground));
  list-style: none;
}
.page-faq summary::-webkit-details-marker { display: none; }
.page-faq summary::before {
  content: '+'; margin-right: 10px; color: hsl(var(--primary)); font-weight: 700;
}
.page-faq[open] summary::before { content: '−'; }
.page-faq p {
  padding: 0 16px 14px;
  font-size: 12.5px; line-height: 1.6;
  color: hsl(var(--muted-foreground));
}

@media (max-width: 800px) {
  .vscode-hero { grid-template-columns: 1fr; gap: 12px; }
}

/* ── COURSE: двухколоночный layout ─────────────────────── */
.course-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - 44px - 48px);
  max-width: 1200px;
  margin: 0 auto;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  overflow: hidden;
}
.course-side {
  border-right: 1px solid hsl(var(--border));
  overflow-y: auto;
  background: hsl(var(--card));
}
.course-side-head {
  padding: 16px 18px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex; flex-direction: column; gap: 2px;
}
.course-side-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  letter-spacing: .04em; color: hsl(var(--foreground));
}
.course-side-sub {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.course-tree { display: flex; flex-direction: column; padding: 6px 0; }
.course-tree-intro {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 18px;
  background: transparent;
  border: none; border-left: 2px solid transparent;
  cursor: pointer; text-align: left;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: hsl(var(--foreground));
}
.course-tree-intro:hover { background: hsl(var(--accent)); }
.course-tree-intro.active {
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  border-left-color: hsl(var(--primary));
}
.course-tree-intro-no { color: hsl(var(--primary)); font-size: 12px; }

.course-tree-module {
  border-top: 1px solid hsl(var(--border));
}
.course-tree-mod-head {
  display: flex; gap: 8px; align-items: baseline;
  width: 100%; padding: 10px 18px;
  background: transparent; border: none;
  cursor: pointer; text-align: left;
  font-family: var(--font-mono);
  color: hsl(var(--foreground));
}
.course-tree-mod-head:hover { background: hsl(var(--accent)); }
.course-tree-caret {
  color: hsl(var(--muted-foreground));
  font-size: 9px; flex-shrink: 0;
  transition: transform .15s;
}
.course-tree-module.is-open .course-tree-caret { transform: rotate(90deg); }
.course-tree-mod-no {
  font-size: 10px; font-weight: 700;
  letter-spacing: .08em;
  color: hsl(var(--primary));
  flex-shrink: 0;
}
.course-tree-mod-title {
  font-size: 11px; font-weight: 600;
  line-height: 1.35;
}
.course-tree-mod-body { display: none; padding-bottom: 6px; }
.course-tree-module.is-open .course-tree-mod-body { display: block; }
.course-tree-lesson, .course-tree-card {
  display: flex; gap: 10px; align-items: baseline;
  width: 100%; padding: 6px 18px 6px 36px;
  background: transparent;
  border: none; border-left: 2px solid transparent;
  cursor: pointer; text-align: left;
  font-family: var(--font-mono); font-size: 10.5px;
  color: hsl(var(--muted-foreground));
  line-height: 1.4;
  transition: background .1s, color .1s, border-color .1s;
}
.course-tree-lesson:hover, .course-tree-card:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}
.course-tree-lesson.active, .course-tree-card.active {
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  border-left-color: hsl(var(--primary));
}
.course-tree-lesson-no {
  width: 14px; flex-shrink: 0;
  text-align: right;
  font-weight: 700;
  color: hsl(var(--muted-foreground));
}
.course-tree-lesson.active .course-tree-lesson-no { color: hsl(var(--primary)); }
.course-tree-card { font-weight: 600; }
.course-tree-card-icon { font-size: 11px; }
.course-tree-card-materials .course-tree-card-icon { filter: hue-rotate(10deg); }

.course-content {
  overflow-y: auto;
  padding: 32px 40px;
}
.course-placeholder {
  margin-top: 24px;
  padding: 36px 24px;
  background: hsl(var(--background));
  border: 1px dashed hsl(var(--border));
  text-align: center;
}
.course-placeholder-icon { font-size: 32px; margin-bottom: 10px; }
.course-placeholder-title {
  font-family: var(--font-mono); font-size: 13px; font-weight: 700;
  letter-spacing: .04em; color: hsl(var(--foreground));
  margin-bottom: 6px;
}
.course-placeholder-desc {
  font-size: 12px; line-height: 1.55;
  color: hsl(var(--muted-foreground));
  max-width: 56ch; margin: 0 auto;
}
.course-nav {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border));
}
.course-nav-prev, .course-nav-next {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-family: var(--font-mono); font-size: 10.5px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, color .15s;
}
.course-nav-next { text-align: right; }
.course-nav-prev:hover, .course-nav-next:hover {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}

.course-intro-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.course-intro-card {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  padding: 14px 16px;
}
.course-intro-card-no {
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  letter-spacing: .06em; color: hsl(var(--primary));
}
.course-intro-card-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  line-height: 1.45;
  color: hsl(var(--foreground));
  margin-top: 6px;
}
.course-intro-card-meta {
  font-size: 10px; color: hsl(var(--muted-foreground));
  margin-top: 6px;
}

@media (max-width: 800px) {
  .course-layout { grid-template-columns: 1fr; height: auto; }
  .course-side { max-height: 40vh; }
}

/* ── LINKS: big tiles + readable link color ───────────── */
.link-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.link-tiles-primary { margin-bottom: 28px; }
.link-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 20px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.link-tile:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.06);
}
.link-tile-label {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: hsl(var(--primary));
}
.link-tile-title {
  font-family: var(--font-mono); font-size: 16px; font-weight: 700;
  letter-spacing: -.01em;
  color: hsl(var(--foreground));
  margin-top: 4px;
}
.link-tile-desc {
  font-size: 12px; line-height: 1.5;
  color: hsl(var(--muted-foreground));
  margin-top: 6px;
}
.link-tile-alt .link-tile-label { color: hsl(var(--muted-foreground)); }

.page-h2 {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: hsl(var(--foreground));
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid hsl(var(--border));
}

/* ── Читаемый цвет ссылок в текстовых страницах ───────── */
.page-list a,
.page-lead a,
.course-placeholder-desc a {
  color: hsl(190 80% 60%);  /* мягкий cyan, на тёмном фоне читается лучше чем primary */
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.page-list a:hover,
.page-lead a:hover,
.course-placeholder-desc a:hover {
  color: hsl(190 90% 70%);
  text-decoration-thickness: 2px;
}
html:not(.dark) .page-list a,
html:not(.dark) .page-lead a,
html:not(.dark) .course-placeholder-desc a {
  color: hsl(210 80% 45%);
}
html:not(.dark) .page-list a:hover,
html:not(.dark) .page-lead a:hover,
html:not(.dark) .course-placeholder-desc a:hover {
  color: hsl(210 90% 35%);
}

/* ── Course intro card → кликабельная ──────────────────── */
.course-intro-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
.course-intro-card:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.06);
}
.course-intro-card-cta {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: .04em;
  color: hsl(var(--primary));
}

/* ── Module overview: 2 big action buttons + lessons list ── */
.module-actions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px; margin-bottom: 8px;
}
.module-action-btn {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  cursor: pointer; text-align: left;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
.module-action-btn:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.06);
}
.module-action-icon {
  font-size: 18px; line-height: 1; flex-shrink: 0;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}
.module-action-body {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.module-action-label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: hsl(var(--foreground));
}
.module-action-sub {
  font-size: 11.5px; line-height: 1.4;
  color: hsl(var(--muted-foreground));
}
.module-action-hw .module-action-icon { background: hsl(var(--smui-green) / 0.15); color: hsl(var(--smui-green)); }
.module-action-mk .module-action-icon { background: hsl(40 80% 55% / 0.15); color: hsl(40 80% 55%); }
.module-action-bonus .module-action-icon { background: hsl(280 60% 65% / 0.15); color: hsl(280 60% 65%); }

.module-lessons {
  display: flex; flex-direction: column; gap: 4px;
}
.module-lesson {
  display: grid; grid-template-columns: 28px 1fr auto;
  align-items: baseline; gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  cursor: pointer; text-align: left;
  font-family: var(--font-mono);
  transition: border-color .15s, background .15s, color .15s;
}
.module-lesson:hover {
  border-color: hsl(var(--primary) / 0.6);
  background: hsl(var(--primary) / 0.04);
}
.module-lesson-no {
  font-size: 10px; font-weight: 700;
  letter-spacing: .04em;
  color: hsl(var(--primary));
  text-align: center;
}
.module-lesson-title {
  font-size: 12px; line-height: 1.45;
  color: hsl(var(--foreground));
}
.module-lesson-cta {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
}
.module-lesson:hover .module-lesson-cta { color: hsl(var(--primary)); }

@media (max-width: 700px) {
  .module-actions { grid-template-columns: 1fr; }
}

/* Подсветка для выбранного модуля в sidebar */
.course-tree-mod-head.active {
  background: hsl(var(--primary) / 0.10);
  border-left: 2px solid hsl(var(--primary));
  padding-left: 16px;
}
.course-tree-mod-head.active .course-tree-mod-no,
.course-tree-mod-head.active .course-tree-mod-title { color: hsl(var(--primary)); }

/* ── Шаблоны для скачивания (materials > Шаблоны) ─────────── */
.dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.dl-card {
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.dl-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.dl-card-icon { font-size: 26px; line-height: 1; }
.dl-card-title {
  font-size: 15px;
  font-weight: 700;
  color: hsl(var(--foreground));
}
.dl-card-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  margin-top: 2px;
}
.dl-card-desc {
  font-size: 13px;
  line-height: 1.55;
  color: hsl(var(--muted-foreground));
  margin-bottom: 16px;
  flex: 1;
}
.dl-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.dl-btn { text-decoration: none; text-align: center; }
.dl-btn-sec {
  text-decoration: none;
  text-align: center;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
.dl-btn-sec:hover { color: hsl(var(--foreground)); border-color: hsl(var(--foreground) / .4); }

/* ── Публикация приложений ─────────────────────────────────── */
.pub-row { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; font-size: 13px; cursor: pointer; }
.pub-row input { margin-top: 2px; }
.pub-url-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: hsl(var(--accent) / .4); border: 1px solid hsl(var(--border));
  border-radius: 6px; padding: 8px 10px; margin: 10px 0;
}
.pub-url { font-family: var(--font-mono); font-size: 12px; color: hsl(var(--foreground)); word-break: break-all; flex: 1; }
.pub-status { font-family: var(--font-mono); font-size: 11px; color: hsl(var(--muted-foreground)); margin: 6px 0; }


/* ── Кнопки в футере модалок — одного размера ──────────────── */
.modal-footer .btn { min-width: 96px; }

/* ── Кастомный select (вместо системного) ─────────────────── */
.kg-select-native { display: none !important; }
.kg-select { position: relative; width: 100%; font-family: var(--font-mono); }
.kg-select-btn {
  height: 32px; width: 100%; padding: 0 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid hsl(var(--input)); background: hsl(var(--secondary));
  color: hsl(var(--foreground)); font-size: 13px; font-family: var(--font-mono);
  cursor: pointer; text-align: left; transition: border-color .15s;
}
.kg-select-btn:hover { border-color: hsl(var(--smui-border-hover)); }
.kg-select.open .kg-select-btn { border-color: hsl(var(--primary)); }
.kg-select-btn svg { flex-shrink: 0; transition: transform .15s; opacity: .7; }
.kg-select.open .kg-select-btn svg { transform: rotate(180deg); }
.kg-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kg-select-menu {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  z-index: 50; max-height: 240px; overflow-y: auto;
  background: hsl(var(--popover, var(--card))); border: 1px solid hsl(var(--border));
  border-radius: 6px; box-shadow: 0 8px 24px hsl(0 0% 0% / .35);
}
.kg-select.open .kg-select-menu { display: block; }
.kg-select-item {
  width: 100%; text-align: left; padding: 8px 10px; cursor: pointer;
  background: transparent; border: none; border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground)); font-size: 13px; font-family: var(--font-mono);
}
.kg-select-item:last-child { border-bottom: none; }
.kg-select-item:hover { background: hsl(var(--primary) / .12); color: hsl(var(--primary)); }
.kg-select-item.active { background: hsl(var(--primary) / .15); color: hsl(var(--primary)); }

/* ═══════════════════════════════════════════════════════════
 * Конспекты уроков (Курс → урок). Тёмная/светлая темы через токены.
 * ═══════════════════════════════════════════════════════════ */
.lesson-note { max-width: 70ch; margin-top: 4px; }
.lesson-note > p { font-size: 13.5px; line-height: 1.66; color: hsl(var(--foreground)); margin: 0 0 14px; }
.lesson-note > p.muted { color: hsl(var(--muted-foreground)); }
.lesson-note strong { color: hsl(var(--foreground)); font-weight: 600; }
.lesson-note em { font-style: normal; color: hsl(var(--primary)); }

/* «В этом уроке» — чипы-якоря */
.note-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 26px; }
.note-toc-chip {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 10px;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}

/* Заголовок секции с номером */
.note-h2 {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  letter-spacing: .02em; color: hsl(var(--foreground));
  margin: 34px 0 14px; padding-bottom: 9px;
  border-bottom: 1px solid hsl(var(--border));
}
.note-h2-no {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  font-size: 11px; font-weight: 700;
  background: hsl(var(--primary) / .14); color: hsl(var(--primary));
  border: 1px solid hsl(var(--primary) / .4);
}

.lesson-note ul { margin: 0 0 16px; padding: 0; list-style: none; }
.lesson-note ul li {
  position: relative; padding: 3px 0 3px 20px;
  font-size: 13px; line-height: 1.6; color: hsl(var(--foreground));
}
.lesson-note ul li::before {
  content: '▸'; position: absolute; left: 2px; top: 3px;
  color: hsl(var(--primary)); font-size: 11px;
}

/* Инлайн-«клавиша»/код */
.kbd {
  font-family: var(--font-mono); font-size: 11.5px;
  padding: 1px 6px; margin: 0 1px;
  background: hsl(var(--secondary)); color: hsl(var(--smui-frost-2));
  border: 1px solid hsl(var(--border));
  white-space: nowrap;
}

/* Колауты: ключевое / лайфхак / осторожно */
.note-callout {
  display: flex; gap: 12px; align-items: flex-start;
  margin: 18px 0; padding: 13px 15px;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-left-width: 3px;
}
.note-callout-ic { flex: none; font-size: 16px; line-height: 1.4; }
.note-callout-body { font-size: 12.5px; line-height: 1.6; color: hsl(var(--foreground)); }
.note-callout-label {
  display: block; font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; margin-bottom: 4px;
}
.note-callout.is-key  { border-left-color: hsl(var(--primary)); }
.note-callout.is-key  .note-callout-label { color: hsl(var(--primary)); }
.note-callout.is-tip  { border-left-color: hsl(var(--smui-green)); }
.note-callout.is-tip  .note-callout-label { color: hsl(var(--smui-green)); }
.note-callout.is-warn { border-left-color: hsl(var(--smui-orange)); }
.note-callout.is-warn .note-callout-label { color: hsl(var(--smui-orange)); }

/* Промт / цитата */
.note-quote {
  margin: 16px 0; padding: 12px 15px;
  background: hsl(var(--background)); border: 1px dashed hsl(var(--border));
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  color: hsl(var(--smui-frost-2));
}
.note-quote-label {
  display: block; font-size: 9.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: hsl(var(--muted-foreground)); margin-bottom: 6px;
}
.note-quote pre {
  margin: 0; font: inherit; color: inherit;
  white-space: pre; overflow-x: auto;
}

/* Шаги */
.note-steps { margin: 16px 0; padding: 0; list-style: none; counter-reset: st; }
.note-steps li {
  position: relative; counter-increment: st;
  padding: 7px 0 7px 38px; min-height: 26px;
  font-size: 13px; line-height: 1.55; color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
}
.note-steps li:last-child { border-bottom: none; }
.note-steps li::before {
  content: counter(st); position: absolute; left: 0; top: 6px;
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  background: hsl(var(--primary) / .14); color: hsl(var(--primary));
  border: 1px solid hsl(var(--primary) / .4);
}

/* Таблица сравнения */
.note-cmp-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid hsl(var(--border)); }
.note-cmp { width: 100%; border-collapse: collapse; font-size: 12px; }
.note-cmp th, .note-cmp td {
  padding: 9px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid hsl(var(--border));
}
.note-cmp thead th {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: hsl(var(--muted-foreground)); background: hsl(var(--background));
}
.note-cmp tbody tr:last-child td { border-bottom: none; }
.note-cmp tbody td:first-child { font-weight: 600; color: hsl(var(--foreground)); white-space: nowrap; }
.note-cmp td { color: hsl(var(--muted-foreground)); }
.note-cmp .pick { color: hsl(var(--smui-green)); font-weight: 600; }
.note-cmp .nope { color: hsl(var(--smui-red)); }

/* Фигура-диаграмма */
.note-fig {
  margin: 22px 0; padding: 18px;
  background: hsl(var(--background)); border: 1px solid hsl(var(--border));
}
.note-fig svg { width: 100%; height: auto; display: block; }
.note-fig-cap {
  margin-top: 12px; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .03em; color: hsl(var(--muted-foreground)); text-align: center;
}
/* Общая палитра для всех SVG-диаграмм конспектов */
.note-fig svg text { font-family: var(--font-mono); fill: hsl(var(--foreground)); }
.note-fig svg .t-mut  { fill: hsl(var(--muted-foreground)); }
.note-fig svg .t-pri  { fill: hsl(var(--primary)); }
.note-fig svg .t-grn  { fill: hsl(var(--smui-green)); }
.note-fig svg .t-org  { fill: hsl(var(--smui-orange)); }
.note-fig svg .t-red  { fill: hsl(var(--smui-red)); }
.note-fig svg .box    { fill: hsl(var(--card)); stroke: hsl(var(--border)); stroke-width: 1.2; }
.note-fig svg .box-pri{ fill: hsl(var(--primary) / .12); stroke: hsl(var(--primary)); stroke-width: 1.4; }
.note-fig svg .box-grn{ fill: hsl(var(--smui-green) / .12); stroke: hsl(var(--smui-green)); stroke-width: 1.4; }
.note-fig svg .box-org{ fill: hsl(var(--smui-orange) / .12); stroke: hsl(var(--smui-orange)); stroke-width: 1.4; }
.note-fig svg .box-dash { fill: none; stroke: hsl(var(--border)); stroke-width: 1.2; stroke-dasharray: 4 4; }
.note-fig svg .ln    { stroke: hsl(var(--muted-foreground)); stroke-width: 1.4; fill: none; }
.note-fig svg .ln-pri{ stroke: hsl(var(--primary)); stroke-width: 1.6; fill: none; }
.note-fig svg .ln-dash { stroke: hsl(var(--smui-red)); stroke-width: 1.6; fill: none; stroke-dasharray: 5 4; }
.note-fig svg .fill-mut { fill: hsl(var(--muted-foreground)); }
.note-fig svg .fill-pri { fill: hsl(var(--primary)); }
.note-fig svg .fill-bg  { fill: hsl(var(--background)); }
.note-fig svg .fill-track { fill: hsl(var(--secondary)); }

.lesson-note .note-end {
  margin-top: 26px; padding-top: 14px; border-top: 1px solid hsl(var(--border));
  font-size: 12px; color: hsl(var(--muted-foreground));
}

/* ───────────────────────── База знаний (хаб) ───────────────────────── */
.kb-layout { display: grid; grid-template-columns: 234px 1fr; gap: 20px; align-items: start; }
.kb-side { border: 1px solid hsl(var(--border)); background: hsl(var(--smui-surface-1)); position: sticky; top: 70px; }
.kb-group-h { padding: 11px 13px 6px; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: hsl(var(--muted-foreground)); opacity: .8; }
.kb-group-h:not(:first-child) { border-top: 1px solid hsl(var(--border)); margin-top: 4px; }
.kb-item { display: flex; align-items: center; gap: 9px; padding: 8px 13px; cursor: pointer; font-size: 13px; color: hsl(var(--muted-foreground)); border-left: 2px solid transparent; }
.kb-item:hover { background: hsl(var(--smui-surface-2)); }
.kb-item.active { color: hsl(var(--foreground)); border-left-color: hsl(var(--primary)); background: hsl(var(--accent)); }
.kb-item .n { margin-left: auto; font-size: 11px; opacity: .55; }
.kb-search { display: flex; align-items: center; gap: 10px; border: 1px solid hsl(var(--border)); background: hsl(var(--smui-surface-1)); padding: 9px 13px; margin-bottom: 16px; }
.kb-search input { flex: 1; background: transparent; border: none; outline: none; color: hsl(var(--foreground)); font-family: var(--font-mono); font-size: 13px; }
.kb-search .k { font-size: 11px; color: hsl(var(--muted-foreground)); border: 1px solid hsl(var(--border)); padding: 1px 6px; }
@media (max-width: 760px) { .kb-layout { grid-template-columns: 1fr; } .kb-side { position: static; } }

/* ── Chat tool-use blocks (universal) ───────────────────── */
.chat-tool {
  align-self: stretch;
  display: flex; flex-direction: column;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  font-family: var(--font-mono); font-size: 11px;
  overflow: hidden;
}
.chat-tool-header {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; cursor: pointer;
  user-select: none;
  background: hsl(var(--card));
  border-left: 3px solid var(--tool-color, hsl(var(--border)));
}
.chat-tool-header:hover { background: hsl(var(--secondary)); }
.chat-tool-icon { font-size: 12px; flex-shrink: 0; }
.chat-tool-name { font-weight: 700; color: var(--tool-color, hsl(var(--foreground))); flex-shrink: 0; }
.chat-tool-arg  { color: hsl(var(--muted-foreground)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-tool-toggle { margin-left: auto; opacity: .4; font-size: 9px; flex-shrink: 0; transition: transform .15s; }
.chat-tool-header.open .chat-tool-toggle { transform: rotate(90deg); }
.chat-tool-body {
  display: none;
  padding: 7px 12px;
  background: hsl(0 0% 4%);
  color: hsl(120 35% 68%);
  font-size: 10.5px;
  line-height: 1.45;
  white-space: pre-wrap; word-break: break-all;
  max-height: 200px; overflow-y: auto;
  border-top: 1px solid hsl(var(--border));
}
.chat-tool-body.open { display: block; }
.chat-tool-status { margin-left: 6px; font-size: 9px; opacity: .55; flex-shrink: 0; }

/* ── File editor ── */
.expl-editor {
  flex: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  border: none;
  outline: none;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  box-sizing: border-box;
}
.expl-editor:focus {
  box-shadow: inset 0 0 0 1px hsl(var(--primary) / .3);
}

/* ── Kanban board ── */
.kb-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
  font-size: 13px;
}

/* Sidebar */
.kb-sidebar {
  width: 180px;
  min-width: 160px;
  max-width: 200px;
  border-right: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: hsl(var(--card));
  flex-shrink: 0;
}
.kb-sidebar-head {
  padding: 10px 12px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  opacity: .45;
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
}
.kb-proj-list {
  overflow-y: auto;
  flex: 1;
}
.kb-proj-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid hsl(var(--border) / .4);
  transition: background .12s;
}
.kb-proj-item:hover { background: hsl(var(--secondary)); }
.kb-proj-item.active {
  background: hsl(var(--primary) / .12);
  color: hsl(var(--primary));
  font-weight: 600;
}

/* Main area */
.kb-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.kb-topbar {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
  gap: 10px;
}
.kb-proj-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-board {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
}
.kb-empty-hint {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  margin: auto;
  opacity: .6;
}

/* Columns */
.kb-col {
  flex: 1;
  min-width: 220px;
  max-width: 320px;
  background: hsl(var(--secondary) / .5);
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}
.kb-col-head {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
  user-select: none;
}
.kb-col-count {
  font-size: 10px;
  background: hsl(var(--muted));
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 500;
  opacity: .7;
}
.kb-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 60px;
  transition: background .15s;
}
.kb-col-body.drag-over {
  background: hsl(var(--primary) / .07);
  outline: 2px dashed hsl(var(--primary) / .4);
  outline-offset: -4px;
  border-radius: 6px;
}
.kb-col-empty {
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  text-align: center;
  padding: 16px 8px;
  opacity: .5;
  pointer-events: none;
}

/* Cards */
.kb-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  cursor: grab;
  transition: box-shadow .12s, opacity .12s;
  overflow: hidden;
}
.kb-card:hover { box-shadow: 0 2px 8px hsl(0 0% 0% / .12); }
.kb-card.dragging { opacity: .4; cursor: grabbing; }
.kb-card-done { opacity: .6; }
.kb-card-done .kb-card-title { text-decoration: line-through; }
.kb-card-body {
  padding: 9px 10px 7px;
  cursor: pointer;
  user-select: none;
}
.kb-card-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}
.kb-card-desc {
  margin-top: 6px;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.kb-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 6px;
  border-top: 1px solid hsl(var(--border) / .6);
  background: hsl(var(--secondary) / .3);
  flex-wrap: wrap;
}
.kb-action-btn {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  white-space: nowrap;
  transition: background .1s, opacity .1s;
}
.kb-action-btn:hover { background: hsl(var(--secondary)); }
.kb-action-done { border-color: hsl(140 50% 45% / .5); color: hsl(140 50% 45%); }
.kb-action-done:hover { background: hsl(140 50% 45% / .1); }

/* Panel */
.kb-panel {
  width: 380px;
  min-width: 320px;
  max-width: 440px;
  border-left: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  background: hsl(var(--background));
}
.kb-panel-head {
  padding: 9px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid hsl(var(--border));
  flex-shrink: 0;
}
.kb-panel-task-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  flex: 1;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kb-panel-mode {
  font-size: 10px;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}
.kb-mode-plan { background: hsl(220 70% 50% / .15); color: hsl(220 70% 65%); }
.kb-mode-work { background: hsl(30 90% 50% / .15); color: hsl(30 90% 60%); }

.kb-panel-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kb-panel-input {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 8px 10px;
  border-top: 1px solid hsl(var(--border));
  flex-shrink: 0;
}

/* Modal */
.kb-modal-overlay {
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.kb-modal {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 16px 40px hsl(0 0% 0% / .3);
}
.kb-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  font-weight: 600;
  font-size: 14px;
}

/* Todo link */
.kb-todo-link a { font-size: 10px; font-family: var(--font-mono); opacity: .55; text-decoration: none; cursor: default; }
