:root { color-scheme: dark; --bg:#212121; --panel:#2f2f2f; --fg:#ffffff; --muted:#d0d0d0; --accent:#d62839; }
* { box-sizing: border-box; }
body { margin:0; height:100vh; background:var(--bg); color:var(--fg); font:16px/1.5 system-ui, sans-serif; }
[hidden] { display:none !important; }
#orb { position:fixed; inset:0; z-index:-1; background:#000; pointer-events:none; overflow:hidden; --orb-size:36vmin; --time:14s; }
#orb .wrap { position:relative; top:50%; left:50%; width:0; height:0; transform-style:preserve-3d; perspective:1000px; animation:orb-rotate var(--time) infinite linear; }
#orb .c { position:absolute; width:4px; height:4px; border-radius:50%; opacity:0; animation:orb-orbit var(--time) infinite; animation-delay:var(--delay); }
@keyframes orb-rotate { 100% { transform:rotateY(360deg) rotateX(360deg); } }
@keyframes orb-orbit {
  20% { opacity:1; }
  30%, 80% { opacity:1; transform:rotateZ(calc(var(--z) * -1)) rotateY(var(--y)) translateX(var(--orb-size)) rotateZ(var(--z)); }
  100% { transform:rotateZ(calc(var(--z) * -1)) rotateY(var(--y)) translateX(calc(var(--orb-size) * 3)) rotateZ(var(--z)); }
}
@media (prefers-reduced-motion: reduce) {
  #orb .wrap, #orb .c { animation:none; }
  #orb .c { opacity:1; transform:rotateZ(calc(var(--z) * -1)) rotateY(var(--y)) translateX(var(--orb-size)) rotateZ(var(--z)); }
}
button { background:var(--accent); color:#fff; border:0; border-radius:8px; padding:.6rem 1rem; cursor:pointer; font:inherit; }
button.secondary { background:transparent; border:1px solid #555; color:var(--fg); }
button:disabled { opacity:.5; cursor:wait; }
input, textarea { background:var(--panel); color:var(--fg); border:1px solid #444; border-radius:8px; padding:.7rem; font:inherit; }

#auth { height:100%; display:grid; place-items:center; }
#auth-form { display:flex; flex-direction:column; gap:.7rem; width:min(320px,90vw); }
#auth-form h1 { margin:0 0 .5rem; text-align:center; }
.err { color:#ff6b6b; min-height:1.2em; margin:0; }
.logo-lg { height:120px; width:120px; margin:0 auto .5rem; border-radius:20px; display:block; }

#portal { max-width:820px; margin:0 auto; padding:0 1rem; }
#portal header { display:flex; align-items:center; gap:1rem; padding:.8rem 0; }
#who-portal { flex:1; color:var(--muted); font-size:.9rem; }
#admin { max-width:900px; margin:0 auto; padding:0 1rem; }
#admin header { display:flex; align-items:center; gap:1rem; padding:.8rem 0; }
#admin header a { color:var(--muted); text-decoration:none; }
#admin header strong { margin-right:auto; }
#admin-content { padding:1rem 0; }
#create-user-form { display:flex; flex-wrap:wrap; align-items:end; gap:.75rem; padding:1rem 0; border-bottom:1px solid #444; }
#create-user-form label { display:grid; gap:.25rem; color:var(--muted); font-size:.9rem; }
#create-user-form input { min-width:210px; }
#admin-message { min-height:1.5rem; color:var(--muted); }
#admin-message.error { color:#ff6b6b; }
.users-table-wrap { overflow-x:auto; }
#users-table { width:100%; border-collapse:collapse; text-align:left; }
#users-table th, #users-table td { padding:.75rem .5rem; border-bottom:1px solid #444; vertical-align:middle; }
#users-table th { color:var(--muted); font-size:.85rem; font-weight:500; }
.user-actions { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; }
.user-actions form { display:flex; flex-wrap:wrap; gap:.5rem; }
.user-actions input { width:min(240px,55vw); }
.user-actions button { padding:.45rem .7rem; }
#admin .delete-user { color:#ff9a9a; border-color:#7a3939; }
@media (max-width:600px) {
  #admin header { gap:.5rem; }
  #admin header #who-admin { display:none; }
  #create-user-form { align-items:stretch; flex-direction:column; }
  #create-user-form input { width:100%; }
}
#apps { display:flex; flex-wrap:wrap; justify-content:center; gap:2.5rem; margin-top:12vh; }
.app-card { display:flex; flex-direction:column; align-items:center; gap:.4rem; text-align:center; width:min(240px,70vw); color:#fff; text-decoration:none; transition:transform .25s; }
.app-card img { width:100%; aspect-ratio:1; border-radius:50%; object-fit:cover; background:#111; border:3px solid #fff; margin-bottom:.6rem; }
.app-card:hover, .app-card:focus-visible { transform:scale(1.05); outline:none; }
.app-card h2 { margin:0 0 .3rem; }
.app-card p { margin:0; color:#e8e8e8; font-size:.9rem; }
#home { color:var(--muted); text-decoration:none; }

#chat { height:100dvh; display:grid; grid-template-columns:260px minmax(0,1fr); }
#chat-sidebar { min-height:0; display:flex; flex-direction:column; gap:.75rem; padding:.9rem .7rem; background:#191919; border-right:1px solid #3c3c3c; }
.sidebar-top { display:grid; gap:.65rem; }
#home { padding:.2rem .4rem; color:var(--muted); text-decoration:none; }
#new-chat { width:100%; background:#383838; text-align:left; }
#conversation-list { flex:1; min-height:0; overflow-y:auto; display:flex; flex-direction:column; gap:.25rem; }
.conversation-item { width:100%; padding:.55rem .65rem; border:1px solid transparent; border-radius:6px; background:transparent; color:var(--fg); text-align:left; overflow:hidden; }
.conversation-item:hover { background:#2a2a2a; }
.conversation-item.active { background:#343434; border-color:#4a4a4a; }
.conversation-item span { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conversation-item small { color:var(--muted); font-size:.75rem; }
.sidebar-footer { display:flex; align-items:center; gap:.6rem; border-top:1px solid #3c3c3c; padding:.7rem .2rem 0; }
#who { flex:1; overflow:hidden; color:var(--muted); font-size:.9rem; text-overflow:ellipsis; }
#chat-main { min-width:0; min-height:0; display:flex; flex-direction:column; }
#chat-header { min-height:52px; display:flex; align-items:center; padding:.65rem 1rem; border-bottom:1px solid #383838; }
#log { flex:1; overflow-y:auto; padding:1rem; display:flex; flex-direction:column; gap:1.2rem; }
.empty { margin:auto; color:var(--muted); text-align:center; }
.msg { display:flex; flex-direction:column; gap:.5rem; }
.user { align-self:flex-end; background:var(--panel); padding:.6rem .9rem; border-radius:16px; max-width:80%; }
.user img { max-width:200px; border-radius:8px; display:block; margin-bottom:.4rem; }
.reuse-prompt { display:block; width:max-content; padding:.2rem .45rem; border:0; border-radius:4px; background:transparent; color:#f18a92; font-size:.78rem; }
.reuse-prompt:hover { background:#414141; }
.bot img { max-width:min(100%,512px); border-radius:12px; display:block; }
.bot small { color:var(--muted); }
.bot a { color:var(--accent); font-size:.85rem; }
.typing { color:var(--muted); font-style:italic; }

#composer { padding:1rem; }
.settings { display:flex; flex-wrap:wrap; align-items:center; gap:.75rem; margin-bottom:.6rem; }
.model-picker { display:flex; align-items:center; gap:.5rem; color:var(--muted); font-size:.9rem; }
#model { min-width:170px; padding:.4rem .6rem; }
.mode-picker { display:flex; gap:.15rem; padding:.2rem; border:1px solid #444; border-radius:8px; }
.mode-picker label { position:relative; cursor:pointer; }
.mode-picker input { position:absolute; opacity:0; pointer-events:none; }
.mode-picker span { display:block; border-radius:6px; padding:.25rem .7rem; color:var(--muted); }
.mode-picker input:checked + span { background:var(--accent); color:#fff; }
.mode-picker input:focus-visible + span { outline:2px solid var(--fg); outline-offset:2px; }
#composer .row { display:flex; align-items:flex-end; gap:.5rem; background:var(--panel); border-radius:24px; padding:.5rem; }
#composer textarea { flex:1; border:0; resize:none; max-height:160px; background:transparent; outline:none; }
.attach { width:40px; height:40px; display:grid; place-items:center; font-size:1.6rem; cursor:pointer; border-radius:50%; background:#444; }
#send { border-radius:50%; width:40px; height:40px; padding:0; }
#preview { position:relative; display:inline-block; margin-bottom:.5rem; }
#preview img { height:72px; border-radius:8px; display:block; }
#remove { position:absolute; top:-8px; right:-8px; width:22px; height:22px; padding:0; border-radius:50%; background:#000; }

#particles { position:fixed; inset:0; z-index:-1; background:#000; overflow:hidden; pointer-events:none; }
#particles i { position:absolute; bottom:-10px; left:var(--x); width:var(--s); height:var(--s); border-radius:50%; background:var(--c); box-shadow:0 0 8px var(--c); opacity:0; animation:particle-rise var(--d) linear infinite; animation-delay:var(--delay); }
@keyframes particle-rise { 10%, 90% { opacity:.9; } 100% { transform:translate(var(--dx), -110vh); opacity:0; } }
@media (prefers-reduced-motion: reduce) { #particles i { animation:none; opacity:.6; bottom:calc(var(--s) * 20); } }
@media (max-width:700px) {
  #chat { grid-template-columns:minmax(0,1fr); grid-template-rows:150px minmax(0,1fr); }
  #chat-sidebar { gap:.45rem; padding:.55rem .65rem; border-right:0; border-bottom:1px solid #3c3c3c; }
  .sidebar-top { grid-template-columns:auto minmax(0,1fr); align-items:center; gap:.55rem; }
  #new-chat { text-align:center; }
  #conversation-list { flex-direction:row; overflow-x:auto; overflow-y:hidden; }
  .conversation-item { flex:0 0 180px; align-self:stretch; }
  .sidebar-footer { display:none; }
  #chat-header { min-height:42px; }
  #log { padding:.75rem; }
  #composer { padding:.65rem; }
}
