/* Kvant cabinet — stylesheet
   Adapted from wireframes styles.css. The key change: the two-pane
   .pane.light / .pane.dark scoping from the prototype is replaced with
   semantic CSS variables that flip on <html class="theme-*">. */

/* ═══ semantic tokens — default is LIGHT ════════════════════════════ */
:root {
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-hand: 'Kalam', 'Caveat', cursive;

  --radius: 3px;
  --radius-lg: 6px;
  --border-w: 1px;

  --bg:          #fafaf9;
  --panel:       #ffffff;
  --panel-2:     #f4f4f2;
  --border:      #d9d9d6;
  --border-2:    #e6e6e3;
  --fg:          #1f1f1e;
  --fg-2:        #555553;
  --fg-3:        #8a8a87;
  --accent:      #3b6ea5;
  --accent-2:    #eaf1f8;
  --accent-fg:   #ffffff;
  --warn:        #b58a2a;
  --warn-bg:     #fbf3df;
  --warn-border: #e5d3a3;
  --err:         #a33b3b;
  --err-bg:      #f7e5e5;
  --err-border:  #e5b8b8;
  --ok:          #3d7a4c;
  --ok-bg:       #e2efe6;
  --ok-border:   #b9d3c0;
  --ai:          #f4ecdf;
  --ai-border:   #d9c9a8;
  --ai-fg:       #6b5a31;
  --input-bg:    #ffffff;
  --shadow:      rgba(0,0,0,0.08);
  --hover:       rgba(0,0,0,0.04);
}

/* user picked dark explicitly */
html.theme-dark {
  --bg:          #1e1e1e;
  --panel:       #252526;
  --panel-2:     #2d2d2e;
  --border:      #3a3a3c;
  --border-2:    #2e2e30;
  --fg:          #d4d4d4;
  --fg-2:        #9da0a3;
  --fg-3:        #6e7071;
  --accent:      #569cd6;
  --accent-2:    #2d3b4a;
  --accent-fg:   #0b1a26;
  --warn:        #d7a85c;
  --warn-bg:     #3b3220;
  --warn-border: #5a4a2a;
  --err:         #d96b6b;
  --err-bg:      #3b2424;
  --err-border:  #5a3a3a;
  --ok:          #6fb07e;
  --ok-bg:       #223029;
  --ok-border:   #3a5a44;
  --ai:          #2e2a21;
  --ai-border:   #4a4132;
  --ai-fg:       #c6b68a;
  --input-bg:    #1a1a1a;
  --shadow:      rgba(0,0,0,0.4);
  --hover:       rgba(255,255,255,0.06);
}

/* auto: follow OS, but keep the explicit override from .theme-dark/.theme-light */
@media (prefers-color-scheme: dark) {
  html.theme-auto {
    --bg:          #1e1e1e;
    --panel:       #252526;
    --panel-2:     #2d2d2e;
    --border:      #3a3a3c;
    --border-2:    #2e2e30;
    --fg:          #d4d4d4;
    --fg-2:        #9da0a3;
    --fg-3:        #6e7071;
    --accent:      #569cd6;
    --accent-2:    #2d3b4a;
    --accent-fg:   #0b1a26;
    --warn:        #d7a85c;
    --warn-bg:     #3b3220;
    --warn-border: #5a4a2a;
    --err:         #d96b6b;
    --err-bg:      #3b2424;
    --err-border:  #5a3a3a;
    --ok:          #6fb07e;
    --ok-bg:       #223029;
    --ok-border:   #3a5a44;
    --ai:          #2e2a21;
    --ai-border:   #4a4132;
    --ai-fg:       #c6b68a;
    --input-bg:    #1a1a1a;
    --shadow:      rgba(0,0,0,0.4);
    --hover:       rgba(255,255,255,0.06);
  }
}

/* ═══ base ══════════════════════════════════════════════════════════ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  color-scheme: light dark;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

.mono { font-family: var(--font-mono); }
.hand { font-family: var(--font-hand); }
.muted { opacity: 0.6; }
.small { font-size: 11px; }
.xsmall { font-size: 10.5px; }

.flex { display: flex; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ═══ app chrome ════════════════════════════════════════════════════ */
/* 5-column grid mirroring VSCode:
   [primary activity 44 | primary sidebar 220 | main 1fr | secondary
    sidebar 220 | secondary activity 44].
   Primary bar = work slots (Overview, Projects, ...). Secondary bar =
   communication / utility slots (Chat, AI-Chat, Forum, Help, Profile).
   See partials/nav.templ#NavKey for the full slot inventory. */
.app {
  --sb-left: 220px;
  --sb-right: 220px;
  display: grid;
  grid-template-columns: 44px var(--sb-left) 1fr var(--sb-right) 44px;
  /* Fixed viewport height + clipped frame: the page itself never
     scrolls. Each region (main editor, sidebars, activity bars) owns
     its own scrollbar instead. */
  height: 100vh;
  overflow: hidden;
}

/* ═══ collapsible sidebars (VSCode-style) ══════════════════════════
   State lives in localStorage and is reflected as a class on <html>:
   - boot.js applies it synchronously in <head> so there's no flash;
   - main.ts toggles it live when the active activity-bar icon is
     re-clicked (and clears it when navigating to another section).
   Collapsing zeroes the sidebar's grid column and hides the panel; the
   activity bar that owns it stays visible so it can be re-opened. */
html.sb-left-collapsed  .app { --sb-left: 0px; }
html.sb-right-collapsed .app { --sb-right: 0px; }
/* Keep the collapsed sidebar as a ZERO-WIDTH grid item — never
   display:none. Removing it from the grid makes the remaining items
   reflow into the wrong columns (the main editor slides into the zeroed
   track and disappears). Clipping a zeroed box hides it without
   disturbing the column layout. */
html.sb-left-collapsed  .sidebar-primary,
html.sb-right-collapsed .sidebar-secondary {
  padding: 0;
  border: 0;
  overflow: hidden;
}

.activity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  background: var(--panel-2);
  overflow-y: auto;
}
.activity-primary { border-right: 1px solid var(--border); }
.activity-secondary { border-left: 1px solid var(--border); }
.activity .ico {
  width: 26px; height: 26px;
  flex-shrink: 0;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  opacity: 0.55;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  /* Glyph is enlarged to fill the 26px button; button size unchanged. */
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--fg-2);
}
.activity a { color: inherit; }
.activity .ico:hover { opacity: 0.85; }
.activity .ico.active { opacity: 1; border-width: 2px; color: var(--fg); }
.activity .sep { flex: 1; }

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 6px 8px 10px;
  font-size: 12px;
  background: var(--panel-2);
  overflow-y: auto;
}

/* Collapse control pinned to the bottom of each sidebar (margin-top:auto
   in the flex column). Hiding the panel itself is handled by main.ts +
   the html.sb-*-collapsed classes; this is just the trigger. */
.sidebar-foot {
  margin-top: auto;
  padding-top: 10px;
}
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg-2);
  font: 11px var(--font-ui);
  cursor: pointer;
}
.sidebar-collapse-btn:hover { background: var(--hover); color: var(--fg); }
.sidebar-collapse-btn .cbtn-ico {
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1;
}
.sidebar-primary  { border-right: 1px solid var(--border); }
.sidebar-secondary { border-left: 1px solid var(--border); }
.sidebar .brand {
  display: block;
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 6px;
}
.sidebar .brand .name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}
.sidebar .brand .org {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 4px;
}
.sidebar .sidebar-head {
  padding: 2px 8px 10px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 6px;
  position: relative;
}
.sidebar .sidebar-head .sec-mono {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.55;
}
.sidebar .sidebar-head .sec-title {
  font-weight: 600;
  font-size: 13px;
  margin-top: 2px;
}
.sidebar .sidebar-head .sec-sub {
  font-size: 11px;
  opacity: 0.6;
  font-family: var(--font-mono);
  margin-top: 2px;
}
.sidebar .sidebar-head .sec-cta {
  position: absolute;
  right: 6px;
  top: 2px;
}
.sidebar .sidebar-filters {
  padding: 6px 2px 8px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 6px;
}
.sidebar .sidebar-filters .filter-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.sidebar .sidebar-hint {
  padding: 8px 8px 4px;
  line-height: 1.4;
}
.sidebar .sec {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.55;
  margin: 10px 8px 4px;
}
.sidebar .item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: inherit;
}
.sidebar .item:hover { background: var(--hover); text-decoration: none; }
.sidebar .item.active { font-weight: 500; background: var(--accent-2); color: var(--accent); }
.sidebar .item .glyph {
  width: 14px; flex-shrink: 0; text-align: center; opacity: 0.55;
  font-family: var(--font-mono); font-size: 11px;
}
.sidebar .item .item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar .item .item-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  opacity: 0.75;
  background: var(--panel);
}
.sidebar .item .item-extra {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.55;
  margin-left: 4px;
}

/* ═══ activity-bar drag states ═════════════════════════════════════ */
.activity .ico[draggable="true"] { cursor: grab; }
.activity .ico[draggable="true"]:active { cursor: grabbing; }
.activity .ico.dragging {
  opacity: 0.3;
  background: var(--accent-2);
  border-color: var(--accent);
}

.main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 28px;
  overflow: auto;
  min-width: 0;
}
.main h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
.main h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
.main .sub { font-size: 11px; opacity: 0.65; margin-bottom: 16px; }

/* ═══ frame primitive ══════════════════════════════════════════════ */
.frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
}
.frame-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  background: var(--panel-2);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.frame-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; opacity: 0.3;
}
.frame-body { padding: 14px; }

/* ═══ form bits ════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 11px; opacity: 0.75; }
.input {
  display: block;
  width: 100%;
  padding: 7px 9px;
  font: 13px var(--font-ui);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--fg);
}
.input::placeholder { color: var(--fg-3); opacity: 1; font-family: var(--font-hand); font-size: 14px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

select.input {
  padding-right: 24px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-2) 50%),
                    linear-gradient(135deg, var(--fg-2) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  font: 12px var(--font-ui);
  text-decoration: none;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--err); }
.btn.xsmall { padding: 3px 8px; font-size: 11px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.hr { height: 1px; border: 0; margin: 14px 0; background: var(--border-2); }

/* ═══ tables ═══════════════════════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th, .tbl td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}
.tbl th {
  font-weight: 500;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

/* ═══ badges & pills ═══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  color: var(--fg-2);
  background: var(--panel-2);
}
.badge.ok   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-border); }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.badge.err  { color: var(--err);  background: var(--err-bg);  border-color: var(--err-border); }
.badge.muted { opacity: 0.65; }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 10.5px;
  color: var(--fg-2);
  text-decoration: none;
}
a.pill:hover { border-color: var(--accent); color: var(--fg); }
.pill.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

/* ═══ audit filters ═══════════════════════════════════════════════ */
.audit-filters {
  display: flex; flex-wrap: wrap;
  gap: 14px 24px;
  align-items: center;
}
.audit-pills {
  display: flex; align-items: center; gap: 6px;
}
.audit-label {
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--fg-3);
  margin-right: 2px;
}
.input.xsmall {
  padding: 4px 8px;
  font-size: 11px;
}

/* ═══ AI block ═════════════════════════════════════════════════════ */
.ai {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--ai-border);
  border-radius: var(--radius);
  margin: 8px 0;
  font-size: 12px;
  background: var(--ai);
  color: var(--ai-fg);
  position: relative;
}
.ai .ai-glyph {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 4px;
  border: 1px solid var(--ai-border);
  border-radius: 2px;
  height: max-content;
  letter-spacing: 0.08em;
}
.ai-hide .ai { display: none !important; }
.ai-hide .ai-inline { display: none !important; }

/* ═══ traffic light ════════════════════════════════════════════════ */
.tl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
.tl.ok   { color: var(--ok); }
.tl.warn { color: var(--warn); }
.tl.err  { color: var(--err); }

/* ═══ check ═══════════════════════════════════════════════════════ */
.check {
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}
.check .box {
  width: 13px; height: 13px;
  border: 1px solid var(--border); border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px;
  background: var(--input-bg);
}

/* ═══ stepper (onboarding) ═════════════════════════════════════════ */
.stepper { display: flex; gap: 0; margin-bottom: 24px; font-size: 11px; font-family: var(--font-mono); }
.stepper .step {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-right: 0;
  opacity: 0.55;
  background: var(--panel);
}
.stepper .step:last-child { border-right: 1px solid var(--border); }
.stepper .step.active { opacity: 1; font-weight: 600; background: var(--accent-2); color: var(--accent); border-color: var(--accent); }
.stepper .step.done { opacity: 0.75; }

/* ═══ pipeline (CI/CD) ═════════════════════════════════════════════ */
.pipeline { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.pipeline .node {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--panel-2);
}
.pipeline .node.active { border-color: var(--accent); background: var(--accent-2); color: var(--accent); }
.pipeline .arr { padding: 0 8px; opacity: 0.5; font-family: var(--font-mono); }

/* ═══ tree (forum) ═════════════════════════════════════════════════ */
.tree { font-size: 12px; }
.tree .node { margin: 0; }
.tree .line { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-2); }
.tree .avatar {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 50%;
  font-family: var(--font-mono); font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2);
  color: var(--fg-2);
}
.tree .content { flex: 1; min-width: 0; }
.tree .meta-row { display: flex; align-items: center; gap: 8px; font-size: 11px; opacity: 0.7; margin-bottom: 4px; }
.tree .children { margin-left: 18px; padding-left: 14px; border-left: 1px dashed var(--border); }

/* ═══ wiki card ════════════════════════════════════════════════════ */
.wiki { display: grid; grid-template-columns: 1fr 220px; gap: 20px; }
.wiki article p, .wiki article h3 { margin: 0 0 10px; }
.wiki article h3 { font-size: 13px; font-weight: 600; margin-top: 16px; }
.wiki article p { line-height: 1.55; font-size: 12.5px; }
.wiki .para {
  position: relative;
  padding: 4px 6px;
  margin: 0 -6px 10px;
  border-radius: 2px;
  cursor: pointer;
}
.wiki .para:hover { background: var(--hover); }
.wiki .para .thread-ind {
  position: absolute;
  right: 6px; top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 2px;
  opacity: 0.8;
  background: var(--panel);
  color: var(--fg-2);
}
.wiki aside { font-size: 11px; }
.wiki aside .kv { padding: 3px 0; opacity: 0.85; display: flex; justify-content: space-between; gap: 8px; }
.wiki aside h4 {
  font-size: 10.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.6;
  margin: 0 0 8px;
  font-weight: 500;
}

.para-drawer {
  margin: 4px -6px 12px;
  border-left: 2px solid var(--accent);
  padding: 8px 12px;
  background: var(--hover);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ═══ auth ═════════════════════════════════════════════════════════
 *
 * Auth-form styling lives in the Keycloak theme at
 * deploy/compose/_from-backend/themes/kvant/login/. The cabinet's
 * `/login` is just a 302 redirect to /oauth2/sign_in nowadays —
 * no local card is rendered. See server.go:loginHandler. */

/* ═══ landing page (kvant.host root, unauth) ══════════════════════ */
.lp-body {
  font: 14px/1.55 var(--font-ui);
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.lp-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.lp-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
  text-decoration: none;
}
.lp-nav-links {
  display: inline-flex;
  align-items: center;
  gap: 22px;
  font-size: 13px;
}
.lp-nav-links a {
  color: var(--fg-2);
  text-decoration: none;
}
.lp-nav-links a:hover { color: var(--fg); }
.lp-nav-links a.btn { color: #fff; }

.lp-hero {
  padding: 80px 32px 64px;
  background:
    radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 55%),
    radial-gradient(circle at 90% 90%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    var(--bg);
}
.lp-hero-inner {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}
.lp-hero-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg-2);
  margin-bottom: 22px;
}
.lp-h1 {
  font-size: 44px;
  line-height: 1.1;
  font-weight: 700;
  margin: 0 0 18px;
  letter-spacing: -0.5px;
}
.lp-lede {
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-2);
  max-width: 620px;
  margin: 0 auto 26px;
}
.lp-cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.lp-cta-primary, .lp-cta-ghost {
  font-size: 14px;
  padding: 11px 20px;
}
.lp-hero-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3px;
}

.lp-section {
  padding: 64px 32px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.lp-section-alt {
  background: var(--panel);
  max-width: none;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.lp-section-alt > * {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}
.lp-section-head {
  margin-bottom: 36px;
  text-align: center;
}
.lp-h2 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.3px;
}
.lp-h2-tight { margin-bottom: 6px; }
.lp-sub {
  margin: 0;
  font-size: 14px;
}

.lp-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 720px) {
  .lp-grid-3 { grid-template-columns: 1fr; }
  .lp-h1 { font-size: 32px; }
  .lp-hero { padding: 48px 24px; }
  .lp-section { padding: 48px 24px; }
}
.lp-card {
  padding: 26px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
}
.lp-card-glyph {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 12px;
  font-family: var(--font-mono);
  line-height: 1;
}
.lp-card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 10px;
}
.lp-card-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg-2);
  margin: 0;
}

.lp-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.lp-checklist li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-2);
}
.lp-checklist li strong { color: var(--fg); }
.lp-check {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}

.lp-final-cta { text-align: center; }

.lp-footer {
  margin-top: auto;
  padding: 40px 32px 24px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.lp-footer-cols {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
@media (max-width: 720px) {
  .lp-footer-cols { grid-template-columns: 1fr 1fr; }
}
.lp-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}
.lp-footer-tagline { margin-top: 6px; }
.lp-footer-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.lp-footer-section-title {
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 10px;
  margin-bottom: 4px;
}
.lp-footer-section a {
  color: var(--fg-2);
  text-decoration: none;
}
.lp-footer-section a:hover { color: var(--fg); }
.lp-footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11px;
}

/* ═══ top bar (inside main, above content) ════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .breadcrumb { font-family: var(--font-mono); font-size: 12px; color: var(--fg-2); }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg-2);
}

/* ═══ mock placeholder ═════════════════════════════════════════════ */
.mock {
  background: repeating-linear-gradient(135deg, transparent 0 6px, var(--hover) 6px 7px);
  border: 1px dashed var(--fg-3);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font: 11px var(--font-hand);
  color: var(--fg-2);
  opacity: 0.85;
}

/* ═══ quota alert banner ═══════════════════════════════════════════
   Appears at the top of the main area when any metered dimension
   crosses 80% of its effective quota AND overdraft is disabled. Uses
   the same visual grammar as .ai (sandy card) + .tl (traffic light).
*/
.quota-alert {
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
}
.quota-alert-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.quota-alert-head strong { color: var(--fg); }
.quota-alert-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.quota-alert .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 2px;
  font-size: 11px;
  background: var(--panel);
}
.quota-alert .chip-warn { color: var(--warn); border-color: var(--warn-border); }
.quota-alert .chip-err  { color: var(--err);  border-color: var(--err-border); background: var(--err-bg); }
.quota-alert .chip-ok   { color: var(--ok);   border-color: var(--ok-border); }

/* Error variant — when any dimension is >= 100%. */
.quota-alert.is-err {
  border-color: var(--err-border);
  background: var(--err-bg);
  color: var(--err);
}

/* ═══ usage bars (billing screen) ══════════════════════════════════ */
.usage-row { display: grid; grid-template-columns: 160px 1fr 140px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-2); }
.usage-label { font-size: 12px; }
.usage-label .mono { color: var(--fg-2); display: block; font-size: 10.5px; }
.usage-bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; position: relative; }
.usage-fill { height: 100%; background: var(--ok); border-radius: 4px; transition: width 0.3s; }
.usage-fill.warn { background: var(--warn); }
.usage-fill.err  { background: var(--err); }
.usage-qty { font-family: var(--font-mono); font-size: 11.5px; text-align: right; color: var(--fg-2); }
.usage-qty .muted { display: block; font-size: 10px; }

/* ═══ billing balance + run line modifiers ════════════════════════ */
.balance-ok       { /* default color from --fg */ }
.balance-low      { color: var(--warn); }
.balance-negative { color: var(--err); }
.run-warn         { color: var(--warn); }
.run-fail         { color: var(--err); }

/* ═══ project card tabs ════════════════════════════════════════════ */
.project-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.project-tab {
  padding: 8px 14px;
  border-bottom: 2px solid transparent;
  color: var(--fg-2);
  font-size: 12px;
  font-family: var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  margin-bottom: -1px;
}
.project-tab:hover { color: var(--fg); text-decoration: none; }
.project-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

/* ═══ activity report rows ═════════════════════════════════════════
   One row = one aggregated bucket (project / kind / topic etc).
   Uses same data-pct trick as billing usage bars so width is set
   client-side via main.ts.
*/
.activity-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr 180px;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-2);
}
.activity-row:last-child { border-bottom: 0; }
.activity-label {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-bar {
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
}
.activity-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}
.activity-dur {
  text-align: right;
  font-size: 11.5px;
  color: var(--fg-2);
}
.activity-dur .muted { margin-left: 6px; }

/* ═══ thread navigator (forum tree) ════════════════════════════════ */
.thread-tabs {
  display: flex;
  gap: 0;
  padding: 0 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border-2);
  overflow-x: auto;
}
.thread-tab {
  padding: 7px 14px;
  font-size: 12px;
  color: var(--fg-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.thread-tab:hover { color: var(--fg); text-decoration: none; }
.thread-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
  background: var(--panel);
}

/* ═══ topic row ════════════════════════════════════════════════════ */
.topic-row {
  display: block;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border-2);
}
.topic-row:hover { background: var(--hover); text-decoration: none; }
.topic-row.topic-row-last { border-bottom: 0; }
.topic-row .topic-title {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

/* ═══ row action menu («⋯») ════════════════════════════════════════
   Compact per-row dropdown of actions. Behaviour (toggle / outside-click
   close / Escape / confirm / clipboard) lives in main.ts#wireRowMenus. */
.row-menu { position: relative; display: inline-block; }
.row-menu-trigger {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius);
}
.row-menu-trigger:hover { background: var(--hover); color: var(--fg); }
.row-menu-list {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 180px;
  z-index: 50;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px var(--shadow);
  padding: 4px;
  margin-top: 2px;
}
.row-menu.open .row-menu-list { display: block; }
.row-menu-list form { margin: 0; }
.row-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: 12px var(--font-ui);
  cursor: pointer;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
}
.row-menu-item:hover { background: var(--hover); text-decoration: none; }
.row-menu-item.danger { color: var(--err); }

/* ═══ scrollbars (webkit) ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ═══ chat panel (cabinet "Чат" section) ═══════════════════════════
   The chat list lives in the right sidebar (.sidebar-secondary); the
   active conversation occupies the main-editor column. The frame
   below wraps that conversation pane. */
.chat-frame {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px); /* subtract topbar height */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  margin: 8px;
}
.chat-conv {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.chat-conv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-2);
  background: var(--panel-2);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-messages .msg {
  padding: 6px 8px;
  border-radius: var(--radius);
  background: var(--panel-2);
}
.chat-messages .msg.deleted { opacity: 0.55; font-style: italic; }
.msg-header {
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
}
.msg-author { color: var(--accent); font-weight: 600; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.chat-input {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-2);
  background: var(--panel-2);
}
.chat-input textarea {
  flex: 1;
  resize: vertical;
  min-height: 40px;
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--fg);
}
.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* Chat-list rows when rendered into the secondary sidebar — narrow
   form (no last-snippet, no last-meta; just glyph + title + badge). */
.sidebar-secondary .chat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 0;
}
.sidebar-secondary .chat-list-item {
  display: block;
  padding: 6px 8px;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
}
.sidebar-secondary .chat-list-item:hover { background: var(--hover); text-decoration: none; }
.sidebar-secondary .chat-list-item.active { background: var(--accent-2); color: var(--fg); }
.sidebar-secondary .chat-list-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-secondary .chat-list-glyph {
  font-family: var(--font-mono);
  width: 14px;
  text-align: center;
  color: var(--fg-3);
}
.sidebar-secondary .chat-list-title {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-secondary .chat-list-badge {
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 10px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}
