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

:root {
    /* LIGHT THEME (Default) */
    --bg: #F8FAFC;
    --sidebar: #FFFFFF;
    --card: #FFFFFF;
    --text-main: #0F172A;
    --text-dim: #64748B;
    --accent: #0284C7; /* Medical Blue */
    --accent-dark: #0369A1;
    --accent-light: #E0F2FE;
    --border: #E2E8F0;
    --input-bg: #FFFFFF;
    --msg-user: #0284C7;
    --msg-user-text: #FFFFFF;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

/* DARK THEME OVERRIDES */
body.dark-mode {
    --bg: #0F172A;
    --sidebar: #1E293B;
    --card: #1E293B;
    --text-main: #F1F5F9;
    --text-dim: #94A3B8;
    --border: #334155;
    --input-bg: #1E293B;
    --msg-user: #38BDF8;
    --msg-user-text: #0F172A;
    --accent-light: #1E293B;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text-main); height: 100vh; overflow: hidden; transition: background 0.2s; }

/* === LAYOUT === */
.app-layout { display: flex; height: 100%; width: 100%; }

/* SIDEBAR */
.sidebar { 
    width: 280px; background: var(--sidebar); border-right: 1px solid var(--border); 
    display: flex; flex-direction: column; padding: 20px; 
    z-index: 50; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; color: var(--text-main); }
.logo-icon { width: 40px; height: 40px; background: var(--accent); color: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.brand-text { font-weight: 700; font-size: 18px; letter-spacing: -0.5px; }
.pro-tag { background: #F59E0B; color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 4px; vertical-align: middle; letter-spacing: 0.5px; }

.new-chat-btn { width: 100%; padding: 14px; background: var(--accent); color: #fff; border: none; border-radius: 10px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 24px; transition: 0.2s; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3); }
.new-chat-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }

.nav-section { margin-bottom: 24px; flex: 1; overflow-y: auto; min-height: 0; }
.nav-label { font-size: 11px; text-transform: uppercase; color: var(--text-dim); font-weight: 700; margin-bottom: 8px; letter-spacing: 0.5px; padding-left: 10px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; background: transparent; border: none; color: var(--text-dim); cursor: pointer; border-radius: 8px; transition: 0.2s; text-align: left; font-weight: 500; }
.nav-item:hover { background: var(--bg); color: var(--accent); }

/* HISTORY LIST */
.hist-item { padding: 10px; display: flex; align-items: center; gap: 12px; cursor: pointer; border-radius: 8px; color: var(--text-main); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; transition: 0.2s; }
.hist-item:hover { background: var(--bg); }
.hist-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.hist-item .icon { font-size: 18px; color: var(--text-dim); }

/* USER PANEL (PFP) */
.user-panel { border-top: 1px solid var(--border); padding-top: 15px; display: flex; align-items: center; gap: 12px; }
.u-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.u-info { flex: 1; overflow: hidden; }
.u-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-link { font-size: 12px; color: var(--text-dim); text-decoration: none; }
.u-link:hover { color: var(--accent); }
.u-logout { color: #EF4444; text-decoration: none; opacity: 0.7; padding: 5px; }
.u-logout:hover { opacity: 1; background: rgba(239, 68, 68, 0.1); border-radius: 6px; }

/* === WORKSPACE === */
.workspace { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--bg); transition: 0.2s; }

/* TOP BAR */
.top-bar { height: 68px; background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; z-index: 40; }
.mode-selector { display: flex; align-items: center; gap: 10px; background: var(--bg); padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); transition: 0.2s; }
.mode-selector:hover { border-color: var(--accent); }
.mode-icon { color: var(--accent); }
#mode-select { background: transparent; border: none; font-weight: 700; color: var(--text-main); font-size: 14px; outline: none; cursor: pointer; }
.icon-btn { background: transparent; border: 1px solid var(--border); width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-dim); transition: 0.2s; }
.icon-btn:hover { background: var(--bg); color: var(--text-main); border-color: var(--text-dim); }

/* CHAT CANVAS */
.chat-canvas { flex: 1; overflow-y: auto; padding: 30px; display: flex; flex-direction: column; gap: 24px; scroll-behavior: smooth; }
.welcome-screen { margin: auto; text-align: center; color: var(--text-dim); animation: fadeIn 0.5s ease-out; }
.ws-icon { font-size: 80px; color: var(--border); margin-bottom: 20px; }
.welcome-screen h1 { color: var(--text-main); margin-bottom: 10px; }
.quick-chips { display: flex; gap: 10px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.chip { background: var(--card); border: 1px solid var(--border); padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 500; cursor: pointer; transition: 0.2s; }
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* BUBBLES */
.msg-row { display: flex; gap: 16px; width: 100%; max-width: 850px; margin: 0 auto; animation: slideUp 0.2s ease-out; }
@keyframes slideUp { from {opacity:0; transform:translateY(10px);} to {opacity:1; transform:translateY(0);} }
.ai-row { align-items: flex-start; }
.user-row { justify-content: flex-end; }

.avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; font-weight: bold; }
.ai-av { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); box-shadow: 0 4px 10px rgba(2, 132, 199, 0.2); }

.bubble { padding: 16px 22px; border-radius: 16px; font-size: 15px; line-height: 1.6; max-width: 85%; box-shadow: var(--shadow); position: relative; }
.ai-bubble { background: var(--card); border: 1px solid var(--border); color: var(--text-main); border-top-left-radius: 4px; }
.user-bubble { background: var(--msg-user); color: var(--msg-user-text); border-bottom-right-radius: 4px; }

/* Markdown Styling */
.ai-bubble h1, .ai-bubble h2, .ai-bubble h3 { margin-top: 15px; margin-bottom: 8px; font-size: 17px; font-weight: 700; }
.ai-bubble ul, .ai-bubble ol { padding-left: 20px; margin: 10px 0; }
.ai-bubble strong { font-weight: 700; color: inherit; }
.ai-bubble code { background: rgba(0,0,0,0.05); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 13px; }

/* INPUT DOCK */
.input-dock { background: var(--card); padding: 20px; border-top: 1px solid var(--border); width: 100%; z-index: 40; }
.input-bar { max-width: 850px; margin: 0 auto; background: var(--input-bg); border: 1px solid var(--border); border-radius: 16px; padding: 8px; display: flex; align-items: flex-end; gap: 8px; box-shadow: var(--shadow); transition: 0.2s; }
.input-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

textarea { flex: 1; background: transparent; border: none; color: var(--text-main); font-size: 16px; resize: none; max-height: 150px; padding: 12px; outline: none; line-height: 1.5; }
.attach-btn, .mic-btn, .send-btn { width: 44px; height: 44px; border-radius: 10px; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; flex-shrink: 0; }
.attach-btn, .mic-btn { background: transparent; color: var(--text-dim); }
.attach-btn:hover, .mic-btn:hover { background: var(--bg); color: var(--text-main); }
.mic-btn.active { color: #EF4444; background: rgba(239, 68, 68, 0.1); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% {box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);} 70% {box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);} 100% {box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);} }
.send-btn { background: var(--accent); color: #fff; }
.send-btn:hover { background: var(--accent-dark); transform: scale(1.05); }

.file-tag { display: inline-flex; align-items: center; gap: 8px; background: var(--accent-light); color: var(--accent); padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; margin-bottom: 12px; max-width: 850px; margin-left: auto; margin-right: auto; animation: slideUp 0.2s; }
.legal-disclaimer { text-align: center; font-size: 11px; color: var(--text-dim); margin-top: 10px; opacity: 0.7; }
.sys-note { text-align: center; font-size: 12px; color: var(--text-dim); margin: 15px 0; font-style: italic; background: var(--bg); padding: 4px 10px; border-radius: 20px; width: fit-content; margin-left: auto; margin-right: auto; border: 1px solid var(--border); }

/* TOOLS OVERLAY */
.tool-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); animation: fadeIn 0.2s; }
.tool-card { background: var(--card); padding: 0; border-radius: 20px; width: 380px; max-width: 90%; border: 1px solid var(--border); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); overflow: hidden; animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.tool-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg); }
.tool-header h3 { margin: 0; color: var(--text-main); font-size: 16px; font-weight: 700; }
.close-tool-btn { background: transparent; border: none; font-size: 24px; color: var(--text-dim); cursor: pointer; line-height: 1; }
.tool-body { padding: 24px; }
.tool-row, .tool-grid { margin-bottom: 20px; }
.tool-row label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; font-weight: 500; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
input[type="number"] { width: 100%; padding: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text-main); border-radius: 8px; outline: none; font-size: 14px; transition: 0.2s; }
input[type="number"]:focus { border-color: var(--accent); }
.tool-act { width: 100%; padding: 14px; background: var(--accent); color: #fff; border: none; border-radius: 10px; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: 14px; }
.tool-act:hover { background: var(--accent-dark); }
.tool-result { margin-top: 20px; text-align: center; font-size: 16px; background: var(--bg); padding: 15px; border-radius: 10px; color: var(--text-main); border: 1px solid var(--border); font-weight: 500; }

/* === MOBILE FIXES === */
/* 1. Mobile Overlay */
.mobile-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45; /* Below sidebar (50) */
    display: none;
    backdrop-filter: blur(2px);
}
.mobile-overlay.active { display: block; animation: fadeIn 0.2s; }

/* 2. Responsive Sidebar */
@media(max-width: 768px) {
    .sidebar { position: fixed; top: 0; left: 0; height: 100%; width: 280px; transform: translateX(-100%); z-index: 50; box-shadow: none; }
    .sidebar.open { transform: translateX(0); box-shadow: 10px 0 30px rgba(0,0,0,0.2); }
    .mob-menu { display: block; background: none; border: none; color: var(--text-main); padding: 0; cursor: pointer; }
    .mob-menu span { font-size: 28px; }
    .top-bar { padding: 0 16px; }
    .chat-canvas { padding: 15px; }
    .msg-row { max-width: 100%; }
    .bubble { max-width: 90%; font-size: 14px; padding: 12px 16px; }
}
@media(min-width: 769px) { .mob-menu { display: none; } }


/* =========================================================
   CityEyeCenter Website-like UI layer (login + top header)
   (added by fix pack)
   ========================================================= */

.cec-auth{min-height:100vh;display:flex;flex-direction:column;}
.cec-sitebar{height:64px;display:flex;align-items:center;justify-content:space-between;padding:0 22px;background:rgba(255,255,255,.70);border-bottom:1px solid rgba(15,23,42,.08);backdrop-filter:blur(10px);position:sticky;top:0;z-index:30}
.cec-brand{display:flex;align-items:center;gap:12px;font-weight:800}
.cec-brand img{width:38px;height:38px;border-radius:12px;object-fit:cover}
.cec-brand small{display:block;font-weight:600;color:var(--text-dim);margin-top:2px}
.cec-auth-wrap{flex:1;display:grid;grid-template-columns:1.15fr .85fr;gap:26px;align-items:center;padding:26px;max-width:1100px;margin:0 auto;width:100%}
.cec-hero h1{margin:0 0 10px 0;font-size:44px;letter-spacing:-0.02em;line-height:1.05}
.cec-hero p{margin:0 0 14px 0;color:var(--text-dim);font-size:15px;max-width:60ch}
.cec-featuregrid{display:grid;grid-template-columns:repeat(1, minmax(0,1fr));gap:10px;margin-top:12px}
.cec-feature{background:rgba(255,255,255,.75);border:1px solid rgba(15,23,42,.08);border-radius:14px;padding:10px 12px;display:flex;flex-direction:column;gap:3px}
.cec-feature b{font-size:13px}
.cec-feature span{font-size:12px;color:var(--text-dim)}
.cec-auth-card{background:rgba(255,255,255,.90);border:1px solid rgba(15,23,42,.08);border-radius:18px;box-shadow:0 16px 40px rgba(15,23,42,.12);padding:18px}
.cec-cardtitle{margin:0 0 6px 0;font-size:18px;letter-spacing:-0.01em}
.cec-alert{background:rgba(220,38,38,.08);border:1px solid rgba(220,38,38,.22);color:#991b1b;border-radius:14px;padding:10px 12px;margin:10px 0;font-weight:600}
.cec-form{margin-top:8px}
.cec-field{display:flex;flex-direction:column;gap:6px;margin:10px 0}
.cec-field label{font-weight:700;font-size:13px}
.cec-field input{height:44px;border-radius:12px;border:1px solid rgba(15,23,42,.14);background:#fff;padding:0 12px;outline:none}
.cec-field input:focus{border-color:rgba(2,132,199,.55);box-shadow:0 0 0 4px rgba(2,132,199,.16)}
.cec-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:12px}
.cec-check{display:flex;align-items:center;gap:8px;color:var(--text-dim);font-size:12px}
.cec-btn{height:44px;padding:0 14px;border-radius:12px;border:1px solid rgba(2,132,199,.35);background:linear-gradient(180deg, rgba(2,132,199,.95), rgba(2,132,199,.88));color:#fff;font-weight:800;cursor:pointer}
.cec-btn:hover{filter:brightness(1.03)}
.cec-muted{color:var(--text-dim);font-size:12px}
.cec-foot{margin-top:10px}
@media (max-width:980px){.cec-auth-wrap{grid-template-columns:1fr}.cec-hero h1{font-size:34px}}

.cec-topbar{height:58px;display:flex;align-items:center;justify-content:space-between;padding:0 16px;background:rgba(255,255,255,.72);border-bottom:1px solid rgba(15,23,42,.08);backdrop-filter:blur(10px);position:sticky;top:0;z-index:40}
.cec-topbrand{display:flex;align-items:center;gap:10px;font-weight:900}
.cec-topbrand img{width:28px;height:28px;border-radius:9px;object-fit:cover}
.cec-pill{display:inline-flex;align-items:center;padding:2px 10px;border-radius:999px;border:1px solid rgba(15,23,42,.10);background:rgba(255,255,255,.85);font-weight:800;font-size:12px;color:var(--text-dim)}
.cec-quick{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.cec-qbtn{height:34px;padding:0 10px;border-radius:999px;border:1px solid rgba(15,23,42,.12);background:rgba(255,255,255,.92);color:var(--text-main);font-weight:800;font-size:12px;cursor:pointer}
.cec-qbtn:hover{border-color:rgba(2,132,199,.35);box-shadow:0 0 0 4px rgba(2,132,199,.12)}

/* Palette */
.cec-palette{position:fixed;inset:0;background:rgba(15,23,42,.35);display:flex;align-items:flex-start;justify-content:center;padding-top:10vh;z-index:9999}
.cec-palette.hidden{display:none}
.cec-palette-card{width:min(640px,92vw);background:rgba(255,255,255,.92);border:1px solid rgba(15,23,42,.10);border-radius:18px;box-shadow:0 22px 70px rgba(15,23,42,.25);padding:14px;backdrop-filter:blur(10px)}
.cec-palette-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.cec-palette-title{font-weight:900}
.cec-kbd{font-size:12px;color:var(--text-dim);border:1px solid rgba(15,23,42,.12);border-radius:10px;padding:2px 8px;background:rgba(255,255,255,.8)}
.cec-palette-input{width:100%;height:44px;border-radius:12px;border:1px solid rgba(15,23,42,.14);padding:0 12px;outline:none}
.cec-palette-input:focus{border-color:rgba(2,132,199,.55);box-shadow:0 0 0 4px rgba(2,132,199,.16)}
.cec-palette-list{display:flex;flex-direction:column;gap:8px;margin-top:12px}
.cec-palette-item{width:100%;text-align:left;border-radius:14px;border:1px solid rgba(15,23,42,.10);background:rgba(255,255,255,.86);padding:10px 12px;display:flex;align-items:center;justify-content:space-between;cursor:pointer}
.cec-palette-item:hover{border-color:rgba(2,132,199,.35);box-shadow:0 0 0 4px rgba(2,132,199,.10)}
.cec-palette-item b{font-weight:900}
.cec-palette-item span{color:var(--text-dim);font-weight:700;font-size:12px}


.sidebar-search{width:100%;height:34px;border-radius:12px;border:1px solid var(--border);background:var(--input-bg);padding:0 10px;font-size:12px;margin:10px 0;color:var(--text-main)}
.sidebar-search:focus{outline:none;border-color:rgba(2,132,199,.45);box-shadow:0 0 0 4px rgba(2,132,199,.12)}



/* ===== Patch: topbar + layout height (prevents pushed-down UI) ===== */
body{
  display:flex;
  flex-direction:column;
  height:100vh;
}
.cec-topbar{flex:0 0 auto;}
.app-layout{
  flex:1 1 auto;
  height:auto;
  min-height:0;
}
.workspace{min-height:0;}
.chat-canvas{min-height:0;}



/* ===== CityEyeCenter Super UI (Right Panel + Widgets) ===== */
.workspace{
  display:grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  align-items: stretch;
}
@media (max-width: 980px){
  .workspace{ grid-template-columns: 1fr; }
  .cec-rightpanel{ display:none; }
}

/* Right panel */
.cec-rightpanel{
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15,23,42,.10);
  overflow:hidden;
  min-height: 0;
  display:flex;
  flex-direction:column;
}
.cec-rp-tabs{
  display:flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid rgba(15,23,42,.08);
  background: rgba(248,250,252,.75);
}
.cec-rp-tab{
  flex: 1;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.9);
  font-weight: 800;
  font-size: 12px;
  cursor:pointer;
}
.cec-rp-tab.active{
  border-color: rgba(2,132,199,.35);
  box-shadow: 0 0 0 4px rgba(2,132,199,.12);
}
.cec-rp-body{ padding: 12px; overflow:auto; min-height:0; }
.cec-rp-section{ display:none; }
.cec-rp-section.show{ display:block; }

.cec-rp-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 10px;
}
.cec-rp-title{ font-weight: 900; font-size: 14px; }

.cec-mini{
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,.12);
  background: rgba(255,255,255,.9);
  font-weight: 800;
  font-size: 12px;
  cursor:pointer;
}
.cec-mini:hover{
  border-color: rgba(2,132,199,.35);
  box-shadow: 0 0 0 4px rgba(2,132,199,.10);
}

.cec-input{
  width:100%;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.14);
  padding: 0 12px;
  background: #fff;
  outline:none;
}
.cec-input:focus{
  border-color: rgba(2,132,199,.55);
  box-shadow: 0 0 0 4px rgba(2,132,199,.14);
}
.cec-textarea{
  width:100%;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.14);
  padding: 10px 12px;
  background:#fff;
  outline:none;
  resize: vertical;
  font-family: inherit;
}
.cec-textarea:focus{
  border-color: rgba(2,132,199,.55);
  box-shadow: 0 0 0 4px rgba(2,132,199,.14);
}
.cec-grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px){ .cec-grid2{ grid-template-columns: 1fr; } }
.cec-field2 label{ display:block; font-weight: 800; font-size: 12px; margin: 8px 0 6px; color: var(--text-main); }

.cec-tpl-list, .cec-med-list{
  margin-top: 10px;
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.cec-pill{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92);
  cursor:pointer;
}
.cec-pill:hover{
  border-color: rgba(2,132,199,.35);
  box-shadow: 0 0 0 4px rgba(2,132,199,.10);
}
.cec-pill .t{ font-weight: 900; font-size: 12px; }
.cec-pill .s{ font-size: 11px; color: var(--text-dim); }

.cec-note-box{
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(248,250,252,.9);
  overflow:hidden;
}
.cec-note-actions{
  display:flex;
  justify-content:flex-end;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid rgba(15,23,42,.08);
}
.cec-pre{
  margin:0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 12px;
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  min-height: 120px;
}



/* ===== BEST PATCH: Layout + Dark mode + Chat bubbles ===== */

/* Ensure workspace stays column and right panel floats fixed */
.workspace{ display:flex !important; flex-direction:column !important; }
.chat-canvas{ padding-right: 390px; }
@media (max-width: 980px){
  .chat-canvas{ padding-right: 0; }
}

/* Fixed tools panel */
.cec-rightpanel{
  position: fixed;
  top: 86px; /* below topbar */
  right: 14px;
  bottom: 14px;
  width: 360px;
  z-index: 50;
  background: var(--card);
  border: 1px solid rgba(15,23,42,.10);
}
body.dark-mode .cec-rightpanel{
  border-color: rgba(148,163,184,.18);
}

/* Let user hide it */
body.rp-collapsed .cec-rightpanel{ display:none; }
body.rp-collapsed .chat-canvas{ padding-right: 0; }

/* Right panel header background uses theme vars */
.cec-rp-tabs{
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border-bottom: 1px solid rgba(15,23,42,.08);
}
body.dark-mode .cec-rp-tabs{ border-bottom-color: rgba(148,163,184,.16); }

/* Improve dark mode variables if missing */
body.dark-mode{
  --bg: #0B1220;
  --sidebar: #0F172A;
  --card: #0F172A;
  --text-main: #E5E7EB;
  --text-dim: #94A3B8;
  --accent: #38BDF8;
}

/* Top quick buttons readability */
.cec-qbtn{
  background: var(--card);
  color: var(--text-main);
  border-color: rgba(15,23,42,.12);
}
body.dark-mode .cec-qbtn{
  border-color: rgba(148,163,184,.20);
}

/* ChatGPT-like bubbles */
.msg-row{ gap: 10px; }
.ai-row .bubble{
  background: color-mix(in srgb, var(--card) 92%, #ffffff 8%);
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 16px;
  padding: 12px 14px;
  max-width: 780px;
  line-height: 1.45;
  font-size: 14px;
}
.user-row .bubble{
  background: color-mix(in srgb, var(--accent) 16%, var(--card) 84%);
  border: 1px solid rgba(2,132,199,.25);
  border-radius: 16px;
  padding: 12px 14px;
  max-width: 780px;
  line-height: 1.45;
  font-size: 14px;
}
body.dark-mode .ai-row .bubble{
  border-color: rgba(148,163,184,.18);
}
body.dark-mode .user-row .bubble{
  border-color: rgba(56,189,248,.22);
}

/* Markdown inside bubbles */
.bubble h1,.bubble h2,.bubble h3{ margin: 10px 0 6px; }
.bubble ul{ padding-left: 18px; margin: 8px 0; }
.bubble ol{ padding-left: 18px; margin: 8px 0; }
.bubble code{
  background: rgba(2,132,199,.10);
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 12.5px;
}
.bubble pre{
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 14px;
  padding: 10px 12px;
  overflow:auto;
}
body.dark-mode .bubble pre{
  background: rgba(0,0,0,.25);
  border-color: rgba(148,163,184,.16);
}

/* AI Controls chips + switches */
.cec-chiprow{ display:flex; gap:8px; flex-wrap:wrap; }
.cec-chip{
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(15,23,42,.12);
  background: var(--card);
  color: var(--text-main);
  font-weight: 900;
  font-size: 12px;
  cursor:pointer;
}
.cec-chip.active{
  border-color: rgba(2,132,199,.35);
  box-shadow: 0 0 0 4px rgba(2,132,199,.12);
}
body.dark-mode .cec-chip{ border-color: rgba(148,163,184,.20); }
body.dark-mode .cec-chip.active{ box-shadow: 0 0 0 4px rgba(56,189,248,.14); }

.cec-switchrow{ display:flex; gap:10px; align-items:flex-start; }
.cec-sw-title{ font-weight:900; font-size:12px; }
.cec-sw-sub{ font-size:11px; color: var(--text-dim); margin-top:2px; }

.cec-switch{ position:relative; width:44px; height:26px; }
.cec-switch input{ display:none; }
.cec-slider{
  position:absolute; inset:0;
  background: rgba(15,23,42,.12);
  border-radius: 999px;
  cursor:pointer;
  border: 1px solid rgba(15,23,42,.12);
}
.cec-slider:before{
  content:"";
  position:absolute; width:20px; height:20px; top:2px; left:2px;
  border-radius:50%;
  background:#fff;
  transition: .18s;
}
.cec-switch input:checked + .cec-slider{
  background: rgba(2,132,199,.25);
  border-color: rgba(2,132,199,.35);
}
.cec-switch input:checked + .cec-slider:before{ transform: translateX(18px); }

.cec-iconbtn{
  height: 34px;
  width: 34px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.12);
  background: var(--card);
  display:grid;
  place-items:center;
  cursor:pointer;
  margin-right: 10px;
}
body.dark-mode .cec-iconbtn{ border-color: rgba(148,163,184,.20); }



/* ===== Patients page + quickbar + annotation ===== */
.cec-quickbar{
  position: fixed;
  left: 14px;
  top: 72px;
  display:flex;
  gap:10px;
  z-index: 60;
}
.cec-quickbtn{
  display:flex;
  align-items:center;
  gap:8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  font-weight: 900;
  cursor:pointer;
}
body.dark-mode .cec-quickbtn{
  background: rgba(15,23,42,.72);
  border-color: rgba(148,163,184,.16);
}
.cec-page{max-width:1100px;margin:30px auto;padding:0 16px;}
.cec-pagehead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px;}
.cec-title{font-weight: 900;font-size: 20px;}
.cec-card{background:var(--card);border:1px solid rgba(15,23,42,.10);border-radius:18px;padding:14px;box-shadow:0 10px 30px rgba(15,23,42,.08);}
body.dark-mode .cec-card{border-color: rgba(148,163,184,.16);box-shadow:0 10px 30px rgba(15,23,42,.22);}

.cec-pgrid{display:grid;grid-template-columns: repeat(3, 1fr);gap:12px;}
@media (max-width:980px){.cec-pgrid{grid-template-columns: repeat(2, 1fr);}}
@media (max-width:640px){.cec-pgrid{grid-template-columns: 1fr;}}
.cec-ptile{border:1px solid rgba(15,23,42,.10);border-radius:18px;padding:12px;background:color-mix(in srgb, var(--card) 92%, #fff 8%);}
body.dark-mode .cec-ptile{border-color:rgba(148,163,184,.16);}
.cec-ptop{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;}
.cec-ph{font-weight:900;font-size:14px;}
.cec-ps{color:var(--text-dim);font-size:12px;margin-top:2px;}
.cec-pmeta{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap;}
.cec-badge{font-size:11px;font-weight:900;border:1px solid rgba(15,23,42,.10);padding:4px 8px;border-radius:999px;color:var(--text-main);background:rgba(2,132,199,.08);}
body.dark-mode .cec-badge{border-color:rgba(148,163,184,.16);}
.cec-exlist{margin-top:10px;display:flex;flex-direction:column;gap:8px;}
.cec-exitem{border:1px solid rgba(15,23,42,.10);border-radius:14px;padding:10px;display:flex;align-items:center;justify-content:space-between;gap:10px;}
body.dark-mode .cec-exitem{border-color:rgba(148,163,184,.16);}
.cec-exh{font-weight:900;font-size:12px;}
.cec-exa{display:flex;gap:8px;}

.cec-annot-wrap{border:1px solid rgba(15,23,42,.10);border-radius:16px;overflow:hidden;}
body.dark-mode .cec-annot-wrap{border-color:rgba(148,163,184,.16);}
.cec-annot-toolbar{display:flex;gap:8px;align-items:center;padding:10px;background:rgba(2,132,199,.06);}
.cec-annot-stage{background:#000;display:flex;align-items:center;justify-content:center;min-height:320px;}
#photo_canvas{max-width:100%;max-height:520px;width:100%;height:auto;display:block;}



/* ===== Patients v3 (horizontal tiles like hospital systems) ===== */
.cec-plist{display:flex;flex-direction:column;gap:10px;}
.cec-ptileH{
  display:flex; align-items:center; gap:12px;
  border:1px solid rgba(15,23,42,.10);
  border-radius:18px;
  padding:12px;
  background:color-mix(in srgb, var(--card) 92%, #fff 8%);
}
body.dark-mode .cec-ptileH{border-color:rgba(148,163,184,.16);}
.cec-ptileIcon{
  width:48px;height:48px;border-radius:16px;
  display:flex;align-items:center;justify-content:center;
  background:rgba(2,132,199,.10);
  border:1px solid rgba(2,132,199,.25);
  flex:0 0 auto;
}
.cec-ptileIcon .material-symbols-rounded{font-size:26px;}
.cec-ptileMain{flex:1;min-width:0;}
.cec-ptileName{font-weight:900;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.cec-ptileMeta{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:4px;}
.cec-pill{display:inline-flex;align-items:center;justify-content:center;padding:4px 10px;border-radius:999px;font-weight:900;font-size:11px;border:1px solid rgba(15,23,42,.10);background:rgba(2,132,199,.08);}
body.dark-mode .cec-pill{border-color:rgba(148,163,184,.16);}
.cec-ptileActions{display:flex;gap:8px;flex:0 0 auto;}
.cec-mini.danger{border-color:rgba(239,68,68,.35);background:rgba(239,68,68,.10);color:var(--text-main);}
.cec-modal-wide{width:min(1200px,92vw);}

/* photos grid */
.cec-phgrid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;}
@media (max-width:900px){.cec-phgrid{grid-template-columns:repeat(2,1fr);}}
.cec-ph{display:block;border-radius:14px;overflow:hidden;border:1px solid rgba(15,23,42,.10);}
body.dark-mode .cec-ph{border-color:rgba(148,163,184,.16);}
.cec-ph img{width:100%;height:140px;object-fit:cover;display:block;}


/* === FORCE MODALS TO BE REAL MODALS (so they don't show at page bottom) === */
.cec-modal{
  position: fixed !important;
  inset: 0 !important;
  background: rgba(2,6,23,.55) !important;
  backdrop-filter: blur(8px) !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999 !important;
  padding: 16px !important;
}
.cec-modal.open{ display:flex !important; }
body.modal-open{ overflow:hidden !important; }

.cec-modal-card{
  width: min(1200px, 92vw) !important;
  max-height: 90vh !important;
  overflow:auto !important;
  border-radius: 22px !important;
  padding: 18px !important;
  background: var(--card, #fff) !important;
  position: relative !important;
}

.cec-modal-x{
  position: absolute !important;
  right: 14px !important;
  top: 10px !important;
  border: none !important;
  background: transparent !important;
  font-size: 26px !important;
  cursor: pointer !important;
}

