*{box-sizing:border-box}
:root{
  --accent: rgba(120, 190, 255, .95);
  --accent2: rgba(185, 140, 255, .9);
  --accentSoft: rgba(120, 190, 255, .18);
  --glow: 0 0 0 4px rgba(120, 190, 255, .10), 0 0 28px rgba(120, 190, 255, .18);

  --accent:#8be9ff;
  --accent2:#a78bfa;
  --accentGlow:rgba(139,233,255,.22);
  --accentGlow2:rgba(167,139,250,.18);

  --shadow1:0 10px 24px rgba(0,0,0,.28);
  --shadow2:0 18px 45px rgba(0,0,0,.55);
  --shadow3:0 26px 70px rgba(0,0,0,.62);

  --ui-font:16px;

  --bg0:#05060a;
  --bg1:#0b0c10;
  --panel:rgba(12,13,16,.92);
  --panel2:rgba(16,17,20,.92);

  --border:rgba(255,255,255,.10);
  --border2:rgba(255,255,255,.16);

  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.62);

  --soft:rgba(255,255,255,.04);
  --hover:rgba(255,255,255,.06);

  --shadow:0 18px 45px rgba(0,0,0,.55);

  --content-max:940px;
  --content-pad:18px;
}

html,body{
  margin:0;height:100%;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  font-size:var(--ui-font);
  color:var(--text);
}

html[data-theme="angelic"]{
  background:
    var(--nebula3),
    var(--nebula1),
    var(--nebula2),
    radial-gradient(1200px 900px at 50% 110%, rgba(120,190,255,.08), transparent 58%),
    radial-gradient(900px 700px at 25% 70%, rgba(185,140,255,.06), transparent 60%),
    linear-gradient(180deg, #03040b 0%, #070915 45%, #040510 100%);
}
html[data-theme="angelic"]::before{
  content:"";
  position:fixed;
  inset:-20px;
  pointer-events:none;
  z-index:-1;
  background:
    var(--star1),
    var(--star2),
    var(--star3),
    radial-gradient(1px 1px at 10% 60%, rgba(255,255,255,.60), transparent 60%),
    radial-gradient(1px 1px at 90% 75%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1px 1px at 55% 45%, rgba(255,255,255,.45), transparent 60%);
  opacity:.75;
  filter: drop-shadow(0 0 6px rgba(255,255,255,.12));
}

html[data-theme="midnight"]{
  background:
    radial-gradient(1200px 900px at 50% 0%, rgba(255,255,255,.05), transparent 60%),
    radial-gradient(1000px 900px at 15% 20%, rgba(255,255,255,.03), transparent 60%),
    linear-gradient(180deg,#03040a,#090a12);
}
html[data-theme="slate"]{
  background:
    radial-gradient(1100px 800px at 50% -10%, rgba(255,255,255,.06), transparent 60%),
    linear-gradient(180deg,#07080c,#101218);
}
body{background:transparent}

button,input,textarea,select{font-family:inherit}
::selection{background:rgba(255,255,255,.22)}

html.compact{
  --content-max:900px;
}

#introOverlay{
  position:fixed;inset:0;
  background:
    radial-gradient(900px 700px at 50% 15%, rgba(120,190,255,.12), transparent 60%),
    radial-gradient(900px 700px at 80% 25%, rgba(185,140,255,.10), transparent 62%),
    linear-gradient(180deg,#02030a,#060818);
  display:grid;place-items:center;
  z-index:9999;overflow:hidden;
  transition:opacity 1s ease;
}
#introOverlay.fade{opacity:0;pointer-events:none}
.door{
  position:absolute;width:50%;height:100%;
  background:
    radial-gradient(800px 600px at 50% 0%, rgba(255,255,255,.06), transparent 60%),
    linear-gradient(180deg,#111217,#0b0c10);
  transition:transform 1.5s cubic-bezier(.77,0,.18,1);
}
.door.left{left:0}
.door.right{right:0}
#introOverlay.open .door.left{transform:translateX(-100%)}
#introOverlay.open .door.right{transform:translateX(100%)}
.intro-logo{
  width:120px;
  filter:drop-shadow(0 18px 40px rgba(0,0,0,.6));
  animation:pulse 2.1s infinite ease-in-out;
}
@keyframes pulse{0%{transform:scale(1);opacity:1}50%{transform:scale(1.07);opacity:.86}100%{transform:scale(1);opacity:1}}

.banner{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  top:64px;
  display:none;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:6px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(16,17,20,.86);
  backdrop-filter:blur(12px);
  box-shadow:0 10px 26px rgba(0,0,0,.38);
  z-index:20000;
  max-width:min(560px, calc(100vw - 20px));
  pointer-events:auto;
}
.banner.show{display:flex}
.banner.warn{border-color:rgba(255,255,255,.16)}
.banner.danger{border-color:rgba(255,255,255,.22)}
.banner-title{font-weight:700;font-size:12.5px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.banner-btn{
  background:transparent;
  border:1px solid transparent;
  color:rgba(255,255,255,.78);
  border-radius:10px;
  padding:4px 8px;
  cursor:pointer;
  transition:.15s ease;
  font-size:12px;
  line-height:1;
}
.banner-btn:hover{background:var(--hover);border-color:var(--border)}

.app{display:flex;height:100vh;overflow:hidden}

.chat-scroll,.chat-list-container,#prompt,.palette-list,.mem-list{
  scrollbar-width:thin;
  scrollbar-color:rgba(255,255,255,.20) transparent;
}
.chat-scroll::-webkit-scrollbar,.chat-list-container::-webkit-scrollbar,#prompt::-webkit-scrollbar,.palette-list::-webkit-scrollbar,.mem-list::-webkit-scrollbar{width:10px}
.chat-scroll::-webkit-scrollbar-thumb,.chat-list-container::-webkit-scrollbar-thumb,#prompt::-webkit-scrollbar-thumb,.palette-list::-webkit-scrollbar-thumb,.mem-list::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.10);
  border-radius:999px;
  border:2px solid transparent;
  background-clip:padding-box;
}
.chat-scroll::-webkit-scrollbar-thumb:hover,.chat-list-container::-webkit-scrollbar-thumb:hover,#prompt::-webkit-scrollbar-thumb:hover,.palette-list::-webkit-scrollbar-thumb:hover,.mem-list::-webkit-scrollbar-thumb:hover{
  background:rgba(255,255,255,.16);
}

.sidebar{
  width:320px;
  background:var(--panel);
  border-right:1px solid var(--border);
  backdrop-filter:blur(14px);
  display:flex;
  flex-direction:column;
  padding:14px;
  gap:12px;
  transition:transform .25s ease;
  will-change:transform;
}
.sidebar.hidden{transform:translateX(-100%)}
.sidebar-top{display:flex;flex-direction:column;gap:10px}

.brand{display:flex;align-items:center;justify-content:space-between;gap:10px}
.brand-left{display:flex;align-items:center;gap:10px}
.brand-dot{
  width:12px;height:12px;border-radius:999px;
  background: radial-gradient(circle at 30% 30%, #ffffff, rgba(120,190,255,.6));
  box-shadow:
    0 0 0 6px rgba(120,190,255,.08),
    0 0 18px rgba(120,190,255,.25),
    0 0 40px rgba(120,190,255,.15);
}
.brand-text{
  font-size:18px;
  font-weight:900;
  letter-spacing:.8px;
  background: linear-gradient(90deg, rgba(255,255,255,.95), rgba(120,190,255,.95), rgba(185,140,255,.90));
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
  text-shadow: 0 0 22px rgba(120,190,255,.25);
}

.icon-btn{
  background:transparent;
  border:1px solid transparent;
  color:rgba(255,255,255,.85);
  border-radius:12px;
  padding:8px 10px;
  cursor:pointer;
  transition:.15s ease;
}
.icon-btn:hover{background:var(--hover);border-color:var(--border)}
.icon-btn:disabled{opacity:.45;cursor:not-allowed}

.sidebar-search input{
  width:100%;
  padding:10px 12px;
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  border-radius:14px;
  color:var(--text);
  outline:none;
}
.sidebar-search input:focus{
  border-color:rgba(255,255,255,.22);
  box-shadow:0 0 0 4px var(--accentGlow);
}

.sidebar-tools{display:flex;gap:10px}
.tool-btn{
  flex:1;
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px;
  color:rgba(255,255,255,.9);
  cursor:pointer;
  transition:.15s ease;
}
.tool-btn:hover{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.14)}

.chat-list-container{flex:1;overflow-y:auto;padding-right:4px}

.tagbar{
  display:flex;
  gap:8px;
  padding:6px 2px 10px 2px;
}
.tagbar input{
  flex:1;
  padding:9px 10px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:rgba(255,255,255,.9);
  outline:none;
}
.tagbar input:focus{
  border-color:rgba(255,255,255,.22);
  box-shadow:0 0 0 4px var(--accentGlow);
}

.mini{
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  color:rgba(255,255,255,.86);
  border-radius:14px;
  padding:8px 10px;
  cursor:pointer;
}
.mini:hover{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.14)}
.mini.danger{color:#ffb3b3}

.section-label{
  margin:12px 6px 8px;
  font-size:11px;
  color:rgba(255,255,255,.55);
  letter-spacing:.7px;
  text-transform:uppercase;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.section-actions{display:flex;gap:6px}
.section-actions button{
  background:transparent;
  border:1px solid var(--border);
  color:rgba(255,255,255,.8);
  border-radius:12px;
  padding:6px 10px;
  cursor:pointer;
}
.section-actions button:hover{background:rgba(255,255,255,.06)}

.chat-row{
  display:flex;
  flex-direction:column;
  gap:3px;
  padding:10px 10px;
  border-radius:14px;
  cursor:pointer;
  border:1px solid transparent;
  transition:.15s ease;
  user-select:none;
}
.chat-row:hover{background:rgba(255,255,255,.04);border-color:var(--border)}
.chat-row.active{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.18);

  box-shadow:0 0 0 3px rgba(139,233,255,.10), 0 14px 40px rgba(0,0,0,.35);
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border-color:rgba(139,233,255,.26);
}
.chat-title{font-weight:720;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:rgba(255,255,255,.92)}
.chat-mini{font-size:12px;color:rgba(255,255,255,.55);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.sidebar-bottom{display:flex;flex-direction:column;gap:10px}

.profile{position:relative}
.profile-btn{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  padding:10px;
  border-radius:16px;
  cursor:pointer;
  transition:.15s ease;
}
.profile-btn:hover{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.14)}
.avatar{
  width:34px;height:34px;border-radius:999px;
  display:grid;place-items:center;
  background:radial-gradient(circle at 30% 30%, rgba(255,255,255,.20), rgba(255,255,255,.06));
  border:1px solid rgba(255,255,255,.14);
  font-weight:900;
}
.profile-meta{display:flex;flex-direction:column;align-items:flex-start;gap:2px;min-width:0}
.profile-name{font-size:14px;font-weight:800}
.profile-sub{font-size:12px;color:rgba(255,255,255,.55)}
.chev{margin-left:auto;color:rgba(255,255,255,.65)}

.profile-menu{
  position:absolute;left:0;bottom:54px;width:100%;
  background:rgba(14,15,18,.96);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow2);
  overflow:hidden;
  display:none;
}
.profile-menu.open{display:block}
.menu-item{
  width:100%;
  text-align:left;
  background:transparent;
  border:none;
  color:rgba(255,255,255,.88);
  padding:12px;
  cursor:pointer;
}
.menu-item:hover{background:rgba(255,255,255,.06)}
.menu-item.danger{color:#ffb3b3}
.menu-item.danger:hover{background:rgba(255,0,0,.08)}

.main{flex:1;display:flex;flex-direction:column;overflow:hidden}
.topbar{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  background:rgba(10,11,14,.55);
  backdrop-filter:blur(16px);
}
.top-search{flex:1;display:flex;position:relative}
.top-search input{
  width:100%;
  max-width:820px;
  padding:10px 12px;
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  border-radius:14px;
  color:var(--text);
  outline:none;
}
.top-search input:focus{
  border-color:rgba(255,255,255,.22);
  box-shadow:0 0 0 4px var(--accentGlow);
}

.search-results{
  position:absolute;
  top:44px;left:0;
  width:min(820px,100%);
  background:rgba(14,15,18,.96);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow2);
  overflow:hidden;
  display:none;
  z-index:50;
}
.search-results.open{display:block}
.sr-empty{
  padding:12px;
  color:rgba(255,255,255,.62);
  font-size:13px;
}
.sr-item{
  width:100%;
  text-align:left;
  background:transparent;
  border:none;
  color:rgba(255,255,255,.9);
  padding:12px;
  cursor:pointer;
  border-top:1px solid rgba(255,255,255,.06);
}
.sr-item:hover{background:rgba(255,255,255,.06)}
.sr-top{font-size:12px;color:rgba(255,255,255,.55);margin-bottom:4px}
.sr-snippet{font-size:13px;opacity:.95}

.topbar-right{display:flex;gap:10px;align-items:center}

.status-pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:9px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  color:rgba(255,255,255,.88);
  user-select:none;
  white-space:nowrap;
}
.status-dot{
  width:8px;height:8px;border-radius:999px;
  box-shadow:0 0 0 5px rgba(255,255,255,.05);
}
.dot-online{background:rgba(255,255,255,.92);box-shadow:0 0 0 5px rgba(255,255,255,.06),0 0 18px rgba(255,255,255,.18)}
.dot-offline{background:rgba(255,255,255,.25);box-shadow:0 0 0 5px rgba(255,255,255,.05)}
.status-text{font-size:12px}
.status-latency{
  font-size:12px;
  color:rgba(255,255,255,.60);
  padding-left:8px;
  border-left:1px solid rgba(255,255,255,.10);
}

.chat-scroll{flex:1;overflow-y:auto;width:100%}
.chat-inner{width:100%;max-width:var(--content-max);margin:0 auto;padding:28px var(--content-pad) 18px}
.chat-container{width:100%;display:flex;flex-direction:column;gap:18px}

.message{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:6px;
  animation:fadeIn .18s ease;
}
.message.user{align-items:flex-end}

.message.assistant .bubble{
  background:rgba(255,255,255,.03);
  border-color:rgba(255,255,255,.10);
  position:relative;
}
.message.assistant .bubble:before{
  content:"";
  position:absolute;
  left:10px; top:12px; bottom:12px;
  width:2px;
  border-radius:999px;
  background:linear-gradient(180deg,var(--accent),var(--accent2));
  opacity:.9;
}
.message.assistant .bubble{
  padding-left:18px;
}

@keyframes fadeIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}

.bubble{
  max-width:70%;
  padding:14px 16px;
  border-radius:18px;
  line-height:1.55;
  border:1px solid rgba(255,255,255,.10);
  overflow-wrap:anywhere;
  box-shadow:0 10px 30px rgba(0,0,0,.22);
  background:rgba(255,255,255,.04);
}
.message.user .bubble{
  background:
    radial-gradient(700px 300px at 50% -20%, rgba(255,255,255,.09), transparent 60%),
    rgba(255,255,255,.035);
  border-color:rgba(255,255,255,.14);
}

.msg-meta{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
  opacity:.92;
}
.msg-action{
  width:30px;height:30px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:none;
  outline:none;
  border-radius:10px;
  cursor:pointer;
  user-select:none;
  background:rgba(255,255,255,.05);
  color:rgba(255,255,255,.82);
  transition:.15s ease;
  font-size:13px;
  line-height:1;
}
.msg-action:hover{background:rgba(255,255,255,.08);color:rgba(255,255,255,.92)}
.msg-action:focus-visible{box-shadow:0 0 0 3px rgba(255,255,255,.14)}
.msg-action.active{background:rgba(255,255,255,.14);color:rgba(255,255,255,.96)}
.msg-action.bad.active{background:rgba(255,255,255,.14)}

.flash{outline:2px solid rgba(255,255,255,.25);border-radius:16px}

.typing{display:flex;gap:6px;align-items:center;padding:2px 0}
.typing .dot{
  width:6px;height:6px;border-radius:999px;
  background:rgba(255,255,255,.55);
  animation:bounce 1.05s infinite ease-in-out;
}
.typing .dot:nth-child(2){animation-delay:.12s}
.typing .dot:nth-child(3){animation-delay:.24s}
@keyframes bounce{0%,80%,100%{transform:translateY(0);opacity:.55}40%{transform:translateY(-5px);opacity:1}}

.att-wrap{display:flex;gap:10px;flex-wrap:wrap;margin-top:10px}
.att-card{
  width:140px;
  border-radius:14px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(0,0,0,.18);
}
.att-img{width:100%;height:90px;object-fit:cover;display:block}
.att-cap{padding:8px 10px;font-size:12px;color:rgba(255,255,255,.75);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.att-chip{
  padding:7px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  font-size:12px;
  color:rgba(255,255,255,.82);
}

.bubble.markdown :is(p,ul,ol,blockquote,pre,table){margin:0 0 12px 0}
.bubble.markdown p:last-child{margin-bottom:0}
.bubble.markdown a{color:rgba(255,255,255,.92);text-decoration:none;border-bottom:1px solid rgba(255,255,255,.22)}
.bubble.markdown a:hover{border-bottom-color:rgba(255,255,255,.45)}
.bubble.markdown code{
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  padding:2px 6px;
  border-radius:10px;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  font-size:.95em;
}
.bubble.markdown pre{
  background:rgba(0,0,0,.32);
  border:1px solid rgba(255,255,255,.10);
  padding:12px;
  border-radius:16px;
  overflow:auto;
  position:relative;
}
.bubble.markdown pre code{background:transparent;border:none;padding:0;display:block;font-size:13px;line-height:1.45}
.code-copy{
  position:absolute;top:10px;right:10px;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.12);
  border-radius:12px;
  padding:6px 10px;
  font-size:12px;
  color:rgba(255,255,255,.86);
  cursor:pointer;
}
.code-copy:hover{background:rgba(255,255,255,.10);border-color:rgba(255,255,255,.16)}

.input-wrapper{
  width:100%;
  border-top:1px solid var(--border);
  background:rgba(10,11,14,.55);
  backdrop-filter:blur(16px);
}
.input-dock{width:100%;padding:12px var(--content-pad) 10px
  background:rgba(10,11,14,.68);
  box-shadow:0 -18px 45px rgba(0,0,0,.45);
}
.input-inner{max-width:var(--content-max);margin:0 auto;position:relative}
.input-container{
  width:100%;
  display:flex;
  gap:10px;
  align-items:flex-end;
  padding:10px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(800px 340px at 50% -40%, rgba(255,255,255,.07), transparent 60%),
    rgba(255,255,255,.04);
  box-shadow:0 16px 38px rgba(0,0,0,.26);
  position:relative;
}
.chip-btn{
  width:36px;height:36px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  color:rgba(255,255,255,.9);
  cursor:pointer;
  transition:.15s ease;
  display:grid;place-items:center;
}
.chip-btn:hover{background:rgba(255,255,255,.07);border-color:rgba(255,255,255,.16)}
.chip-btn:disabled{opacity:.45;cursor:not-allowed}

#prompt{
  flex:1;min-width:0;width:100%;
  background:transparent;border:none;color:var(--text);
  outline:none;resize:none;font-size:16px;line-height:1.4;
  max-height:180px;overflow-y:auto;padding:6px;
}
#prompt:disabled{opacity:.65}

.send-btn{
  background:
    radial-gradient(120px 60px at 40% 20%, rgba(255,255,255,.35), rgba(255,255,255,.10)),
    rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.18);
  border-radius:14px;
  padding:10px 14px;
  color:#fff;
  cursor:pointer;
  transition:.15s ease;

  background:linear-gradient(135deg,var(--accent),var(--accent2));
  border:1px solid rgba(255,255,255,.10);
  box-shadow:0 10px 22px rgba(0,0,0,.35), 0 0 0 4px rgba(139,233,255,.08);
}
.send-btn:hover{background:rgba(255,255,255,.14);border-color:rgba(255,255,255,.22)}
.send-btn:disabled{opacity:.45;cursor:not-allowed}

.stop-btn{
  display:none;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.14);
  border-radius:14px;
  padding:10px 14px;
  color:rgba(255,255,255,.88);
  cursor:pointer;
  transition:.15s ease;
}
.stop-btn:hover{background:rgba(255,255,255,.07);border-color:rgba(255,255,255,.18)}

.input-hint{
  max-width:var(--content-max);
  margin:0 auto;
  padding:0 var(--content-pad) 12px;
  font-size:12px;
  color:rgba(255,255,255,.45);
}

.template-menu{
  position:absolute;
  left:10px;
  bottom:58px;
  width:220px;
  background:rgba(14,15,18,.96);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow2);
  overflow:hidden;
  display:none;
  z-index:60;
}
.template-menu.open{display:block}
.template-head{
  padding:10px 12px;
  font-weight:800;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.template-list{display:flex;flex-direction:column}
.template-item{
  background:transparent;border:none;
  color:rgba(255,255,255,.9);
  padding:10px 12px;
  text-align:left;
  cursor:pointer;
}
.template-item:hover{background:rgba(255,255,255,.06)}

.menu{
  position:fixed;
  z-index:10060;
  min-width:220px;
  background:rgba(14,15,18,.96);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow2);
  display:none;
  overflow:hidden;
}
.menu.open{display:block}
.menu button{
  width:100%;
  text-align:left;
  background:transparent;
  border:none;
  color:rgba(255,255,255,.88);
  padding:12px;
  cursor:pointer;
}
.menu button:hover{background:rgba(255,255,255,.06)}
.menu .danger{color:#ffb3b3}
.menu .danger:hover{background:rgba(255,0,0,.08)}

.modal-backdrop,.drawer-backdrop{
  position:fixed;inset:0;
  display:none;place-items:center;
  background:rgba(0,0,0,.66);
  z-index:10050;
  padding:18px;
}
.modal-backdrop.open,.drawer-backdrop.open{display:grid}

.modal{
  width:100%;
  max-width:520px;
  background:rgba(14,15,18,.96);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow2);
  overflow:hidden;
}
.modal-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.modal-title{font-weight:850}
.modal-body{padding:14px}
.help{font-size:12px;color:rgba(255,255,255,.62);line-height:1.5;margin-bottom:10px}
.field-row{display:flex;gap:10px}
.field-row input{
  flex:1;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  color:var(--text);
  outline:none;
}
.field-row input:focus{
  border-color:rgba(255,255,255,.22);
  box-shadow:0 0 0 4px var(--accentGlow);
}
.btn{
  padding:12px 14px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  color:#fff;
  cursor:pointer;
}
.btn:hover{background:rgba(255,255,255,.10)}
.btn.primary{
  width:100%;
  margin-top:12px;
  background:rgba(255,255,255,.10);
  border-color:rgba(255,255,255,.18);
}
.btn.primary:hover{background:rgba(255,255,255,.14);border-color:rgba(255,255,255,.22)}

.palette{
  width:100%;
  max-width:680px;
  background:rgba(14,15,18,.96);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow2);
  overflow:hidden;
}
.palette-top{
  display:flex;gap:10px;align-items:center;
  padding:12px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.palette-top input{
  flex:1;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  color:var(--text);
  outline:none;
}
.palette-top input:focus{
  border-color:rgba(255,255,255,.22);
  box-shadow:0 0 0 4px var(--accentGlow);
}
.palette-list{max-height:360px;overflow:auto}
.palette-item{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:12px;cursor:pointer;border-top:1px solid rgba(255,255,255,.06);
}
.palette-item:hover{background:rgba(255,255,255,.05)}
.palette-left{display:flex;flex-direction:column;gap:2px;min-width:0}
.palette-title{font-weight:850;color:rgba(255,255,255,.92);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.palette-sub{font-size:12px;color:rgba(255,255,255,.55);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kbd{
  font-size:11px;color:rgba(255,255,255,.70);
  border:1px solid rgba(255,255,255,.14);
  border-radius:12px;padding:2px 8px;
  background:rgba(255,255,255,.04);
}

.drawer{
  width:100%;
  max-width:620px;
  background:rgba(14,15,18,.96);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow2);
  overflow:hidden;
}
.drawer-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px;border-bottom:1px solid rgba(255,255,255,.08);
}
.drawer-title{font-weight:850}
.drawer-body{padding:14px;display:flex;flex-direction:column;gap:10px}

.label{font-size:12px;color:rgba(255,255,255,.65)}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;color:rgba(255,255,255,.8)}
.input,.textarea,.select{
  width:100%;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  color:rgba(255,255,255,.9);
  outline:none;
}
.input:focus,.textarea:focus,.select:focus{
  border-color:rgba(255,255,255,.22);
  box-shadow:0 0 0 4px var(--accentGlow);
}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.toggles{display:flex;gap:14px;flex-wrap:wrap}
.toggle{font-size:13px;color:rgba(255,255,255,.8);display:flex;gap:8px;align-items:center}
.mem-add{display:flex;gap:10px}
.mem-list{max-height:320px;overflow:auto;padding-right:2px}
.mem-summary{
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.03);
  border-radius:16px;
  padding:12px;
  margin-bottom:10px;
}
.mem-title{font-weight:850;margin-bottom:6px}
.mem-sub{font-size:12px;color:rgba(255,255,255,.62);white-space:pre-wrap}
.mem-row{
  display:flex;justify-content:space-between;gap:10px;
  padding:10px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.03);
  margin-bottom:8px;
}
.mem-text{flex:1;min-width:0;color:rgba(255,255,255,.88);font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mem-actions{display:flex;gap:8px}

.krow{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:10px 0;border-bottom:1px solid rgba(255,255,255,.06);
}
.krow:last-child{border-bottom:none}
.k{
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
  font-size:12px;
  padding:6px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
}
.v{color:rgba(255,255,255,.75)}

@media (max-width:860px){
  :root{

  --accent:#8be9ff;
  --accent2:#a78bfa;
  --accentGlow:rgba(139,233,255,.22);
  --accentGlow2:rgba(167,139,250,.18);

  --shadow1:0 10px 24px rgba(0,0,0,.28);
  --shadow2:0 18px 45px rgba(0,0,0,.55);
  --shadow3:0 26px 70px rgba(0,0,0,.62);
--content-pad:14px}
  .sidebar{position:absolute;z-index:1000;height:100%;box-shadow:var(--shadow)}
  .bubble{max-width:92%;padding:12px 14px;border-radius:16px}
  .topbar{padding:10px 10px}
  .top-search input{max-width:none}
  .status-pill{display:none}
  .template-menu{left:10px;bottom:62px}
  .grid2{grid-template-columns:1fr}
}

@media (prefers-reduced-motion: reduce){
  *{
    animation-duration:0.01ms !important;
    animation-iteration-count:1 !important;
    transition-duration:0.01ms !important;
    scroll-behavior:auto !important;
  }
}

.msg-divider{height:1px;width:100%;background:linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);opacity:.55}

@media (max-width: 860px){
  .sidebar{width:92vw}
  .bubble{max-width:86%}
  .icon-btn{padding:10px 12px;border-radius:14px}
  .msg-action{width:34px;height:34px;border-radius:12px}
  .topbar{background:rgba(10,11,14,.82)}
  .sidebar,.topbar,.banner{backdrop-filter:blur(10px)}
}
@media (prefers-reduced-motion: reduce){
  *{scroll-behavior:auto !important}
  #introOverlay,.door,.intro-logo,.message{animation:none !important;transition:none !important}
}

.noscript{
  position:fixed;left:14px;right:14px;top:12px;
  z-index:21000;
  border:1px solid var(--border);
  border-radius:16px;
  padding:10px 12px;
  background:rgba(16,17,20,.92);
  box-shadow:var(--shadow2);
  color:rgba(255,255,255,.85);
}

.msg-time{
  font-size:11px;
  color:rgba(255,255,255,.42);
  padding:6px 8px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.03);
}

.modal.wide{max-width:720px;width:min(720px,92vw)}
.textarea{
  width:100%;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.04);
  color:rgba(255,255,255,.92);
  outline:none;
  resize:vertical;
}
.textarea:focus{border-color:rgba(139,233,255,.32);box-shadow:0 0 0 4px var(--accentGlow)}
.modal-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:12px}

#scrollToBottom{opacity:.0;transform:translateY(2px);transition:.16s ease}
#scrollToBottom.show{opacity:1;transform:translateY(0)}

.drawer.wide{max-width:980px}
.debug-pre{white-space:pre-wrap;word-break:break-word;background:rgba(255,255,255,.04);border:1px solid var(--border);border-radius:14px;padding:12px;min-height:240px;max-height:55vh;overflow:auto;color:rgba(255,255,255,.88)}

:root{
  --accent: rgba(120, 190, 255, .95);
  --accent2: rgba(185, 140, 255, .9);
  --accentSoft: rgba(120, 190, 255, .18);
  --glow: 0 0 0 4px rgba(120, 190, 255, .10), 0 0 28px rgba(120, 190, 255, .18);
  --star1: radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.75), transparent 60%);
  --star2: radial-gradient(1px 1px at 70% 20%, rgba(255,255,255,.55), transparent 60%);
  --star3: radial-gradient(1px 1px at 40% 80%, rgba(255,255,255,.45), transparent 60%);
  --nebula1: radial-gradient(900px 650px at 20% 25%, rgba(120,190,255,.10), transparent 60%);
  --nebula2: radial-gradient(900px 700px at 85% 20%, rgba(185,140,255,.08), transparent 62%);
  --nebula3: radial-gradient(1100px 900px at 50% -10%, rgba(255,255,255,.06), transparent 58%);
}

.sidebar-search input:focus,
.top-search input:focus,
.input-container textarea:focus,
.input-container:focus-within{
  border-color: rgba(120,190,255,.40) !important;
  box-shadow: var(--glow) !important;
}

.btn.primary,
.send-btn{
  background: linear-gradient(135deg, rgba(120,190,255,.22), rgba(185,140,255,.14));
  border-color: rgba(120,190,255,.30);
}
.btn.primary:hover,
.send-btn:hover{
  background: linear-gradient(135deg, rgba(120,190,255,.28), rgba(185,140,255,.18));
  border-color: rgba(120,190,255,.38);
}

.chat-row.active{
  border-color: rgba(120,190,255,.28) !important;
  box-shadow: 0 0 0 3px rgba(120,190,255,.10), 0 0 24px rgba(120,190,255,.10);
}

.topbar::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(90deg, transparent, rgba(120,190,255,.06), transparent);
  opacity:.6;
}

@media (max-width: 860px){
  .sidebar, .topbar, .banner{
    backdrop-filter: blur(10px);
  }
}

@media (prefers-reduced-motion: reduce){
  .intro-logo{animation:none !important;}
  .door{transition:none !important;}
}

.status-pill{
  transition:.2s ease;
}
.status-dot{
  width:9px;height:9px;border-radius:999px;
}

.status-pill.online{
  border-color: rgba(0,255,150,.35) !important;
  box-shadow: 0 0 14px rgba(0,255,150,.18) !important;
}
.status-pill.online .status-dot{
  background: #00ff96 !important;
  box-shadow: 0 0 0 5px rgba(0,255,150,.12), 0 0 14px rgba(0,255,150,.5) !important;
}

.status-pill.offline{
  border-color: rgba(255,60,60,.35) !important;
  box-shadow: 0 0 14px rgba(255,60,60,.18) !important;
}
.status-pill.offline .status-dot{
  background: #ff3c3c !important;
  box-shadow: 0 0 0 5px rgba(255,60,60,.12), 0 0 14px rgba(255,60,60,.5) !important;
}

.status-pill.warning{
  border-color: rgba(255,165,0,.35) !important;
  box-shadow: 0 0 14px rgba(255,165,0,.18) !important;
}
.status-pill.warning .status-dot{
  background: #ffa500 !important;
  box-shadow: 0 0 0 5px rgba(255,165,0,.12), 0 0 14px rgba(255,165,0,.5) !important;
}

@media (max-width: 860px){
  .banner{top:58px;}
}

.status-pill{
  border:1px solid rgba(255,255,255,.12) !important;
  background:rgba(255,255,255,.04) !important;
  box-shadow:none !important;
  color:rgba(255,255,255,.88) !important;
}
.status-text{color:rgba(255,255,255,.88) !important;}
.status-dot{width:10px;height:10px;border-radius:999px;}

.dot-online{
  background:#00ff96 !important;
  box-shadow:0 0 0 5px rgba(0,255,150,.10), 0 0 14px rgba(0,255,150,.40) !important;
}
.dot-issues{
  background:#ffa500 !important;
  box-shadow:0 0 0 5px rgba(255,165,0,.10), 0 0 14px rgba(255,165,0,.38) !important;
}
.dot-offline{
  background:#ff3c3c !important;
  box-shadow:0 0 0 5px rgba(255,60,60,.10), 0 0 14px rgba(255,60,60,.38) !important;
}
