/* ============================================================
   ChatBase — styles for notify.js (bell), chattools.js (search, pins,
   mentions, maintenance), qotd.js (Home tile), quiz.js (quiz modal)
   and the new Home tiles. Uses neo.css tokens.
   ============================================================ */

/* ---------- Home tiles ---------- */
.neo-homework, .neo-qotd { grid-column: span 3; }
@media (max-width: 900px) {
    .neo-homework, .neo-qotd { grid-column: span 2 !important; }
}

/* ---------- 🔔 Bell ---------- */
.cb-bell-wrap { position: relative; }
.cb-bell {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(255,255,255,.07);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, transform .2s var(--neo-spring, ease);
}
.cb-bell:hover { background: rgba(255,255,255,.13); transform: rotate(-12deg); }
.cb-bell-count {
    position: absolute; top: -3px; right: -3px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px;
    background: #ff4d6d; color: #fff;
    font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
    box-shadow: 0 0 0 2px var(--neo-black, #000);
}
.cb-bell-count[hidden] { display: none; }
.cb-bell-panel {
    position: absolute; top: calc(100% + 10px); right: 0;
    width: min(360px, calc(100vw - 32px));
    max-height: min(70vh, 520px);
    display: flex; flex-direction: column;
    border-radius: 18px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(18, 18, 24, .96);
    -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px);
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
    z-index: 1000;
    overflow: hidden;
}
.cb-bell-panel[hidden] { display: none; }
.cb-bell-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--neo-line, rgba(255,255,255,.08));
    font-size: 15px;
}
.cb-bell-clear { background: none; border: 0; color: var(--neo-accent, #8ab4ff); font: inherit; font-size: 12px; cursor: pointer; }
.cb-bell-list { overflow-y: auto; padding: 6px; }
.cb-n {
    display: flex; flex-direction: column; gap: 3px;
    width: 100%;
    padding: 10px 12px;
    border: 0; border-radius: 12px;
    background: transparent; color: var(--neo-text, #f5f5f7);
    font: inherit; font-size: 13.5px; text-align: left; line-height: 1.4;
    cursor: pointer;
}
.cb-n:hover { background: rgba(255,255,255,.06); }
.cb-n.unread { background: rgba(138,180,255,.1); }
.cb-n.warn { background: rgba(255,180,67,.12); }
.cb-n-req { background: rgba(52,232,176,.1); }
.cb-n-quote {
    display: block; margin-top: 3px; padding-left: 8px;
    border-left: 2px solid var(--neo-line-hi, rgba(255,255,255,.16));
    color: var(--neo-dim, rgba(235,235,245,.6));
    white-space: pre-wrap; overflow-wrap: anywhere;
}
.cb-n-time { font-size: 11px; color: var(--neo-faint, rgba(235,235,245,.32)); }
.cb-n-empty { padding: 30px 16px; text-align: center; color: var(--neo-dim, rgba(235,235,245,.6)); font-size: 14px; line-height: 1.6; }

/* ---------- @mentions ---------- */
.message.cb-mention-me .message-content {
    box-shadow: inset 3px 0 0 #ffd166, 0 0 0 1px rgba(255,209,102,.35) !important;
    background: rgba(255,209,102,.1) !important;
}

/* ---------- 📌 Pinned bar ---------- */
.cb-pin-bar {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 8px;
    padding: 9px 14px;
    border-radius: 14px;
    background: rgba(255,209,102,.1);
    border: 1px solid rgba(255,209,102,.3);
    font-size: 13.5px;
}
.cb-pin-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- 🔍 Room search ---------- */
.chat-container.cb-has-search { position: relative; }
.cb-search-btn {
    position: absolute; top: 10px; right: 12px; z-index: 5;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(20,20,26,.75);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    color: #fff; font-size: 14px; cursor: pointer;
    opacity: .7; transition: opacity .2s;
}
.cb-search-btn:hover { opacity: 1; }
.cb-search {
    position: absolute; top: 52px; right: 12px; left: 12px; z-index: 6;
    max-width: 460px; margin-left: auto;
    max-height: 60%;
    display: flex; flex-direction: column;
    border-radius: 16px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(16,16,22,.97);
    box-shadow: 0 16px 50px rgba(0,0,0,.6);
    overflow: hidden;
}
.cb-search-row { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--neo-line, rgba(255,255,255,.08)); }
.cb-search-input {
    flex: 1; min-width: 0;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(255,255,255,.06);
    color: #fff; font: inherit; font-size: 14px; outline: none;
}
.cb-search-input:focus { border-color: var(--neo-accent, #8ab4ff); }
.cb-search-close { width: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; }
.cb-search-results { overflow-y: auto; padding: 6px; }
.cb-search-hint { padding: 16px; text-align: center; font-size: 13px; color: var(--neo-dim, rgba(235,235,245,.6)); }
.cb-search-hit {
    display: flex; flex-direction: column; gap: 2px;
    width: 100%; padding: 9px 12px;
    border: 0; border-radius: 10px;
    background: transparent; color: inherit;
    font: inherit; text-align: left; cursor: pointer;
}
.cb-search-hit:hover { background: rgba(255,255,255,.06); }
.cb-search-meta { font-size: 11.5px; color: var(--neo-dim, rgba(235,235,245,.6)); }
.cb-search-text { font-size: 13.5px; overflow-wrap: anywhere; }
.cb-search-text mark { background: rgba(255,209,102,.35); color: #fff; border-radius: 3px; padding: 0 2px; }
.message.cb-flash .message-content { animation: cb-flash 1.6s ease; }
@keyframes cb-flash { 0%, 40% { box-shadow: 0 0 0 3px #ffd166; } 100% { box-shadow: none; } }

/* ---------- Sitewide switches ---------- */
.nav-btn.cb-tab-off { display: none !important; }
.cb-maint {
    position: fixed; inset: 0; z-index: 99990;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: rgba(4,5,12,.94);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.cb-maint[hidden] { display: none; }
.cb-maint-box { max-width: 420px; text-align: center; }
.cb-maint-ic { font-size: 64px; margin-bottom: 8px; }
.cb-maint-box h2 { margin: 0 0 8px; font-size: 28px; }
.cb-maint-box p { margin: 0; color: var(--neo-dim, rgba(235,235,245,.6)); font-size: 15px; line-height: 1.6; }

/* ---------- Fake "This site can't be reached" screen (chattools.js downPageHtml) ----------
   A copy of Chrome's own network-error page, down to the fonts and greys, so a glance at the
   screen reads as "the site is down" rather than "ChatBase turned itself off". Everything is
   !important / unset because this sits on top of the whole themed app. */
.cb-maint.cb-dead {
    display: block; padding: 0;
    background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none;
    overflow: auto;
    font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
.cb-dead .cbd {
    box-sizing: border-box;
    max-width: 600px; margin: 0 auto; padding: 14vh 24px 40px;
    text-align: left; color: #202124;
}
.cb-dead .cbd-ic { width: 72px; height: 72px; display: block; margin: 0 0 24px; fill: #dadce0; }
.cb-dead .cbd-fold { fill: #bdc1c6; }
.cb-dead h1 {
    margin: 0 0 16px; padding: 0;
    font-size: 1.6rem; font-weight: 400; line-height: 1.3; color: #202124;
}
.cb-dead p, .cb-dead li { font-size: .875rem; line-height: 1.6; color: #5f6368; }
.cb-dead .cbd-lead { margin: 0 0 24px; }
.cb-dead .cbd-lead b { font-weight: 500; color: #5f6368; }
.cb-dead .cbd-try { margin: 0 0 4px; }
.cb-dead .cbd-list { margin: 0; padding-left: 20px; }
.cb-dead .cbd-list li { margin: 2px 0; }
.cb-dead .cbd-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-top: 36px;
}
.cb-dead .cbd-code { font-size: .8125rem; color: #5f6368; letter-spacing: .01em; }
.cb-dead .cbd-btn {
    flex: none; cursor: pointer;
    padding: 8px 16px; border: 0; border-radius: 4px;
    background: #1a73e8; color: #fff;
    font-family: inherit; font-size: .875rem; font-weight: 500;
}
.cb-dead .cbd-btn:hover { background: #1b66c9; }
/* Chrome's error page follows the OS theme, so this has to as well */
@media (prefers-color-scheme: dark) {
    .cb-maint.cb-dead { background: #202124; }
    .cb-dead .cbd { color: #e8eaed; }
    .cb-dead h1 { color: #e8eaed; }
    .cb-dead p, .cb-dead li, .cb-dead .cbd-code, .cb-dead .cbd-lead b { color: #9aa0a6; }
    .cb-dead .cbd-ic { fill: #3c4043; }
    .cb-dead .cbd-fold { fill: #5f6368; }
    .cb-dead .cbd-btn { background: #8ab4f8; color: #202124; }
    .cb-dead .cbd-btn:hover { background: #aecbfa; }
}

/* ---------- ❓ Question of the Day ---------- */
.qd-q { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 12px; }
.qd-opts { display: flex; flex-direction: column; gap: 8px; }
.qd-opt {
    position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 14px;
    border-radius: 14px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(255,255,255,.04);
    color: inherit; font: inherit; font-size: 14px; text-align: left;
    cursor: pointer;
    transition: border-color .2s, transform .2s var(--neo-spring, ease);
}
.qd-opt:hover { border-color: var(--neo-accent, #8ab4ff); transform: translateY(-1px); }
.qd-opt.mine { border-color: var(--neo-accent, #8ab4ff); }
.qd-fill {
    position: absolute; inset: 0 auto 0 0;
    background: linear-gradient(90deg, rgba(138,180,255,.28), rgba(182,156,255,.18));
    transition: width .6s var(--neo-ease, ease);
}
.qd-opt.mine .qd-fill { background: linear-gradient(90deg, rgba(138,180,255,.45), rgba(182,156,255,.3)); }
.qd-label, .qd-pct { position: relative; }
.qd-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.qd-foot { margin-top: 10px; font-size: 12px; color: var(--neo-faint, rgba(235,235,245,.32)); }

/* ---------- 🧠 Quiz modal ---------- */
.qz-launch { background: var(--gradient-purple) !important; color: #fff !important; border-color: transparent !important; }
.qz-modal {
    position: fixed; inset: 0; z-index: 99993;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(4,5,14,.8);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.qz-modal[hidden] { display: none; }
.qz-box {
    position: relative;
    width: min(560px, 100%);
    max-height: 92vh; overflow-y: auto;
    padding: 28px 24px 22px;
    border-radius: 24px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(16,16,24,.96);
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.qz-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; }
.qz-title { margin: 0 0 4px; font-size: 22px; }
.qz-sub { margin: 0 0 16px; color: var(--neo-dim, rgba(235,235,245,.6)); }
.qz-modes { display: grid; gap: 10px; }
.qz-mode {
    display: flex; flex-direction: column; gap: 3px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(255,255,255,.04);
    color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.qz-mode:hover:not(:disabled) { border-color: var(--neo-accent, #8ab4ff); }
.qz-mode:disabled { opacity: .45; cursor: not-allowed; }
.qz-mode small { color: var(--neo-dim, rgba(235,235,245,.6)); }
.qz-reward { margin: 14px 0 0; font-size: 12.5px; color: var(--neo-dim, rgba(235,235,245,.6)); }
.qz-progress { height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.qz-progress span { display: block; height: 100%; background: var(--gradient-purple); transition: width .4s var(--neo-ease, ease); }
.qz-count { margin: 10px 0 12px; font-size: 12.5px; color: var(--neo-dim, rgba(235,235,245,.6)); }
.qz-q { font-size: 20px; font-weight: 700; line-height: 1.35; margin-bottom: 16px; overflow-wrap: anywhere; }
.qz-opts { display: grid; gap: 8px; }
.qz-opt {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(255,255,255,.04);
    color: inherit; font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
}
.qz-opt:hover:not(:disabled) { border-color: var(--neo-accent, #8ab4ff); }
.qz-opt.right { border-color: #34e8b0; background: rgba(52,232,176,.15); }
.qz-opt.wrong { border-color: #ff5a7a; background: rgba(255,90,122,.15); }
.qz-key { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 8px; background: rgba(255,255,255,.08); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.qz-type { display: flex; gap: 8px; }
.qz-input {
    flex: 1; min-width: 0;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--neo-line-hi, rgba(255,255,255,.16));
    background: rgba(255,255,255,.06);
    color: #fff; font: inherit; font-size: 15px; outline: none;
}
.qz-input:focus { border-color: var(--neo-accent, #8ab4ff); }
.qz-link { margin-top: 10px; background: none; border: 0; padding: 0; color: var(--neo-accent, #8ab4ff); font: inherit; font-size: 13px; cursor: pointer; }
.qz-fb { margin: 16px 0 12px; padding: 12px 14px; border-radius: 14px; font-size: 14.5px; }
.qz-fb.ok { background: rgba(52,232,176,.14); }
.qz-fb.bad { background: rgba(255,90,122,.14); }
.qz-next { width: 100%; }
.qz-result { text-align: center; margin: 4px 0 16px; }
.qz-score { font-size: 64px; font-weight: 800; letter-spacing: -0.04em; }
.qz-score span { font-size: 28px; color: var(--neo-dim, rgba(235,235,245,.6)); }
.qz-msg { font-size: 18px; font-weight: 700; }
.qz-missed { margin: 0 0 14px; display: grid; gap: 6px; font-size: 13.5px; }
.qz-miss { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,.04); }
.qz-miss span { color: var(--neo-dim, rgba(235,235,245,.6)); }
.qz-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.qz-actions .send-btn { flex: 1 1 100%; }

@media (prefers-reduced-motion: reduce) {
    .cb-bell:hover, .qd-opt:hover { transform: none; }
    .message.cb-flash .message-content { animation: none; }
}
