/* =========================================================================
   NexGenius Chat — application stylesheet
   One file, no framework. Sections follow the component tree:
   tokens → base → shell → chat → NexBuddy → pages/admin → components → auth → responsive
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
    --brand: #4f46e5;
    --brand-600: #4338ca;
    --brand-700: #3730a3;
    --brand-50: #eef2ff;
    --brand-100: #e0e7ff;

    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --chat-bg: #f1f3f9;
    --border: #e4e7ef;
    --border-strong: #d0d5e1;

    --text: #1b1f2c;
    --text-2: #4a5268;
    --muted: #727a90;

    --success: #16a34a;
    --success-bg: #e8f8ee;
    --warning: #b45309;
    --warning-bg: #fef4e2;
    --danger: #dc2626;
    --danger-bg: #fdecec;
    --info: #2563eb;
    --info-bg: #e8f0fe;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);
    --shadow: 0 4px 16px rgba(20, 24, 40, .08);
    --shadow-lg: 0 18px 48px rgba(20, 24, 40, .18);
    --ring: 0 0 0 3px rgba(79, 70, 229, .25);

    --topbar-h: 60px;
    --sidebar-w: 320px;
    --details-w: 320px;

    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Segoe UI Emoji", "Apple Color Emoji";
    --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; color: var(--text); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .82em; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .1em .4em; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
h1:focus { outline: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c9cedb; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #aab1c3; }

.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: fixed; left: 12px; top: -60px; z-index: 1000;
    background: var(--brand); color: #fff; padding: .5rem .9rem; border-radius: var(--radius-sm);
    transition: top .15s;
}
.skip-link:focus { top: 12px; text-decoration: none; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.pad { padding: 1rem; }
.wrap { flex-wrap: wrap; }
.wrap-text { white-space: normal; word-break: break-word; max-width: 420px; }
.danger { color: var(--danger) !important; }
.error-text, .text-danger { color: var(--danger); }
.w-100 { width: 100%; }
.mb-3 { margin-bottom: 1rem; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.row-gap { display: flex; align-items: center; gap: .5rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.section-title { font-size: .78rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2; white-space: nowrap;
    cursor: pointer; text-decoration: none !important; user-select: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .35); }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #b9c0d0; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-link { background: none; border: 0; color: var(--brand); padding: .35rem .5rem; font-weight: 600; }
.btn-link:hover:not(:disabled) { background: var(--brand-50); }
.btn-link.danger:hover:not(:disabled) { background: var(--danger-bg); }

.btn-sm { padding: .38rem .7rem; font-size: .82rem; }
.btn-xs { padding: .1rem .35rem; font-size: .75rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }

.btn-reset { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-align: inherit; }

.icon-btn {
    display: inline-grid; place-items: center; flex: 0 0 auto;
    width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent;
    font-size: 1.05rem; line-height: 1; color: var(--text-2); cursor: pointer; text-decoration: none !important;
    transition: background .15s;
}
.icon-btn:hover:not(:disabled) { background: #eceef5; }
.icon-btn[aria-pressed="true"] { background: var(--brand-50); }
.icon-btn:disabled { opacity: .5; cursor: not-allowed; }

.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* ---------- Forms ---------- */
.input, .form-control {
    display: block; width: 100%;
    padding: .6rem .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit; line-height: 1.35;
    transition: border-color .15s, box-shadow .15s;
}
.input:hover, .form-control:hover { border-color: #b9c0d0; }
.input:focus, .form-control:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input::placeholder { color: #9aa1b4; }
.input:disabled { background: var(--surface-2); color: var(--muted); }
textarea.input { resize: vertical; min-height: 2.6rem; }
select.input { appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23727a90' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; }
.input-auto { width: auto; min-width: 160px; }

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; flex: 1; }
.field > label, .label, .form-label, .control-label, legend { font-weight: 600; font-size: .86rem; color: var(--text-2); }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; }
.field-error, .validation-message { color: var(--danger); font-size: .82rem; }
.help { color: var(--muted); font-size: .82rem; margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); margin-top: .25rem; }

.validation-summary, ul.validation-errors { margin: 0; padding: .6rem .9rem .6rem 2rem; color: var(--danger); background: var(--danger-bg); border-radius: var(--radius-sm); font-size: .86rem; }
.validation-summary:empty, ul.validation-errors:empty { display: none; }
.valid.modified:not([type=checkbox]):not([type=radio]) { border-color: #7dd3a0; }
.invalid { border-color: var(--danger) !important; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: .45rem; }

.checkbox { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text-2); cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; }

.radio-group > div, .radio-group { display: flex; flex-wrap: wrap; gap: .5rem; }
.radio-group legend { width: 100%; }
.radio-group label {
    display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .8rem;
    border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; font-size: .9rem;
}
.radio-group label:has(input:checked) { border-color: var(--brand); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

/* Toggle switch: <label class="switch"><input type=checkbox/><span><strong/><small/></span></label> */
.switch { display: flex; align-items: flex-start; gap: .8rem; cursor: pointer; }
.switch input[type=checkbox] {
    appearance: none; -webkit-appearance: none; flex: 0 0 auto;
    width: 40px; height: 22px; margin-top: 1px; border-radius: 999px; background: #cfd4e0;
    position: relative; cursor: pointer; transition: background .2s;
}
.switch input[type=checkbox]::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch input[type=checkbox]:checked { background: var(--brand); }
.switch input[type=checkbox]:checked::after { transform: translateX(18px); }
.switch input[type=checkbox]:focus-visible { box-shadow: var(--ring); }
.switch input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }
.switch > span { display: flex; flex-direction: column; }
.switch strong { font-weight: 600; }
.switch small { color: var(--muted); font-size: .84rem; }

.days { display: flex; flex-wrap: wrap; gap: .4rem; }
.days legend { width: 100%; }
.day-chip, .topic-chip {
    display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--surface); font-size: .86rem; cursor: pointer; user-select: none;
    transition: background .15s, border-color .15s;
}
.day-chip input, .topic-chip input { position: absolute; opacity: 0; pointer-events: none; }
.day-chip:hover, .topic-chip:hover { border-color: var(--brand); }
.day-chip.on, .topic-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.day-chip:has(input:focus-visible), .topic-chip:has(input:focus-visible) { box-shadow: var(--ring); }
.topic-grid { display: flex; flex-wrap: wrap; gap: .45rem; }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr); height: 100vh; height: 100dvh; }

.topbar {
    display: flex; align-items: center; gap: 1.25rem; padding: 0 1rem 0 1.25rem;
    background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 30;
}

.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none !important; flex: 0 0 auto; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-weight: 800; font-size: 1.05rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
.brand-name { font-size: 1.05rem; font-weight: 500; letter-spacing: -.01em; }
.brand-name strong { font-weight: 750; color: var(--brand); }
.brand-lg { justify-content: center; margin-bottom: 1.5rem; }
.brand-lg .brand-mark { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 12px; }
.brand-lg .brand-name { font-size: 1.35rem; }

.topnav { display: flex; align-items: center; gap: .25rem; height: 100%; }
.topnav-link {
    position: relative; display: inline-flex; align-items: center; gap: .45rem; height: 40px; padding: 0 .85rem;
    border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: .9rem; text-decoration: none !important;
    transition: background .15s, color .15s;
}
.topnav-link:hover { background: #f0f1f7; color: var(--text); }
.topnav-link.active { background: var(--brand-50); color: var(--brand-700); }
.topnav-link .badge { margin-left: .1rem; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.presence-toggle { min-width: 0; padding-block: .3rem; font-size: .85rem; }
@media (max-width: 640px) { .presence-toggle { max-width: 9rem; } }

.conn-pill {
    display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 999px;
    background: var(--warning-bg); color: var(--warning); font-size: .8rem; font-weight: 600;
}
.conn-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }

.user-btn {
    display: inline-flex; align-items: center; gap: .55rem; padding: .25rem .7rem .25rem .25rem;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font: inherit; cursor: pointer;
}
.user-btn:hover { background: var(--surface-2); }
.user-name { font-weight: 600; font-size: .88rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-main { min-height: 0; overflow: auto; outline: none; }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 220px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: .35rem; animation: pop .12s ease-out;
}
.dropdown-wide { width: 360px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; }
.dropdown-item {
    display: flex; width: 100%; align-items: center; gap: .55rem; padding: .55rem .7rem; border: 0; border-radius: 8px;
    background: none; color: var(--text); font: inherit; font-size: .9rem; text-align: left; cursor: pointer; text-decoration: none !important;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-header { display: flex; align-items: center; justify-content: space-between; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.dropdown-pad { padding: 1.25rem; text-align: center; }

.bell { position: relative; }
.notification-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.notification {
    display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; width: 100%; padding: .75rem .9rem;
    border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; text-align: left; cursor: pointer;
}
.notification:hover { background: var(--surface-2); }
.notification.unread { background: var(--brand-50); }
.notification.unread .notification-title::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-right: .45rem; vertical-align: middle; }
.notification-title { font-weight: 600; font-size: .9rem; }
.notification-body { grid-column: 1; color: var(--text-2); font-size: .85rem; }
.notification-time { grid-column: 2; grid-row: 1; color: var(--muted); font-size: .75rem; white-space: nowrap; }

/* ---------- Badges, pills, chips ---------- */
.badge {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1;
}
.badge-dot { position: absolute; top: 1px; right: 0; min-width: 18px; height: 18px; font-size: .66rem; background: var(--danger); border: 2px solid var(--surface); }

.pill { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 650; vertical-align: middle; }
.pill-blue { background: var(--info-bg); color: var(--info); }
.pill-green { background: var(--success-bg); color: var(--success); }
.pill-amber { background: var(--warning-bg); color: var(--warning); }
.pill-red { background: var(--danger-bg); color: var(--danger); }
.pill-grey { background: #eef0f4; color: var(--muted); }

.ai-badge {
    display: inline-flex; align-items: center; padding: .1rem .5rem; margin-left: .35rem; border-radius: 999px;
    background: linear-gradient(135deg, #ede9fe, #e0e7ff); color: #5b21b6; font-size: .7rem; font-weight: 700;
    letter-spacing: .02em; vertical-align: middle;
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .4rem .3rem .7rem; border-radius: 999px;
    background: var(--brand-50); color: var(--brand-700); font-size: .82rem; font-weight: 600; border: 1px solid var(--brand-100);
}
.chip-x { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: .75rem; cursor: pointer; }
.chip-x:hover { background: var(--brand-100); }
.chip-btn { padding: .38rem .8rem; background: var(--surface); color: var(--text-2); border-color: var(--border-strong); cursor: pointer; font: inherit; font-size: .83rem; font-weight: 500; }
.chip-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-700); background: var(--brand-50); }
.chip-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Avatars ---------- */
.avatar {
    --avatar-hue: 240;
    position: relative; display: inline-grid; place-items: center; flex: 0 0 auto;
    width: 40px; height: 40px; border-radius: 50%;
    background: hsl(var(--avatar-hue) 70% 92%); color: hsl(var(--avatar-hue) 55% 32%);
    font-weight: 700; font-size: .9rem; user-select: none;
}
.avatar > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-xl { width: 92px; height: 92px; font-size: 1.9rem; }
.presence-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); }
.avatar-sm .presence-dot { width: 10px; height: 10px; }
.avatar-xl .presence-dot { width: 18px; height: 18px; border-width: 3px; right: 4px; bottom: 4px; }
.presence-dot.online { background: #22c55e; }
.presence-dot.offline { background: #b6bccb; }

/* ---------- Chat layout ---------- */
.chat-layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100%; min-height: 0; }
.chat-layout.with-details { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--details-w); }

.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }

.profile-card { display: flex; align-items: center; gap: .75rem; padding: 1rem; border-bottom: 1px solid var(--border); }
.profile-card-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.profile-card-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card-text small { color: var(--muted); }

.sidebar-search { padding: .75rem 1rem .25rem; }
.sidebar-search .input { background: var(--surface-2); border-color: var(--border); border-radius: 999px; padding-left: 1rem; }
.sidebar-search .input:focus { background: var(--surface); }

.sidebar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 1rem; }
.sidebar-section { padding: .25rem .5rem .5rem; }
.sidebar-section > .section-title { padding: .5rem .5rem .35rem; }
.sidebar-section.scroll { flex: 1; min-height: 0; overflow-y: auto; }

.segmented { display: inline-flex; padding: 3px; background: #eef0f5; border-radius: 10px; }
.segment { border: 0; background: none; padding: .32rem .75rem; border-radius: 8px; font: inherit; font-size: .82rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.segment:hover { color: var(--text); }
.segment.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.conv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-item {
    display: flex; align-items: center; gap: .75rem; width: 100%; padding: .65rem .6rem; border: 0; border-radius: var(--radius);
    background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; text-decoration: none !important;
    transition: background .12s;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--brand-50); }
.select-bar { display: flex; align-items: center; gap: .6rem; padding: .4rem .75rem; border-bottom: 1px solid var(--border, #e5e7eb); }
.select-bar .select-all { display: flex; align-items: center; gap: .35rem; font-size: .875rem; cursor: pointer; }
.select-bar .btn-danger { margin-left: auto; }
.conv-selectable { display: flex; align-items: center; gap: .25rem; padding-left: .5rem; }
.conv-selectable .conv-item { flex: 1; min-width: 0; }
.conv-check { width: 1.1rem; height: 1.1rem; flex: none; cursor: pointer; }
.conv-item .pin { margin-right: .3rem; font-size: .8em; }
.quick-actions { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 0 .5rem; }
.quick-actions .btn { white-space: nowrap; }
.conv-item:disabled { opacity: .6; }
.conv-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1; }
.conv-text > strong, .conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.conv-text small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .83rem; }
.conv-top, .conv-bottom { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.conv-top time { flex: 0 0 auto; color: var(--muted); font-size: .74rem; }
.conv-bottom small { flex: 1; min-width: 0; }
.conv-item.unread .conv-top strong { font-weight: 750; }
.conv-item.unread .conv-bottom small { color: var(--text); font-weight: 500; }
.conv-item.unread .conv-top time { color: var(--brand); font-weight: 600; }
.typing { color: var(--success); font-style: normal; font-weight: 500; }

/* ---------- Conversation pane ---------- */
.conversation-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--chat-bg); }

.conversation-header {
    display: flex; align-items: center; gap: .8rem; padding: .7rem 1.1rem; min-height: 64px;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.conversation-title { flex: 1; min-width: 0; }
.conversation-title h1 { font-size: 1.02rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtitle { margin: 0; color: var(--muted); font-size: .82rem; }
.header-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

.message-list {
    flex: 1; min-height: 0; overflow-y: auto; padding: 1.25rem clamp(.75rem, 3vw, 2.5rem);
    display: flex; flex-direction: column; gap: .3rem;
    background-color: var(--chat-bg);
    background-image: radial-gradient(rgba(79, 70, 229, .045) 1px, transparent 1px);
    background-size: 18px 18px;
}
.load-older { display: flex; justify-content: center; padding-bottom: .5rem; }

.day-separator { display: flex; justify-content: center; margin: .9rem 0 .5rem; }
.day-separator span {
    padding: .2rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .9); border: 1px solid var(--border);
    color: var(--muted); font-size: .74rem; font-weight: 600; box-shadow: var(--shadow-sm);
}

.message-row { display: flex; align-items: flex-end; gap: .35rem; max-width: 100%; }
.message-row.mine { flex-direction: row-reverse; }

.bubble {
    position: relative; max-width: min(72%, 620px); padding: .5rem .8rem .35rem; border-radius: 16px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    overflow-wrap: anywhere; animation: rise .16s ease-out;
}
.theirs .bubble { border-bottom-left-radius: 5px; }
.mine .bubble { background: var(--brand); border-color: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.bubble.failed { background: var(--danger-bg); border-color: #f5b5b5; color: var(--text); }
.bubble.bot { background: linear-gradient(180deg, #ffffff, #faf8ff); border-color: #e5defa; }

.bubble-sender { font-size: .76rem; font-weight: 700; color: var(--brand); margin-bottom: .1rem; }
.bubble.bot .bubble-sender { color: #7c3aed; }
.bubble-text { white-space: pre-wrap; line-height: 1.45; }
.bubble-reply {
    display: flex; flex-direction: column; margin: .1rem 0 .35rem; padding: .3rem .6rem; border-left: 3px solid var(--brand);
    background: var(--brand-50); border-radius: 6px; font-size: .82rem; color: var(--text-2);
}
.bubble-reply strong { font-size: .76rem; color: var(--brand-700); }
.bubble-reply span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine .bubble-reply { background: rgba(255, 255, 255, .16); border-left-color: rgba(255, 255, 255, .7); color: rgba(255, 255, 255, .9); }
.mine .bubble-reply strong { color: #fff; }

.bubble-image { display: block; margin: .3rem 0; border-radius: 10px; overflow: hidden; }
.bubble-image img { display: block; max-height: 280px; width: auto; object-fit: cover; }
.bubble-file {
    display: flex; align-items: center; gap: .5rem; margin: .3rem 0; padding: .5rem .7rem; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none !important;
}
.bubble-file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bubble-file small { color: var(--muted); }
.mine .bubble-file { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }
.mine .bubble-file small { color: rgba(255, 255, 255, .75); }

.bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: .3rem; margin-top: .1rem; font-size: .7rem; color: var(--muted); }
.mine .bubble-meta { color: rgba(255, 255, 255, .78); }
.mine .bubble-meta .btn-link { color: #fff; }
.bubble.failed .bubble-meta, .bubble.failed .bubble-meta .btn-link { color: var(--danger); }
.status { font-size: .74rem; letter-spacing: -.12em; }
.status-read { color: #a5f3fc; font-weight: 700; }

.reply-btn {
    width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-sm);
    cursor: pointer; opacity: 0; transition: opacity .15s; flex: 0 0 auto; margin-bottom: 4px;
}
.message-row:hover .reply-btn, .reply-btn:focus-visible { opacity: 1; }
.reply-btn:hover { color: var(--brand); }

.typing-bubble { padding: .65rem .9rem; }
.dots { display: inline-flex; gap: 3px; margin-left: .3rem; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .4; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
.typing-bubble .dots { color: var(--muted); margin: 0; }

/* Composer */
.composer { display: flex; flex-direction: column; gap: .5rem; padding: .75rem 1rem .9rem; background: var(--surface); border-top: 1px solid var(--border); }
.composer-reply {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .5rem .4rem .8rem;
    border-left: 3px solid var(--brand); background: var(--brand-50); border-radius: 8px; font-size: .85rem; color: var(--text-2);
}
.composer-reply span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-reply .icon-btn { width: 28px; height: 28px; font-size: .85rem; }
.composer-row { display: flex; align-items: flex-end; gap: .5rem; }
.composer-input {
    flex: 1; min-height: 44px; max-height: 160px; padding: .65rem 1rem; resize: none; field-sizing: content;
    border: 1px solid var(--border-strong); border-radius: 22px; background: var(--surface-2); font: inherit; line-height: 1.4; color: var(--text);
}
.composer-input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: var(--ring); }
.composer-row .icon-btn { width: 44px; height: 44px; }
.send-btn { height: 44px; padding: 0 1.2rem; border-radius: 22px; }
.suggestions { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.suggestions::-webkit-scrollbar { display: none; }
.suggestions .chip { flex: 0 0 auto; }
.disclaimer { margin: 0; text-align: center; font-size: .74rem; color: var(--muted); }

/* ---------- Details pane ---------- */
.details-pane { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--border); }
.details-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; min-height: 64px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.details-header h2 { margin: 0; font-size: 1rem; }
.details-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 1.5rem 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.details-hero h3 { margin: .5rem 0 0; font-size: 1.1rem; }
.details-hero p { margin: 0; }
.details-hero .stack { width: 100%; text-align: left; gap: .5rem; }
.presence-text { color: var(--muted); font-size: .84rem; }
.details-section { padding: 1rem; border-bottom: 1px solid var(--border); }
.details-section .section-head { margin-bottom: .5rem; }
.member-list { list-style: none; margin: 0; padding: 0; }
.member { display: flex; align-items: center; gap: .65rem; padding: .45rem 0; }
.member-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-text strong { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-text small { color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1rem; margin: 0; padding: 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.card .kv, .manage-body .kv { padding: 0; }

/* ---------- Empty / loading states ---------- */
.page-center { flex: 1; display: grid; place-items: center; padding: 2rem; min-height: 0; overflow: auto; }
.page-loading { display: grid; place-items: center; min-height: 60vh; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 2.5rem 1.5rem; max-width: 420px; margin: auto; }
.empty-icon {
    display: grid; place-items: center; width: 76px; height: 76px; margin-bottom: .6rem; border-radius: 50%;
    background: var(--surface); box-shadow: var(--shadow); font-size: 2.1rem;
}
.empty-title { font-size: 1.1rem; margin: 0; }
.empty-text { color: var(--muted); margin: 0 0 .75rem; }

.spinner-wrap { display: inline-flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--brand-100); border-top-color: var(--brand); animation: spin .7s linear infinite; flex: 0 0 auto; }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

.boot-loader {
    position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
    background: var(--bg); color: var(--muted); font-weight: 500;
}
.boot-loader .spinner { width: 36px; height: 36px; border-width: 4px; }

/* ---------- Alerts ---------- */
.alert {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .9rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; font-size: .9rem; margin-bottom: .75rem;
}
.alert-error, .alert-danger { background: var(--danger-bg); color: #991b1b; border-color: #f8caca; }
.alert-warn, .alert-warning { background: var(--warning-bg); color: #92400e; border-color: #f9dca8; }
.alert-info { background: var(--info-bg); color: #1e40af; border-color: #c7d8fb; }
.alert-success { background: var(--success-bg); color: #166534; border-color: #b7e8c8; }
.alert .btn-link { color: inherit; text-decoration: underline; }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 800; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 32px)); }
.toast {
    display: flex; align-items: center; gap: .5rem; padding: .7rem .5rem .7rem 1rem; border-radius: var(--radius);
    background: #1f2433; color: #fff; box-shadow: var(--shadow-lg); border-left: 4px solid var(--info); animation: rise .2s ease-out;
}
.toast-success { border-left-color: #22c55e; }
.toast-error { border-left-color: #ef4444; }
.toast-text { flex: 1; font-size: .9rem; }
button.toast-text { text-decoration: underline; text-underline-offset: 2px; }
.toast .icon-btn { color: #c3c8d6; width: 30px; height: 30px; font-size: .85rem; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, .1); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 600; background: rgba(17, 20, 33, .45); backdrop-filter: blur(2px); animation: fade .15s; }
.modal {
    position: fixed; z-index: 601; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
    background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: pop-center .16s ease-out;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 1.08rem; }
.modal-body { padding: 1.25rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.modal-body form { display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Employee picker */
.picker { display: flex; flex-direction: column; gap: .6rem; }
.picker-results { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .3rem; }
.picker-results:empty { display: none; }
.picker-results > .muted, .picker-results > .spinner-wrap { padding: .6rem; }
.picker-row { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .45rem .55rem; border: 0; border-radius: 8px; background: none; font: inherit; text-align: left; cursor: pointer; }
.picker-row:hover { background: var(--surface-2); }
.picker-row.selected { background: var(--brand-50); }
.picker-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.picker-text small { color: var(--muted); }
.check { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-strong); color: #fff; font-size: .75rem; font-weight: 700; }
.picker-row.selected .check { background: var(--brand); border-color: var(--brand); }

/* ---------- NexBuddy ---------- */
.buddy-layout { height: 100%; display: flex; justify-content: center; background: var(--chat-bg); }
.buddy-pane { width: 100%; max-width: 980px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.buddy-pane .avatar { background: linear-gradient(135deg, #ede9fe, #e0e7ff); font-size: 1.2rem; }
.optin-card {
    max-width: 520px; padding: 2rem; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow); text-align: center;
}
.optin-card .empty-icon { margin: 0 auto 1rem; background: linear-gradient(135deg, #ede9fe, #e0e7ff); }
.optin-card p { color: var(--text-2); }
.checklist { list-style: none; padding: 0; margin: 1rem 0 1.5rem; text-align: left; display: flex; flex-direction: column; gap: .5rem; }
.checklist li { padding: .55rem .8rem; background: var(--surface-2); border-radius: var(--radius-sm); font-size: .9rem; }

/* ---------- Pages (settings, profile, admin) ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 1.75rem clamp(1rem, 3vw, 2rem) 3rem; display: flex; flex-direction: column; gap: 1.25rem; }
.page-header { display: flex; flex-direction: column; gap: .5rem; }
.page-header h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.01em; }
.page-header p { margin: 0; max-width: 720px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1.25rem; align-items: start; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.35rem; box-shadow: var(--shadow-sm); min-width: 0; }
.card > h2:first-child, .card > header h2 { font-size: 1.05rem; }
.card h2 { margin: 0; }
.settings-section { display: flex; flex-direction: column; gap: .9rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--border); }
.settings-section:last-of-type { border-bottom: 0; padding-bottom: 0; }
.settings-section > h2, .settings-section > h3 { margin: 0; font-size: 1rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-top: .25rem; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 0 0 auto; padding: .6rem .9rem; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent;
    margin-bottom: -1px; text-decoration: none !important; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.toolbar > .input:first-of-type { flex: 1 1 260px; max-width: 420px; }
.toolbar > .btn-primary { margin-left: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.stat { display: flex; flex-direction: column; gap: .2rem; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); opacity: .8; }
.stat-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .84rem; font-weight: 500; }
.stat-warn::before { background: var(--danger); }
.stat-warn .stat-value { color: var(--danger); }

.health-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; font-size: .9rem; }
.health-list li { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot.ok { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

.bar { display: inline-block; height: 8px; width: calc(var(--w, 0%) * .7); min-width: 2px; max-width: 70%; border-radius: 4px; background: linear-gradient(90deg, #6366f1, #8b5cf6); vertical-align: middle; margin-right: .4rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .89rem; }
.table th { text-align: left; padding: .7rem .9rem; background: var(--surface-2); color: var(--muted); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfe; }
.table td.actions { white-space: nowrap; text-align: right; }
.card .table th:first-child, .card .table td:first-child { padding-left: 0; }
.card .table-wrap .table th:first-child, .card .table-wrap .table td:first-child { padding-left: .9rem; }
.row-muted td, li.row-muted { opacity: .6; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; color: var(--muted); font-size: .86rem; padding-top: .25rem; }

.lookup-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lookup-list li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
.lookup-list li:last-child { border-bottom: 0; }
.lookup-list li:hover { background: #fafbfe; }
.lookup-list li > .input { flex: 1; min-width: 160px; }
.lookup-name { flex: 1; min-width: 0; font-weight: 500; }

.copy-box { display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem .5rem .8rem; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.copy-box > :first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: .82rem; }
.copy-box .input { font-family: var(--mono); font-size: .82rem; background: transparent; border: 0; box-shadow: none; padding: 0; }

.recovery-code { display: inline-block; margin: .2rem; padding: .3rem .6rem; font-size: .95rem; }

/* ---------- Auth pages (sign-in, invitation, account security) ---------- */
.auth-shell {
    min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem;
    padding: 2rem 1rem;
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(99, 102, 241, .22), transparent 60%),
        radial-gradient(800px 500px at 110% 110%, rgba(139, 92, 246, .2), transparent 60%),
        var(--bg);
}
.auth-card {
    width: 100%; max-width: 440px; padding: 2.25rem 2rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: 22px; box-shadow: var(--shadow-lg);
}
.auth-card:has(.manage-body) { max-width: 760px; }
.auth-title { text-align: center; font-size: 1.45rem; margin-bottom: .3rem; }
.auth-subtitle { text-align: center; color: var(--muted); margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form .btn-primary { padding: .75rem 1rem; font-size: .95rem; margin-top: .25rem; }
.auth-hint { text-align: center; color: var(--muted); font-size: .82rem; margin: .25rem 0 0; }
.auth-footer { color: var(--muted); font-size: .78rem; margin: 0; }
.auth-card > .btn { margin-top: .5rem; }
.auth-card > .help { text-align: center; }

.manage-body { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.manage-body h3 { margin-top: .5rem; }
.manage-body form { display: flex; flex-direction: column; gap: 1rem; }
/* Identity markup puts the label after the input */
.manage-body .field > label, .form-floating > label { order: -1; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.col-md-4, .col-md-12, .col-xl-6 { flex: 1 1 100%; min-width: 0; }
.form-floating { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }

.blazor-error-boundary { padding: 1rem 1rem 1rem 1.25rem; background: var(--danger-bg); color: #991b1b; border-radius: var(--radius-sm); border-left: 4px solid var(--danger); }
.blazor-error-boundary::after { content: "An error has occurred."; }

#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; padding: .7rem 1.25rem;
    background: #fff7d6; box-shadow: 0 -1px 8px rgba(0, 0, 0, .15); font-size: .9rem;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes pop-center { from { opacity: 0; transform: translate(-50%, -48%) scale(.97); } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Responsive ---------- */
.mobile-only { display: none !important; }

@media (max-width: 1180px) {
    .chat-layout.with-details { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
    .chat-layout.with-details .details-pane {
        position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: min(var(--details-w), 100vw); z-index: 40; box-shadow: var(--shadow-lg);
        animation: slide-in .18s ease-out;
    }
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }

@media (max-width: 900px) {
    :root { --sidebar-w: 280px; }
    .topnav-label, .user-name { display: none; }
    .topnav-link { padding: 0 .7rem; }
    .brand-name { display: none; }
}

@media (max-width: 720px) {
    :root { --topbar-h: 56px; }
    .topbar { gap: .5rem; padding: 0 .5rem 0 .75rem; }
    .user-btn { padding: .2rem; border: 0; }
    .mobile-only { display: inline-grid !important; }

    .chat-layout, .chat-layout.with-details { grid-template-columns: minmax(0, 1fr); }
    .chat-layout.mobile-list .conversation-pane { display: none; }
    .chat-layout.mobile-conversation .sidebar { display: none; }
    .sidebar { border-right: 0; }

    .bubble { max-width: 85%; }
    .reply-btn { opacity: .6; }
    .send-btn { padding: 0 1rem; }
    .conversation-header { padding: .5rem .6rem; gap: .5rem; }
    .header-actions .btn { padding: .35rem .55rem; }

    .page { padding-top: 1.25rem; }
    .page-header h1 { font-size: 1.35rem; }
    .card { padding: 1.1rem; border-radius: var(--radius); }
    .toolbar > .btn-primary { margin-left: 0; width: 100%; }
    .toolbar > .input:first-of-type { max-width: none; }
    .auth-card { padding: 1.75rem 1.25rem; }
    .kv { grid-template-columns: 1fr; gap: .15rem; }
    .kv dd { margin-bottom: .5rem; }
    .modal { top: auto; bottom: 0; transform: translateX(-50%); width: 100vw; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; animation: rise .18s ease-out; }
}

/* ---------- Directory & Admin Communication Center ---------- */
.inline-user { display: inline-flex; align-items: center; gap: .6rem; }
.comm-layout { display: grid; grid-template-columns: minmax(320px, 1.2fr) minmax(240px, .8fr) minmax(340px, 1.4fr); gap: 1rem; align-items: start; }
.comm-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 220px); }
.comm-panel > header { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.comm-panel > header h2 { font-size: 1rem; margin: 0; }
.comm-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.comm-row { display: flex; gap: .6rem; align-items: center; width: 100%; padding: .6rem 1rem; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.comm-row:hover { background: var(--surface-2); }
.comm-row.active { background: var(--brand-50); }
.comm-row .grow { flex: 1; min-width: 0; }
.comm-row .grow small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comm-messages { padding: .75rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
.comm-msg { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .7rem; background: var(--surface-2); }
.comm-msg.admin { border-color: var(--info); background: var(--info-bg); }
.comm-msg header { display: flex; gap: .5rem; align-items: baseline; font-size: .8rem; }
.comm-msg p { margin: .2rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comm-composer { border-top: 1px solid var(--border); padding: .6rem; display: flex; flex-direction: column; gap: .4rem; }
.policy-banner { background: var(--info-bg); color: var(--text); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem; font-size: .88rem; }
@media (max-width: 1100px) {
    .comm-layout { grid-template-columns: 1fr; }
    .comm-panel { max-height: none; }
}
