/* MCC Sovereign Core obsidian theme - core */
:root {
  --bg0: #0a0c14; --bg1: #0e1117; --bg2: #131722; --bg3: #1a1f2e;
  --line: rgba(255, 255, 255, 0.08);
  --txt: #e4e4e7; --mut: #6b7280; --dim: #5b5f73;
  --cyan: #00f3ff; --cyan-d: #06b6d4; --violet: #8b5cf6; --amber: #f59e0b; --green: #10b981; --red: #f43f5e;
  --r: 14px;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-md: 1.125rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font: 'Geist', system-ui, -apple-system, sans-serif; --mono: 'JetBrains Mono', monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg0); color: var(--txt); line-height: 1.6; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg1); }
::-webkit-scrollbar-thumb { background: #2a2f42; border-radius: 4px; }
a { color: var(--cyan); }
#boot { position: fixed; inset: 0; background: var(--bg0); z-index: 9999; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; }
#boot.hide { display: none; }
.ring { width: 46px; height: 46px; border: 3px solid transparent; border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.work { display: flex; flex: 1; min-height: 0; }
/* Slim top header Nick asked for: title + engine pill + panel toggles */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: rgba(14, 17, 23, 0.94);
  position: sticky; top: 0; z-index: 120; }
/* Keep the pinned Backup/Restore actions usable on small screens: drop the
   subtitle + engine pill first, let buttons shrink, before anything wraps. */
@media (max-width: 900px) {
  .topbar { gap: 6px; padding: 8px 10px; }
  .tb-title span, #tbEngine { display: none; }
  .topbar .btn { padding: 8px 10px; font-size: 12px; }
}

@media (max-width: 768px) {
  .side { position: fixed; left: -250px; top: 53px; height: calc(100vh - 53px); z-index: 100; transition: left 0.3s ease; box-shadow: 4px 0 12px rgba(0,0,0,0.5); }
  .side.show { left: 0; }
  .main { margin-left: 0 !important; padding: 8px; }
  .panel { margin: 8px 4px; }
  .topbar { padding: 6px 8px; }
  .topbar .btn { padding: 6px 8px; font-size: 11px; }
}

@media (max-width: 480px) {
  .side { width: 200px; }
  .btn { padding: 6px 10px; font-size: 0.85rem; }
  .inp { font-size: 0.85rem; padding: 4px 6px; }
}
.tb-title { display: flex; align-items: baseline; gap: 8px; }
.tb-title b { font-size: 14px; }
.grow { flex: 1; }
.btn-icon { padding: 9px 12px; }
.btn-xs { padding: 2px 6px; font-size: 0.75rem; }
.btn-s { padding: 6px 12px; font-size: 0.875rem; }
.btn { padding: 8px 16px; font-size: 1rem; }
.btn-g { padding: 12px 24px; font-size: 1rem; }
/* Right live-agent panel: mirror of the left, collapsible, mobile-safe */
.rside { width: 300px; min-width: 300px; border-left: 1px solid var(--line);
  background: rgba(14, 17, 23, 0.94); display: flex; flex-direction: column;
  position: sticky; top: 53px; height: calc(100vh - 105px); overflow-y: auto; }
.rhead { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: rgba(14, 17, 23, 0.97); z-index: 2; }
.rhead h3 { margin: 0; font-size: 14px; }
.rhead p { margin: 2px 0 0; }
.rsec { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.rlab { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--dim); margin-bottom: 8px; }
.rfeed { max-height: 46vh; overflow-y: auto; }
.rev .prog { height: 5px; background: #22283a; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.rev .prog i { display: block; height: 100%; background: linear-gradient(90deg, #06b6d4, #00f3ff); }
body.hide-left .side { display: none; }
body.hide-right .rside { display: none; }
/* Footer engine toggle: segmented API/Auto/Local switch */
.fseg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.fseg button { background: transparent; border: 0; color: var(--mut); font-size: 11px;
  font-weight: 700; padding: 3px 10px; cursor: pointer; font-family: var(--font); }
.fseg button.on { background: rgba(0, 243, 255, 0.15); color: var(--cyan); }
.side { width: 264px; min-width: 264px; border-right: 1px solid var(--line); background: rgba(14, 17, 23, 0.94); display: flex; flex-direction: column; position: sticky; top: 53px; height: calc(100vh - 53px); }
.brand { display: flex; gap: 12px; align-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
.mark { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--cyan), var(--violet)); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #06080f; font-size: 20px; }
.brand h1 { font-size: 15px; margin: 0; }
.brand p { margin: 2px 0 0; font-size: 11px; color: var(--mut); }
.nav { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.nav button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; color: var(--mut); padding: 10px 12px; border-radius: 12px; font-size: 13.5px; cursor: pointer; font-family: var(--font); }
.nav button:hover { background: rgba(255, 255, 255, 0.04); color: var(--txt); }
.nav button.on { background: rgba(0, 243, 255, 0.1); border-color: rgba(0, 243, 255, 0.25); color: var(--cyan); }
.nav button .ico { width: 22px; text-align: center; }
.vitals { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--mut); }
.vitals .row { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--mono); }
.main { flex: 1; min-width: 0; padding: 28px; }
@media (max-width: 1250px) { .rside { display: none; } body.show-right .rside { display: flex; position: fixed; right: 0; top: 53px; z-index: 130; box-shadow: -12px 0 32px rgba(0,0,0,.5); } }
.view { display: none; }
.view.on { display: block; animation: up 0.25s ease-out; }
@keyframes up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.hd { margin-bottom: 20px; }
.hd h2 { margin: 0; font-size: 26px; }
.hd p { margin: 6px 0 0; color: var(--mut); font-size: 13.5px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* Cabinet panel grid: responsive columns that never squish or overlap */
.cabinet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  overflow-x: auto;
  width: 100%;
}
.cabinet-card { min-width: 300px; overflow: hidden; }
@media (max-width: 900px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .side { display: none; } body.show-left .side { display: flex; position: fixed; left: 0; top: 53px; z-index: 130; height: calc(100vh - 53px); box-shadow: 12px 0 32px rgba(0,0,0,.5); } .main { padding: 16px; } }
.card { background: rgba(19, 23, 34, 0.85); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.lead { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(139, 92, 246, 0.1); border: 1px solid rgba(139, 92, 246, 0.3); font-size: 12.5px; margin-bottom: 16px; }
.lead b { color: var(--violet); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 12px; font-weight: 600; font-size: 13px; cursor: pointer; border: 1px solid transparent; font-family: var(--font); }
.btn-p { background: var(--cyan); color: #06080f; }
.btn-s { background: #22283a; color: var(--txt); border-color: #313852; }
/* Pinned-header Backup/Restore quick actions */
.btn-bk { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.45); }
.btn-bk:hover { background: rgba(16, 185, 129, 0.28); }
.btn-rs { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border-color: rgba(245, 158, 11, 0.45); }
.btn-rs:hover { background: rgba(245, 158, 11, 0.28); }
.btn-export { background: rgba(139, 92, 246, 0.16); color: #a78bfa; border-color: rgba(139, 92, 246, 0.45); }
.btn-export:hover { background: rgba(139, 92, 246, 0.28); }
/* Scan System button: dark glassmorphism with cyan hover glow */
.btn-scan {
  background: rgba(14, 17, 23, 0.9);
  color: var(--cyan);
  border: 1px solid rgba(0, 243, 255, 0.35);
  box-shadow: 0 0 0 rgba(0, 243, 255, 0);
}
.btn-scan:hover {
  background: rgba(14, 17, 23, 1);
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 243, 255, 0.55), inset 0 0 10px rgba(0, 243, 255, 0.12);
}
.btn-scan .scan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  margin-left: 6px;
  background: rgba(0, 243, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 243, 255, 0.3);
}
.btn-scan .scan-badge.scanning {
  animation: scanPulse 1.2s ease-in-out infinite;
}
@keyframes scanPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: 0.75; }
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-g { background: transparent; color: var(--mut); }
.btn-d { background: rgba(244, 63, 94, 0.12); color: #fda4af; border-color: rgba(244, 63, 94, 0.3); }
.inp, .sel, .ta { width: 100%; padding: 10px 14px; border-radius: 12px; background: rgba(9, 10, 15, 0.6); border: 1px solid #2a3048; color: var(--txt); font-size: 13.5px; font-family: var(--font); }
.inp:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--cyan); }
.ta { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.lbl { display: block; font-size: 12px; color: var(--mut); margin: 12px 0 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.ok { background: rgba(16, 185, 129, 0.15); color: var(--green); border: 1px solid rgba(16, 185, 129, 0.35); }
.pill.bad { background: rgba(244, 63, 94, 0.12); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.35); }
.pill.warn { background: rgba(245, 158, 11, 0.12); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.35); }
.pill.info { background: rgba(0, 243, 255, 0.1); color: var(--cyan); border: 1px solid rgba(0, 243, 255, 0.3); }
.kpi .v { font-size: 26px; font-weight: 800; margin: 4px 0; }
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mut); }
.bar { height: 6px; background: #22283a; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.chatlog { display: flex; flex-direction: column; gap: 12px; max-height: 52vh; overflow-y: auto; padding: 6px 2px; }
.msg { max-width: 78%; padding: 12px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.msg.u { align-self: flex-end; background: rgba(0, 243, 255, 0.12); border: 1px solid rgba(0, 243, 255, 0.25); border-bottom-right-radius: 6px; }
.msg.a { align-self: flex-start; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg img.prev { max-width: 100%; border-radius: 10px; margin-top: 8px; cursor: zoom-in; border: 1px solid var(--line); }
.cmdbar { position: sticky; bottom: 12px; display: flex; gap: 10px; align-items: center; background: rgba(13, 17, 23, 0.95); border: 1px solid var(--line); border-radius: 18px; padding: 10px 12px; margin-top: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-size: 11.5px; background: rgba(0, 243, 255, 0.1); border: 1px solid rgba(0, 243, 255, 0.3); color: var(--cyan); padding: 4px 10px; border-radius: 999px; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal.on { display: flex; }
.modal img { max-width: 100%; border-radius: 12px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.rowitem { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.rowitem .grow { flex: 1; min-width: 0; }
.rowitem .t { font-weight: 600; font-size: 13.5px; }
.rowitem .s { font-size: 12px; color: var(--mut); margin-top: 2px; }
.av { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; background: rgba(139, 92, 246, 0.15); border: 1px solid rgba(139, 92, 246, 0.4); color: var(--violet); flex-shrink: 0; }
.toast { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast div { background: rgba(13, 17, 23, 0.95); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13px; }
pre.code { background: #080a10; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12px; overflow-x: auto; font-family: var(--mono); }
.mut { color: var(--mut); } .sm { font-size: 12px; } .mono { font-family: var(--mono); }
.mt { margin-top: 12px; } .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
/* Async GGUF download progress */
.dlcard { background: rgba(9, 10, 15, 0.6); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.bar.dbar { height: 12px; border-radius: 99px; background: #161b2c; border: 1px solid rgba(0, 243, 255, 0.18); }
.bar.dbar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #06b6d4, #00f3ff); box-shadow: 0 0 12px rgba(0, 243, 255, 0.55); transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1); }
#ggufList input[type="radio"] { accent-color: #00f3ff; width: 16px; height: 16px; cursor: pointer; }

/* ================= Pinned footer: active engine / model / GGUF ================= */
#mccFoot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
  background: rgba(10, 12, 20, 0.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px); }
#mccFoot .fin { display: flex; align-items: center; gap: 8px; padding: 7px 16px;
  font-size: 12px; max-width: 100%; overflow: hidden; }
#mccFoot .flab { color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 10px; white-space: nowrap; }
#mccFoot b { color: var(--txt); font-weight: 600; max-width: 42vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#mccFoot .fsep { width: 1px; height: 14px; background: var(--line); flex-shrink: 0; }
#mccFoot .fdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--dim); }
#mccFoot .fdot.ok { background: var(--green); box-shadow: 0 0 8px rgba(16, 185, 129, 0.7); }
#mccFoot .fdot.bad { background: var(--red); box-shadow: 0 0 8px rgba(244, 63, 94, 0.8); }
#mccFoot .fdot.warn { background: var(--amber); box-shadow: 0 0 8px rgba(245, 158, 11, 0.7); }
/* leave room so content never hides behind the footer */
.main { padding-bottom: 56px; }
@media (max-width: 900px) { .main { padding-bottom: 64px; } #mccFoot .fsep, #mccFoot .flab { display: none; } }

/* ================= Visible errors (no more silent empty panels) ================= */
.errbox { background: rgba(244, 63, 94, 0.08); border: 1px solid rgba(244, 63, 94, 0.4);
  border-left: 3px solid var(--red); border-radius: 10px; padding: 12px 14px;
  font-size: 13px; color: #ffe4e6; }

/* ================= Chat: locked composer + real scroll ================= */
/* Base (non :has) rule: flex-height, never 100vh — the :has() full-bleed block above wins when active */
#v-chat .card.chatcard { display: flex; flex-direction: column; padding: 14px;
  height: auto; min-height: 320px; max-height: 100%; flex: 1 1 auto; overflow: hidden; }
#v-chat .chatlog { flex: 1 1 auto; min-height: 120px; max-height: none;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #2a2f42 var(--bg1); }
#v-chat .chatlog::-webkit-scrollbar { width: 10px; }
#v-chat .chatlog::-webkit-scrollbar-track { background: var(--bg1); border-radius: 6px; }
#v-chat .chatlog::-webkit-scrollbar-thumb { background: #3a4160; border-radius: 6px; }
#v-chat .chatlog::-webkit-scrollbar-thumb:hover { background: var(--cyan-d); }
#v-chat .composer { flex-shrink: 0; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line); background: rgba(19, 23, 34, 0.9); }
#v-chat .cmdbar { position: static; align-items: flex-end; margin-top: 0;
  background: transparent; border: none; padding: 0; }
#v-chat #chatInp { flex: 1; min-height: 44px; max-height: 168px; resize: none;
  line-height: 1.5; font-size: 14px; padding: 12px 14px; overflow-y: auto;
  font-family: var(--font); }
#v-chat #btnSend, #v-chat #btnAttach { height: 44px; flex-shrink: 0; }
@media (max-width: 900px) { #v-chat .card.chatcard { min-height: 320px; max-height: 100%; } }

/* Scrollable list boxes (model catalog, long panels) */
.scrollbox { max-height: 340px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #2a2f42 var(--bg1); padding-right: 4px; }
.scrollbox::-webkit-scrollbar { width: 10px; }
.scrollbox::-webkit-scrollbar-track { background: var(--bg1); border-radius: 6px; }
.scrollbox::-webkit-scrollbar-thumb { background: #3a4160; border-radius: 6px; }
.scrollbox::-webkit-scrollbar-thumb:hover { background: var(--cyan-d); }


/* ================= Text size (accessibility: dyslexia / ADHD) ================= */
.tsize { padding: 10px 18px; border-top: 1px solid var(--line); }
.tsize .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--dim); display: block; margin-bottom: 6px; }
.tsize .btn { flex: 1; justify-content: center; }
.tsize .btn.on { background: rgba(0, 243, 255, 0.12); border-color: rgba(0, 243, 255, 0.3);
  color: var(--cyan); }
html[data-tsize="1"] body { font-size: 17px; }
html[data-tsize="1"] .msg { font-size: 15px; line-height: 1.75; }
html[data-tsize="1"] .card p, html[data-tsize="1"] .hd p { font-size: 15px; }
html[data-tsize="2"] body { font-size: 19px; }
html[data-tsize="2"] .msg { font-size: 16.5px; line-height: 1.9; }
html[data-tsize="2"] .card p, html[data-tsize="2"] .hd p { font-size: 16.5px; }
html[data-tsize="2"] .nav button { font-size: 15.5px; padding: 12px; }
html[data-tsize="1"], html[data-tsize="2"] { scroll-behavior: smooth; }

/* ================= Plan/Act Toggle ================= */
#chatModeLabel { margin-right: 8px; }
#btnPlanAct { display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.2s ease; }
#btnPlanAct[data-mode="plan"] { background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3); color: var(--violet); }
#btnPlanAct[data-mode="act"] { background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3); color: var(--green); }
#btnPlanAct:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

/* ================= Chat Messages: markdown, timestamps, copy ================= */
.msg { position: relative; }
.msg-content { line-height: 1.6; }
.msg-content pre { background: #080a10; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; overflow-x: auto; font-size: 12px; font-family: var(--mono); }
.msg-content code { background: rgba(0, 243, 255, 0.08); padding: 2px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 0.9em; }
.msg-content pre code { background: transparent; padding: 0; }
.msg-content h1, .msg-content h2, .msg-content h3 { margin: 12px 0 8px; }
.msg-content ul, .msg-content ol { margin: 8px 0; padding-left: 24px; }
.msg-content li { margin: 4px 0; }
.msg-content blockquote { border-left: 3px solid var(--cyan); padding-left: 12px;
  margin: 12px 0; color: var(--mut); }
.msg-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.msg-content th, .msg-content td { border: 1px solid var(--line); padding: 8px 12px; }
.msg-content th { background: var(--bg2); }

.msg-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--line); font-size: 11px; color: var(--dim); }
.msg-time { font-family: var(--mono); }
.msg-copy { background: transparent; border: 1px solid var(--line); color: var(--mut);
  padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 11px; }
.msg-copy:hover { background: rgba(0, 243, 255, 0.1); border-color: var(--cyan); color: var(--cyan); }
.msg-copy.copied { background: var(--green); border-color: var(--green); color: #000; }

/* Typing indicator */
#typingNow { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ================= CHAT LAYOUT FIX: Full-width, footer-safe, no overlap ================= */

/* SINGLE source: bounded flex column, footer-safe (topbar ~53px + fixed footer) */
.work { min-height: 0; }
.main:has(#v-chat.on) {
  max-width: none;
  margin: 0;
  padding: 0 0 56px 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 53px);
  max-height: calc(100vh - 53px);
}

/* Hide non-chat content in chat view */
.main:has(#v-chat.on) > section.view:not(#v-chat) {
  display: none;
}

/* Chat card fills parent flex row (not 100vh) so composer stays visible above footer */
.main:has(#v-chat.on) > #v-chat.view.on {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
}
.main:has(#v-chat.on) #v-chat.view.on .card.chatcard {
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  border-radius: 0;
  border: none;
  background: var(--bg0);
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Chat header */
#v-chat.view.on .card.chatcard > .hd {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--bg1);
}

/* Chat log fills all available space */
#v-chat.view.on .chatlog {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  max-height: none;
}

/* Composer fixed at bottom of card (NOT sticky) — never shrink, always visible */
#v-chat.view.on .composer {
  flex-shrink: 0;
  flex-grow: 0;
  min-height: fit-content;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg1);
}

#v-chat.view.on .cmdbar {
  position: static !important;
  background: transparent;
  border: none;
  padding: 0;
  margin-top: 0;
  align-items: flex-end;
}

#v-chat.view.on #chatInp {
  flex: 1;
  min-height: 44px;
  max-height: 200px;
  resize: none;
  line-height: 1.5;
  font-size: 14px;
  padding: 12px 16px;
  overflow-y: auto;
  font-family: var(--font);
  border-radius: 12px;
  background: rgba(9, 10, 15, 0.8);
  border: 1px solid #2a3048;
  color: var(--txt);
}

#v-chat.view.on #btnSend,
#v-chat.view.on #btnAttach {
  height: 48px;
  flex-shrink: 0;
}

/* Message styling for full-width chat */
#v-chat.view.on .msg {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#v-chat.view.on .msg.u {
  align-self: flex-end;
  background: rgba(0, 243, 255, 0.12);
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-bottom-right-radius: 6px;
}

#v-chat.view.on .msg.a {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

#v-chat.view.on .msg-content {
  line-height: 1.7;
}

#v-chat.view.on .msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
  font-size: 11px;
  color: var(--dim);
}

#v-chat.view.on .msg-time {
  font-family: var(--mono);
  font-size: 10px;
}

#v-chat.view.on .msg-copy {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--mut);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

#v-chat.view.on .msg-copy:hover {
  background: rgba(0, 243, 255, 0.1);
  border-color: var(--cyan);
  color: var(--cyan);
}

#v-chat.view.on .msg-copy.copied {
  background: var(--green);
  border-color: var(--green);
  color: #000;
}

/* Chat log scrollbar */
#v-chat.view.on .chatlog {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: #3a4160 var(--bg1);
}

#v-chat.view.on .chatlog::-webkit-scrollbar { width: 8px; }
#v-chat.view.on .chatlog::-webkit-scrollbar-track { background: transparent; }
#v-chat.view.on .chatlog::-webkit-scrollbar-thumb {
  background: #3a4160;
  border-radius: 4px;
  border: 2px solid var(--bg0);
}
#v-chat.view.on .chatlog::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-d);
}

/* Override old sticky composer behavior for chat */
#v-chat.view.on .cmdbar {
  position: static !important;
}

/* Action buttons row stacked under the chat input */
.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  align-items: flex-start;
}
.action-row .btn {
  flex-shrink: 0;
}
#v-chat.view.on .action-row {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 8px;
}

/* (Duplicate .main:has(#v-chat.on) block removed — single source above wins.) */

/* Mobile adjustments */
@media (max-width: 900px) {
  .main:has(#v-chat.on) {
    padding-bottom: 64px;
  }
  .main:has(#v-chat.on) #v-chat.view.on .card.chatcard {
    max-height: 100%;
  }
}

/* Footer spacing handled by main padding */
.main {
  padding-bottom: 56px;
}

@media (max-width: 900px) {
  .main { padding-bottom: 64px; }
}

/* ================= Toggle Switches ================= */
.accessibility-toggles {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 8px 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--txt);
}

.toggle input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  position: relative;
  transition: all 0.2s ease;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--txt);
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle input:checked + .toggle-slider {
  background: var(--cyan);
  border-color: var(--cyan);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
  background: #06080f;
}

.toggle-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--mut);
  white-space: nowrap;
}

.toggle input:checked + .toggle-slider + .toggle-label {
  color: var(--cyan);
  font-weight: 600;
}

.accessibility-toggles {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 8px 0;
}

/* Chat input area - ensure proper spacing */
#v-chat.view.on .cmdbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

#v-chat.view.on .accessibility-toggles {
  width: 100%;
  order: -1;
}

#v-chat.view.on #chatInp {
  flex: 1;
  min-height: 44px;
  max-height: 200px;
}

#v-chat.view.on #btnSend,
#v-chat.view.on #btnAttach {
  height: 44px;
  flex-shrink: 0;
}

#v-chat.view.on #btnPlanAct {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

/* Toggle button states */
#btnPlanAct[data-mode="plan"] {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
  color: var(--violet);
}

#btnPlanAct[data-mode="act"] {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green);
}

#btnPlanAct:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ================= File Cabinet / Link Auditor ================= */
.agent-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.agent-card:hover {
  border-color: var(--cyan);
  box-shadow: 0 4px 16px rgba(0, 243, 255, 0.08);
}

.agent-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.agent-info {
  flex: 1;
  min-width: 0;
}

.agent-url {
  font-size: 12px;
  color: var(--mut);
  word-break: break-all;
  font-family: var(--mono);
  margin-bottom: 6px;
}

.agent-progress {
  height: 6px;
  background: var(--bg1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.agent-progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width 0.3s ease;
  border-radius: 3px;
}

.agent-status {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
}

/* Audit Library Cards */
.audit-card {
  border-left: 3px solid var(--cyan);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg2);
  border-radius: 0 var(--r) var(--r) 0;
  transition: transform 0.2s, box-shadow 0.2s;
}
.audit-card:hover {
  transform: translateX(4px);
  box-shadow: 4px 0 16px rgba(0, 243, 255, 0.1);
}
.audit-card.compatible { border-left-color: var(--green); }
.audit-card.conditional { border-left-color: var(--amber); }
.audit-card.incompatible { border-left-color: var(--red); }
.audit-card.informational { border-left-color: var(--violet); }

.audit-badge {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
  font-weight: 600;
  background: rgba(0, 243, 255, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(0, 243, 255, 0.3);
}
.audit-card.compatible .audit-badge { background: rgba(16, 185, 129, 0.15); color: var(--green); border-color: rgba(16, 185, 129, 0.3); }
.audit-card.conditional .audit-badge { background: rgba(245, 158, 11, 0.15); color: var(--amber); border-color: rgba(245, 158, 11, 0.3); }
.audit-card.incompatible .audit-badge { background: rgba(244, 63, 94, 0.15); color: var(--red); border-color: rgba(244, 63, 94, 0.3); }
.audit-card.informational .audit-badge { background: rgba(139, 92, 246, 0.15); color: var(--violet); border-color: rgba(139, 92, 246, 0.3); }

.audit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.audit-tag {
  font-size: 10px;
  background: var(--bg1);
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 99px;
  color: var(--mut);
  transition: all 0.2s;
}
.audit-tag:hover {
  background: var(--cyan);
  color: #06080f;
  border-color: var(--cyan);
}

/* Detail Modal */
#cabinetDetailModal .box {
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.cursor { cursor: pointer; }

/* Scrollbar for agent grid */
#agentGrid {
  max-height: 60vh;
  overflow-y: auto;
}
#agentGrid::-webkit-scrollbar { width: 6px; }
#agentGrid::-webkit-scrollbar-track { background: var(--bg1); }
#agentGrid::-webkit-scrollbar-thumb { background: #2a2f42; border-radius: 3px; }
#agentGrid::-webkit-scrollbar-thumb:hover { background: var(--cyan-d); }


/* Progress bar for File Cabinet audits */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary, #1e1e2e);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  margin: 4px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent, #00d4aa), var(--accent-bright, #00ffcc));
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}
.progress-fill.bad {
  background: linear-gradient(90deg, var(--danger, #ff4757), var(--danger-bright, #ff6b7a));
}
.progress-text {
  position: absolute;
  right: 4px;
  top: -18px;
  font-size: 10px;
  color: var(--text-muted, #888);
  font-family: var(--font-mono, monospace);
}

/* Agent card progress integration */
.agent-card .progress-bar {
  margin: 6px 0 4px;
}


/* ===== FEATURE PANEL MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.on {
  display: flex;
}

.modal .box.card {
  background: var(--bg-elevated, #1a1a1a);
  border: 1px solid var(--border, #333);
  border-radius: var(--radius-lg, 16px);
  max-height: 85vh;
  overflow-y: auto;
  width: 100%;
  max-width: 500px;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal .box.card .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal .box.card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal .box.card h3 i {
  width: 20px;
  height: 20px;
}

.modal .btn-icon {
  padding: 6px;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.modal .btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--fg);
}

/***** FEATURE PANEL GRID *****/
.feature-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border: 1px solid var(--border, #333);
  border-radius: var(--radius-md, 12px);
  background: var(--bg, #0d0d0d);
  color: var(--fg, #f5f5f5);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.feature-item:hover {
  border-color: var(--accent, #22d3ee);
  background: var(--bg-hover, #1a1a1a);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.15);
}

.feature-item:active {
  transform: scale(0.98);
}

.feature-item i {
  width: 28px;
  height: 28px;
  color: var(--accent, #22d3ee);
  margin-bottom: 4px;
}

.feature-item span {
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--fg);
}

/***** FEATURE ITEM ACTIVE STATE *****/
.feature-item.active {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.1);
}

/***** MODAL OVERLAY *****/
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.on {
  display: flex;
}

/***** MODAL CLOSE BUTTON *****/
.modal .btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal .btn-icon i {
  width: 18px;
  height: 18px;
}

/***** FEATURE PANEL MODAL SPECIFIC *****/
#featurePanelModal .box.card {
  max-width: 520px;
}

#featurePanelModal .feature-panel-grid {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 480px) {
  #featurePanelModal .feature-panel-grid {
    grid-template-columns: 1fr;
  }
}

/***** FEATURE ITEM ACTIVE STATE FOR TOGGLES *****/
.feature-item.active,
.btn-g.active {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.15);
  color: var(--accent);
}

.btn-g.active i {
  color: var(--accent);
}

/***** TOGGLE BUTTON STATES *****/
.btn-g.active {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.1);
}

.btn-g.active i {
  color: var(--accent);
}

/***** VOICE BUTTON STATES *****/
#btnVoice.active {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.15);
}

#btnVoice.active i {
  color: var(--accent);
}

/***** FEATURE PANEL MODAL ANIMATION *****/
/* Research mode button */
#btnResearch.active {
  border-color: var(--green) !important;
  background: rgba(16, 185, 129, 0.15) !important;
  color: var(--green) !important;
}

#btnResearch.active i {
  color: var(--green) !important;
}

/* Mode-based message highlighting */
.msg.plan {
  border-left: 3px solid var(--cyan) !important;
  background: rgba(0, 243, 255, 0.05) !important;
}

.msg.act {
  border-left: 3px solid var(--green) !important;
  background: rgba(16, 185, 129, 0.08) !important;
}

/* Mode indicator in chat log */
.mode-indicator {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.mode-indicator.plan {
  background: rgba(0, 243, 255, 0.15);
  color: var(--cyan);
}

.mode-indicator.act {
  background: rgba(16, 185, 129, 0.15);
  color: var(--green);
}

/* Research results container */
#researchResults {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border, #333);
  border-radius: var(--radius-md, 12px);
  background: var(--bg, #0d0d0d);
  display: none;
  animation: fadeIn 0.2s ease-out;
}

#researchResults.on {
  display: block;
}

#researchResults h4 {
  margin: 0 0 8px 0;
  color: var(--fg);
}

#researchResults .result-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

#researchResults .result-item:last-child {
  border-bottom: none;
}

#researchResults .result-title {
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 4px;
}

#researchResults .result-url {
  font-size: 12px;
  color: var(--accent, #22d3ee);
  word-break: break-all;
}

#researchResults .result-text {
  font-size: 13px;
  color: var(--mut);
  line-height: 1.4;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal.on {
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Modern segmented Plan/Act toggle */
.mode-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: rgba(255,255,255,0.03); }
.mode-seg-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0; color: var(--mut); font-size: 12px; font-weight: 700; padding: 6px 12px; cursor: pointer; font-family: var(--font); }
.mode-seg-btn i { width: 14px; height: 14px; }
.mode-seg-btn.is-active[data-setmode="plan"] { background: rgba(0,243,255,0.16); color: var(--cyan); }
.mode-seg-btn.is-active[data-setmode="act"] { background: rgba(16,185,129,0.18); color: var(--green); }
#btnPlanAct.is-plan { box-shadow: inset 0 0 0 1px rgba(0,243,255,0.25); }
#btnPlanAct.is-act { box-shadow: inset 0 0 0 1px rgba(16,185,129,0.35); }
.research-head { display: flex; align-items: center; justify-content: space-between; }
.research-head h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.research-controls { display: flex; gap: 8px; margin-bottom: 8px; }
.research-controls .inp { flex: 1; }
#researchResults .result-url { display: block; }

/* PANEL FIX: nav always clickable, keyboard focus visible */
#nav{position:relative;z-index:5;}
#nav button:focus-visible{outline:2px solid var(--cyan);outline-offset:2px;}
body.show-left .side,body.show-right .rside{animation:up .2s ease-out;}

/* :has() fallback for chat full-bleed */
#v-chat.view.on{display:flex;flex-direction:column;min-height:0;}
#v-chat.view.on .card.chatcard{flex:1;min-height:0;}

/* OBEY-YOU: plan announcement + Allow/Reject approval rows */
.plan-notice { margin: 8px 0; padding: 10px 12px; border: 1px solid rgba(245,158,11,.45); background: rgba(245,158,11,.08); border-radius: 12px; font-size: 13px; }
.plan-notice b { color: var(--amber); }
.plan-notice .approval-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }


/* Agent Task Tab Styles */
.agent-task-container { display: flex; flex-direction: column; gap: 12px; }
.agent-task-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.agent-task-header h3 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.agent-task-title { font-size: 1.1rem; font-weight: 600; }
.agent-task-progress { flex: 1; min-width: 120px; }
.agent-task-progress > span { font-size: 0.9rem; min-width: 40px; text-align: right; }
.agent-task-log,
.agent-task-chat-log { flex: 1; min-height: 120px; overflow-y: auto; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg1); }
.agent-task-chat { display: flex; flex-direction: column; gap: 8px; min-height: 260px; }
.agent-task-chat-composer { display: flex; gap: 8px; margin-top: auto; }
.agent-task-chat-input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg1); color: var(--txt); }
.agent-task-chat-composer .btn { padding: 8px 12px; }

/* Stats grid alignment */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-card { display: flex; flex-direction: column; justify-content: center; padding: 16px; background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r); }

/* Empty states */
.empty-state { color: var(--mut); font-style: italic; text-align: center; padding: 24px; }

/* Simulation log scroll container */
.log-content { max-height: 300px; overflow-y: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg1); }

/* Focus indicators for keyboard navigation */
button:focus, input:focus, select:focus, textarea:focus, a:focus {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ===== SIMULATION LABORATORY ===== */
.simulation-container { display: flex; flex-direction: column; gap: 12px; }
.simulation-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.simulation-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.simulation-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.simulation-dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; width: 100%; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-family: var(--mono); color: var(--txt); }
.simulation-log, .simulation-steps { display: flex; flex-direction: column; gap: 8px; min-height: 220px; }
.simulation-timer { font-family: var(--mono); font-size: 12px; color: var(--mut); }
.step-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg1); font-size: 13px; }
.step-item.step-completed { border-color: var(--green); }
.step-item.step-failed { border-color: var(--danger); }
.step-item.step-running { border-color: var(--cyan); }
.step-name { font-weight: 600; color: var(--txt); }
.step-message { color: var(--mut); font-size: 12.5px; }
.step-time, .step-info { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-left: auto; }
.steps-content { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 300px; }
.steps-header { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--mut); margin-bottom: 4px; }
.timer-display { font-family: var(--mono); font-size: 1.25rem; font-weight: 700; }

/* ===== STUDIO HUB ===== */
.studio-container { display: flex; flex-direction: column; gap: 12px; }
.studio-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.studio-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.studio-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.studio-body,
.studio-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; width: 100%; }
.studio-file-item, .file-card { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg1); padding: 12px; }
.studio-preview { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg1); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.preview-image { max-width: 100%; max-height: 240px; border-radius: 6px; background: var(--bg2); }
.file-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.file-name { font-weight: 600; color: var(--txt); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-type-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(125,125,125,0.15); color: var(--mut); }
.file-info-detail { font-size: 12px; color: var(--mut); font-family: var(--mono); }
.file-meta { font-size: 11.5px; color: var(--dim); font-family: var(--mono); }
.file-content { font-family: var(--mono); font-size: 12px; overflow-x: auto; }
.file-actions { display: flex; gap: 6px; margin-top: 8px; }
.filter-container, .sort-container, .search-container { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.view-toggle { display: flex; gap: 4px; }
.empty-state, .loading, .error { text-align: center; color: var(--mut); padding: 24px; font-size: 13px; }
.error { color: var(--danger); text-align: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(244,63,94,0.08); }

/* ===== NOTIFICATIONS (Simulation / Agent Office alerts) ===== */
.notification {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px; border-radius: var(--r); margin: 8px 0;
  animation: slideIn 0.2s ease-out; font-size: 13px;
}
.notification-info { background: rgba(0,243,255,0.10); border: 1px solid var(--cyan); color: var(--txt); }
.notification-success { background: rgba(16,185,129,0.10); border: 1px solid var(--green); color: #6ee7b7; }
.notification-warning { background: rgba(245,158,11,0.10); border: 1px solid var(--amber); color: #fcd34d; }
.notification-error, .notification-red { background: rgba(244,63,94,0.10); border: 1px solid var(--danger); color: #fda4af; }
@keyframes slideIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== BADGE SMALL (Auto-Provisioned skill badge) ===== */
.badge-sm { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px;
  border-radius: 999px; font-size: 10px; font-weight: 700; }
.badge-sm.warn { background: rgba(245,158,11,0.15); border: 1px solid var(--amber); color: #fcd34d; }

/* ===== FLOATING NOTIFICATION & QUICK CHAT WIDGET ===== */
.mickey-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: var(--font);
  /* Explicit size to contain absolute children; overflow visible for drawer/toast */
  width: 56px;
  height: 56px;
  overflow: visible;
}
.widget-fab {
  position: absolute;
  top: 0;
  right: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--cyan), #06b6d4);
  color: #002028;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 243, 255, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.widget-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(0, 243, 255, 0.6);
}
.widget-fab i {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}
.widget-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #090a0f;
  animation: badgeBounce 0.5s ease-out;
}
.widget-badge.zero, .widget-badge:empty { display: none; }
@keyframes badgeBounce {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
.widget-toast {
  position: absolute;
  right: 0;
  bottom: 70px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.widget-toast div {
  background: rgba(13, 17, 23, 0.97);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--txt);
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  pointer-events: auto;
  max-width: 280px;
  animation: toastSlide 0.35s cubic-bezier(0.2,0,0,1) both;
}
.widget-toast div.warn { border-left-color: var(--amber); }
.widget-toast div.error, .widget-toast div.red { border-left-color: var(--red); }
.widget-toast div.ok, .widget-toast div.success { border-left-color: var(--green); }
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(40px) translateY(6px); }
  to { opacity: 1; transform: none; }
}
.widget-drawer {
  position: absolute;
  right: 0;
  bottom: 135px;
  width: 360px;
  height: 520px;
  background: rgba(14, 17, 23, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.widget-drawer.widget-closed {
  transform: translateY(120%) scale(0.95);
  opacity: 0;
  pointer-events: none;
}
.widget-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 23, 0.98);
}
.widget-drawer-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--txt);
  display: flex;
  align-items: center;
  gap: 8px;
}
.widget-drawer-title i { width: 16px; height: 16px; color: var(--cyan); }
.widget-btn-min {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  color: var(--mut);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.widget-btn-min:hover { background: rgba(255,255,255,0.12); color: var(--txt); }
.widget-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.widget-messages { display: flex; flex-direction: column; gap: 10px; }
.widget-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.widget-msg.you {
  align-self: flex-end;
  background: rgba(0, 243, 255, 0.12);
  border: 1px solid rgba(0, 243, 255, 0.25);
}
.widget-msg.mickey {
  align-self: flex-start;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}
.widget-drawer-footer {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: rgba(14, 17, 23, 0.98);
}
.widget-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #313852;
  background: rgba(9, 10, 15, 0.6);
  color: var(--txt);
  font-size: 13px;
  font-family: var(--font);
}
.widget-input:focus { outline: none; border-color: var(--cyan); }
.widget-btn-send {
  background: var(--cyan);
  color: #002028;
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.widget-btn-send:hover { filter: brightness(1.15); }
.widget-btn-send i { width: 18px; height: 18px; stroke-width: 2; }
.widget-drawer-body::-webkit-scrollbar { width: 7px; }
.widget-drawer-body::-webkit-scrollbar-thumb { background: #2a2f42; border-radius: 4px; }
   .widget-drawer-body::-webkit-scrollbar { width: 7px; }
   .widget-drawer-body::-webkit-scrollbar-thumb { background: #2a2f42; border-radius: 4px; }

   /* ===== Mickey Attention Animations ===== */
   @keyframes mickeyBlink {
     0%, 80%, 100% { transform: scaleY(1); }
     85%, 90% { transform: scaleY(0.2); }
   }
   @keyframes notifyPulse {
     0%, 100% { transform: scale(1); }
     50% { transform: scale(1.05); }
   }
   @keyframes badgeShake {
     0%, 100% { transform: translateX(0); }
     20% { transform: translateX(-2px); }
     40% { transform: translateX(2px); }
     60% { transform: translateX(-2px); }
     80% { transform: translateX(2px); }
   }
   @keyframes notifyPing {
     0% { transform: scale(0); opacity: 0.4; }
     70% { transform: scale(1.5); opacity: 0; }
     100% { transform: scale(2); opacity: 0; }
   }

   /* Notification pulse on FAB when unread > 0 */
   .widget-fab.notify {
     animation: notifyPulse 2s ease-in-out infinite;
   }
   .widget-fab.notify .widget-fab i {
     animation: mickeyBlink 4s ease-in-out infinite;
   }
   /* Active badge gets a gentle shake */
   .widget-badge.active {
     animation: badgeShake 0.6s ease-in-out infinite;
   }
   /* Ping ripple behind FAB when notification arrives */
   .widget-fab.notify-ping::after {
     content: '';
     position: absolute;
     inset: 0;
     border-radius: 50%;
     border: 2px solid var(--red);
     animation: notifyPing 1.5s ease-out;
     pointer-events: none;
   }


/* ================= SILENT SCANNER STYLES ================= */
.tbl-wrap {
  overflow-x: auto;
  margin-top: 12px;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  background: var(--bg2);
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--cyan);
  white-space: nowrap;
}
.tbl td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
}
.tbl tr:hover td {
  background: rgba(0, 243, 255, 0.03);
}
.tbl .mono {
  font-family: var(--mono);
  font-size: 12px;
}
.tbl .s.mut {
  font-size: 11px;
  opacity: 0.7;
}
.tbl .pill {
  font-size: 11px;
  padding: 4px 8px;
}
.execute-btn {
  min-width: 80px;
}
#scannerControlCard {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(0, 243, 255, 0.05));
}
#scannerControlCard h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--violet);
}
#scannerMetrics .card {
  text-align: center;
  padding: 16px;
  background: var(--bg1);
  border-radius: 12px;
  border: 1px solid var(--line);
}
#scannerMetrics h4 {
  font-size: 11px;
  color: var(--mut);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#scannerMetrics .t.mono {
  font-size: 24px;
  font-weight: 700;
  color: var(--cyan);
}
#opportunityTable .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
#opportunityTable h3 {
  margin: 0;
  color: var(--txt);
}
#scannerSearch, #opportunityFilter {
  flex-shrink: 0;
}
