:root {
  --bg: #0b1020; --panel: rgba(255,255,255,.055); --line: rgba(255,255,255,.12);
  --text: #e6eaf5; --muted: #8b95b0; --accent: #22d3ee; --accent2: #818cf8; --err: #fb7185;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.6 "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg); display: flex; flex-direction: column; }

.bg { position: fixed; inset: 0; z-index: -1; background:
  radial-gradient(600px 400px at 15% -5%, rgba(34,211,238,.22), transparent 70%),
  radial-gradient(700px 500px at 100% 10%, rgba(129,140,248,.22), transparent 70%),
  linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px) 0 0/40px 40px,
  linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px) 0 0/40px 40px,
  var(--bg); }

.top { display: flex; justify-content: space-between; align-items: center; padding: 16px 28px; border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.brand { display: flex; gap: 14px; align-items: center; }
.logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #06202a; background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 0 24px rgba(34,211,238,.4); }
h1 { margin: 0; font-size: 18px; letter-spacing: .3px; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); }
.status { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 99px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 8px #34d399; }
.status.busy i { background: #fbbf24; box-shadow: 0 0 8px #fbbf24; animation: pulse 1s infinite; }

main { flex: 1; overflow-y: auto; padding: 28px 20px 12px; }
main > * { max-width: 780px; margin-left: auto; margin-right: auto; }

.hero { text-align: center; padding: 6vh 0 10px; }
.hero[hidden] { display: none; }
.hero h2 { margin: 0 0 6px; font-size: 32px; font-weight: 650; background: linear-gradient(90deg, #fff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0 0 22px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { font: inherit; font-size: 13.5px; color: var(--text); background: var(--panel); border: 1px solid var(--line); padding: 8px 16px; border-radius: 99px; cursor: pointer; transition: .15s; }
.chip:hover { border-color: var(--accent); box-shadow: 0 0 16px rgba(34,211,238,.25); transform: translateY(-1px); }

.turn { margin-bottom: 22px; animation: rise .3s ease; }
.you { margin-left: auto; max-width: 85%; width: fit-content; padding: 12px 16px; border-radius: 16px 16px 4px 16px; background: linear-gradient(135deg, rgba(34,211,238,.25), rgba(129,140,248,.25)); border: 1px solid rgba(129,140,248,.35); white-space: pre-wrap; overflow-wrap: anywhere; }
.you .att { display: block; margin-top: 6px; font-size: 12.5px; color: var(--accent); }
.bot { margin-top: 12px; display: flex; gap: 12px; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #06202a; background: linear-gradient(135deg, var(--accent), var(--accent2)); font-size: 13px; font-weight: 700; }
.bubble { flex: 1; min-width: 0; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.error { border-color: rgba(251,113,133,.5); color: var(--err); }
.bubble .tools { margin-top: 8px; }
.tools button { font: inherit; font-size: 12px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px; cursor: pointer; }
.tools button:hover { color: var(--text); border-color: var(--accent); }
.dots span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--accent); animation: bounce 1.1s infinite; }
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }

.composer { width: 100%; max-width: 780px; margin: 0 auto; padding: 8px 20px 18px; }
.row { display: flex; align-items: flex-end; gap: 8px; padding: 8px; background: rgba(18,24,48,.85); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(12px); box-shadow: 0 10px 40px rgba(0,0,0,.4); transition: .15s; }
.row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,.15), 0 10px 40px rgba(0,0,0,.4); }
textarea { flex: 1; resize: none; max-height: 200px; padding: 9px 4px; font: inherit; color: var(--text); background: none; border: 0; outline: none; }
textarea::placeholder { color: var(--muted); }
.attach, #send { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; border: 0; transition: .15s; }
.attach { color: var(--muted); background: none; }
.attach:hover { color: var(--accent); background: var(--panel); }
.attach input { display: none; }
#send { color: #06202a; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
#send:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 0 18px rgba(34,211,238,.5); }
#send:disabled { opacity: .4; cursor: default; }
.filechip { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 8px 4px; padding: 5px 6px 5px 12px; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; color: var(--accent); }
.filechip[hidden] { display: none; }
.filelist { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px 4px; }
.filelist[hidden] { display: none; }
.filelist .filechip { margin: 0; max-width: 100%; }
.filechip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.you .att { display: block; margin-top: 4px; font-size: 12.5px; color: var(--accent); overflow-wrap: anywhere; }
.filechip small { color: var(--muted); }
.filechip button { width: 22px; height: 22px; line-height: 1; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: var(--text); cursor: pointer; }
.hint { display: flex; justify-content: space-between; padding: 6px 10px 0; font-size: 12px; color: var(--muted); }

.drop { position: fixed; inset: 0; display: none; place-items: center; z-index: 10; background: rgba(11,16,32,.8); backdrop-filter: blur(4px); }
.drop.on { display: grid; }
.drop div { padding: 50px 80px; font-size: 20px; color: var(--accent); border: 2px dashed var(--accent); border-radius: 22px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 600px) { .top { padding: 12px 16px; } .brand p, .status { display: none; } .hero h2 { font-size: 24px; } }

/* ---- login page ---- */
body.loginpage { align-items: center; justify-content: center; }
.logincard { width: min(380px, calc(100vw - 32px)); padding: 32px 28px 28px; text-align: center; background: rgba(18,24,48,.85); border: 1px solid var(--line); border-radius: 20px; backdrop-filter: blur(12px); box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: rise .3s ease; }
.logincard .logo { margin: 0 auto 14px; width: 48px; height: 48px; }
.logincard h1 { font-size: 22px; }
.logincard p { margin: 2px 0 22px; color: var(--muted); font-size: 13.5px; }
.logincard label { display: block; margin-bottom: 14px; text-align: left; font-size: 12.5px; color: var(--muted); }
.logincard input { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-size: 15px; color: var(--text); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; outline: none; transition: .15s; }
.logincard input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
.logincard button { width: 100%; margin-top: 6px; padding: 11px; font: inherit; font-weight: 600; color: #06202a; border: 0; border-radius: 10px; cursor: pointer; background: linear-gradient(135deg, var(--accent), var(--accent2)); transition: .15s; }
.logincard button:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 0 18px rgba(34,211,238,.4); }
.logincard button:disabled { opacity: .5; cursor: default; }
.loginerr { margin: 0 0 12px; padding: 8px 12px; font-size: 13px; color: var(--err); background: rgba(251,113,133,.1); border: 1px solid rgba(251,113,133,.35); border-radius: 8px; }
.loginerr[hidden] { display: none; }
.signout { font: inherit; font-size: 12.5px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 99px; padding: 5px 14px; cursor: pointer; transition: .15s; }
.signout:hover { color: var(--text); border-color: var(--accent); }
.topright { display: flex; align-items: center; gap: 10px; }

.or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msbtn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; font-size: 14.5px; font-weight: 600; color: var(--text); text-decoration: none; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; transition: .15s; }
.msbtn:hover { border-color: var(--accent); background: rgba(255,255,255,.1); }
.msbtn.off { opacity: .55; }

/* ---- login: Microsoft primary, admin secondary ---- */
.msbtn.primary { padding: 12px; font-size: 15px; color: #1f1f1f; background: #fff; border-color: #fff; }
.msbtn.primary:hover { background: #f1f5f9; box-shadow: 0 0 20px rgba(34,211,238,.35); }
.msbtn.primary.off { opacity: .6; }
.mshint { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.admin { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); text-align: left; }
.admin summary { cursor: pointer; list-style: none; text-align: center; font-size: 12.5px; color: var(--muted); user-select: none; }
.admin summary::-webkit-details-marker { display: none; }
.admin summary::after { content: " ▾"; }
.admin[open] summary::after { content: " ▴"; }
.admin summary:hover { color: var(--text); }
.admin form { margin-top: 16px; }

.admin[hidden] { display: none; }
