/* App shell: sidebar, top bar, viewport, right rail, modals/sheets, toasts, coach marks, mockup chrome. */
.app { height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; overflow: hidden; }

/* ---- Sidebar ---- */
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { height: var(--topbar-h); display: flex; align-items: center; gap: 11px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.brand svg { width: 26px; height: 26px; }
.brandname { font: 700 21px var(--disp); letter-spacing: -0.05em; background: linear-gradient(135deg, #5b9bf6, #a78bfa 45%, #f472b6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { padding: 10px 8px 6px; }
.nav.scroll { flex: 1; min-height: 0; overflow: auto; }
.navrow { position: relative; border-radius: var(--r2); }
.navrow .navbtn { width: 100%; }
.navrow.active .navbtn { color: var(--text); background: var(--hover); }
.navrow.active .navbtn svg { color: var(--violet); }
.navrow .navbtn .cnt.live { color: var(--green); font-size: 10.5px; }
/* the fold control sits over the icon; it only appears on hover, and only it toggles the list */
.fold { position: absolute; left: 4px; top: 5px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); border-radius: var(--r1); opacity: 0; transition: opacity var(--fast); }
.fold svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; transform: rotate(-90deg); transition: transform var(--fast) var(--ease); }
.fold.open svg { transform: rotate(0); }
.navrow:hover .fold, .fold:focus-visible { opacity: 1; }
.navrow:hover .navbtn > svg { opacity: 0; }
.fold:hover { color: var(--text); background: var(--raised); }
.agentlist.nested { flex: none; overflow: visible; padding: 2px 0 6px 14px; margin-left: 17px; border-left: 1px solid var(--line); }
.agentlist.nested.folded { display: none; }
.agentlist.nested .agbtn { padding: 6px 8px; }
.agentlist.nested .av { width: 26px; height: 26px; }
.more-link svg, .archived-link svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; margin: 0 5px; }
.navbtn { width: 100%; height: 38px; display: flex; align-items: center; gap: 11px; padding: 0 10px; border-radius: var(--r2); color: var(--muted); font-size: 13px; transition: var(--fast); }
.navbtn:hover { color: var(--text); background: var(--hover); }
.navbtn.active { color: var(--text); background: var(--hover); }
.navbtn.active svg { color: var(--violet); }
.navbtn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.navbtn .cnt { margin-left: auto; font: var(--fs-0) var(--mono); color: var(--violet); }
.navbtn .cnt.warn { color: var(--amber); }
.sidelabel { display: flex; align-items: center; padding: 18px 18px 8px; width: 100%; text-align: left; cursor: pointer; }
.sidelabel:hover .lbl, .sidelabel.active .lbl { color: var(--text); }
.sidelabel .r { margin-left: auto; font: var(--fs-0) var(--mono); color: var(--green); display: flex; gap: 6px; align-items: center; }
.sidelabel .r::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
.agentlist { flex: 1; min-height: 0; overflow: auto; padding: 0 8px; }
.agbtn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r2); text-align: left; color: var(--muted); transition: var(--fast); position: relative; }
.agbtn:hover, .agbtn.active { background: var(--hover); color: var(--text); }
.agbtn.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; background: var(--ac, var(--violet)); }
.agtxt { min-width: 0; flex: 1; }
.agtxt b { display: block; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agtxt small { display: block; font-size: var(--fs-1); color: var(--quiet); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agval { font: var(--fs-1) var(--mono); color: var(--green); }
.agval.neg { color: var(--red); }
.sidefoot { padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.newbtn { width: 100%; height: 36px; border: 1px solid var(--line2); border-radius: var(--r1); color: var(--body); font-size: var(--fs-2); display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--fast); }
.newbtn:hover { border-color: var(--violet); color: var(--violet); }
.device { margin-top: 14px; display: flex; gap: 9px; align-items: flex-start; font-size: var(--fs-1); color: var(--muted); line-height: 1.4; }
.device i { margin-top: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; }
.device.ro i { background: var(--amber); }

/* ---- Stage ---- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.top { height: var(--topbar-h); display: flex; align-items: center; padding: 0 28px; gap: 14px; border-bottom: 1px solid var(--line); flex: none; }
.top h1 { font-size: 15px; font-weight: 500; }
.top .sub { font: var(--fs-1) var(--mono); color: var(--quiet); margin-top: 3px; letter-spacing: 0.04em; text-transform: uppercase; }
.topr { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.bell { position: relative; }
.bell.has::after { content: ''; position: absolute; top: 8px; right: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--pink); }

/* System bar (read-only / update / tab warning), sits under the top bar, never fixed over content */
.sysbar { display: flex; align-items: center; gap: 12px; padding: 9px 28px; font-size: var(--fs-2); color: var(--body); border-bottom: 1px solid var(--line); background: var(--panel); }
.sysbar.warn { border-left: 3px solid var(--amber); }
.sysbar.info { border-left: 3px solid var(--violet); }
.sysbar .btn { margin-left: auto; }

.vp { flex: 1; min-height: 0; overflow: auto; }
.view { display: none; min-height: 100%; }
.view.active { display: block; }
.view.active > * { animation: fade var(--slow) var(--ease) both; }
.wrap { max-width: var(--content-max); margin: 0 auto; padding: 34px 32px 70px; }
.wrap.narrow { max-width: 720px; }

/* Section header */
.sh { display: flex; align-items: baseline; gap: 12px; margin: 44px 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.sh:first-child { margin-top: 0; }
.sh h3 { font-size: var(--fs-4); font-weight: 600; letter-spacing: -0.02em; }
.sh .r { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.sh .r button { color: var(--muted); font-size: var(--fs-2); }
.sh .r button:hover { color: var(--text); }

/* Stat strip, unboxed columns with hairlines */
.strip { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); padding-bottom: 28px; border-bottom: 1px solid var(--line); position: relative; }
.strip > div { padding: 0 26px; min-width: 0; }
.strip > div:first-child { padding-left: 0; }
.strip > div + div { border-left: 1px solid var(--line); }
.strip .v { font: 600 30px/1 var(--sans); letter-spacing: -0.03em; margin-top: 10px; }
.strip .v small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 5px; }
.strip .v.disp { font: 600 var(--fs-7)/0.9 var(--disp); letter-spacing: -0.045em; margin-top: 12px; }
.strip .v.disp small { font: 600 22px var(--disp); color: var(--muted); margin-left: 0; }
.strip .v.disp.md { font-size: 30px; }
.strip .d { margin-top: 10px; font-size: var(--fs-2); color: var(--muted); }
.strip .acts { display: flex; gap: 6px; margin-top: 16px; }
.dotfield { position: absolute; left: 0; top: -14px; width: 44%; height: 130px; background-image: radial-gradient(circle, rgba(167, 139, 250, 0.28) 1px, transparent 1.2px); background-size: 9px 9px; mask: radial-gradient(ellipse at 20% 50%, #000 20%, transparent 75%); pointer-events: none; opacity: 0.6; }
.spark { height: 44px; margin-top: 14px; max-width: 340px; }
.spark svg { width: 100%; height: 100%; overflow: visible; }

/* Key/value rows */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: var(--fs-2); color: var(--muted); }
.kv:first-child { border-top: 0; }
.kv b { color: var(--body); font-weight: 500; font-family: var(--mono); font-size: 12px; text-align: right; }
.kv b.sans { font-family: var(--sans); font-size: var(--fs-2); }

/* Tabs / filters, underline style */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs button { height: 36px; padding: 0 12px; font-size: var(--fs-2); color: var(--muted); position: relative; }
.tabs button:hover { color: var(--body); }
.tabs button.active { color: var(--text); }
.tabs button.active::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--violet); }
.tabs.inline { border: 0; }

/* Right rail */
.rail { border-left: 1px solid var(--line); overflow: auto; padding: 22px 22px 30px; position: relative; min-width: 0; }
.ws { position: relative; }
.railgrip { position: absolute; top: 0; bottom: 0; right: calc(var(--rail-w) - 5px); width: 10px; cursor: col-resize; z-index: 3; }
.railgrip::after { content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: var(--violet); opacity: 0; transition: opacity var(--fast); }
.railgrip:hover::after, body.resizing .railgrip::after { opacity: 0.8; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .rail, body.resizing .chatcol { pointer-events: none; }
.rc { padding: 0 0 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.rc:last-of-type { border: 0; }
.rc .l { display: flex; align-items: center; }
.rc .l .btn { margin-left: auto; font-size: var(--fs-2); }
.rc .v { font: 600 26px var(--sans); letter-spacing: -0.03em; margin-top: 8px; }
.rc .v small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.bar { height: 5px; background: var(--raised); margin-top: 14px; overflow: hidden; display: flex; gap: 2px; border-radius: 2px; }
.bar i { height: 100%; transition: width var(--slow) var(--ease); }
.leg { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; font-size: var(--fs-1); color: var(--muted); }
.leg i { display: inline-block; width: 8px; height: 8px; border-radius: 1px; margin-right: 6px; vertical-align: middle; }

/* Modal / sheet */
.overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); display: none; align-items: center; justify-content: center; z-index: 50; animation: fadeIn var(--med) both; }
.overlay.open { display: flex; }
.modal { width: min(520px, calc(100% - 40px)); background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r2); animation: slideUp var(--slow) var(--ease) both; max-height: 90%; overflow: auto; }
.modal .mh { padding: 20px 24px 0; display: flex; align-items: flex-start; gap: 12px; }
.modal .mh h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.modal .mh p { color: var(--muted); font-size: var(--fs-2); margin-top: 4px; }
.modal .mh .x { margin-left: auto; color: var(--quiet); font-size: 18px; line-height: 1; }
.modal .mb { padding: 20px 24px; display: grid; gap: 16px; }
.modal .mf { padding: 16px 24px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.modal .mf .left { margin-right: auto; }

/* Choice list (in modals) */
.choice { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r1); cursor: pointer; transition: var(--fast); }
.choice:hover { border-color: var(--line2); background: var(--raised); }
.choice.sel { border-color: var(--violet); background: var(--vbg); }
.choice b { display: block; font-size: 13px; }
.choice small { color: var(--muted); font-size: var(--fs-1); }
.choice .r { margin-left: auto; font: var(--fs-1) var(--mono); color: var(--quiet); }

/* Toast, one at a time, bottom center, plain */
.toast { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--line2); border-left: 3px solid var(--green); padding: 10px 14px; font-size: var(--fs-2); color: var(--body); border-radius: var(--r1); display: none; gap: 12px; align-items: center; z-index: 60; animation: slideUp var(--med) var(--ease) both; }
.toast.show { display: flex; }
.toast.err { border-left-color: var(--red); }
.toast .btn.link { font-size: var(--fs-2); }

/* Coach mark (onboarding, inline, replaces the spotlight tour) */
.coach { position: relative; }
.coach::before { content: ''; position: absolute; inset: -8px; border: 1px dashed var(--violet); border-radius: var(--r2); pointer-events: none; animation: fadeIn var(--slow) both; }
.coachtip { position: absolute; z-index: 5; background: var(--violet); color: #15111f; padding: 10px 12px; border-radius: var(--r1); font-size: var(--fs-2); line-height: 1.45; max-width: 260px; }
.coachtip b { display: block; font-weight: 600; margin-bottom: 2px; }
.coachtip .row { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
.coachtip .row small { font: var(--fs-0) var(--mono); opacity: 0.7; margin-right: auto; }
.coachtip .row button { font-size: var(--fs-1); font-weight: 600; }
.coachtip::after { content: ''; position: absolute; top: -6px; left: 18px; border: 6px solid transparent; border-top: 0; border-bottom-color: var(--violet); }
.coachtip.below::after { top: auto; bottom: -6px; border-bottom: 0; border-top: 6px solid var(--violet); }

/* Empty state, one line + one action */
.empty { padding: 40px 0; text-align: center; color: var(--muted); font-size: var(--fs-2); }
.empty .btn { margin-top: 14px; }

/* Mockup chrome: screen switcher (not part of the product) */
.mock { position: fixed; right: 14px; bottom: 14px; z-index: 100; display: flex; gap: 4px; background: rgba(20, 20, 20, 0.92); border: 1px solid var(--line2); border-radius: var(--r2); padding: 6px; backdrop-filter: blur(8px); flex-wrap: wrap; max-width: 620px; justify-content: flex-end; }
.mock button { font: var(--fs-0) var(--mono); letter-spacing: 0.06em; padding: 6px 8px; border-radius: var(--r1); color: var(--muted); text-transform: uppercase; }
.mock button:hover { color: var(--text); background: var(--hover); }
.mock button.on { color: var(--violet); background: var(--vbg); }
.mock .sep { width: 1px; background: var(--line2); margin: 2px 4px; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .rail { display: none; }
  .strip { grid-template-columns: 1fr; }
  .strip > div { padding: 16px 0; border-left: 0 !important; }
}

/* Mockup switcher as its own bottom bar, the app sits above it, nothing overlaps. */
:root { --mock-h: 34px; }
.app { height: calc(100vh - var(--mock-h)); }
.mock { position: fixed; left: 0; right: 0; bottom: 0; height: var(--mock-h); max-width: none; border: 0; border-top: 1px solid var(--line2); border-radius: 0; padding: 0 10px; gap: 2px; flex-wrap: nowrap; justify-content: flex-start; align-items: center; overflow-x: auto; background: #0a0a0a; backdrop-filter: none; }
.mock button { padding: 4px 8px; white-space: nowrap; }
.mock .sep { margin: 0 6px; height: 14px; }
.mock::before { content: 'mockup'; font: var(--fs-0) var(--mono); letter-spacing: 0.1em; color: var(--quiet); text-transform: uppercase; margin-right: 10px; }
.toast { bottom: 16px; }
body.light .mock { background: #e9e6e0; }


/* Sidebar: collapse control, sign out, bot.fun social links */
.brand { position: relative; }
.collapse { margin-left: auto; width: 28px; height: 28px; border-radius: var(--r1); color: var(--quiet); display: grid; place-items: center; transition: var(--fast); }
.collapse:hover { color: var(--text); background: var(--hover); }
.collapse svg, .signout svg, .soc svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sidebottom { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sidebottom .navbtn { height: 34px; margin: 0 -8px; width: calc(100% + 16px); font-size: 13px; }
.sidebottom .navbtn .cnt.who { font: 11px var(--sans); color: var(--quiet); }
.social { display: flex; gap: 4px; flex: none; margin: 6px -8px 0; padding: 8px 0 0 3px; border-top: 1px solid var(--line); }
.soc { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r1); color: var(--quiet); transition: var(--fast); }
.soc svg { width: 15px; height: 15px; }
.soc:hover { color: var(--text); background: var(--hover); }

/* Collapsed: icon rail. Labels hide; nav + agents keep tooltips via title. */
.app.collapsed { grid-template-columns: 60px 1fr; }
.app.collapsed .brandname, .app.collapsed .navbtn span:not(.cnt), .app.collapsed .navbtn .cnt, .app.collapsed .sidelabel, .app.collapsed .agtxt, .app.collapsed .agval,
.app.collapsed .newbtn span, .app.collapsed .device, .app.collapsed .signout span, .app.collapsed .social { display: none; }
.app.collapsed .brand { padding: 0; justify-content: center; gap: 0; }
.app.collapsed .brand > svg { display: none; }
.app.collapsed .collapse { margin: 0; }
.app.collapsed .navbtn, .app.collapsed .agbtn { justify-content: center; padding: 0; height: 40px; }
.app.collapsed .agbtn { padding: 5px 0; }
.app.collapsed .nav, .app.collapsed .agentlist { padding-left: 10px; padding-right: 10px; }
.app.collapsed .fold, .app.collapsed .navrow .cnt { display: none; }
.app.collapsed .agentlist.nested { margin-left: 0; border-left: 0; padding: 2px 0; }
.app.collapsed .agentlist.nested.folded { display: block; }
.app.collapsed .sidebottom .navbtn { margin: 0; width: 40px; }
.app.collapsed .sidefoot { padding: 10px; }
.app.collapsed .newbtn { width: 40px; height: 40px; margin: 0 auto; }
.app.collapsed .sidebottom { justify-content: center; border-top: 0; margin-top: 8px; padding-top: 0; }
.app.collapsed .signout { flex: none; width: 40px; justify-content: center; padding: 0; }
.app.collapsed .navbtn.active svg { color: var(--violet); }
.sidebottom { flex-direction: column; align-items: stretch; gap: 4px; }
.social { justify-content: flex-start; }
.app.collapsed .sidebottom { align-items: center; }
.app.collapsed .social { display: none; }

.soc svg { fill: currentColor; stroke: none; }
.soc svg[data-stroke] { fill: none; }
.soc:first-child svg { fill: none; stroke: currentColor; width: 17px; height: 17px; }
/* .wrap is a flex item (the view is a flex column): auto margins would shrink it to fit content,
   making pages jump width with their content. Force full width; max-width still caps it. */
.view.active > .wrap { width: 100%; }
.settings > div { min-width: 0; }
