/* PrivateOfficeAI Local — app stylesheet. Light, flat, modern. No shadows, no glows. */

/* The HTML `hidden` attribute must always win. Author rules like
   `display:flex` otherwise override it, leaving toggled panels/modals stuck
   visible — force it here so `el.hidden = true` reliably hides anything. */
[hidden] { display: none !important; }

/* Dark is the default; light is opt-in via data-theme="light". */
:root, :root[data-theme="dark"] {
    --bg: #0e1116;
    --panel: #161b22;
    --border: #262c36;
    --border-strong: #39414d;
    --text: #e6e9ee;
    --dim: #9099a6;
    --accent: #4d8ee8;
    --accent-dark: color-mix(in srgb, var(--accent) 82%, #fff);
    --accent-soft: color-mix(in srgb, var(--accent) 16%, #0e1116);
    --ok: #3fb984;
    --ok-soft: color-mix(in srgb, #3fb984 16%, #0e1116);
    --err: #e5686b;
    --err-dark: color-mix(in srgb, #e5686b 80%, #000);
    --err-soft: color-mix(in srgb, #e5686b 16%, #0e1116);
    --code-bg: #0a0d12;
    --r: 8px;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #fafafa;
    --panel: #ffffff;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #18181b;
    --dim: #71717a;
    --accent: #1a5dab;
    --accent-dark: color-mix(in srgb, var(--accent) 78%, #000);
    --accent-soft: color-mix(in srgb, var(--accent) 9%, #fff);
    --ok: #0a7d55;
    --ok-soft: #e8f6f0;
    --err: #bf3131;
    --err-dark: color-mix(in srgb, #bf3131 82%, #000);
    --err-soft: #fbeeee;
    --code-bg: #171e29;
    color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.55;
    font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* ---------- App header ---------- */
:root { --appbar-h: 56px; }
.appbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 18px;
    height: var(--appbar-h);
    padding: 0 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.appbar .brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.appbar .brand img { height: 26px; width: 26px; }
.appbar nav { display: flex; gap: 6px; }
.appbar nav a {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--dim);
    font-weight: 500;
    font-size: 0.93rem;
}
.appbar nav a:hover { background: var(--bg); color: var(--text); border-color: var(--dim); }
.appbar nav a.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
/* Mobile page-switcher (hidden on desktop) + the Log out row inside the menu. */
.pagenav-btn {
    display: none;
    align-items: center;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    padding: 7px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
}
.appbar nav .nav-user { display: none; }
body.pagenav-open .appbar nav .nav-user {
    display: block;
    padding: 10px 12px 9px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    border-radius: 0;
    color: var(--text);
}
body.pagenav-open .appbar nav .nav-user .nav-user-name { display: block; font-weight: 600; font-size: 0.95rem; }
body.pagenav-open .appbar nav .nav-user .nav-user-roles { display: inline-flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.appbar nav .nav-logout { display: none; }
body.pagenav-open .appbar nav .nav-logout { display: block; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
body.pagenav-open .appbar nav .nav-logout button {
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 11px 12px;
    font-size: 0.95rem;
    color: var(--err);
    cursor: pointer;
    font-family: inherit;
    border-radius: var(--r);
}
body.pagenav-open .appbar nav .nav-logout button:hover { background: var(--err-soft); }
.appbar .spacer { flex: 1; }
.appbar .who { color: var(--dim); font-size: 0.88rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.appbar .who .who-account { display: inline-flex; align-items: center; justify-content: center; }
.menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r);
    width: 38px; height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
}

/* ---------- Buttons & inputs ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: var(--r);
    padding: 9px 16px;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    line-height: 1.2;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: var(--panel); color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 6px 12px; font-size: 0.87rem; }

.input, textarea.input, select.input {
    width: 100%;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    padding: 9px 12px;
    font-size: 0.95rem;
    color: var(--text);
    font-family: inherit;
}
.input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
/* Live-validation: a finished value in the wrong format (e.g. a half-typed
   phone or bad email). Cleared the moment they start fixing it. */
.input.input-invalid { border-color: var(--err); }
.input.input-invalid:focus { border-color: var(--err); }
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 14px 0 5px; color: var(--text); }
label small { font-weight: 400; color: var(--dim); }

.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 0.88rem; padding: 0; font-family: inherit; font-weight: 500; }
.linkbtn:hover { color: var(--accent-dark); }
.linkbtn.danger { color: var(--err); }

/* ---------- Cards, tables, badges, notices ---------- */
.page { width: 100%; padding: 24px 28px 60px; }
.page h1 { font-size: 1.45rem; letter-spacing: -0.01em; margin-bottom: 4px; }
.page .sub { color: var(--dim); margin-bottom: 24px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
}
.card h3 { font-size: 1rem; margin-bottom: 10px; }
.card + .card { margin-top: 16px; }
.grid2 > .card + .card { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 16px 0 40px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.92rem; white-space: nowrap; }
.table th { font-weight: 600; font-size: 0.78rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.04em; }
.table tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; padding: 2px 9px; font-size: 0.75rem; font-weight: 600; border-radius: 20px; background: transparent; border: 1px solid var(--border); color: var(--dim); }
.badge.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge.off { background: var(--err-soft); border-color: transparent; color: var(--err); }
.badge.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
/* Role badges in the nav dropdown always carry a light hairline border. */
.nav-user-roles .badge { border: 1px solid var(--border); }

.notice { border-radius: var(--r); padding: 11px 14px; font-size: 0.92rem; margin-bottom: 16px; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.err { background: var(--err-soft); color: var(--err); }
.dim { color: var(--dim); }

/* ---------- Auth (login / setup) ---------- */
.auth-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 32px 28px; width: 100%; max-width: 400px; }
.auth-card .logo { text-align: center; font-weight: 700; font-size: 1.15rem; margin-bottom: 22px; }
.auth-card .logo span { color: var(--accent); }
.auth-card .btn { width: 100%; margin-top: 22px; }
.auth-card .error { background: var(--err-soft); color: var(--err); border-radius: var(--r); padding: 10px 13px; font-size: 0.9rem; margin-bottom: 6px; }
.auth-card input { width: 100%; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--r); padding: 9px 12px; font-size: 0.95rem; color: var(--text); }
.auth-card input:focus { outline: none; border-color: var(--accent); }

/* ---------- Chat ---------- */
.chat-shell { display: flex; height: calc(100dvh - var(--appbar-h)); overflow: hidden; }

.chat-side {
    width: 264px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 14px 10px 20px;
}
.side-section { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); margin: 18px 8px 6px; font-weight: 700; }
.side-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--r);
    color: var(--text);
    font-size: 0.9rem;
}
.side-item:hover { background: var(--bg); color: var(--text); }
.side-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-owner { font-size: 0.72rem; color: var(--dim); flex-shrink: 0; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}
.chat-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chat-sub { flex-shrink: 0; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Auto "what we're talking about" label, centered in the room header. */
.chat-topic { flex: 1 1 auto; min-width: 0; text-align: center; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; font-size: 0.82rem; color: var(--dim, #8a9099); font-weight: 400; }
.chat-topic:empty { display: none; }
.chat-topic .ct-label { opacity: .7; }
.chat-topic .ct-text { font-weight: 600; color: var(--text, #1c1e21); }
/* Shimmer the topic text for a beat whenever it changes. */
.chat-topic.shimmer .ct-text {
    background: linear-gradient(90deg, var(--dim,#8a9099) 15%, var(--accent,#1a5dab) 50%, var(--dim,#8a9099) 85%);
    background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    animation: ctshim 0.9s ease-in-out 2;
}
@keyframes ctshim { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .chat-topic.shimmer .ct-text { animation: none; } }
.room-earlier, .chat-earlier { display: block; margin: 10px auto; padding: 6px 14px; border: 1px solid var(--border);
    background: var(--panel); border-radius: 999px; font-size: 0.82rem; color: var(--text-dim, #565959); cursor: pointer; }
.room-earlier:hover, .chat-earlier:hover { background: var(--bg); }
.room-earlier:disabled, .chat-earlier:disabled { opacity: .6; cursor: default; }
.chat-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; margin-left: auto; }
.btn.ghost.danger-ghost { color: var(--err); }
.btn.ghost.danger-ghost:hover { background: var(--err-soft); }

.chat-log { flex: 1; overflow-y: auto; padding: 20px 20px 10px; }
.chat-log-inner { max-width: 760px; margin: 0 auto; }
/* The welcome screen centers vertically in the whole chat area. */
.chat-log-inner:has(.chat-empty) {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
}
/* Rooms: the empty state sits straight in .chat-main (no .chat-log-inner
   wrapper). margin:auto centres it both ways inside the flex column without
   depending on :has() support. */
.chat-main > .chat-empty { margin: auto; }
.chat-empty { text-align: center; padding: 0 10px; }
/* Quick-access room pills on the empty screen — so you don't have to open the
   sidebar/hamburger just to pick a room. */
.room-pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px auto 0; max-width: 460px; }
.room-pill { display: inline-block; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 999px;
    font-size: 0.9rem; font-weight: 600; color: var(--text); background: var(--panel); text-decoration: none; }
.room-pill:hover { border-color: var(--accent); color: var(--accent); }
.chat-empty h2 { font-size: 1.5rem; margin-bottom: 8px; letter-spacing: -0.01em; }
.chat-empty p { color: var(--dim); max-width: 420px; margin: 0 auto; }
.biz-know { max-width: 560px; margin: 18px auto 0; text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.biz-know > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 12px 15px; font-size: 0.9rem; font-weight: 600; color: var(--text); list-style: none; }
.biz-know > summary::-webkit-details-marker { display: none; }
.biz-know > summary svg { color: var(--accent); flex-shrink: 0; }
.biz-know[open] > summary { border-bottom: 1px solid var(--border); }
.biz-know > p { padding: 13px 16px; margin: 0; font-size: 0.9rem; line-height: 1.6; color: var(--dim); max-width: none; }
.empty-group { max-width: 560px; margin: 26px auto 0; text-align: left; }
.empty-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); margin-bottom: 10px; padding-left: 2px; }
.empty-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.empty-chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 13px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--card); color: var(--text); font-size: 0.9rem;
    cursor: pointer; text-align: left; line-height: 1.3; font-family: inherit;
    transition: border-color 0.12s ease, background 0.12s ease;
}
.empty-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.empty-chip svg { color: var(--dim); flex-shrink: 0; }
.empty-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }

.msg {
    position: relative;
    max-width: 82%;
    width: fit-content;
    padding: 10px 14px;
    margin: 10px 0;
    font-size: 0.95rem;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    border-radius: 12px;
    animation: msgin 0.16s ease-out;
}
@keyframes msgin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.me { margin-left: auto; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { margin-right: auto; background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.err { color: var(--err); background: var(--err-soft); border-color: transparent; }
.msg.typing { display: inline-flex; gap: 5px; align-items: center; padding: 15px 16px; }
.tdot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: tpulse 1.2s infinite; }
.tdot:nth-child(2) { animation-delay: 0.2s; }
.tdot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tpulse { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.chat-inputbar { background: var(--panel); border-top: 1px solid var(--border); padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); }
.chat-input { display: flex; gap: 10px; align-items: flex-end; max-width: 760px; margin: 0 auto; }
.chat-input textarea {
    flex: 1;
    min-height: 46px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 160px;
    background: var(--panel);
    color: var(--text);
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); }
.chat-input .btn { border-radius: 12px; padding: 0 18px; height: 46px; }
/* Send button: paper plane normally, stop square while generating. */
#send .ic-stop { display: none; }
#send.gen .ic-send { display: none; }
#send.gen .ic-stop { display: inline-block; }
.chat-status { max-width: 760px; margin: 4px auto 0; font-size: 0.8rem; color: var(--dim); min-height: 1.1em; }

/* ---------- Mobile ---------- */
.side-backdrop { display: none; }
@media (max-width: 760px) {
    /* One 56px row: [chats ☰] brand … [Current page ▾] theme. The page list
       opens as a dropdown card — inline pills can never fit a phone, and a
       clipped nav means no way to reach Settings. */
    .appbar { gap: 8px; padding: 0 10px; }
    .appbar .brand { font-size: 0.95rem; min-width: 0; flex-shrink: 1; }
    .appbar nav { display: none; }
    body.pagenav-open .appbar nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
        position: fixed;
        top: calc(var(--appbar-h) + 6px);
        right: 10px;
        min-width: 200px;
        background: var(--panel);
        border: 1px solid var(--border-strong);
        border-radius: 12px;
        padding: 6px;
        z-index: 60;
    }
    body.pagenav-open .appbar nav a { border: 0; padding: 11px 12px; font-size: 0.95rem; }
    .pagenav-btn { display: inline-flex; order: 5; margin-left: 0; }
    .appbar .who { order: 6; }
    .appbar .who .logout-form { display: none; }   /* Log out lives in the menu */
    .appbar .who .who-account { display: none; }   /* identity lives in the menu */
    .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .chat-side {
        position: fixed;
        top: var(--appbar-h);
        left: 0;
        bottom: 0;
        z-index: 40;
        width: 280px;
        transform: translateX(-102%);
        transition: transform 0.2s ease;
    }
    body.side-open .chat-side { transform: none; }
    body.side-open .side-backdrop {
        display: block;
        position: fixed;
        inset: var(--appbar-h) 0 0 0;
        background: rgba(0, 0, 0, 0.28);
        z-index: 39;
    }
    .chat-log { padding: 14px 12px 8px; }
    .msg { max-width: 92%; }
    .msg.ai { max-width: 100%; }          /* answers get the whole width */
    .chat-inputbar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
    .page { padding: 20px 14px 50px; }
    .card { padding: 16px; }

    /* iOS zooms the whole page when a focused field is under 16px — keep
       every text field at 16px on phones so focusing never jolts the layout. */
    .chat-input textarea, .input, textarea.input, select.input, .auth-card input { font-size: 16px; }

    /* Chat header: the title gets its own row; actions sit compact below it. */
    /* Row 1: room name + Edit/Delete. Row 2: the topic, full width, left-aligned. */
    .chat-head { flex-wrap: wrap; padding: 8px 12px; gap: 2px 8px; }
    .chat-title { flex: 1 1 auto; order: 0; }
    .chat-actions { order: 1; }
    .chat-topic { order: 2; flex-basis: 100%; text-align: left; font-size: 0.76rem; }
    .chat-sub { flex-basis: 100%; white-space: normal; }
    .chat-actions .btn.sm { padding: 4px 10px; font-size: 0.8rem; }

    /* Composer: icon-only Web + Send buttons, tighter row, room for the text. */
    .web-btn span { display: none; }
    #send .send-label { display: none; }
    .chat-input { gap: 7px; }
    .chat-input .btn { padding: 0 13px; }
    .empty-chip span { max-width: 190px; }

    /* Tables (Team page etc): let cells wrap instead of forcing a wide scroll. */
    .table th, .table td { white-space: normal; padding: 8px 10px; font-size: 0.88rem; }
}

/* ---------- Color input ---------- */
input[type="color"] {
    display: block;
    width: 56px; height: 36px; padding: 2px;
    border: 1px solid var(--border-strong); border-radius: var(--r);
    background: var(--panel); cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

/* ---------- Uploader (Drive-style) ---------- */
.drop {
    border: 2px dashed var(--border-strong);
    border-radius: 10px;
    padding: 26px 16px;
    text-align: center;
    color: var(--dim);
    font-size: 0.92rem;
    cursor: pointer;
    margin-top: 14px;
    transition: border-color 0.12s, background 0.12s;
}
.drop strong { color: var(--accent); font-weight: 600; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop input[type="file"] { display: none; }

.filelist { margin-top: 6px; }
.filerow {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 4px;
    border-top: 1px solid var(--border);
    font-size: 0.92rem;
    animation: msgin 0.16s ease-out;
}
.filerow:first-child { border-top: 0; }
.fext {
    flex-shrink: 0;
    min-width: 42px; text-align: center;
    background: var(--accent-soft); color: var(--accent);
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    padding: 5px 6px; border-radius: 6px; letter-spacing: 0.03em;
}
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmeta { color: var(--dim); font-size: 0.82rem; white-space: nowrap; }
.fstatus { font-size: 0.82rem; white-space: nowrap; }
.fstatus.up { color: var(--accent); }
.fstatus.done { color: var(--ok); }
.fstatus.fail { color: var(--err); }

/* Folder header row */
.folder-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.folder-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.folder-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.folder-title .folder-ico { color: var(--accent); flex-shrink: 0; }
.folder-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: 1rem; }
.folder-meta { font-size: 0.82rem; margin-top: 2px; }
.folder-editbtn { flex-shrink: 0; }
.folder-editbtn svg { margin-right: 5px; vertical-align: -2px; }
.filemore {
    margin-top: 10px; background: none; border: none; cursor: pointer;
    color: var(--accent); font-family: inherit; font-size: 0.85rem; font-weight: 600;
    padding: 4px 2px;
}
.filemore:hover { text-decoration: underline; }

/* ---------- File grid (Drive-style) ---------- */
.filegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; margin-top: 14px; }
.ftile {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    padding: 16px 10px 10px;
    text-align: center;
    animation: msgin 0.16s ease-out;
}
.ftile:hover { border-color: var(--border-strong); }
/* Trash icon in the top-right corner — quiet until you mean it. */
.ftile .fremove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    border-radius: 6px;
    color: var(--dim);
    cursor: pointer;
    opacity: 0.6;
}
.ftile .fremove:hover { color: var(--err); background: var(--err-soft); opacity: 1; }
.ficon {
    width: 46px; height: 58px;
    margin: 0 auto 10px;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 6px 14px 6px 6px;   /* folded corner */
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 7px;
}
.ficon span {
    background: var(--accent);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    max-width: 40px;
    overflow: hidden;
}
.ftile .fname {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}
.ftile .fmeta { color: var(--dim); font-size: 0.78rem; display: flex; align-items: center; justify-content: center; gap: 6px; }
.rdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.rdot.on { background: var(--ok); }
.rdot.off { background: var(--err); }

.ftile .fstatus { font-size: 0.8rem; margin-top: 6px; }
.fstatus.up { color: var(--accent); }
.fstatus.done { color: var(--ok); }
.fstatus.fail { color: var(--err); }

/* ---------- AI Engine tiers ---------- */
.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.tier {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    background: var(--panel);
}
.tier:hover { border-color: var(--accent); }
.tier.active { border-color: var(--accent); background: var(--accent-soft); cursor: default; }
.tier.disabled { opacity: 0.55; cursor: not-allowed; }
.tier.disabled:hover { border-color: var(--border); }
.tier-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.tier p { font-size: 0.86rem; margin-bottom: 8px; }
.tier-caps { list-style: none; margin: 0 0 10px; padding: 0; }
.tier-caps li { font-size: 0.82rem; padding: 2px 0 2px 20px; position: relative; color: var(--text); }
.tier-caps li::before { content: '✓'; position: absolute; left: 2px; color: var(--ok, #3fb950); font-weight: 700; }
.tier-caps li.cap-no { color: var(--dim); }
.tier-caps li.cap-no::before { content: '—'; color: var(--dim); font-weight: 400; }
.tier-state { font-size: 0.8rem; border-top: 1px solid var(--border); padding-top: 8px; }
.pbar { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; max-width: 460px; }
.pfill { height: 100%; background: var(--accent); width: 0; border-radius: 20px; transition: width 0.25s ease; }
.pfill.pull-error { background: var(--err); }
p.pull-error { color: var(--err); }

/* ---------- Modal dialogs ---------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(24, 24, 27, 0.35);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
/* The display:flex above beats the browser's [hidden] rule, so a toggled
   overlay would show anyway — this restores hide-when-hidden. */
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 20px;
    width: 100%; max-width: 380px;
    animation: msgin 0.14s ease-out;
}
.modal.modal-wide { max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-msg { font-size: 0.95rem; margin-bottom: 14px; }
.modal .input { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.danger { background: var(--err); border-color: var(--err); }
.btn.danger:hover { background: var(--err-dark); border-color: var(--err-dark); }
.logout-form { margin: 0; display: inline-flex; }

/* ---------- Markdown inside AI replies ---------- */
.msg.ai.md { white-space: normal; }
.msg.ai.md > *:first-child { margin-top: 0; }
.msg.ai.md > *:last-child { margin-bottom: 0; }
.msg.ai.md p { margin: 8px 0; }
.msg.ai.md h3, .msg.ai.md h4, .msg.ai.md h5 { margin: 12px 0 6px; font-size: 1rem; }
.msg.ai.md ul, .msg.ai.md ol { margin: 8px 0; padding-left: 22px; }
.msg.ai.md li { margin: 3px 0; }
.msg.ai.md code { background: var(--accent-soft); color: var(--accent-dark); border-radius: 4px; padding: 1px 6px; font-size: 0.86em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.msg.ai.md pre { background: var(--code-bg); color: #e8ebf0; border-radius: 10px; padding: 14px; overflow-x: auto; margin: 10px 0; }
.msg.ai.md .prewrap { margin: 10px 0; background: var(--code-bg); border-radius: 10px; border: 1px solid var(--border); }
.msg.ai.md .prewrap pre { background: transparent; border-radius: 0; margin: 0; padding-top: 2px; }
.msg.ai.md pre code { background: none; color: inherit; border: 0; padding: 0; font-size: 0.85rem; line-height: 1.6; }
.msg.ai.md blockquote { border-left: 3px solid var(--border-strong); padding-left: 12px; color: var(--dim); margin: 8px 0; }
.msg.ai.md hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.msg.ai.md .md-table { overflow-x: auto; margin: 8px 0; }
.msg.ai.md table { border-collapse: collapse; font-size: 0.9rem; }
.msg.ai.md th, .msg.ai.md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.msg.ai.md th { font-weight: 600; }
.msg.ai.md a { text-decoration: underline; }

/* ---------- Deep thinking: the collapsible thought box ---------- */
.think-box {
    margin: 0 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    font-size: 0.84rem;
    color: var(--dim);
}
.think-box summary {
    cursor: pointer;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--dim);
    list-style: none;
    user-select: none;
}
.think-box summary::before { content: '▸ '; }
.think-box[open] summary::before { content: '▾ '; }
.think-box summary::-webkit-details-marker { display: none; }
.think-pre {
    margin: 0;
    padding: 0 12px 10px;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    max-height: 260px;
    overflow-y: auto;
    font-family: inherit;
    line-height: 1.5;
}
/* (web-btn.on styled below with svg tint — shared by think-btn) */

/* Copy button on draft/code boxes + typing stage label */
.copybtn {
    position: sticky; top: 8px; z-index: 2;
    display: block; margin: 8px 8px 2px auto;
    background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px; padding: 3px 11px; font-size: 0.78rem; font-weight: 600;
    color: #cdd4dd; cursor: pointer; font-family: inherit;
}
.copybtn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.typing-label { margin-left: 9px; font-size: 0.85rem; color: var(--dim); }

/* Syntax highlighting (dark boxes) */
.msg.ai.md pre .token.comment, .msg.ai.md pre .token.prolog, .msg.ai.md pre .token.doctype, .msg.ai.md pre .token.cdata { color: #7d8799; font-style: italic; }
.msg.ai.md pre .token.string, .msg.ai.md pre .token.char, .msg.ai.md pre .token.attr-value { color: #9ecb88; }
.msg.ai.md pre .token.keyword, .msg.ai.md pre .token.atrule, .msg.ai.md pre .token.rule { color: #c792ea; }
.msg.ai.md pre .token.function, .msg.ai.md pre .token.class-name { color: #82aaff; }
.msg.ai.md pre .token.number, .msg.ai.md pre .token.boolean, .msg.ai.md pre .token.constant { color: #f78c6c; }
.msg.ai.md pre .token.tag, .msg.ai.md pre .token.selector, .msg.ai.md pre .token.important { color: #f07178; }
.msg.ai.md pre .token.attr-name, .msg.ai.md pre .token.property, .msg.ai.md pre .token.variable { color: #ffcb6b; }
.msg.ai.md pre .token.punctuation, .msg.ai.md pre .token.operator { color: #91a0b5; }
.msg.ai.md pre .token.regex { color: #89ddff; }

/* Jump-to-newest arrow */
.jumpdown {
    position: absolute;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: none;
    width: 38px; height: 38px;
    align-items: center; justify-content: center;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    font-size: 1.05rem;
    color: var(--text);
    cursor: pointer;
}
.jumpdown.show { display: inline-flex; }
.jumpdown:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Sidebar search */
.side-search { margin: 10px 0 2px; font-size: 0.88rem; padding: 7px 10px; }

/* Attachment chips (Claude-style) */
.chips { display: flex; gap: 8px; flex-wrap: wrap; max-width: 760px; margin: 0 auto; }
.chips:not(:empty) { padding-bottom: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--panel); border: 1px solid var(--border-strong);
    border-radius: 8px; padding: 5px 6px 5px 5px; font-size: 0.82rem; max-width: 220px;
}
.chip img { width: 30px; height: 30px; object-fit: cover; border-radius: 5px; }
.chip-ext {
    background: var(--accent-soft); color: var(--accent);
    font-size: 0.62rem; font-weight: 700; padding: 6px 6px; border-radius: 5px;
    letter-spacing: 0.03em;
}
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x {
    background: none; border: 0; color: var(--dim); font-size: 1rem;
    cursor: pointer; padding: 0 3px; line-height: 1;
}
.chip-x:hover { color: var(--err); }
.attach-btn { width: 46px; height: 46px; padding: 0; border-radius: 12px; flex-shrink: 0; }

/* Tools drop-up: one "+" button opens a menu of attach + calendar/contacts/web/
   think, so the composer isn't a row of buttons. */
.tools-wrap { position: relative; flex-shrink: 0; display: flex; }
/* A dot on the + when any tool is on or a file is attached. */
.attach-btn.has-active { border-color: var(--accent); color: var(--accent); }
.attach-btn.has-active::after {
    content: ''; position: absolute; top: 7px; right: 7px;
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.tools-menu {
    position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 60;
    display: flex; flex-direction: column; min-width: 208px; padding: 6px;
    background: var(--panel); border: 1px solid var(--border-strong); border-radius: 12px;
}
.tool-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 10px; border: none; background: none; cursor: pointer;
    font: inherit; font-size: 0.9rem; color: var(--text); text-align: left; border-radius: 8px;
}
.tool-item:hover { background: var(--accent-soft); }
.tool-item svg { width: 17px; height: 17px; color: var(--dim); flex-shrink: 0; }
.tool-item .tool-dot { margin-left: auto; width: 16px; height: 16px; flex-shrink: 0; }
.tool-item.on { color: var(--accent); }
.tool-item.on svg { color: var(--accent); }
/* Checkmark on an active toggle. */
.tool-item.on .tool-dot {
    border-radius: 50%; background: var(--accent);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6L9 17l-5-5'/></svg>") center / 12px no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6L9 17l-5-5'/></svg>") center / 12px no-repeat;
}
.web-btn { height: 46px; padding: 0 12px; border-radius: 12px; flex-shrink: 0; gap: 6px; font-size: 0.86rem; }
.web-btn.on, .think-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.web-btn.on svg, .think-btn.on svg { color: var(--accent); }
.websrc-lead { font-size: 0.78rem; color: var(--dim); align-self: center; margin-right: 2px; }
.web-upsell {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    margin-top: 12px; padding: 9px 12px; font-size: 0.85rem;
    border: 1px solid var(--border); border-radius: var(--r);
    background: var(--accent-soft); color: var(--text);
}
.web-upsell svg { color: var(--accent); flex-shrink: 0; }
.web-upsell a { font-weight: 600; }

/* Whole-answer copy + sources */
.msgcopy {
    position: absolute; top: 8px; right: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    width: 27px; height: 27px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 7px; color: var(--dim); cursor: pointer;
    opacity: 0; transition: opacity 0.12s;
}
.msg.ai:hover .msgcopy { opacity: 1; }
.msgcopy:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.msg.ai.md { padding-right: 42px; }
.msg-sources { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }

/* Chip upload states */
.chip.uploading { opacity: 0.6; }
.chip.uploading .chip-x { pointer-events: none; }
.chip.failed { border-color: var(--err); background: var(--err-soft); }

/* Clickable source pills */
.msg-sources a {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--panel); border: 1px solid var(--border);
    color: var(--text); font-size: 0.78rem; font-weight: 500;
    padding: 4px 11px; border-radius: 8px; text-decoration: none;
    max-width: 260px;
}
.msg-sources a svg { color: var(--dim); flex-shrink: 0; }
.msg-sources a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.msg-sources a:hover svg { color: var(--accent); }

/* "Which file did you mean?" chooser — shown when retrieval wasn't sure. */
.doc-choose { margin-top: 12px; }
.doc-choose-label { font-size: 0.78rem; color: var(--dim); margin-bottom: 7px; }
.doc-choose-row { display: flex; gap: 7px; flex-wrap: wrap; }
.doc-choose-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--panel); border: 1px solid var(--border);
    color: var(--text); font-size: 0.78rem; font-weight: 500;
    padding: 4px 11px; border-radius: 8px; cursor: pointer;
    font-family: inherit; max-width: 260px;
}
.doc-choose-chip svg { color: var(--dim); flex-shrink: 0; }
.doc-choose-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.doc-choose-chip:hover svg { color: var(--accent); }
.doc-choose-chip.used { border-style: dashed; }
.doc-choose-chip.all { font-weight: 600; }

/* Confirm-and-edit card the AI drops into chat to add a calendar event. */
.event-card {
    margin-top: 12px; width: 100%; box-sizing: border-box;
    background: var(--panel); border: 1px solid var(--border-strong);
    border-radius: 12px; padding: 14px 16px;
}
.event-card-head {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 0.92rem; margin-bottom: 12px;
}
.event-card-head svg { color: var(--accent); flex-shrink: 0; }
.event-card label { display: block; font-size: 0.8rem; color: var(--dim); margin: 10px 0 4px; }
.event-card .input { width: 100%; min-width: 0; box-sizing: border-box; }
.event-card .ec-when { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Grid tracks default to min-width:auto, so a datetime-local input's intrinsic
   width forces overflow — let the columns (and their inputs) shrink. */
.event-card .ec-when > div { min-width: 0; }
.event-card .ec-share {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.85rem; color: var(--text); margin-top: 12px; cursor: pointer;
}
.event-card .ec-share input { width: auto; margin: 0; accent-color: var(--accent); }
.event-card .ec-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.event-card .ec-status { font-size: 0.82rem; }
.event-card.done { border-color: var(--ok); }
.event-card.done .event-card-head { margin-bottom: 0; }
.event-card.done .event-card-head svg { color: var(--ok); }
.event-card.done a { margin-top: 12px; }
@media (max-width: 640px) { .event-card .ec-when { grid-template-columns: 1fr; gap: 0; } }

/* Compact "already on your calendar" state, shown on reload for an added event. */
.event-added {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 12px; padding: 9px 13px;
    background: var(--ok-soft); border: 1px solid var(--ok); border-radius: 10px;
    font-size: 0.88rem; color: var(--text);
}
.event-added svg { color: var(--ok); flex-shrink: 0; }
.event-added a { font-weight: 600; margin-left: auto; }

/* Attachment chips inside the user's own (accent) bubble */
.msg-attached { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.msg.me .msg-attached a {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff; font-size: 0.78rem; font-weight: 500;
    padding: 4px 11px; border-radius: 8px; text-decoration: none; max-width: 260px;
}
.msg.me .msg-attached a:hover { background: rgba(255, 255, 255, 0.26); color: #fff; }
.msg.me .msg-attached a svg { color: rgba(255, 255, 255, 0.85); flex-shrink: 0; }

/* Your box health grid */
.boxgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.boxcell { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.boxcell.warn { border-color: var(--err); background: var(--err-soft); }
.boxval { font-weight: 700; font-size: 1.02rem; }
.boxcell.warn .boxval { color: var(--err); }
.boxlabel { color: var(--dim); font-size: 0.78rem; margin-top: 2px; }
.appbar .who a.name { color: var(--dim); font-weight: 500; }
.appbar .who a.name:hover { color: var(--accent); }

/* ---------- Theme toggle + real buttons in the topbar ---------- */
.appbar .who { display: flex; align-items: center; gap: 8px; }
.appbar .who a.name {
    color: var(--dim); font-weight: 500; padding: 6px 10px;
    border-radius: var(--r); text-decoration: none;
}
.appbar .who a.name:hover { background: var(--bg); color: var(--text); }
.iconbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    background: var(--panel); border: 1px solid var(--border-strong);
    border-radius: var(--r); color: var(--dim); cursor: pointer;
}
.iconbtn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.appbar .logout-btn { text-decoration: none; }
@media (max-width: 760px) {
    .appbar .who a.name { display: none; }
}

/* Modal + drop zone follow the theme */
.modal-overlay { background: rgba(0, 0, 0, 0.55); }
.drop { background: var(--panel); }
.chip img { background: var(--bg); }

:root[data-theme="light"] .theme-light-icon { display: none; }
:root[data-theme="light"] .theme-dark-icon { display: inline-flex; }
:root .theme-dark-icon { display: none; }
:root .theme-light-icon { display: inline-flex; }
.iconbtn svg { display: block; }

/* Compact action buttons inside table rows / tiles */
.table td .btn.sm { padding: 5px 10px; font-size: 0.82rem; }


/* ---------- Add-on cards (uniform grid, equal height in every state) ------- */
.addon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: 1fr;          /* every row the same height, not just siblings */
    align-items: stretch;
    gap: 16px;
}
/* Cards inside a grid must not inherit the vertical-stack ".card + .card"
   top margin, or every card after the first is nudged down inside its cell. */
.addon-grid > .card + .card { margin-top: 0; }
.addon-card { display: flex; flex-direction: column; height: 100%; }
.addon-card p.dim { font-size: 0.92rem; flex: 1 1 auto; margin-bottom: 0; }
.addon-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.addon-head h3 { margin: 0; }
.addon-foot {
    margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
    min-height: 78px;             /* a button and a status panel occupy the same space */
    display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.addon-foot .btn { width: 100%; }
.addon-foot .btn.sm { width: auto; align-self: flex-start; }
.addon-foot p { margin: 0; }
#remotebox { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 640px) { .addon-grid { grid-template-columns: 1fr; grid-auto-rows: auto; } }

/* ---------- Role chips ---------- */
.rolepick { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.rolechip {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--border-strong); border-radius: 20px;
    padding: 2px 10px; font-size: 0.78rem; font-weight: 600;
    color: var(--dim); cursor: pointer; margin: 0; white-space: nowrap;
}
.rolechip input { width: 13px; height: 13px; margin: 0; accent-color: var(--accent); }
.rolechip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.rolechip:hover { border-color: var(--accent); }
.table td input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.accessbox { display: none; margin-top: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.accessbox.open { display: block; }

/* Share dialog */
.share-opts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.share-opt { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; margin: 0; font-weight: 400; }
.share-opt:hover { border-color: var(--accent); }
.share-opt input { margin-top: 3px; accent-color: var(--accent); }
.share-opt strong { display: block; font-size: 0.92rem; }
.share-opt em { display: block; font-style: normal; color: var(--dim); font-size: 0.8rem; }

/* ---------- Roles & permissions ---------- */
.rolecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 14px; }
.rolecard { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 16px; display: flex; flex-direction: column; }
.rolecard form { display: contents; }
.rolecard-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.rolecard-head h4 { font-size: 1rem; margin: 0; }
.rolecard-foot { margin-top: auto; padding-top: 12px; display: flex; gap: 8px; }

.permgroup { margin-bottom: 14px; }
.permgroup:last-of-type { margin-bottom: 0; }
.permgroup-title {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
    font-weight: 700; color: var(--dim); margin-bottom: 6px;
    padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.permrow {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 6px 0; margin: 0; font-weight: 400; cursor: pointer;
}
.permrow input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.permrow input:disabled { opacity: 0.6; cursor: not-allowed; }
.permrow strong { display: block; font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.permrow em { display: block; font-style: normal; font-size: 0.78rem; color: var(--dim); line-height: 1.35; }
.permrow:hover strong { color: var(--accent); }

.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.preset-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--panel); }
.preset-card strong { display: block; margin-bottom: 4px; }
.preset-card p { font-size: 0.85rem; line-height: 1.5; margin: 0 0 12px; }
.newrole { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.newrole h4 { font-size: 1rem; margin-bottom: 10px; }
.permcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 16px; }

@media (max-width: 640px) {
    .rolecards { grid-template-columns: 1fr; }
    .permcols { grid-template-columns: 1fr; gap: 14px; }
}

/* Role badges beside the user's name in the top bar */
.appbar .who a.name { display: inline-flex; align-items: center; gap: 8px; }
.rolebadges { display: inline-flex; gap: 4px; }
.rolebadge { font-size: 0.68rem; padding: 1px 8px; font-weight: 700; letter-spacing: 0.01em; }
@media (max-width: 900px) { .rolebadges { display: none; } }

/* First-run model download screen */
.box-setup { max-width: 460px; }
.setup-bar { height: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; margin: 20px auto 10px; }
.setup-fill { height: 100%; background: var(--accent); border-radius: 20px; transition: width 0.4s ease; }
.setup-status { font-size: 0.9rem; }

/* Add-to-home-screen prompt (mobile PWA install) */
.a2hs {
    position: fixed; left: 14px; right: 14px; bottom: 14px; z-index: 500;
    max-width: 440px; margin: 0 auto;
    display: flex; align-items: center; gap: 12px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    padding: 11px 13px;
}
.a2hs[hidden] { display: none; }
.a2hs-icon { width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0; }
.a2hs-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.a2hs-text strong { font-size: 0.9rem; }
.a2hs-text span { font-size: 0.8rem; color: var(--dim); margin-top: 2px; }
.a2hs .btn.sm { flex-shrink: 0; }
.a2hs-x { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--dim); cursor: pointer; padding: 0 2px; flex-shrink: 0; }

/* ---------- Create tab (document generator) ---------- */
.create-page .sub { margin-bottom: 22px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tpl-card {
    position: relative; display: flex; flex-direction: column; gap: 4px;
    text-align: left; background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 18px; cursor: pointer; transition: border-color .12s, background .12s;
}
.tpl-card:hover, .tpl-card:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.tpl-ico { color: var(--accent); margin-bottom: 6px; font-size: 1.4rem; line-height: 1; display: inline-flex; }
.tpl-name { font-weight: 600; font-size: 1rem; }
.tpl-desc { font-size: 0.85rem; color: var(--dim); line-height: 1.4; }
.tpl-new { border-style: dashed; }
.tpl-edit {
    position: absolute; top: 10px; right: 10px; width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
    color: var(--dim); cursor: pointer; opacity: 0; transition: opacity .12s;
}
.tpl-card:hover .tpl-edit { opacity: 1; }
.tpl-edit:hover { color: var(--accent); border-color: var(--accent); }

.create-view { max-width: 760px; }
.create-view .linkbtn { margin-bottom: 8px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.doc-out {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    padding: 26px 30px; line-height: 1.65;
}
.doc-out h1, .doc-out h2, .doc-out h3 { line-height: 1.3; margin: 0.6em 0 0.3em; }
.doc-out h1:first-child, .doc-out h2:first-child { margin-top: 0; }
.doc-out table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.doc-out th, .doc-out td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }

.ed-field-row { display: grid; grid-template-columns: 1fr 90px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.ed-field-row .input { margin: 0; }
.ef-del { background: none; border: 1px solid var(--border); border-radius: 7px; width: 34px; height: 34px; color: var(--dim); cursor: pointer; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.ef-del:hover { color: var(--err); border-color: var(--err); }
@media (max-width: 620px) {
    .ed-field-row { grid-template-columns: 1fr auto; }
    .ed-field-row .ef-type, .ed-field-row .ef-ph { grid-column: 1 / -1; }
}

/* Create — theme switcher + PDF preview */
.theme-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.theme-bar .dim { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; margin-right: 2px; }
.theme-btn {
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
    padding: 5px 13px; font-size: 0.85rem; font-weight: 500; color: var(--text);
    cursor: pointer; font-family: inherit;
}
.theme-btn:hover { border-color: var(--accent); }
.theme-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.doc-preview {
    width: 100%; height: 72vh; min-height: 480px; border: 1px solid var(--border);
    border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* Create — inline revise bar */
.refine-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.refine-bar .input { margin: 0; flex: 1; }
.refine-bar .btn { flex-shrink: 0; }

/* Create — template tabs (switch between document types) */
.tpl-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.tpl-tab {
    background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
    padding: 7px 16px; font-size: 0.9rem; font-weight: 500; color: var(--text);
    cursor: pointer; font-family: inherit;
}
.tpl-tab:hover { border-color: var(--accent); }
.tpl-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tpl-tab-new { border-style: dashed; color: var(--dim); }
.form-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Contacts & Calendar ---------- */
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head-row .btn { flex-shrink: 0; margin-top: 4px; }
#contactpick { margin-bottom: 6px; }

.contact-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.contact-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 16px; cursor: pointer; transition: border-color .12s;
}
.contact-card:hover { border-color: var(--accent); }
.contact-name { font-weight: 600; }
.contact-sub { font-size: 0.85rem; margin-top: 3px; word-break: break-word; }

.agenda-day {
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim);
    font-weight: 700; margin: 22px 0 8px;
}
.agenda-day:first-child { margin-top: 4px; }
.agenda-event {
    display: flex; gap: 14px; align-items: baseline;
    background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
    padding: 12px 16px; margin-bottom: 8px; cursor: pointer; transition: border-color .12s;
}
.agenda-event:hover { border-color: var(--accent); }
.ae-time { font-weight: 600; font-size: 0.9rem; color: var(--accent); white-space: nowrap; min-width: 74px; }
.ae-title { font-weight: 500; }
.ae-meta { font-size: 0.84rem; margin-top: 2px; }

/* ---------- Calendar: month grid, agenda, visibility ---------- */
.viewtoggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.vt-btn { background: var(--panel); border: 0; padding: 9px 14px; font-size: 0.9rem; line-height: 1.2; font-weight: 500; color: var(--dim); cursor: pointer; font-family: inherit; }
.vt-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.month-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.month-nav #monthlabel { font-weight: 600; font-size: 1.05rem; min-width: 150px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-dow { background: var(--panel); padding: 8px 6px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dim); text-align: center; }
.cal-cell { background: var(--bg); min-height: 96px; padding: 6px 6px 8px; cursor: pointer; transition: background .1s; }
.cal-cell:hover { background: var(--panel); }
.cal-cell.empty { background: var(--panel); opacity: 0.5; cursor: default; }
.cal-cell.today { background: var(--accent-soft); }
.cal-daynum { font-size: 0.8rem; font-weight: 600; color: var(--dim); margin-bottom: 4px; }
.cal-cell.today .cal-daynum { color: var(--accent); }
.cal-ev {
    background: var(--accent); color: #fff; font-size: 0.72rem; line-height: 1.25;
    padding: 2px 6px; border-radius: 5px; margin-bottom: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-ev.private { background: var(--dim); }
.cal-more { font-size: 0.7rem; color: var(--dim); padding-left: 2px; }
@media (max-width: 620px) {
    .cal-cell { min-height: 64px; padding: 4px 3px; }
    .cal-ev { font-size: 0.62rem; padding: 1px 4px; }
    .month-nav #monthlabel { min-width: 0; font-size: 0.95rem; }
}

/* Event visibility picker + role checkboxes */
.vis-pick { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.radiorow { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; font-weight: 500; cursor: pointer; margin: 0; }
.radiorow input { width: auto; }
.role-pick { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--panel); }
/* display:flex above beats the browser's [hidden] rule — restore hiding. */
.role-pick[hidden] { display: none; }
.rolechk { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; font-weight: 500; margin: 0; cursor: pointer; }
.rolechk input { width: auto; }

/* Contacts: toolbar, bulk bar, selection */
.contacts-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.selall { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; cursor: pointer; margin: 0; }
.selall input { width: auto; }
.bulk-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 8px 14px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r); font-size: 0.9rem; }
.contact-card { position: relative; padding-left: 40px; }
.contact-card .c-check { position: absolute; top: 14px; left: 14px; width: auto; cursor: pointer; }
.contact-card.sel { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Mobile: Create / Contacts / Calendar ---------- */
@media (max-width: 640px) {
    /* Two-up field rows (email/phone, start/end) stack instead of overflowing. */
    .grid2 { grid-template-columns: 1fr; gap: 0; margin: 8px 0 20px; }
    /* But a grid2 of CARDS (e.g. Settings) loses both the grid gap and the
       suppressed card margin when stacked — put the spacing back between them. */
    .grid2 > .card + .card { margin-top: 16px; }
    .month-nav { flex-wrap: wrap; }
    .contact-list { grid-template-columns: 1fr; }
    .doc-preview { height: 62vh; min-height: 380px; }
    .tpl-tabs { gap: 6px; }
    .vis-pick { gap: 12px 16px; }
    .refine-bar { flex-wrap: wrap; }
    .refine-bar .input { min-width: 0; }
    /* Header drops to its own line under the heading; add breathing room before
       the search bar / calendar that follows it. */
    .page-head-row { gap: 10px; margin-bottom: 20px; }
    .page-head-row > div:last-child { flex: 1 1 100%; flex-wrap: wrap; margin-top: 0 !important; }
    /* Action buttons share the row evenly instead of clustering to the left. */
    .page-head-row > div:last-child > .btn,
    .page-head-row > div:last-child > .viewtoggle { flex: 1 1 auto; margin-top: 0; }
    .page-head-row > div:last-child > .viewtoggle .vt-btn { flex: 1 1 auto; }
}

/* Brief focus flash on the composer when "New chat" is a no-op (already blank). */
#prompt.nudge { animation: poai-nudge 0.6s ease; }
@keyframes poai-nudge { 30% { box-shadow: 0 0 0 3px var(--accent-soft); } }

/* Reference-file chip in the composer + the team-aware file picker modal. */
.chip.ref .chip-doc { width: 16px; height: 16px; color: var(--dim); flex-shrink: 0; }
.fp-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 10px; }
.fp-item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    padding: 10px 12px; border: none; border-bottom: 1px solid var(--border);
    background: none; cursor: pointer; font: inherit; color: var(--text);
}
.fp-item:last-child { border-bottom: none; }
.fp-item:hover { background: var(--accent-soft); }
.fp-item svg { width: 16px; height: 16px; color: var(--dim); flex-shrink: 0; }
.fp-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-folder { font-size: 0.78rem; margin-left: auto; flex-shrink: 0; padding-left: 8px; }
.fp-item.added, .fp-item.added svg { color: var(--accent); }
.fp-check { margin-left: 6px; color: var(--accent); }

/* "Update available" pill in the header (only shown to admins who can update). */
.update-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 20px; font-size: 0.82rem; font-weight: 600;
    background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
    text-decoration: none; white-space: nowrap;
}
.update-pill:hover { background: var(--accent); color: #fff; }
.update-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: poai-pulse 1.8s ease-in-out infinite; }
@keyframes poai-pulse { 50% { opacity: 0.35; } }

/* ---- Avatars (used in team rooms + account) ---- */
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.avatar-initial { color: #fff; font-weight: 600; font-size: 0.82rem; }
.avatar-ai { background: var(--accent); color: #fff; font-weight: 700; font-size: 0.66rem; letter-spacing: 0.03em; }

/* ---- Team chat rooms ---- */
.room-item .side-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-badge {
    margin-left: auto; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 5px;
    background: var(--dim); color: var(--bg); font-size: 0.72rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.room-badge.ping { background: var(--accent); color: #fff; }
.room-msg { display: flex; gap: 10px; padding: 8px 4px; align-items: flex-start; }
.room-msg .avatar { margin-top: 2px; }
.rm-body { min-width: 0; flex: 1; }
.rm-head { display: flex; align-items: baseline; gap: 8px; }
.rm-author { font-weight: 600; font-size: 0.9rem; }
.rm-author[data-h] { cursor: pointer; }
.rm-author[data-h]:hover { text-decoration: underline; }
.room-msg.ai .rm-author { color: var(--accent); }
/* Inline room image — capped so it's always a consistent size and never
   overflows the column; click opens the in-app viewer. */
.rm-img { display: block; margin-top: 6px; max-width: min(320px, 100%); max-height: 320px; width: auto; height: auto;
    border: 1px solid var(--border); border-radius: 10px; cursor: zoom-in; }

/* Image viewer (lightbox): image fit to viewport, download/close in a top bar. */
.imgview { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.82);
    display: flex; align-items: center; justify-content: center; padding: 44px 16px 16px; }
.imgview img { max-width: 100%; max-height: calc(100vh - 76px); width: auto; height: auto;
    border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,0.5); cursor: default; }
.imgview-bar { position: absolute; top: 10px; right: 12px; display: flex; gap: 8px; }
.imgview-btn { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center;
    justify-content: center; background: rgba(255,255,255,0.12); border: 0; color: #fff;
    cursor: pointer; padding: 0; }
.imgview-btn:hover { background: rgba(255,255,255,0.24); color: #fff; }
/* Pending-upload preview above the composer */
.img-preview { max-width: 760px; margin: 0 auto 8px; }
.img-chip { position: relative; display: inline-block; }
.img-chip img { max-height: 74px; max-width: 130px; border: 1px solid var(--border-strong); border-radius: 8px; display: block; }
.img-chip.uploading { font-size: 0.85rem; color: var(--dim); padding: 8px 10px; border: 1px dashed var(--border-strong); border-radius: 8px; }
.img-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); cursor: pointer;
    font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; }
.rm-time { font-size: 0.75rem; }
.rm-text { font-size: 0.94rem; line-height: 1.5; margin-top: 2px; overflow-wrap: anywhere; }
.rm-text.md > :first-child { margin-top: 0; }
.rm-text.md > :last-child { margin-bottom: 0; }
.mention { color: var(--accent); font-weight: 600; }
.mention-me { background: var(--accent-soft); border-radius: 4px; padding: 0 3px; }

/* Room typing indicator */
.typing-ind { padding: 2px 16px 8px; font-size: 0.82rem; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--dim); animation: poai-typing 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes poai-typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* @mention autocomplete in rooms */
.chat-inputbar { position: relative; }
.mention-box {
    position: absolute; bottom: calc(100% - 6px); left: 14px; z-index: 60;
    min-width: 220px; max-width: 340px; max-height: 240px; overflow-y: auto;
    background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; padding: 5px;
}
.mention-opt { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 0.9rem; }
.mention-opt.active, .mention-opt:hover { background: var(--accent-soft); }

/* Past-year "Update · Care Plan" upsell pill (amber, distinct from the blue one). */
.update-pill.needs-care {
    background: color-mix(in srgb, #f59e0b 16%, transparent);
    color: #d97706; border-color: #f59e0b;
}
.update-pill.needs-care:hover { background: #f59e0b; color: #fff; }
:root[data-theme="dark"] .update-pill.needs-care,
.update-pill.needs-care { color: #f59e0b; }

/* Align the typing indicator + @menu with the centered message column (fixes
   them sitting at the far-left edge on wide screens). */
.typing-ind { max-width: 760px; margin: 0 auto; box-sizing: border-box; padding: 2px 20px 6px 44px; }
.chat-input { position: relative; }
.mention-box { left: 0; }

/* Emoji picker */
.emoji-btn { flex-shrink: 0; width: 42px; height: 46px; background: transparent; color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 12px; font-size: 1.15rem; line-height: 1;
    cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; }
.emoji-btn:hover { border-color: var(--accent); }
.emoji-panel { position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 90;
    width: min(340px, 92vw); max-height: 224px; overflow-y: auto;
    background: var(--panel); border: 1px solid var(--border-strong); border-radius: 12px; padding: 8px;
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-i { background: transparent; border: 0; padding: 5px 0; font-size: 1.3rem; line-height: 1;
    cursor: pointer; border-radius: 6px; }
.emoji-i:hover { background: var(--bg); }
@media (max-width: 620px) { .emoji-panel { grid-template-columns: repeat(7, 1fr); } }

/* Chat-settings modal rows */
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 13px 0; border-top: 1px solid var(--border); cursor: pointer; }
.setrow:first-of-type { border-top: 0; }
.setrow > span { display: flex; flex-direction: column; font-weight: 600; font-size: 0.95rem; }
.setrow small { font-weight: 400; color: var(--dim); font-size: 0.8rem; margin-top: 2px; }
.setrow input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
@media (max-width: 760px) {
    .typing-ind { padding-left: 40px; }
}
