@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

/* ═══════════════════════════════════════
   DESIGN TOKENS — white clean palette
   ═══════════════════════════════════════ */
:root {
  --bg: #ffffff;
  --bg-subtle: #f8f8f6;
  --surface: #fafaf8;
  --card: #ffffff;
  --border: #e8e5de;
  --border-hover: #d4d0c8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.08);
  --text-primary: #1a1814;
  --text-secondary: #6b6560;
  --text-muted: #a8a19a;
  --accent-red: #EF3124;
  --accent-red-hover: #d42b1f;
  --accent-terra: #C96A42;
  --accent-terra-dim: rgba(201,106,66,.08);
  --green: #2d8659;
  --green-dim: rgba(45,134,89,.08);
  --blue: #3b6fc2;
  --blue-dim: rgba(59,111,194,.07);
  --purple: #7c5cbf;
  --purple-dim: rgba(124,92,191,.07);
  --orange: #d4890a;
  --orange-dim: rgba(212,137,10,.07);
  --nav-h: 52px;
  --radius: 10px;
  --radius-lg: 14px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}


/* ═══════════════════════════════════════
   TOP NAVIGATION
   ═══════════════════════════════════════ */
.top-nav {
  height: var(--nav-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 100;
}
.tn-left { display: flex; align-items: center; gap: 28px; }
.tn-right { display: flex; align-items: center; gap: 10px; }
.tn-tabs { display: flex; gap: 4px; }
.tn-tab {
  background: none; border: none; padding: 7px 16px;
  border-radius: 8px; font-family: inherit; font-size: 13px;
  font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.tn-tab:hover { color: var(--text-secondary); background: var(--bg-subtle); }
.tn-tab.active { background: var(--accent-terra-dim); color: var(--accent-terra); font-weight: 600; }

.logo-area { display: flex; align-items: center; gap: 9px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent-red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.logo-text { font-weight: 700; font-size: 15px; letter-spacing: -.4px; }
.avatar-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-terra); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; cursor: pointer; border: none;
}
.tn-help {
  width: 28px; height: 28px; border-radius: 50%;
  background: none; border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.tn-help:hover { border-color: var(--accent-terra); color: var(--accent-terra); }

.profile-menu {
  position: absolute; top: 48px; right: 20px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  min-width: 210px; display: none; z-index: 200;
}
.profile-menu.show { display: block; }
.pm-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.pm-header span { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.pm-item { padding: 10px 16px; font-size: 12.5px; cursor: pointer; transition: background .1s; }
.pm-item:hover { background: var(--bg-subtle); }


/* ═══════════════════════════════════════
   PAGES
   ═══════════════════════════════════════ */
.page { height: calc(100vh - var(--nav-h)); display: none; overflow: hidden; }
.page.active { display: flex; flex-direction: column; }
.page-scroll { flex: 1; overflow-y: auto; }
.page-scroll::-webkit-scrollbar { width: 6px; }
.page-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }


/* ═══════════════════════════════════════
   WELCOME (AI Assistant page)
   ═══════════════════════════════════════ */
.ws-content { flex: 1; display: flex; flex-direction: column; transition: opacity .3s; }
.ws-content.hidden { display: none; }
.ws-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; padding: 28px 32px 32px; overflow-y: auto;
}
.ws-spacer { flex: 1 1 auto; min-height: 20px; }
/* Input area — TOP, prominent */
.ws-input-area.ws-input-top { max-width: 680px; width: 100%; margin-bottom: 24px; animation: fadeUp .5s ease; }
.ws-input-label {
  font-size: 26px; font-weight: 800; letter-spacing: -.6px; margin-bottom: 14px; text-align: center;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-terra));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  min-height: 36px;
  opacity: 0; transform: translateY(6px);
  transition: opacity .5s ease, transform .5s ease;
}
.ws-input-label.label-visible {
  opacity: 1; transform: translateY(0);
}
.ws-input-wrap.ws-input-big {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--card); border: 2px solid var(--border);
  border-radius: 16px; padding: 6px; transition: all .25s;
  box-shadow: var(--shadow-md);
}
.ws-input-wrap.ws-input-big:focus-within { border-color: var(--accent-red); box-shadow: 0 0 0 4px rgba(239,49,36,.1), var(--shadow-md); }
.ws-input-wrap.ws-input-big textarea {
  flex: 1; background: none; border: none; outline: none;
  font-family: inherit; font-size: 14.5px; color: var(--text-primary);
  padding: 12px 16px; resize: none; line-height: 1.5; min-height: 72px; max-height: 120px;
}
.ws-input-wrap.ws-input-big textarea::placeholder { color: var(--text-secondary); font-size: 13.5px; transition: color .3s; }

/* Живой печатающийся placeholder — мигающий курсор */
.ws-input-wrap.ws-input-big textarea.ph-typing::placeholder { color: var(--text-primary); }
.ws-input-wrap.ws-input-big:has(textarea.ph-typing) {
  animation: inputBreathe 3s ease-in-out infinite;
}
@keyframes inputBreathe {
  0%, 100% { box-shadow: var(--shadow-md); }
  50% { box-shadow: 0 4px 20px rgba(201,106,66,.12), var(--shadow-md); }
}
.ws-send {
  width: 40px; height: 40px; border-radius: 12px; background: var(--accent-red); border: none; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .2s; flex-shrink: 0;
}
.ws-send:hover { background: var(--accent-red-hover); }
.ws-send svg { width: 16px; height: 16px; }

/* Divider hint between input and scenarios */
.ws-divider {
  font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; font-weight: 500;
  display: flex; align-items: center; gap: 14px; max-width: 680px; width: 100%; margin-bottom: 16px;
}
.ws-divider::before, .ws-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Hero scenario card */
.scenario-hero {
  max-width: 680px; width: 100%;
  background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent-red);
  border-radius: var(--radius-lg); padding: 16px 20px;
  cursor: pointer; transition: all .25s; text-align: left;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 10px; color: var(--text-primary); animation: fadeUp .55s ease .05s both;
}
.scenario-hero:hover { border-color: var(--accent-red); box-shadow: 0 4px 16px rgba(239,49,36,.1); transform: translateY(-2px); }
.sh-icon { width: 40px; height: 40px; border-radius: 10px; background: rgba(239,49,36,.08); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.sh-body { flex: 1; min-width: 0; }
.sh-title { font-size: 14px; font-weight: 600; letter-spacing: -.2px; margin-bottom: 2px; color: var(--text-primary); }
.sh-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.sh-arrow { font-size: 18px; color: var(--text-muted); flex-shrink: 0; transition: all .2s; }
.scenario-hero:hover .sh-arrow { transform: translateX(4px); color: var(--accent-red); }

/* Smaller scenario cards */
.scenario-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; max-width: 680px; width: 100%; margin-top: 18px; animation: fadeUp .6s ease .1s both; }
.scenario-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  cursor: pointer; transition: all .2s; text-align: left;
}
.scenario-card:hover { border-color: var(--accent-terra); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.sc-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; margin-bottom: 6px; }
.sc-icon.terra { background: var(--accent-terra-dim); }
.sc-icon.blue { background: var(--blue-dim); } .sc-icon.green { background: var(--green-dim); }
.sc-icon.purple { background: var(--purple-dim); } .sc-icon.orange { background: var(--orange-dim); }
.sc-title { font-size: 12px; font-weight: 400; margin-bottom: 2px; }
.sc-desc { font-size: 10px; color: var(--text-secondary); line-height: 1.35; }

/* Legacy ws-input-area (bottom) — keep for chat input */
.ws-input-area:not(.ws-input-top) { max-width: 600px; width: 100%; margin-top: 16px; }
.ws-input-wrap:not(.ws-input-big) {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 4px; transition: all .2s;
}
.ws-input-wrap:not(.ws-input-big):focus-within { border-color: var(--accent-terra); box-shadow: 0 0 0 3px var(--accent-terra-dim); }
.ws-input-wrap:not(.ws-input-big) textarea {
  flex: 1; background: none; border: none; outline: none;
  font-family: inherit; font-size: 13.5px; color: var(--text-primary);
  padding: 10px 14px; resize: none; line-height: 1.45; max-height: 100px; min-height: 22px;
}
.ws-input-wrap:not(.ws-input-big) textarea::placeholder { color: var(--text-muted); }


/* ═══════════════════════════════════════
   PLAN VISUALIZATION (step progress in chat)
   ═══════════════════════════════════════ */
.plan-steps {
  display: flex; flex-direction: column; gap: 0; margin: 6px 0; padding: 0;
  border-left: 2px solid var(--border); margin-left: 8px;
}
.plan-step {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px 8px 16px;
  position: relative; font-size: 12.5px; transition: all .3s;
}
.plan-step::before {
  content: ''; position: absolute; left: -7px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--border); transition: all .3s;
}
.plan-step.done::before { background: var(--green); border-color: var(--green); }
.plan-step.active::before { background: var(--accent-red); border-color: var(--accent-red); box-shadow: 0 0 0 3px rgba(239,49,36,.15); }
.plan-step.pending::before { background: var(--bg); border-color: var(--border); }
.plan-step .ps-name { font-weight: 600; color: var(--text-primary); }
.plan-step .ps-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.plan-step.done .ps-name { color: var(--green); }
.plan-step.active .ps-name { color: var(--accent-red); }
.plan-step.done .ps-check { color: var(--green); font-size: 11px; }


/* ═══════════════════════════════════════
   PAGE TRANSITION ANIMATIONS
   ═══════════════════════════════════════ */
.page { animation: none; }
.page.active { animation: pageFadeIn .3s ease; }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Chat enter animation */
.app-layout.active { animation: chatSlideIn .35s ease; }
@keyframes chatSlideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }


/* ═══════════════════════════════════════
   APP LAYOUT (chat + right panel)
   ═══════════════════════════════════════ */
.app-layout { display: none; height: calc(100vh - var(--nav-h)); }
.app-layout.active { display: flex; }
.left-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg); transition: all .35s ease; }
.app-layout.has-panel .left-panel { flex: 0 0 50%; min-width: 380px; border-right: 1px solid var(--border); }
/* When panel + rail both open — tighter left panel to fit all three */
.app-layout.has-panel.has-rail .left-panel { flex: 0 0 30%; min-width: 300px; }
/* Rail collapsed (agent card open) — clean 50/50 split */
.app-layout.has-panel.rail-collapsed .left-panel { flex: 0 0 50%; }
/* Focus mode: narrow left, wide right */
.app-layout.has-panel.focus-right .left-panel { flex: 0 0 30%; min-width: 300px; }
.app-layout.has-panel.focus-right .right-panel { flex: 1 1 70%; }
.right-panel {
  width: 0; min-width: 0; display: flex; flex-direction: column;
  background: var(--bg-subtle); overflow: hidden;
  opacity: 0; pointer-events: none; transition: all .35s ease; flex: 0 0 0%;
}
.app-layout.has-panel .right-panel { flex: 1 1 50%; width: auto; opacity: 1; pointer-events: all; }
.app-layout.has-panel.has-rail .right-panel { flex: 1 1 auto; }

/* ═══════════════════════════════════════
   CONTEXT RAIL (Cowork-style sidebar widgets)
   ═══════════════════════════════════════ */
.context-rail {
  width: 0; min-width: 0; overflow: hidden; opacity: 0;
  display: flex; flex-direction: column; gap: 0;
  background: var(--bg-subtle); border-left: 1px solid var(--border);
  transition: all .35s cubic-bezier(.4,0,.2,1);
  flex-shrink: 0; order: 10; /* always rightmost */
}
.app-layout.has-rail .context-rail {
  width: 260px; min-width: 260px; opacity: 1;
  overflow-y: auto; padding: 12px 10px;
}
.app-layout.has-rail .context-rail::-webkit-scrollbar { width: 4px; }
.app-layout.has-rail .context-rail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
/* When panel is also open — slightly narrower */
.app-layout.has-panel.has-rail .context-rail { width: 230px; min-width: 230px; }

/* Rail collapsed state — slides out to the right */
.app-layout.rail-collapsed .context-rail {
  width: 0 !important; min-width: 0 !important; padding: 0 !important;
  opacity: 0; overflow: hidden;
  transition: all .4s cubic-bezier(.4,0,.2,1);
}

/* Right panel exit animation (slides left before test mode) */
.right-panel.panel-exit-left {
  animation: panelExitLeft .4s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes panelExitLeft {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-60px); opacity: 0; }
}

.cr-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 8px;
  overflow: hidden; animation: fadeUp .3s ease;
}
.cr-card-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; cursor: pointer; user-select: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.cr-card:not(.collapsed) .cr-card-hdr { border-bottom-color: var(--border); }
.cr-card-title {
  font-size: 11.5px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .3px;
}
.cr-card-toggle {
  font-size: 13px; color: var(--text-muted); transition: transform .2s;
  line-height: 1;
}
.cr-card.collapsed .cr-card-toggle { transform: rotate(-90deg); }
.cr-card-body {
  padding: 10px 12px; transition: all .25s ease;
  max-height: 400px; overflow-y: auto;
}
.cr-card.collapsed .cr-card-body {
  max-height: 0; padding: 0 12px; overflow: hidden;
}
.cr-card-body::-webkit-scrollbar { width: 3px; }
.cr-card-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.cr-empty { font-size: 11px; color: var(--text-muted); text-align: center; padding: 8px 0; }

/* Context items */
.cr-ctx-item {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 5px 0; font-size: 11.5px; line-height: 1.45;
}
.cr-ctx-item + .cr-ctx-item { border-top: 1px solid var(--border); padding-top: 6px; }
.cr-ctx-label { font-weight: 600; color: var(--text-secondary); min-width: 0; white-space: nowrap; flex-shrink: 0; }
.cr-ctx-val { color: var(--text-primary); }

/* Plan progress bar */
.cr-plan-progress { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 0 2px; }
.cr-plan-bar { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.cr-plan-bar-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width .5s ease; }
.cr-plan-pct { font-size: 10px; font-weight: 700; color: var(--green); min-width: 28px; text-align: right; }

/* Plan steps in rail */
.cr-plan-steps { position: relative; padding-left: 11px; }
/* Vertical connector line */
.cr-plan-steps::before {
  content: ''; position: absolute; left: 9px; top: 14px; bottom: 14px;
  width: 2px; background: var(--border); border-radius: 1px;
}
.cr-plan-step {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 0; font-size: 11.5px; transition: all .3s;
  position: relative;
}
.cr-plan-dot {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff;
  border: 2px solid var(--border); background: var(--bg);
  transition: all .3s; z-index: 1;
}
.cr-plan-step.done .cr-plan-dot { background: var(--green); border-color: var(--green); }
.cr-plan-step.active .cr-plan-dot { background: var(--accent-red); border-color: var(--accent-red); box-shadow: 0 0 0 3px rgba(239,49,36,.12); animation: planPulse 2s ease-in-out infinite; }
.cr-plan-step.pending .cr-plan-dot { background: var(--bg); border-color: var(--border); color: var(--text-muted); }
.cr-plan-info { flex: 1; min-width: 0; padding-top: 1px; }
.cr-plan-name { font-weight: 600; color: var(--text-primary); font-size: 11.5px; }
.cr-plan-desc { font-size: 10px; color: var(--text-muted); margin-top: 1px; line-height: 1.35; }
.cr-plan-step.done .cr-plan-name { color: var(--green); text-decoration: line-through; text-decoration-color: rgba(52,199,89,.3); }
.cr-plan-step.active .cr-plan-name { color: var(--accent-red); }
.cr-plan-step.pending .cr-plan-name { color: var(--text-muted); }
@keyframes planPulse { 0%,100% { box-shadow: 0 0 0 3px rgba(239,49,36,.12); } 50% { box-shadow: 0 0 0 5px rgba(239,49,36,.18); } }

.lp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg); flex-shrink: 0;
}
.back-btn {
  background: none; border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 12px; cursor: pointer; font-family: inherit; font-size: 11.5px;
  color: var(--text-muted); transition: all .2s;
}
.back-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.lp-logo { display: flex; align-items: center; gap: 7px; }
.lp-logo .logo-mark { width: 22px; height: 22px; font-size: 10px; border-radius: 5px; }
.lp-logo-text { font-weight: 700; font-size: 12px; }


/* ═══════════════════════════════════════
   CHAT
   ═══════════════════════════════════════ */
.chat-area { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.messages-wrap { padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 4px; max-width: 680px; margin: 0 auto; width: 100%; }
.msg { display: flex; gap: 10px; animation: fadeUp .3s ease; }
.msg + .msg { margin-top: 6px; }
.msg-user { justify-content: flex-end; }
.msg-avatar {
  width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; margin-top: 2px; background: var(--accent-terra); color: #fff;
}
.msg-bubble { max-width: 88%; padding: 10px 13px; font-size: 13px; line-height: 1.55; border-radius: var(--radius); }
.msg-ai .msg-bubble { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) var(--radius) 4px; }
.msg-user .msg-bubble { background: var(--text-primary); color: #fff; border-radius: var(--radius) var(--radius) 4px var(--radius); }

/* Tool call */
.tool-call { margin: 4px 0 6px 34px; max-width: 88%; animation: fadeUp .3s ease; }
.tc-hdr { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; font-size: 10.5px; color: var(--text-muted); padding: 3px 0; }
.tc-hdr:hover { color: var(--text-secondary); }
.tc-chev { font-size: 9px; transition: transform .2s; display: inline-block; }
.tool-call.expanded .tc-chev { transform: rotate(90deg); }
.tc-body { max-height: 0; overflow: hidden; transition: max-height .25s; font-family: 'SF Mono','Fira Code',monospace; font-size: 10.5px; color: var(--text-secondary); padding-left: 16px; line-height: 1.6; }
.tool-call.expanded .tc-body { max-height: 150px; }
.tp { color: var(--blue); } .tr { color: var(--green); }

/* Choice chips */
.chat-choices { margin: 6px 0 4px 34px; display: flex; flex-wrap: wrap; gap: 5px; max-width: 90%; animation: fadeUp .3s ease; }
.chat-chip {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 14px; font-size: 12px; font-weight: 500; color: var(--text-primary);
  cursor: pointer; transition: all .2s; font-family: inherit;
}
.chat-chip:hover { border-color: var(--accent-terra); background: var(--accent-terra-dim); color: var(--accent-terra); }
.chat-chip.selected { border-color: var(--accent-terra); background: var(--accent-terra-dim); color: var(--accent-terra); pointer-events: none; }

/* Mini cards */
.chat-card-grid { margin: 8px 0 4px 34px; display: flex; flex-direction: column; gap: 5px; max-width: 92%; animation: fadeUp .35s ease; }
.chat-mini-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px; cursor: pointer; transition: all .2s;
}
.chat-mini-card:hover { border-color: var(--accent-terra); box-shadow: var(--shadow-sm); }
.cmc-icon { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.cmc-info { flex: 1; min-width: 0; }
.cmc-name { font-size: 12.5px; font-weight: 600; }
.cmc-desc { font-size: 10.5px; color: var(--text-secondary); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.cmc-meta { display: flex; gap: 4px; margin-top: 2px; align-items: center; }
.cmc-badge { font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.badge-agent { background: var(--accent-terra-dim); color: var(--accent-terra); }
.badge-plugin { background: var(--purple-dim); color: var(--purple); }
.badge-assistant { background: var(--green-dim); color: var(--green); }
.badge-flow { background: var(--blue-dim); color: var(--blue); }
.cmc-stat { font-size: 10px; color: var(--text-muted); margin-left: auto; }

/* Artifact inline */
.artifact-inline {
  margin: 8px 0 4px 34px; max-width: 88%;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 13px;
  cursor: pointer; transition: all .2s; display: flex; align-items: center; gap: 10px; animation: fadeUp .35s ease;
}
.artifact-inline:hover { border-color: var(--accent-terra); box-shadow: var(--shadow-sm); }
.ai-icon { width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.ai-icon.red { background: rgba(239,49,36,.06); } .ai-icon.terra { background: var(--accent-terra-dim); }
.ai-icon.blue-i { background: var(--blue-dim); } .ai-icon.green-i { background: var(--green-dim); }
.ai-icon.purple-i { background: var(--purple-dim); } .ai-icon.orange-i { background: var(--orange-dim); }
.ai-label .ai-title { font-size: 12px; font-weight: 600; }
.ai-label .ai-sub { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.ai-arrow { margin-left: auto; color: var(--text-muted); font-size: 12px; }

/* Status + typing */
.chat-status { margin: 6px 0 4px 34px; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; padding: 5px 11px; border-radius: 7px; animation: fadeUp .3s ease; }
.chat-status.ok { background: var(--green-dim); color: var(--green); }
.chat-status.warn { background: var(--orange-dim); color: var(--orange); }
.chat-status.info { background: var(--blue-dim); color: var(--blue); }
.chat-status .cs-dot { width: 6px; height: 6px; border-radius: 50%; animation: pulse 1.4s infinite; }
.chat-status.ok .cs-dot { background: var(--green); } .chat-status.warn .cs-dot { background: var(--orange); }
.typing-indicator { display: none; align-items: center; gap: 4px; padding: 8px 0; max-width: 680px; margin: 0 auto; width: 100%; padding-left: 14px; }
.typing-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); animation: pulse 1.1s infinite; }
.typing-dot:nth-child(2) { animation-delay: .15s; } .typing-dot:nth-child(3) { animation-delay: .3s; }
.typing-label { font-size: 10.5px; color: var(--text-muted); margin-left: 6px; }

/* Input bar */
.input-bar { flex-shrink: 0; padding: 8px 12px 12px; background: var(--bg); border-top: 1px solid var(--border); }
.input-row { display: flex; align-items: flex-end; gap: 8px; max-width: 680px; margin: 0 auto; width: 100%; }
.input-wrap { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 11px; display: flex; align-items: flex-end; padding: 3px; transition: all .2s; }
.input-wrap:focus-within { border-color: var(--accent-terra); box-shadow: 0 0 0 3px var(--accent-terra-dim); }
.input-wrap textarea { flex: 1; background: none; border: none; outline: none; font-family: inherit; font-size: 13px; color: var(--text-primary); padding: 8px 12px; resize: none; line-height: 1.45; max-height: 100px; min-height: 20px; }
.input-wrap textarea::placeholder { color: var(--text-muted); }
.send-btn { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-red); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .2s; flex-shrink: 0; }
.send-btn:hover { background: var(--accent-red-hover); }
.send-btn svg { width: 14px; height: 14px; }


/* ═══════════════════════════════════════
   RIGHT PANEL
   ═══════════════════════════════════════ */
.rp-bc { padding: 10px 20px; font-size: 11.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--bg); flex-shrink: 0; display: flex; align-items: center; gap: 6px; }
.rp-bc .crumb { color: var(--text-secondary); font-weight: 500; }
.rp-close { margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 11px; color: var(--text-muted); font-family: inherit; transition: all .2s; }
.rp-close:hover { border-color: var(--border-hover); color: var(--text-primary); }
.rp-body { flex: 1; overflow-y: auto; }
.rp-body::-webkit-scrollbar { width: 5px; }
.rp-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.av { display: none; padding: 24px; animation: fadeUp .35s ease; }
.av.active { display: block; }


/* ═══════════════════════════════════════
   SHARED COMPONENTS
   ═══════════════════════════════════════ */
.sec-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 8px; }
.btn-red { background: var(--accent-red); color: #fff; border: none; padding: 9px 20px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .2s; }
.btn-red:hover { background: var(--accent-red-hover); }
.btn-outline { background: var(--card); border: 1px solid var(--border); color: var(--text-primary); padding: 9px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; transition: all .2s; }
.btn-outline:hover { border-color: var(--text-muted); }
.btn-sm { padding: 6px 14px; border-radius: 7px; font-size: 11.5px; font-weight: 600; border: none; cursor: pointer; font-family: inherit; transition: all .15s; }
.btn-sm.primary { background: var(--accent-terra); color: #fff; }
.btn-sm.primary:hover { background: #b55e38; }
.btn-sm.ghost { background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-secondary); }
.btn-sm.ghost:hover { border-color: var(--border-hover); color: var(--text-primary); }
.tool-tag { font-family: 'SF Mono','Fira Code',monospace; font-size: 10px; padding: 3px 8px; border-radius: 5px; background: var(--blue-dim); color: var(--blue); }
.code-block { background: #1e1d1a; color: #d4cfc0; border-radius: 8px; padding: 12px 14px; margin-top: 8px; font-family: 'SF Mono','Fira Code',monospace; font-size: 11px; line-height: 1.6; overflow-x: auto; }
.code-block .kw { color: #C96A42; } .code-block .str { color: #3C7A58; } .code-block .fn { color: #6A9FD4; } .code-block .cmt { color: #7C7565; font-style: italic; }
.disc-cat { font-size: 11px; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); cursor: pointer; font-family: inherit; color: var(--text-secondary); transition: all .15s; }
.disc-cat.active { border-color: var(--accent-terra); background: var(--accent-terra-dim); color: var(--accent-terra); }


/* ═══════════════════════════════════════
   AGENT DETAIL (right panel)
   ═══════════════════════════════════════ */
.agent-detail { max-width: 600px; }
.ag-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.ag-big { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.ag-big.r { background: rgba(239,49,36,.06); } .ag-big.t { background: var(--accent-terra-dim); }
.ag-big.b { background: var(--blue-dim); } .ag-big.g { background: var(--green-dim); } .ag-big.p { background: var(--purple-dim); }
.ag-meta h2 { font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.ag-meta .ag-author { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.ag-meta .ag-badges { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.ag-ver { font-size: 9.5px; color: var(--text-muted); background: var(--bg-subtle); border: 1px solid var(--border); padding: 2px 7px; border-radius: 5px; }
.ag-type { font-size: 9.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; }
.ag-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; padding: 12px 14px; background: var(--bg-subtle); border-radius: var(--radius); }
.tools-list { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 16px; }
.stats-row { display: flex; gap: 8px; margin-bottom: 16px; }
.stat-card { flex: 1; background: var(--bg-subtle); border-radius: var(--radius); padding: 10px; text-align: center; }
.stat-val { font-size: 17px; font-weight: 700; }
.stat-lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.stat-card.gr .stat-val { color: var(--green); } .stat-card.te .stat-val { color: var(--accent-terra); }
.reviews-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; }
.stars { color: var(--accent-terra); } .review-c { color: var(--text-muted); font-size: 11.5px; }
.ag-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ag-config { margin-top: 16px; padding: 14px; background: var(--bg-subtle); border-radius: var(--radius); }
.ag-config .sec-title { margin-bottom: 8px; }
.cfg-row { display: flex; gap: 12px; margin-bottom: 5px; font-size: 12px; }
.cfg-label { color: var(--text-muted); min-width: 90px; } .cfg-val { color: var(--text-primary); font-weight: 500; }

/* MCP section */
.ag-mcp { margin-top: 16px; padding: 14px; background: var(--bg-subtle); border-radius: var(--radius); }
.mcp-tool-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 11.5px; }
.mcp-tool-row:last-child { border-bottom: none; }
.mcp-tool-name { font-family: 'SF Mono','Fira Code',monospace; font-size: 11px; color: var(--blue); flex: 1; }
.mcp-tool-desc { font-size: 10.5px; color: var(--text-muted); flex: 2; }
.mcp-toggle { width: 36px; height: 20px; border-radius: 10px; background: var(--border); border: none; cursor: pointer; position: relative; transition: background .2s; flex-shrink: 0; }
.mcp-toggle.on { background: var(--green); }
.mcp-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.mcp-toggle.on::after { transform: translateX(16px); }

/* RAG section */
.ag-rag { margin-top: 16px; padding: 14px; background: var(--bg-subtle); border-radius: var(--radius); }
.rag-source-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 11.5px; }
.rag-source-row:last-child { border-bottom: none; }
.rag-icon { font-size: 16px; flex-shrink: 0; }
.rag-info { flex: 1; } .rag-name { font-weight: 600; font-size: 12px; } .rag-desc { font-size: 10.5px; color: var(--text-muted); }
.rag-status { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.rag-status.connected { background: var(--green-dim); color: var(--green); }
.rag-status.planned { background: var(--orange-dim); color: var(--orange); }


/* ═══════════════════════════════════════
   DEPLOY / SESSION / PUBLISH (views)
   ═══════════════════════════════════════ */
.deploy { max-width: 600px; } .deploy h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.deploy .dep-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }
.step-block { background: var(--bg-subtle); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 5px; background: var(--accent-terra-dim); color: var(--accent-terra); font-size: 9.5px; font-weight: 700; margin-right: 6px; }
.step-title { font-size: 12px; font-weight: 600; display: inline; }
.step-desc { font-size: 11.5px; color: var(--text-secondary); margin-top: 5px; line-height: 1.5; }
.sf { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 11px; border-radius: 7px; font-size: 11.5px; font-weight: 500; }
.sf.ok { background: var(--green-dim); color: var(--green); } .sf.pend { background: var(--orange-dim); color: var(--orange); }
.sf-dot { width: 7px; height: 7px; border-radius: 50%; animation: pulse 1.4s infinite; }
.sf.ok .sf-dot { background: var(--green); } .sf.pend .sf-dot { background: var(--orange); }
.deploy-bar { margin-top: 8px; background: var(--border); border-radius: 5px; overflow: hidden; height: 6px; }
.deploy-fill { height: 100%; border-radius: 5px; background: var(--green); width: 0%; transition: width 2s ease; }

.session { max-width: 600px; } .session h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.session .ses-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 14px; }
.ses-header { display: flex; align-items: center; gap: 11px; padding: 10px 12px; background: var(--bg-subtle); border-radius: var(--radius); margin-bottom: 12px; }
.ses-h-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; background: var(--green-dim); }
.ses-h-name { font-size: 13px; font-weight: 600; }
.ses-h-status { font-size: 10.5px; color: var(--green); font-weight: 500; display: flex; align-items: center; gap: 4px; }
.ses-h-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; }
.ses-chat { background: var(--bg-subtle); border-radius: var(--radius-lg); padding: 12px; display: flex; flex-direction: column; gap: 7px; max-height: 280px; overflow-y: auto; }
.ses-msg { padding: 8px 12px; border-radius: 8px; font-size: 12px; line-height: 1.5; max-width: 85%; }
.ses-msg.agent { background: var(--card); align-self: flex-start; border: 1px solid var(--border); } .ses-msg.user { background: var(--text-primary); color: #fff; align-self: flex-end; }
.ses-input-row { display: flex; gap: 7px; margin-top: 8px; }
.ses-input { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 7px; padding: 8px 12px; font-family: inherit; font-size: 12px; color: var(--text-primary); outline: none; }
.ses-input:focus { border-color: var(--accent-terra); }
.ses-send { width: 32px; height: 32px; border-radius: 7px; background: var(--accent-red); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; }

.publish { max-width: 560px; } .publish h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.publish .pub-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }
.fg { margin-bottom: 12px; } .fl { font-size: 11px; font-weight: 600; margin-bottom: 4px; display: block; color: var(--text-secondary); }
.fi { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-family: inherit; font-size: 12.5px; color: var(--text-primary); outline: none; transition: border-color .2s; }
.fi:focus { border-color: var(--accent-terra); }
textarea.fi { resize: vertical; min-height: 52px; line-height: 1.5; }
.chk-group { display: flex; flex-direction: column; gap: 5px; }
.chk-item { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.chk-item input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; border: 1.5px solid var(--border); border-radius: 4px; background: var(--card); cursor: pointer; position: relative; transition: all .15s; flex-shrink: 0; }
.chk-item input[type="checkbox"]:checked { background: var(--accent-terra); border-color: var(--accent-terra); }
.chk-item input[type="checkbox"]:checked::after { content: '✓'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: #fff; font-size: 10px; font-weight: 700; }


/* ═══════════════════════════════════════
   MARKETPLACE PAGE
   ═══════════════════════════════════════ */
.mp-wrap { max-width: 1060px; margin: 0 auto; padding: 28px 32px; }
.mp-hero { margin-bottom: 28px; }
.mp-hero h1 { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 6px; }
.mp-hero p { font-size: 13px; color: var(--text-secondary); }

/* Search */
.mp-search-row { margin-bottom: 20px; }
.mp-search {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 18px;
  font-family: inherit; font-size: 14px; color: var(--text-primary); outline: none; transition: all .2s;
}
.mp-search:focus { border-color: var(--accent-terra); box-shadow: 0 0 0 3px var(--accent-terra-dim); }
.mp-search::placeholder { color: var(--text-muted); }

/* Filters */
.mp-filters { display: flex; gap: 6px; margin-bottom: 24px; flex-wrap: wrap; align-items: center; }
.mp-pill {
  font-size: 12px; padding: 6px 16px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--card);
  cursor: pointer; font-family: inherit; color: var(--text-secondary); transition: all .15s; font-weight: 500;
}
.mp-pill:hover { border-color: var(--border-hover); color: var(--text-primary); }
.mp-pill.active { border-color: var(--accent-terra); background: var(--accent-terra-dim); color: var(--accent-terra); }
.mp-divider { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

/* Featured strip */
.mp-featured { margin-bottom: 32px; }
.mp-featured-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.mp-featured-title::before { content: '🔥'; }
.mp-featured-grid { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.mp-featured-grid::-webkit-scrollbar { height: 0; }
.mp-feat-card {
  flex: 0 0 240px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; cursor: pointer; transition: all .2s;
  display: flex; flex-direction: column; gap: 8px;
}
.mp-feat-card:hover { border-color: var(--accent-terra); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.mp-feat-top { display: flex; align-items: center; gap: 10px; }
.mp-feat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.mp-feat-name { font-size: 13.5px; font-weight: 700; }
.mp-feat-author { font-size: 10.5px; color: var(--text-muted); }
.mp-feat-stat { font-size: 11px; color: var(--text-secondary); }
.mp-feat-stat strong { color: var(--accent-terra); }

/* Main grid */
.mp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.mp-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
  cursor: pointer; transition: all .2s; display: flex; flex-direction: column;
}
.mp-card:hover { border-color: var(--accent-terra); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.mp-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.mp-card-icon { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.mp-card-info { flex: 1; min-width: 0; }
.mp-card-name { font-size: 14px; font-weight: 600; }
.mp-card-author { font-size: 10.5px; color: var(--text-muted); }
.mp-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.45; margin-bottom: 10px; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mp-card-bottom { display: flex; align-items: center; justify-content: space-between; }
.mp-card-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.mp-card-stat { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }
.mp-card-stat strong { color: var(--text-primary); font-weight: 600; }
.mp-card-rating { color: var(--accent-terra); font-weight: 600; font-size: 11.5px; }


/* ═══════════════════════════════════════
   MY TOOLS PAGE
   ═══════════════════════════════════════ */
.mt-layout { display: flex; height: calc(100vh - var(--nav-h)); overflow: hidden; }
.mt-main { flex: 1; overflow-y: auto; padding: 28px 32px; }
.mt-header { margin-bottom: 20px; }
.mt-header h1 { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.mt-header p { font-size: 13px; color: var(--text-secondary); }

/* Filter pills */
.mt-filters { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.mt-pill {
  padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--card); font-size: 12px; cursor: pointer; transition: all .15s;
  color: var(--text-secondary); font-weight: 500;
}
.mt-pill:hover { border-color: var(--accent-terra); color: var(--text-primary); }
.mt-pill.active { background: var(--accent-terra-dim); border-color: var(--accent-terra); color: var(--accent-terra); font-weight: 600; }

/* Tool cards */
.mt-grid { display: flex; flex-direction: column; gap: 8px; }
.mt-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  transition: all .15s; cursor: pointer;
}
.mt-card:hover { border-color: var(--accent-terra); box-shadow: var(--shadow-sm); }
.mt-card-icon { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.mt-card-body { flex: 1; min-width: 0; }
.mt-card-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
.mt-card-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 10px; align-items: center; }
.mt-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mt-badge-type { font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 4px; letter-spacing: .3px; }
.mt-badge-published { font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: var(--green-dim); color: var(--green); }
.mt-badge-status { font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 4px; }
.badge-model { background: var(--accent-terra-dim); color: var(--accent-terra); }
.mt-card-request { border-left: 3px solid var(--orange); }

/* Right sidebar */
.mt-sidebar {
  width: 250px; min-width: 250px; flex-shrink: 0;
  border-left: 1px solid var(--border); background: var(--bg-subtle);
  padding: 12px 10px; overflow-y: auto;
}


/* ═══════════════════════════════════════
   ANALYTICS PAGE — personal monitoring
   ═══════════════════════════════════════ */
.an-wrap { max-width: 1060px; margin: 0 auto; padding: 28px 32px; }
.an-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.an-header-left h1 { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.an-header-left p { font-size: 13px; color: var(--text-secondary); }
.an-period-sel {
  display: flex; gap: 4px; background: var(--bg-subtle); border-radius: 8px; padding: 3px;
}
.an-period-btn {
  font-size: 11.5px; padding: 5px 14px; border-radius: 6px; border: none;
  background: none; font-family: inherit; font-weight: 500;
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.an-period-btn.active { background: var(--card); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* KPIs */
.kpi-row { display: flex; gap: 12px; margin-bottom: 24px; }
.kpi-card { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.kpi-lbl { font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; }
.kpi-val { font-size: 22px; font-weight: 800; }
.kpi-delta { font-size: 11px; margin-top: 2px; font-weight: 500; }
.kpi-delta.up { color: var(--green); } .kpi-delta.dn { color: var(--accent-red); }

/* PPM Cards section */
.ppm-section { margin-bottom: 28px; }
.ppm-section-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.ppm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ppm-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  transition: all .15s;
}
.ppm-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
.ppm-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ppm-card-name { font-size: 13px; font-weight: 700; }
.ppm-card-id { font-size: 10px; color: var(--text-muted); font-family: 'SF Mono','Fira Code',monospace; }
.ppm-link-id { color: var(--blue); text-decoration: none; cursor: pointer; transition: color .15s; }
.ppm-link-id:hover { color: var(--accent-terra); text-decoration: underline; }
.ppm-bar-wrap { height: 6px; background: var(--bg-subtle); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.ppm-bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }
.ppm-bar-fill.ok { background: var(--green); }
.ppm-bar-fill.warn { background: var(--orange); }
.ppm-bar-fill.danger { background: var(--accent-red); }
.ppm-card-stats { display: flex; gap: 16px; font-size: 11.5px; color: var(--text-secondary); margin-bottom: 8px; }
.ppm-card-stats strong { color: var(--text-primary); }
.ppm-tools-list { display: flex; flex-wrap: wrap; gap: 4px; }
.ppm-tool-chip {
  font-size: 10px; padding: 3px 8px; border-radius: 5px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  color: var(--text-secondary); display: flex; align-items: center; gap: 4px;
}
.ppm-tool-chip .ptc-icon { font-size: 11px; }

/* Daily chart */
.chart-sec { margin-bottom: 24px; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chart-title { font-size: 14px; font-weight: 700; }
.chart-legend { display: flex; gap: 12px; font-size: 10.5px; color: var(--text-muted); }
.chart-legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: middle; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 0 2px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; display: flex; flex-direction: column-reverse; gap: 1px; }
.bar { width: 100%; border-radius: 3px; transition: height .6s cubic-bezier(.4,0,.2,1); min-height: 0px; }
.bar-label { font-size: 9px; color: var(--text-muted); }
.bar-wrap:hover .bar { opacity: .8; }

/* Tool usage table */
.tool-usage-section { margin-bottom: 24px; }
.tool-usage-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: left; font-weight: 600; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .nm { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.tbl .nm-icon { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.tbl .ppm-link { font-size: 10px; font-family: 'SF Mono','Fira Code',monospace; color: var(--blue); cursor: pointer; }
.tbl .ppm-link:hover { text-decoration: underline; }
.tbl .mini-bar-wrap { width: 60px; height: 4px; background: var(--bg-subtle); border-radius: 2px; display: inline-block; vertical-align: middle; margin-left: 6px; }
.tbl .mini-bar { height: 100%; border-radius: 2px; background: var(--accent-terra); }

/* 2-column layout for chart + table */
.an-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 800px) { .an-cols { grid-template-columns: 1fr; } }


/* ═══════════════════════════════════════
   ONBOARDING
   ═══════════════════════════════════════ */
.onboard-overlay { position: fixed; inset: 0; z-index: 600; background: rgba(26,24,20,.45); display: none; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
.onboard-overlay.show { display: flex; }
.onboard-card { background: var(--card); border-radius: 18px; width: 420px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); position: relative; padding: 32px 28px 24px; }
.ob-progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--border); border-radius: 18px 18px 0 0; overflow: hidden; }
.ob-fill { height: 100%; background: var(--accent-terra); transition: width .4s ease; width: 25%; }
.ob-step { display: none; animation: fadeUp .3s ease; } .ob-step.active { display: block; }
.ob-emoji { font-size: 36px; margin-bottom: 10px; }
.ob-step h2 { font-size: 18px; font-weight: 700; margin-bottom: 5px; }
.ob-step p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 14px; }
.ob-q { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.ob-options { display: flex; flex-direction: column; gap: 6px; }
.ob-opt { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-family: inherit; font-size: 13px; color: var(--text-primary); cursor: pointer; transition: all .2s; text-align: left; }
.ob-opt:hover { border-color: var(--accent-terra); background: var(--accent-terra-dim); }
.ob-opt.selected { border-color: var(--accent-terra); background: var(--accent-terra-dim); color: var(--accent-terra); font-weight: 600; }
.ob-next { margin-top: 14px; width: 100%; padding: 10px; background: var(--accent-terra); color: #fff; border: none; border-radius: 8px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s; }
.ob-next:disabled { opacity: .4; cursor: not-allowed; } .ob-next:not(:disabled):hover { background: #b55e38; }
.ob-skip { position: absolute; top: 14px; right: 16px; background: none; border: none; font-family: inherit; font-size: 11.5px; color: var(--text-muted); cursor: pointer; }
.ob-skip:hover { color: var(--text-primary); }
.ob-program { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.ob-prog-item { background: var(--bg-subtle); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.ob-prog-step { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-terra-dim); color: var(--accent-terra); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }


/* ═══════════════════════════════════════
   SANDBOX
   ═══════════════════════════════════════ */
.sandbox-overlay { position: fixed; inset: 0; z-index: 400; background: rgba(26,24,20,.4); display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.sandbox-overlay.show { display: flex; }
.sandbox-card { background: var(--card); border-radius: 16px; width: 480px; max-height: 80vh; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.sb-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sb-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.sb-badge { font-size: 9px; font-weight: 700; letter-spacing: .5px; padding: 3px 8px; border-radius: 4px; background: var(--orange-dim); color: var(--orange); }
.sb-chat { flex: 1; overflow-y: auto; padding: 14px; min-height: 200px; max-height: 400px; display: flex; flex-direction: column; gap: 8px; }
.sb-input-row { display: flex; gap: 7px; padding: 10px 14px; border-top: 1px solid var(--border); }
.sb-footer { padding: 8px 14px; font-size: 10px; color: var(--text-muted); text-align: center; border-top: 1px solid var(--border); background: var(--bg-subtle); }


/* ═══════════════════════════════════════
   TOAST + ANIMATIONS
   ═══════════════════════════════════════ */
/* ═══════════════════════════════════════
   AGENT MODAL (popup from marketplace)
   ═══════════════════════════════════════ */
.agent-modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(26,24,20,.35);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
  animation: fadeIn .2s ease;
}
.agent-modal-overlay.show { display: flex; }
.agent-modal {
  background: var(--card);
  border-radius: 18px;
  width: 580px; max-width: 92vw;
  max-height: 85vh;
  box-shadow: 0 16px 48px rgba(0,0,0,.14);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp .25s ease;
  position: relative;
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.agent-modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card);
  font-size: 14px; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.agent-modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.agent-modal-body {
  overflow-y: auto; padding: 28px 26px 24px;
}
/* Reuse agent-detail styles inside modal */
.agent-modal-body .ag-top { display: flex; gap: 14px; align-items: flex-start; }
.agent-modal-body .ag-big { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.agent-modal-body .ag-meta h2 { font-size: 18px; font-weight: 700; line-height: 1.2; }
.agent-modal-body .ag-author { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.agent-modal-body .ag-badges { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.agent-modal-body .ag-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.55; margin: 14px 0; }
.agent-modal-body .stats-row { display: flex; gap: 8px; margin: 12px 0; }
.agent-modal-body .stat-card { flex: 1; background: var(--bg-subtle); border-radius: 10px; padding: 10px 12px; text-align: center; }
.agent-modal-body .stat-val { font-size: 17px; font-weight: 700; }
.agent-modal-body .stat-lbl { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.agent-modal-body .stat-card.te .stat-val { color: var(--accent-terra); }
.agent-modal-body .stat-card.gr .stat-val { color: var(--green); }
.agent-modal-body .reviews-row { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 6px 0 14px; }
.agent-modal-body .ag-btns { display: flex; gap: 8px; margin: 4px 0 16px; }
.agent-modal-body .sec-title { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--text-muted); margin: 14px 0 8px; }
.agent-modal-body .mcp-tool-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 12px; }
.agent-modal-body .mcp-tool-name { font-weight: 500; font-size: 11.5px; }
.agent-modal-body .mcp-tool-desc { font-size: 11px; color: var(--text-muted); flex: 1; }
.agent-modal-body .rag-source-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.agent-modal-body .rag-icon { font-size: 15px; }
.agent-modal-body .rag-name { font-size: 12px; font-weight: 500; }
.agent-modal-body .rag-desc { font-size: 11px; color: var(--text-muted); }
.agent-modal-body .rag-status { font-size: 10px; font-weight: 500; margin-left: auto; }
.agent-modal-body .rag-status.connected { color: var(--green); }
.agent-modal-body .rag-status.planned { color: var(--text-muted); }
.agent-modal-body .cfg-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.agent-modal-body .cfg-label { color: var(--text-muted); }
.agent-modal-body .cfg-val { font-weight: 500; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--text-primary); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  transform: translateY(80px); opacity: 0; transition: all .35s cubic-bezier(.4,0,.2,1);
}
.toast.show { transform: translateY(0); opacity: 1; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }


/* ═══════════════════════════════════════
   TEST MODE (agent testing split view)
   ═══════════════════════════════════════ */

/* Hide normal chat elements in test mode */
.app-layout.test-mode .lp-header,
.app-layout.test-mode .chat-area,
.app-layout.test-mode .input-bar { display: none !important; }
/* Rail visible in test mode — shows agent info & test plan */
.app-layout.test-mode.has-rail .context-rail {
  width: 240px; min-width: 240px; opacity: 1;
  overflow-y: auto; padding: 12px 10px;
  animation: railSlideIn .45s cubic-bezier(.4,0,.2,1);
}
@keyframes railSlideIn {
  from { width: 0; min-width: 0; opacity: 0; padding: 0; transform: translateX(30px); }
  to   { width: 240px; min-width: 240px; opacity: 1; transform: translateX(0); }
}

/* Force both panels visible */
.app-layout.test-mode .left-panel { flex: 0 0 38%; min-width: 340px; border-right: 1px solid var(--border); }
.app-layout.test-mode .right-panel { flex: 1 1 auto; width: auto; opacity: 1; pointer-events: all; }

/* Show test-left-content */
.test-left-content { display: none; flex-direction: column; height: 100%; }
.app-layout.test-mode .test-left-content { display: flex; animation: testSlideIn .4s cubic-bezier(.4,0,.2,1); }

.tl-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--bg);
}
.tl-badge {
  font-size: 9px; font-weight: 700; letter-spacing: .5px; padding: 3px 8px;
  border-radius: 4px; background: var(--orange-dim); color: var(--orange);
}
.tl-body { flex: 1; overflow-y: auto; padding: 20px 18px; }
.tl-body::-webkit-scrollbar { width: 5px; }
.tl-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tl-agent-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tl-agent-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.tl-agent-name { font-size: 17px; font-weight: 700; letter-spacing: -.3px; display: flex; align-items: center; gap: 8px; }
.tl-active-badge { font-size: 10px; font-weight: 600; padding: 2px 10px; border-radius: 10px; background: var(--green-dim); color: var(--green); }
.tl-agent-author { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.tl-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; margin-bottom: 18px; padding: 12px 14px; background: var(--bg-subtle); border-radius: var(--radius); }

.tl-section { margin-bottom: 16px; }
.tl-section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px; }
.tl-cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tl-cfg-item { background: var(--bg-subtle); border-radius: 8px; padding: 8px 10px; }
.tl-cfg-label { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; }
.tl-cfg-val { font-size: 12px; font-weight: 600; }
.tl-instruction { background: #1e1d1a; color: #d4cfc0; border-radius: 8px; padding: 10px 12px; font-size: 11px; line-height: 1.5; max-height: 100px; overflow-y: auto; font-family: 'SF Mono','Fira Code',monospace; }
.tl-mcp-list { display: flex; flex-direction: column; gap: 4px; }
.tl-mcp-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg-subtle); border-radius: 7px; font-size: 11.5px; }
.tl-mcp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.tl-mcp-dot.off { background: var(--border); }
.tl-mcp-name { font-family: 'SF Mono','Fira Code',monospace; color: var(--blue); font-size: 11px; }
.tl-mcp-desc { font-size: 10px; color: var(--text-muted); margin-left: auto; }

.tl-footer {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--bg);
}
.tl-footer .btn-red, .tl-footer .btn-outline { flex: 1; text-align: center; }

/* Test chat view (right panel) */
#v-test-chat.active { display: flex; flex-direction: column; height: calc(100vh - var(--nav-h) - 40px); padding: 0; animation: testSlideInRight .45s cubic-bezier(.4,0,.2,1); }
.tch-header { padding: 16px 20px; font-size: 14px; font-weight: 700; color: var(--text-secondary); flex-shrink: 0; }
.tch-messages { flex: 1; overflow-y: auto; padding: 0 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.tch-messages::-webkit-scrollbar { width: 5px; }
.tch-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tch-input-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--bg); }
.tch-input-row .ses-input { flex: 1; }

/* Test mode: collapsed left panel */
.app-layout.test-mode.test-collapsed .left-panel { flex: 0 0 52px !important; min-width: 52px !important; overflow: hidden; }
.app-layout.test-mode.test-collapsed .test-left-content { min-width: 52px; }
.app-layout.test-mode.test-collapsed .tl-body,
.app-layout.test-mode.test-collapsed .tl-footer { display: none; }
.app-layout.test-mode.test-collapsed .tl-header { flex-direction: column; align-items: center; padding: 8px 4px; gap: 6px; }
.app-layout.test-mode.test-collapsed .tl-header .back-btn { display: none; }
.app-layout.test-mode.test-collapsed .tl-badge { writing-mode: vertical-rl; font-size: 8px; }
.tl-collapse-btn {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg-subtle); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted); transition: all .2s; margin-left: auto; flex-shrink: 0;
}
.tl-collapse-btn:hover { border-color: var(--accent-terra); color: var(--accent-terra); }
.app-layout.test-mode.test-collapsed .tl-collapse-btn { margin: 0; }

@keyframes testSlideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes testSlideInRight {
  from { transform: translateX(80px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
