:root {
  /* Sunny Angels theme (same as the Assessment Center + hiring site):
     indigo primary, navy-to-indigo chrome, soft lavender background, crystal-star pink + blue */
  --bg: #f6f6fb;
  --side-bg: linear-gradient(170deg, #07060f 0%, #1c1350 55%, #3d33c9 120%);
  --side-text: #ffffff;
  --side-muted: rgba(255, 255, 255, .62);
  --side-hover: rgba(255, 255, 255, .10);
  --side-line: rgba(255, 255, 255, .14);
  --panel: #ffffff;
  --text: #1a1830;
  --muted: #66647d;
  --line: #e3e2f0;
  --accent: #4f46e5;
  --accent-2: #ec4faf;
  --accent-3: #2bb3f0;
  --accent-soft: #edebfd;
  --grad: linear-gradient(120deg, #4f46e5 0%, #8b5cf6 50%, #ec4faf 100%);
  --user: #edebfd;
  --quote: #fdf2fa;
  --err: #c8391f;
  --ok: #1f8a4c;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0d1c; --panel: #1a1730; --text: #f1effb; --muted: #a9a6c4; --line: #2d2950;
    --accent-soft: #2a2560; --user: #2a2560; --quote: #2a1b33; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); min-height: 1.2em; margin: 0; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent-soft); font-weight: 600; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .25); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px; font-size: 18px; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--accent-soft); }

.brand { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }
.logo { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(236, 79, 175, .35)); }
.brand.big .logo { width: 40px; height: 40px; }
.logo.huge { width: 84px; height: 84px; }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand.big { font-size: 26px; justify-content: center; }


/* auth screens */
.screen.center { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 15% 10%, rgba(43, 179, 240, .14), transparent 40%), radial-gradient(circle at 85% 90%, rgba(236, 79, 175, .14), transparent 45%), var(--bg); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.auth { width: 100%; max-width: 380px; display: grid; gap: 14px; text-align: center; box-shadow: 0 12px 40px rgba(28, 19, 80, .12); }
.auth label { display: grid; gap: 6px; text-align: left; font-weight: 600; font-size: 14px; }
.auth p { margin: 0; }

/* app layout */
#app { display: flex; height: 100%; }
#side { width: 270px; background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; padding: 14px; gap: 10px; flex: none; }
.side-top { display: flex; align-items: center; justify-content: space-between; }
.btn.new { text-align: left; background: var(--side-hover); border: 1px solid var(--side-line); color: var(--side-text); }
.btn.new:hover { background: rgba(255, 255, 255, .18); }
#side .icon-btn:hover { background: var(--side-hover); }
#side .muted { color: var(--side-muted); }
#side .btn.ghost { border-color: var(--side-line); color: var(--side-text); }
.side-label { font-size: 12px; font-weight: 700; color: var(--side-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
#chatList { flex: 1; overflow-y: auto; overflow-x: hidden; display: grid; align-content: start; gap: 2px; margin: 0 -6px; }
.chat-item { display: flex; align-items: center; border-radius: 10px; }
.chat-item a { flex: 1; padding: 8px 10px; color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.chat-item:hover, .chat-item.on { background: var(--side-hover); }
.chat-item.on { box-shadow: inset 3px 0 0 var(--accent-2); }
.chat-item .del { visibility: hidden; width: 30px; height: 30px; font-size: 14px; }
.chat-item:hover .del { visibility: visible; }
.side-bottom { display: grid; gap: 10px; border-top: 1px solid var(--side-line); padding-top: 10px; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.me-text { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.me-text > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-wrap { position: relative; }
.menu { position: absolute; bottom: 42px; right: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 170px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 5; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; }
.menu button:hover { background: var(--accent-soft); }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 52px; background: var(--panel); }
.topbar-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#thread { flex: 1; overflow-y: auto; padding: 16px; }
#messages { max-width: 780px; margin: 0 auto; display: grid; gap: 18px; }

.empty { max-width: 640px; margin: 8vh auto 0; text-align: center; }
.empty h1 { font-size: 26px; margin: 8px 0; letter-spacing: -.01em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; font-size: 14px; }
.chip:hover { border-color: var(--accent-2); color: var(--accent); }

.msg { display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--user); border-radius: 18px 18px 4px 18px; padding: 10px 14px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .shot { display: block; max-width: 260px; max-height: 320px; border-radius: 10px; margin-bottom: 6px; }
.msg.user .shot-tag { font-size: 13px; color: var(--muted); display: block; }
.msg.ai .ai-av { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.msg.ai .ai-av img { width: 22px; height: 22px; object-fit: contain; }
.msg.ai .bubble { flex: 1; min-width: 0; }
.bubble p { margin: 0 0 8px; }
.bubble ul { margin: 0 0 8px; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.reply { display: flex; align-items: center; gap: 8px; background: var(--quote); border: 1px solid var(--line); border-left: 4px solid var(--accent-2); border-radius: 10px; padding: 8px 8px 8px 12px; margin: 0 0 8px; }
.reply span { flex: 1; }
.reply button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; font-size: 12px; padding: 4px 8px; flex: none; }
.ai-actions { display: flex; gap: 4px; margin-top: 2px; }
.ai-actions button { border: 0; background: none; padding: 4px 6px; border-radius: 8px; opacity: .55; font-size: 14px; }
.ai-actions button:hover, .ai-actions button.on { opacity: 1; background: var(--accent-soft); }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 4px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.bubble.error { color: var(--err); }

#composer { padding: 8px 16px 12px; max-width: 812px; width: 100%; margin: 0 auto; }
.compose-row { display: flex; align-items: flex-end; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 6px; }
.compose-row:focus-within { border-color: var(--accent); }
#input { border: 0; resize: none; max-height: 200px; padding: 8px 4px; background: transparent; outline: none; }
.clip { cursor: pointer; }
.send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; font-size: 16px; flex: none; }
.send:disabled { opacity: .45; }
#attach { position: relative; display: inline-block; margin: 0 0 8px 6px; }
#attachImg { max-height: 110px; max-width: 200px; border-radius: 10px; border: 1px solid var(--line); display: block; }
#attach .x { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); font-size: 12px; }
.foot { text-align: center; margin: 6px 0 0; }
body.dragging #composer .compose-row { border: 2px dashed var(--accent); }

/* manager panel */
#admin { position: fixed; inset: 0; background: var(--bg); overflow-y: auto; z-index: 20; }
.admin-inner { max-width: 1000px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.admin-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 8px 12px; border-bottom: 2px solid transparent; font-weight: 600; color: var(--muted); }
.tab.on { color: var(--accent); border-color: var(--accent-2); }
.tabpane { display: grid; gap: 12px; }
.row-form { display: grid; grid-template-columns: 1.3fr 1fr 0.8fr auto; gap: 8px; padding: 12px; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }
.notice code { font-size: 16px; font-weight: 700; user-select: all; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); }
td .btn { padding: 5px 9px; font-size: 13px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); }
.pill.off { background: #f3d6d2; color: var(--err); }
.log-item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.log-item .q { font-weight: 600; white-space: pre-wrap; }
.log-item details { margin-top: 6px; }
.log-item .a { white-space: pre-wrap; font-size: 14px; margin-top: 6px; }
.settings { display: grid; gap: 12px; max-width: 420px; }
.settings label { display: grid; gap: 6px; font-weight: 600; }

#toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 50; }

.only-mobile { display: none; }
@media (max-width: 760px) {
  .only-mobile { display: inline-grid; }
  #side { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; width: 82%; max-width: 300px; }
  #app.side-open #side { transform: none; }
  #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 9; }
  #thread { padding: 12px 16px; }
  #composer { padding: 8px 12px 10px; }
  .row-form { grid-template-columns: 1fr; }
  .empty h1 { font-size: 22px; }
  .chat-item .del { visibility: visible; }
}

.bubble p.angle { margin: 10px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--accent); }

.modal { position: fixed; inset: 0; background: rgba(15, 13, 28, .45); display: grid; place-items: center; padding: 16px; z-index: 60; }
.modal-card { width: 100%; max-width: 460px; display: grid; gap: 10px; }
.modal-card h3 { margin: 0; }
.modal-card textarea { resize: vertical; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.tab .count { background: var(--accent-2); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.tab .count:empty { display: none; }
.fb-item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 12px; align-items: flex-start; }
.fb-item.done { opacity: .55; }
.fb-item .fb-text { white-space: pre-wrap; flex: 1; }
.fb-item label { font-size: 13px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.fb-item input { width: auto; }
.modal-card .anon { display: flex; gap: 8px; align-items: center; }
.modal-card .anon input { width: auto; }
