/* ==========================================================================
   Nanaberry AI Chat – plain CSS (flexbox-first, no frameworks)
   1. Tokens & reset   2. Topbar   3. Forms & buttons   4. Alerts
   5. Auth             6. Dashboard 7. Chat             8. Utilities
   ========================================================================== */

/* ---------------------------------------------------------------- 1. tokens */
:root {
    --bg:            #f3f4f8;
    --surface:       #ffffff;
    --surface-soft:  #f8f9fc;
    --border:        #e3e6ee;
    --text:          #14171f;
    --muted:         #6a7183;
    --accent:        #b5355f;
    --accent-strong: #92264a;
    --accent-soft:   #fbeaf0;
    --ai:            #087e8b;
    --ai-soft:       #e1f4f2;
    --success:       #15803d;
    --success-soft:  #dcfce7;
    --danger:        #b91c1c;
    --danger-soft:   #fee2e2;
    --info:          #1d4ed8;
    --info-soft:     #dbeafe;
    --radius:        14px;
    --radius-sm:     9px;
    --shadow:        0 1px 2px rgba(16, 20, 40, .05), 0 8px 24px rgba(16, 20, 40, .06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
p  { margin: 0; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    background: var(--accent-soft);
    color: var(--accent-strong);
    padding: .1em .4em;
    border-radius: 6px;
    font-size: .9em;
    font-family: var(--font);
    word-wrap: break-word;
}

/* ----- Markdown-enhanced elements ----- */
pre {
    background: #1e2330;
    border: 1px solid #2d3548;
    border-radius: 8px;
    padding: 1rem;
    margin: .8rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
pre code {
    background: transparent;
    color: #e2e8f0;
    padding: 0;
    border-radius: 0;
    font-size: .92em;
    white-space: pre;
    display: block;
}
strong {
    font-weight: 700;
    color: var(--text);
}
ul {
    margin: .8rem 0;
    padding-left: 1.6rem;
    list-style-type: disc;
}
ul li {
    margin: .35rem 0;
    line-height: 1.55;
}

/* --------------------------------------------------------------- 2. topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.02rem;
    color: var(--text);
    letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), #e16a78);
    color: #fff;
    font-size: .95rem;
}

.nav { display: flex; align-items: center; gap: 14px; }

.nav-link {
    color: var(--muted);
    font-weight: 600;
    font-size: .92rem;
}
.nav-link:hover, .nav-link.is-active { color: var(--text); text-decoration: none; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
    font-size: .82rem;
    padding: 5px 12px;
    border-radius: 999px;
    max-width: 180px;
    overflow: hidden;
}
.user-chip-name {
    display: none;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
@media (min-width: 720px) {
    .user-chip-name { display: inline; }
}

/* ------------------------------------------------------- 3. forms & buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font: inherit;
    font-weight: 650;
    font-size: .92rem;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .05s ease;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }

.btn-ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-soft); text-decoration: none; }

.btn-sm { padding: 6px 12px; font-size: .84rem; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
}
.icon-btn:hover { background: var(--accent-soft); text-decoration: none; }

.stack { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 650; font-size: .87rem; color: var(--text); }
.hint { color: var(--muted); font-weight: 500; }

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    width: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; }

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(181, 53, 95, .15);
}

/* Assistant-role suggestion chips (create-room + room settings forms) ----- */
.role-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.role-chip:hover,
.role-chip.is-active {
    background: var(--ai-soft);
    border-color: var(--ai);
    color: var(--ai);
}

.role-chip.is-active { font-weight: 600; }

/* --------------------------------------------------------------- 4. alerts */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 0 0;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    font-weight: 600;
    animation: fade-in .2s ease;
}
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error   { background: var(--danger-soft);  color: var(--danger); }
.alert-info    { background: var(--info-soft);    color: var(--info); }

.alert-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    opacity: .6;
    padding: 2px 4px;
}
.alert-close:hover { opacity: 1; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------- 5. auth (login/register) */
.auth-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.auth-title { margin-bottom: 4px; }
.auth-subtitle { color: var(--muted); font-size: .92rem; margin-bottom: 20px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: .9rem; color: var(--muted); }

/* Google Sign-In button + "or" divider on the auth cards. */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 600;
}
.btn-google:hover { background: var(--surface-soft); text-decoration: none; }
.btn-google .google-g { width: 18px; height: 18px; flex: 0 0 auto; }
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 18px;
    color: var(--muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ----------------------------------------------------------- 6. dashboard */
.main {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 22px 20px 40px;
}

.dashboard {
    display: flex;
    align-items: flex-start;
    gap: 22px;
    flex-wrap: wrap;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.panel-rooms { flex: 1 1 480px; min-width: 0; }
.panel-create { flex: 0 1 330px; }

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.muted { color: var(--muted); font-size: .88rem; }

.room-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.room-card {
    flex: 1 1 260px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    color: inherit;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.room-card:hover {
    text-decoration: none;
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.room-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.room-card-top h2 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-persona {
    color: var(--muted);
    font-size: .87rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.room-meta {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
}

.room-owner { color: var(--muted); font-size: .78rem; margin-top: auto; }
.room-meta { flex-wrap: wrap; align-items: center; }
.room-meta > span { white-space: nowrap; }
.room-unread { padding: 2px 8px; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 750; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
    flex: 0 0 auto;
}
.badge-owner  { background: var(--accent-soft); color: var(--accent-strong); }
.badge-member { background: #e8eaef; color: var(--muted); }
.badge-ai     { background: var(--ai-soft); color: var(--ai); }

.fineprint { margin-top: 14px; font-size: .78rem; color: var(--muted); }

/* ----------------------------------------------------------------- 7. chat */
.chat {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    height: calc(100vh - 150px);
    min-height: 420px;
}

.chat-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.chat-title { flex: 1 1 220px; min-width: 0; }
.chat-title h1 {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.persona-chip {
    margin-top: 3px;
    font-size: .8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.persona-label {
    display: inline-block;
    background: var(--ai-soft);
    color: var(--ai);
    font-weight: 700;
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 1px 7px;
    border-radius: 999px;
    margin-right: 6px;
    vertical-align: 1px;
}

.chat-head-side {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.member-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: .7rem;
    font-weight: 750;
    color: var(--muted);
}
.chip-owner { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }

.invite { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.invite-row { display: flex; gap: 6px; align-items: center; max-width: 100%; }
.invite-row input {
    width: 230px;
    max-width: 46vw;
    padding: 6px 9px;
    font-size: .78rem;
    background: var(--surface-soft);
}
.invite-expiry { font-size: .72rem; color: var(--muted); }

/* message feed */
.messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background:
        radial-gradient(circle at 15% 10%, rgba(181, 53, 95, .04), transparent 40%),
        var(--surface-soft);
    scroll-behavior: smooth;
}

.msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 78%;
    animation: msg-in .18s ease;
}
.msg-own { align-self: flex-end; flex-direction: row-reverse; }
.msg-ai  { max-width: 88%; }

@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.msg-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: .74rem;
    font-weight: 800;
    user-select: none;
}
.msg-avatar.avatar-ai {
    background: linear-gradient(135deg, var(--ai), var(--accent));
    color: #fff;
    font-size: .95rem;
}

.msg-main { min-width: 0; }

.msg-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 3px;
    padding: 0 4px;
}
.msg-own .msg-meta { flex-direction: row-reverse; }

.msg-author { font-size: .76rem; font-weight: 700; color: var(--muted); }
.msg-time   { font-size: .7rem; color: var(--muted); opacity: .8; }

.msg-content {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 9px 13px;
    border-radius: 4px 14px 14px 14px;
    font-size: .93rem;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 1px rgba(16, 20, 40, .04);
}

.msg-own .msg-content {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    border-radius: 14px 4px 14px 14px;
}

.msg-ai .msg-content {
    background: var(--ai-soft);
    border-color: transparent;
    color: #0c4a6e;
}

.msg.is-pending { opacity: .55; }
.msg.is-pending .msg-content { font-style: italic; }

.msg-typing .msg-content {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    color: var(--muted);
}
.msg-typing .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: bounce 1.2s infinite ease-in-out;
}
.msg-typing .dot:nth-child(2) { animation-delay: .15s; }
.msg-typing .dot:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* Reply-to quote inside a message bubble. */
.msg-reply-to {
    margin: 2px 0 4px;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    font-size: .8rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    cursor: pointer;
    opacity: .9;
}
.msg-reply-to:hover { opacity: 1; border-color: var(--accent); }
.msg-ai .msg-reply-to { border-left-color: var(--ai); }
.msg-reply-label { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.msg-reply-author { font-weight: 700; color: var(--accent-strong); }
.msg-reply-content {
    color: var(--text);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.msg.is-highlighted .msg-content { box-shadow: 0 0 0 3px var(--accent-soft); transition: box-shadow .3s; }

/* Reply preview bar above the composer. */
.reply-preview {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: .78rem;
    margin-bottom: 8px;
    animation: slideDown .2s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.reply-preview-header { display: flex; align-items: center; justify-content: space-between; }
.reply-preview-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-strong); }
.reply-preview-content { display: flex; flex-direction: column; gap: 2px; }
.reply-preview-author { font-weight: 700; color: var(--text); }
.reply-preview-text { color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.reply-preview-remove {
    background: none; border: none; color: var(--accent-strong); cursor: pointer;
    font-size: 1.3rem; line-height: 1; padding: 0 2px;
}
.reply-preview-remove:hover { color: var(--accent); opacity: .9; }

/* Context menu for right-click actions on messages. */
.msg-context-menu {
    position: fixed;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(16,20,40,.15);
    padding: 4px 0;
    min-width: 140px;
    font-size: .85rem;
}
.msg-context-menu ul { list-style: none; margin: 0; padding: 0; }
.msg-context-menu li { padding: 6px 14px; cursor: pointer; color: var(--text); }
.msg-context-menu li:hover { background: var(--surface-soft); }

/* composer */
.composer {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.composer-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 42px;
    max-height: 140px;
    resize: none;
    line-height: 1.4;
    padding: 10px 12px;
}

.composer-send { flex: 0 0 auto; height: 42px; }

.composer-hint {
    flex: 0 0 auto;
    padding: 0 16px 12px;
    font-size: .76rem;
    color: var(--muted);
    background: var(--surface);
}
.composer-hint-line { display: block; }

/* Room packages – owner's package table, usage bars, create-image toggle */
.package-table-wrap { overflow-x: auto; }
.package-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.package-table th, .package-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.package-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.package-table tbody th { font-weight: 650; }
.package-table td { font-variant-numeric: tabular-nums; }
.package-table tr.is-active { background: var(--accent-soft); }
.package-table tr.is-locked td { color: var(--muted); }
.package-table .badge { margin-left: 6px; }
.badge-muted { background: var(--surface-soft); color: var(--muted); }
.usage-bar { display: inline-block; width: 90px; height: 8px; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--border); overflow: hidden; vertical-align: middle; }
.usage-bar > span { display: block; height: 100%; background: var(--accent); }
.package-credit-form { display: flex; gap: 6px; align-items: center; }
.package-credit-form input { width: 90px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--surface); color: var(--text); }
@media (max-width: 900px) {
  .package-table th, .package-table td { padding: 6px 6px; }
  .package-table .usage-bar { width: 50px; }
  .package-credit-form input { width: 64px; }
}
.package-select { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.create-image-toggle { cursor: pointer; }
.create-image-toggle.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.credit-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: .78rem;
    font-weight: 700;
}

.credit-chip-label { font-weight: 600; opacity: .8; }
.credit-chip-value { font-variant-numeric: tabular-nums; }
.credit-chip { text-decoration: none; }
.credit-chip:hover { background: var(--accent); color: #fff; }
.credit-chip-action { padding-left: 6px; border-left: 1px solid currentColor; font-weight: 650; opacity: .9; }

/* Billing – credit top-up page */
.billing { max-width: 880px; margin: 0 auto; display: grid; gap: 20px; }
.billing-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.billing-head h1 { margin: 0 0 4px; }
.billing-balance { text-align: right; }
.billing-balance strong { display: block; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.billing-packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; border: 0; padding: 0; margin: 0; }
.billing-pack { position: relative; display: grid; gap: 4px; align-content: start; padding: 18px 16px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.billing-pack:hover { border-color: var(--accent); }
.billing-pack input { position: absolute; opacity: 0; pointer-events: none; }
.billing-pack:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.billing-pack:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.billing-pack-price { font-size: 1.5rem; font-weight: 750; }
.billing-pack-credits { font-weight: 650; }
.billing-pack-bonus { justify-self: start; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.billing-custom-input { display: flex; align-items: center; gap: 6px; }
.billing-custom-input input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }
.billing-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.billing-note { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }
.package-card { cursor: default; grid-template-rows: auto auto auto auto 1fr auto auto; }
.package-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.package-card-name { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; }
.package-card-summary { margin: 6px 0 0; font-size: .88rem; }
.package-card-costs { margin: 4px 0 8px; padding-left: 18px; font-size: .8rem; }
.package-buy-form .btn { width: 100%; }
.billing-history { width: 100%; border-collapse: collapse; font-size: .86rem; }
.billing-history th, .billing-history td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.billing-history th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.billing-history td { font-variant-numeric: tabular-nums; }

.kbd {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border: 1px solid #cdd2ff;
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 0 6px;
    font-weight: 750;
    font-size: .74rem;
}

/* system notices injected by app.js */
.msg-system {
    align-self: center;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: .8rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    max-width: 90%;
    text-align: center;
    animation: fade-in .2s ease;
}
.msg-system.is-info { background: var(--info-soft); color: var(--info); }

/* ----------------------------------------------------------- 8. utilities */
.empty-state {
    text-align: center;
    padding: 44px 18px;
    color: var(--muted);
}
.empty-state h2 { margin: 10px 0 6px; color: var(--text); font-size: 1.02rem; }
.empty-state p { font-size: .9rem; }
.empty-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 1.4rem;
}
.empty-chat { margin: auto; }

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

.footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 14px 20px;
    text-align: center;
}
.footer p { color: var(--muted); font-size: .78rem; }

/* --------------------------------------------- 9. knowledge base & rules -- */
.kb-panel {
    flex: 0 0 auto;
    padding: 10px 16px 0;
    background: var(--surface);
}

.kb-details {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    overflow: hidden;
}

.kb-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: .84rem;
    font-weight: 650;
    color: var(--text);
    list-style: none;
}
.kb-summary::-webkit-details-marker { display: none; }
.kb-summary:hover { background: var(--accent-soft); }

.kb-title { white-space: nowrap; }

.kb-state {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--muted);
    background: #e8eaef;
    border-radius: 999px;
    padding: 2px 9px;
    white-space: nowrap;
}
.kb-state.is-set { background: var(--ai-soft); color: var(--ai); }

.kb-caret { margin-left: auto; color: var(--muted); transition: transform .15s ease; }
.kb-details[open] .kb-caret { transform: rotate(180deg); }

.kb-view {
    margin: 0;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    line-height: 1.55;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow: auto;
}

.kb-empty {
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: .85rem;
    color: var(--muted);
}

.kb-form {
    gap: 12px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.kb-form textarea { font-family: var(--font); }
.kb-form textarea[name="knowledge_base"] {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .84rem;
}

.kb-chip { color: var(--muted); }
.kb-chip .persona-label { background: var(--surface-soft); color: var(--muted); border: 1px solid var(--border); }

/* Telegram bridge ------------------------------------------------------------ */
.badge-telegram { background: #e3f2fb; color: #1a7fb5; }

.tg-chip { color: var(--muted); }
.tg-chip .persona-label { background: #e3f2fb; color: #1a7fb5; border: 1px solid #cfe8f6; }
.tg-chip.is-linked { color: #1a7fb5; font-weight: 600; }
.tg-chip.is-linked .persona-label { background: #229ed9; color: #fff; border-color: #229ed9; }

.tg-form {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px 4px;
    margin: 4px 0 14px;
    background: var(--surface-soft);
}
.tg-form-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
    margin-bottom: 8px;
}
.tg-form-head .hint { font-weight: 500; text-transform: none; letter-spacing: 0; }
.tg-hint { margin: 0 0 10px; }
.tg-hint code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    word-break: break-all;
}


/* "KB rules" pill on the dashboard room cards */
.kb-badge {
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--ai-soft);
    color: var(--ai);
}

/* Telegram setup wizard ------------------------------------------------------ */
.tg-setup { max-width: 880px; margin: 0 auto; padding: 22px 20px 48px; }

.tg-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
}
.tg-head-text { flex: 1 1 220px; min-width: 0; }
.tg-head-text .muted { margin-top: 4px; }

.tg-state {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: 5px 11px;
    border-radius: 999px;
    background: #e8eaef;
    color: var(--muted);
    white-space: nowrap;
}
.tg-state.is-on { background: #229ed9; color: #fff; }

.tg-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
}
.tg-step {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 13px;
}
.tg-step span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e8eaef;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
}
.tg-step.is-done { border-color: #229ed9; color: #1a7fb5; }
.tg-step.is-done span { background: #229ed9; color: #fff; }
.tg-step.is-current { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.tg-step.is-current span { background: var(--accent); color: #fff; }

.tg-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 14px;
}

.tg-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.tg-card-head h2 { font-size: 1.02rem; }
.tg-card-head .hint { font-weight: 500; }

.tg-num {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: .92rem;
}

.tg-how { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 9px; font-size: .92rem; }
.tg-how li { padding-left: 3px; }

.tg-copyrow { display: flex; gap: 8px; align-items: stretch; margin-top: 7px; max-width: 640px; }
.tg-copyrow input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    font-size: .82rem;
    color: var(--text);
}
.tg-copyrow .btn { flex: 0 0 auto; }

.tg-copy.is-copied { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tg-copy:disabled { opacity: .5; cursor: not-allowed; }
.tg-status.is-loading p { color: var(--muted); }
.tg-guide-link { margin-left: auto; font-size: .8rem; white-space: nowrap; }

.tg-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.tg-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.tg-tip {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--info-soft);
    color: var(--info);
    font-size: .86rem;
}
.tg-tip ul { margin: 6px 0; padding-left: 20px; }
.tg-tip .hint { color: var(--info); opacity: .85; }

.tg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tg-connect { gap: 14px; }

.tg-disconnect {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

.tg-req {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    padding: 14px 16px;
}
.tg-req-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.tg-req-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}
.tg-req-row > label { font-size: .8rem; font-weight: 650; color: var(--muted); }
.tg-req-row .tg-copyrow { margin-top: 0; }

.tg-details { margin-top: 8px; font-size: .86rem; }
.tg-details summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0; }
.tg-pre {
    margin: 8px 0;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
    max-height: 240px;
    overflow: auto;
}
.tg-req-note { margin-top: 12px; line-height: 1.6; }

.tg-status {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    padding: 12px 14px;
    font-size: .88rem;
}
.tg-status.is-ok  { background: var(--success-soft); border-color: transparent; color: var(--success); }
.tg-status.is-bad { background: var(--danger-soft);  border-color: transparent; color: var(--danger); }
.tg-status ul { margin: 6px 0 0; padding-left: 18px; }
.tg-status li { margin-bottom: 3px; word-break: break-all; }
.tg-status code { background: rgba(255,255,255,.75); }

.tg-verify {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--accent-soft);
    font-size: .87rem;
    color: var(--accent-strong);
}
.tg-verify ol { margin: 7px 0 0; padding-left: 20px; }
.tg-verify code { background: rgba(255,255,255,.8); }

.tg-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: .85rem;
}

/* ------------------------------------------------------------ public home */
.room-management { border-top: 1px solid var(--border); padding: 10px 0; }
.chat [hidden] { display: none; }
.invitation-page { max-width: 680px; margin: 32px auto; display: grid; gap: 20px; }
.invitation-page h1 { font-size: 2rem; overflow-wrap: anywhere; }
.invitation-page > p { color: var(--muted); }
.invitation-image { display: block; width: 100%; height: auto; border-radius: 8px; }
.invitation-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.room-management summary { cursor: pointer; font-weight: 650; }
.room-management-body { display: grid; gap: 14px; padding: 14px 0; max-height: 45vh; overflow-y: auto; }
.room-member-list { list-style: none; padding: 0; margin: 0; }
.room-member-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.room-member-list li > span:first-child { overflow-wrap: anywhere; min-width: 0; }
.room-delete { border-top: 1px solid var(--border); padding-top: 12px; }
.room-delete summary, .room-closed-label { color: var(--danger); }
.room-delete p { margin: 10px 0; font-size: .85rem; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #991b1b; }
.composer-input:disabled { background: var(--surface-soft); cursor: not-allowed; }
.room-closed-label { font-size: .8rem; font-weight: 650; }
.model-settings select { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.message-image { display: block; width: 260px; max-width: 100%; max-height: 300px; object-fit: contain; margin-top: 8px; border-radius: 6px; }

.message-image-wrapper { position: relative; display: inline-block; max-width: 100%; border-radius: 6px; overflow: hidden; }

.badge-staged {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(220, 38, 38, 0.92);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.attachment-preview { display: flex; gap: 12px; align-items: center; padding: 8px 16px; }
.attachment-preview[hidden] { display: none; }
.attachment-preview img { width: 72px; height: 72px; object-fit: contain; }
.attachment-preview > span { min-width: 0; overflow-wrap: anywhere; }
.attachment-upload { cursor: pointer; }
.message-document { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; }
.message-document span:last-child { overflow-wrap: anywhere; }
.upgrade-reason { overflow-wrap: anywhere; }
.landing { padding: 26px 0 18px; }
.admin-page { min-height: 100vh; background: var(--surface-soft); }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.admin-header-actions, .admin-actions, .admin-row-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-row-head { justify-content: space-between; }
.admin-shell { display: flex; width: 100%; max-width: 1440px; margin: 0 auto; flex: 1; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; width: 208px; flex: 0 0 208px; padding: 24px 16px; border-right: 1px solid var(--border); }
.admin-nav a { padding: 10px 12px; color: var(--text); font-weight: 650; border-radius: 6px; }
.admin-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.admin-content { flex: 1; min-width: 0; padding: 24px; }
.admin-content h1 { margin-bottom: 24px; font-size: 1.5rem; }
.admin-content h2 { font-size: 1.05rem; overflow-wrap: anywhere; }
.admin-login, .admin-form { width: 100%; max-width: 520px; margin: 20px 0; }
.admin-login { max-width: 380px; }
.admin-credential-checks { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr); gap: 10px 16px; margin: 20px 0; max-width: 800px; }
.admin-credential-checks dt { font-weight: 650; }
.admin-credential-checks dd { margin: 0; overflow-wrap: anywhere; color: var(--muted); }
.admin-form select { max-width: 100%; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.admin-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 20px 0 28px; }
.admin-metrics a { display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.admin-metrics strong { font-size: 2rem; color: var(--accent-strong); }
.admin-metrics span { font-size: .85rem; }
.admin-section { padding: 16px 0; border-top: 1px solid var(--border); }
.admin-section summary { cursor: pointer; font-weight: 650; }
.admin-request { padding: 20px 0; border-bottom: 1px solid var(--border); }
.admin-room-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.admin-room-box { padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.admin-request p { margin: 10px 0; color: var(--muted); }
.admin-text { overflow-wrap: anywhere; }
.admin-table-scroll { max-width: 100%; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; text-align: left; }
.admin-table th, .admin-table td { padding: 12px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.admin-empty { color: var(--muted); padding: 20px 0; }
.admin-review-note { margin: 12px 0; color: var(--muted); font-size: .86rem; }
.admin-review-pagination { margin: 18px 0; }
.admin-review-message { padding: 16px 0; border-top: 1px solid var(--border); }
.admin-message-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.admin-message-meta strong { overflow-wrap: anywhere; }
.admin-message-meta time, .admin-message-meta > span:last-child { color: var(--muted); font-size: .78rem; }
.admin-review-content { margin-top: 10px; overflow-wrap: anywhere; }
.admin-message-delete { max-width: 100%; }
.admin-message-delete summary { cursor: pointer; color: var(--danger); font-size: .82rem; font-weight: 650; }
.admin-message-delete form { padding: 10px 0; }
.admin-message-delete p { margin-bottom: 8px; font-size: .82rem; }
.panel-notifications { flex: 1 1 100%; }
.customer-notifications { margin-bottom: 20px; }
.customer-notification { display: flex; gap: 12px; justify-content: space-between; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.customer-notification p { margin-top: 5px; overflow-wrap: anywhere; }
.customer-notification-head { display: flex; align-items: center; gap: 10px; }
.customer-notification-from { font-size: .85rem; color: var(--muted); }
.customer-notification-new { background: var(--accent-soft); border-left: 4px solid var(--accent); border-bottom: none; border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(181, 53, 95, .08); }
.customer-notification-new:last-of-type { margin-bottom: 0; }
.badge-new { background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
@media (max-width: 760px) {
    .admin-shell { flex-direction: column; }
    .admin-nav { width: 100%; flex: 0 0 auto; flex-direction: row; flex-wrap: wrap; padding: 10px; border-right: 0; border-bottom: 1px solid var(--border); }
    .admin-content { padding: 16px; }
    .admin-header { padding: 12px; flex-wrap: wrap; }
    .admin-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .admin-metrics a { padding: 14px; }
    .customer-notification { flex-direction: column; }
}
.landing-section-nav { display: flex; flex-wrap: wrap; gap: 12px 24px; font-size: .86rem; font-weight: 650; }
.landing-section-nav a { color: var(--muted); }
.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(400px, 1.05fr);
    align-items: center;
    gap: clamp(36px, 6vw, 76px);
    padding: 38px 0 64px;
}
.landing-copy { max-width: 490px; }
.landing-eyebrow {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--accent-strong);
    font-size: .76rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.landing-eyebrow > span { width: 8px; height: 8px; border-radius: 50%; background: #42a88c; }
.landing-copy h1 {
    margin: 18px 0;
    max-width: 520px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.7rem, 5vw, 4.35rem);
    font-weight: 500;
    line-height: 1.04;
}
.landing-copy h1 em { color: var(--accent); font-weight: 500; }
.landing-lede { max-width: 450px; color: #525968; font-size: 1.08rem; line-height: 1.75; }
.landing-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 28px; }
.landing-primary { padding: 12px 18px; }
.landing-primary span, .btn-light span { font-size: 1.1em; }
.landing-secondary { color: var(--text); font-size: .9rem; font-weight: 650; }
.landing-reassurance { margin-top: 15px; color: var(--muted); font-size: .81rem; }

.landing-preview {
    position: relative;
    overflow: hidden;
    border: 1px solid #e4d9d5;
    border-radius: 12px;
    background: #fffefa;
    box-shadow: 0 18px 50px rgba(78, 45, 53, .12);
    transform: rotate(1deg);
}
.preview-topbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 17px 20px; border-bottom: 1px solid #eee8e4; }
.preview-brand, .preview-people { display: flex; align-items: center; }
.preview-brand { gap: 10px; font-weight: 750; font-size: .92rem; }
.preview-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: white; font-family: Georgia, serif; font-size: 1.2rem; }
.preview-people { padding-left: 8px; }
.preview-avatar { display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 auto; border: 2px solid #fffefa; border-radius: 50%; color: #fff; font-size: .7rem; font-weight: 750; }
.preview-people .preview-avatar + .preview-avatar { margin-left: -7px; }
.avatar-berry { background: #bd5570; }
.avatar-green { background: #538b73; }
.avatar-gold { background: #c39145; }
.preview-count { margin-left: 5px; color: var(--muted); font-size: .76rem; font-weight: 650; }
.preview-context { display: flex; align-items: center; gap: 8px; padding: 11px 20px; background: #f5f3eb; color: #496b58; font-size: .77rem; font-weight: 700; }
.preview-dot, .preview-foot-dot { width: 7px; height: 7px; border-radius: 50%; background: #48a67f; }
.preview-context-note { margin-left: auto; color: #788174; font-weight: 500; }
.preview-thread { display: flex; flex-direction: column; gap: 21px; min-height: 258px; padding: 23px 20px 20px; }
.preview-message { display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; }
.preview-message > .preview-avatar, .preview-ai-avatar { width: 32px; height: 32px; }
.preview-byline { display: flex; align-items: center; gap: 9px; margin: 1px 0 4px; color: #343842; font-size: .78rem; font-weight: 750; }
.preview-byline > span { color: #9698a0; font-size: .68rem; font-weight: 500; }
.preview-message p { max-width: 420px; color: #555a63; font-size: .83rem; line-height: 1.55; }
.preview-ai-message { margin: 0 0 0 12px; padding: 13px; border-left: 2px solid #4aab9c; border-radius: 0 8px 8px 0; background: #f0f7f3; }
.preview-ai-avatar { display: grid; place-items: center; border-radius: 50%; background: #d6eee6; color: #267a6c; font-size: .64rem; font-weight: 800; }
.preview-byline .preview-ai-label { padding: 3px 7px; border-radius: 999px; background: #dff0e8; color: #347c68; font-size: .64rem; }
.preview-composer { display: flex; align-items: center; justify-content: space-between; margin: 0 20px; padding: 10px 10px 10px 13px; border: 1px solid #e9e2dd; border-radius: 8px; color: #9a9ba1; font-size: .77rem; }
.preview-send { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 6px; background: var(--accent); color: white; font-size: 1rem; }
.preview-foot { display: flex; justify-content: center; align-items: center; gap: 7px; padding: 12px 10px 15px; color: #7c817b; font-size: .68rem; }
.preview-foot-dot { width: 6px; height: 6px; }

.landing-benefits { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #e5dfd9; border-bottom: 1px solid #e5dfd9; }
.landing-benefit { display: flex; gap: 15px; padding: 24px 22px 24px 0; }
.landing-benefit + .landing-benefit { padding-left: 22px; border-left: 1px solid #e5dfd9; }
.benefit-number { color: var(--accent); font-family: Georgia, serif; font-size: 1.2rem; }
.benefit-number-teal { color: var(--ai); }
.benefit-number-gold { color: #ad7c33; }
.landing-benefit h2 { margin: 1px 0 7px; font-size: .98rem; }
.landing-benefit p { color: var(--muted); font-size: .83rem; line-height: 1.6; }
.landing-benefit strong { color: var(--text); }
.landing-pricing { padding: 58px 0 54px; border-bottom: 1px solid #e5dfd9; scroll-margin-top: 24px; }
.landing-pricing-intro { max-width: 580px; margin: 0 auto 28px; text-align: center; }
.landing-pricing-intro h2 { margin: 10px 0; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; line-height: 1.2; }
.landing-pricing-intro > p:last-child { color: var(--muted); font-size: .9rem; line-height: 1.6; }
.landing-pricing-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 32px rgba(78, 45, 53, .06); }
.landing-pricing-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.landing-pricing-table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; text-align: center; font-size: .84rem; }
.landing-pricing-table caption { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.landing-pricing-table th, .landing-pricing-table td { padding: 14px 12px; border-bottom: 1px solid var(--border); }
.landing-pricing-table thead th { width: 19%; padding-top: 20px; padding-bottom: 18px; background: #fffefa; vertical-align: top; }
.landing-pricing-table thead th:first-child { width: 24%; }
.landing-pricing-table tbody tr:last-child th, .landing-pricing-table tbody tr:last-child td { border-bottom: 0; }
.landing-pricing-table tbody tr:nth-child(even) { background: var(--surface-soft); }
.landing-pricing-feature { position: sticky; left: 0; z-index: 1; width: 24%; min-width: 180px; background: var(--surface); text-align: left; font-weight: 650; }
.landing-pricing-table tbody tr:nth-child(even) .landing-pricing-feature { background: var(--surface-soft); }
.landing-pricing-table thead .landing-pricing-feature { z-index: 2; background: #fffefa; }
.plan-feature-status { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px; border-radius: 50%; font-size: 1.05rem; font-weight: 800; line-height: 1; }
.plan-feature-status.is-included { background: #e4f4e9; color: #18743a; }
.plan-feature-status.is-excluded { background: #fce8e7; color: #b42318; }
.plan-feature-status .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.landing-plan-name, .landing-plan-price, .landing-plan-credits { display: block; }
.landing-plan-name { margin-bottom: 8px; color: var(--accent-strong); font-size: .95rem; font-weight: 750; }
.landing-plan-price { font-size: 1.02rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.landing-plan-price small { display: block; margin-top: 3px; color: var(--muted); font-size: .7rem; font-weight: 500; }
.landing-plan-credits { margin-top: 8px; color: var(--muted); font-size: .75rem; }
.landing-pricing-scroll-hint { display: none; margin: 9px 0 0; color: var(--muted); font-size: .75rem; text-align: center; }
.landing-pricing-note { max-width: 850px; margin: 16px auto 0; color: var(--muted); font-size: .78rem; line-height: 1.6; text-align: center; }
.landing-pricing-action { margin: 20px 0 0; text-align: center; }
.landing-pricing-action .btn { padding: 11px 18px; }

.landing-how { display: grid; grid-template-columns: .75fr 1.25fr; gap: 70px; padding: 58px 0 62px; }
.landing-how-intro h2, .landing-close h2 { margin-top: 12px; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; line-height: 1.18; }
.landing-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin: 0; padding: 0; list-style: none; }
.landing-steps li { display: flex; flex-direction: column; gap: 13px; }
.landing-steps li > span { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #e8bdca; border-radius: 50%; color: var(--accent-strong); font-size: .8rem; font-weight: 750; }
.landing-steps h3 { margin-bottom: 6px; font-size: .9rem; }
.landing-steps p { color: var(--muted); font-size: .8rem; line-height: 1.6; }
.landing-close { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 27px 32px; border-radius: 10px; background: #8e2949; color: #fff; }
.landing-close .landing-eyebrow { color: #f2c8d3; }
.landing-close .landing-eyebrow > span { background: #83c1a1; }
.landing-close h2 { max-width: 470px; margin-top: 8px; font-size: 1.75rem; }
.btn-light { flex: 0 0 auto; background: #fff; color: #812540; }
.btn-light:hover { background: #f9eaf0; color: #812540; text-decoration: none; }

.landing-audiences { padding: 52px 0 48px; border-top: 1px solid #e5dfd9; border-bottom: 1px solid #e5dfd9; }
.landing-audiences-intro { max-width: 540px; margin-bottom: 28px; }
.landing-audiences-intro h2, .contact-intro h2 { margin-top: 10px; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; line-height: 1.2; }
.audience-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px; }
.audience-item { display: grid; grid-template-columns: 42px 1fr; gap: 15px; padding: 22px 20px 20px 0; }
.audience-item + .audience-item { padding-left: 28px; border-left: 1px solid #e5dfd9; }
.audience-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-family: Georgia, serif; font-size: 1.1rem; font-weight: 700; }
.audience-icon-berry { background: #fbeaf0; color: var(--accent-strong); }
.audience-icon-teal { background: #e1f4f2; color: var(--ai); }
.audience-label { margin: 1px 0 7px; color: var(--muted); font-size: .74rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.audience-item h3 { margin-bottom: 9px; font-family: Georgia, "Times New Roman", serif; font-size: 1.3rem; font-weight: 500; }
.audience-item > div > p:not(.audience-label) { color: var(--muted); font-size: .86rem; line-height: 1.65; }
.audience-item ul { display: grid; gap: 7px; margin: 14px 0 0; padding: 0; list-style: none; }
.audience-item li { position: relative; padding-left: 18px; color: #424954; font-size: .81rem; line-height: 1.5; }
.audience-item li::before { position: absolute; left: 0; color: #3f9a7c; content: "✓"; font-weight: 800; }
.audience-note { margin: 10px 0 0; color: var(--muted); font-size: .76rem; }
.landing-faq { padding: 44px 0; border-bottom: 1px solid var(--border); }
.landing-faq details { border-top: 1px solid var(--border); padding: 16px 0; }
.landing-faq summary { cursor: pointer; font-weight: 650; }
.landing-faq details p { max-width: 780px; margin-top: 12px; color: var(--muted); line-height: 1.7; }
#how-it-works, #use-cases, #questions { scroll-margin-top: 88px; }

.landing-contact { display: grid; grid-template-columns: .8fr 1.2fr; gap: 60px; align-items: start; padding: 56px 0; scroll-margin-top: 88px; }
.contact-intro { max-width: 390px; }
.contact-intro h2 { font-size: 2.15rem; }
.contact-intro > p:last-child { margin-top: 14px; color: var(--muted); font-size: .92rem; line-height: 1.7; }
.contact-form { display: grid; gap: 15px; padding: 22px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.contact-fields-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.contact-form select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.contact-form input:focus, .contact-form select:focus, .contact-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181, 53, 95, .15); }
.contact-form textarea { min-height: 118px; }
.contact-submit-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.contact-submit-row small { max-width: 250px; color: var(--muted); font-size: .73rem; line-height: 1.5; }
.contact-honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 900px) {
    .landing-hero { grid-template-columns: minmax(0, .9fr) minmax(340px, 1.1fr); gap: 28px; }
    .landing-copy h1 { font-size: 3rem; }
    .landing-benefit { padding-right: 14px; }
    .landing-benefit + .landing-benefit { padding-left: 14px; }
    .landing-how { gap: 36px; }
    .landing-contact { gap: 32px; }
}
@media (max-width: 700px) {
    .landing { padding-top: 6px; }
    .landing-hero { grid-template-columns: 1fr; gap: 34px; padding: 24px 0 42px; }
    .landing-copy { max-width: 560px; }
    .landing-copy h1 { max-width: 460px; font-size: 3.1rem; }
    .landing-lede { font-size: 1rem; }
    .landing-preview { transform: none; }
    .landing-benefits { grid-template-columns: 1fr; }
    .landing-benefit, .landing-benefit + .landing-benefit { padding: 18px 0; border-left: 0; }
    .landing-benefit + .landing-benefit { border-top: 1px solid #e5dfd9; }
    .landing-pricing { padding: 42px 0; }
    .landing-pricing-intro { text-align: left; }
    .landing-pricing-intro h2 { font-size: 1.75rem; }
    .landing-pricing-scroll { border-radius: 9px; }
    .landing-pricing-table th, .landing-pricing-table td { padding: 12px 10px; }
    .landing-pricing-scroll-hint { display: block; }
    .landing-how { grid-template-columns: 1fr; gap: 26px; padding: 42px 0; }
    .landing-steps { gap: 15px; }
    .audience-grid { grid-template-columns: 1fr; gap: 0; }
    .audience-item, .audience-item + .audience-item { padding: 20px 0; border-left: 0; }
    .audience-item + .audience-item { border-top: 1px solid #e5dfd9; }
    .landing-contact { grid-template-columns: 1fr; gap: 24px; padding: 42px 0; }
    .landing-close { align-items: flex-start; flex-direction: column; padding: 24px; }
}
@media (max-width: 460px) {
    .topbar-inner { gap: 8px; padding-right: 14px; padding-left: 14px; }
    .brand { gap: 6px; font-size: .88rem; white-space: nowrap; }
    .nav { gap: 8px; }
    .nav-link { font-size: .82rem; white-space: nowrap; }
    .nav .btn-sm { padding-right: 8px; padding-left: 8px; font-size: .78rem; }
    .landing-copy h1 { font-size: 2.65rem; }
    .landing-actions { align-items: flex-start; flex-direction: column; gap: 13px; }
    .landing-primary:hover { text-decoration: none; }
    .preview-topbar, .preview-thread { padding-left: 13px; padding-right: 13px; }
    .preview-context { padding-left: 13px; padding-right: 13px; }
    .preview-composer { margin-right: 13px; margin-left: 13px; }
    .preview-people .preview-avatar { width: 25px; height: 25px; }
    .preview-count { font-size: .68rem; }
    .landing-steps { grid-template-columns: 1fr; gap: 20px; }
    .landing-steps li { flex-direction: row; align-items: flex-start; gap: 12px; }
    .landing-steps li > span { flex: 0 0 auto; }
    .contact-form { padding: 16px; }
    .contact-fields-row { grid-template-columns: 1fr; }
    .contact-submit-row { align-items: flex-start; flex-direction: column; }
}

/* ---------------------------------------------------------- responsive -- */
@media (max-width: 760px) {
    .dashboard { flex-direction: column; }
    .panel-rooms, .panel-create, .panel-notifications { flex: 1 1 auto; width: 100%; }

    .msg { max-width: 92%; }
    .msg-ai { max-width: 95%; }

    .chat { height: calc(100vh - 130px); }
    .chat-head-side { width: 100%; justify-content: space-between; }
    .invite-row input { width: 150px; }

    .kb-panel { padding: 8px 10px 0; }
    .kb-view { max-height: 160px; }
    .kb-title { white-space: normal; }

    .tg-setup { padding: 16px 12px 40px; }
    .tg-card { padding: 14px 14px 16px; }
    .tg-req-row { grid-template-columns: 1fr; gap: 3px; }
    .tg-copyrow { max-width: none; }
    .tg-steps .tg-step { flex: 1 1 40%; justify-content: center; }

    /* Role chips wrap onto extra rows on narrow screens. */
    .role-suggestions { gap: 6px; }
    .role-chip { font-size: 11px; padding: 3px 9px; }
}

/* --------------------------------------------------------- reminders panel */
.reminders-panel {
    position: fixed;
    top: 110px;
    right: 16px;
    width: 340px;
    max-height: 70vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.reminders-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.reminders-panel-header h3 {
    font-size: 1rem;
    color: var(--text);
}

.reminders-panel-body {
    padding: 12px 16px;
    overflow-y: auto;
    max-height: calc(70vh - 56px);
}

.reminders-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reminder-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.92em;
}

.reminder-item:last-child { border-bottom: none; }

.reminder-time {
    min-width: 95px;
    color: var(--muted);
    font-size: 0.85em;
}

.reminder-content {
    flex: 1;
    color: var(--text);
    word-wrap: break-word;
}

.reminders-empty {
    color: var(--muted);
    font-size: 0.92em;
    padding: 20px 0;
    text-align: center;
}

#reminders-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    padding: 0 4px;
}

#reminders-close:hover { color: var(--text); }

@media (max-width: 760px) {
    .reminders-panel {
        top: auto;
        bottom: 70px;
        left: 10px;
        right: 10px;
        width: auto;
        max-height: 45vh;
    }
}

/* ------------------------------------- Phase 5: shadowed mentions (private) */
.msg-shadowed .msg-content,
.msg-shadowed.msg-own .msg-content,
.msg-shadowed.msg-ai .msg-content {
    background: #eef1f8;
    border: 1.5px dashed #6a7fb5;          /* slate blue */
    color: #2b3550;
    box-shadow: none;
}
.msg-shadowed .msg-content a { color: #3d4f86; }

.badge-shadowed {
    display: inline-block;
    flex: 0 1 auto;
    min-width: 0;
    background: #e4e8f4;
    color: #4a5a8c;
    font-style: italic;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.msg-author[role="button"] { cursor: pointer; }
.msg-author[role="button"]:hover,
.msg-author[role="button"]:focus-visible { color: var(--text); text-decoration: underline; outline: none; }

.composer { position: relative; }

.mention-dropdown {
    position: absolute;
    left: 14px;
    bottom: calc(100% + 6px);
    z-index: 40;
    min-width: 220px;
    max-width: min(340px, calc(100% - 28px));
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.mention-dropdown[hidden] { display: none; }
.mention-option {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .88rem;
}
.mention-option.is-active,
.mention-option:hover { background: var(--info-soft); }
.mention-name { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-hint { color: var(--muted); font-size: .75rem; white-space: nowrap; }

.reminder-item .badge-shadowed { align-self: flex-start; }

/* ================================================= App shell: three panes */
/* Logged-in pages: left .sidebar-global + .app-main. The room page adds the
   center .chat-pane and the right .sidebar-room-settings inside .chat. */
body.has-app-shell { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.app-layout { height: 100vh; height: 100dvh; display: flex; overflow: hidden; width: 100%; }

/* ----- left: global sidebar */
.sidebar-global {
    width: 250px;
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.sidebar-global-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 10px; }
.sidebar-global-rooms { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 10px 12px; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 6px; }
.sidebar-heading-link { font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sidebar-heading-link:hover, .sidebar-heading-link.is-active { color: var(--text); text-decoration: none; }
.sidebar-new {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 7px;
    color: var(--muted); font-weight: 700; font-size: 1.05rem; line-height: 1;
}
.sidebar-new:hover { background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; }
.sidebar-room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-room-list li { margin: 0; }
.sidebar-room {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 8px;
    color: var(--text); font-size: .9rem; font-weight: 550;
}
.sidebar-room:hover { background: var(--surface-soft); text-decoration: none; }
.sidebar-room.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.sidebar-room.is-closed .sidebar-room-name { color: var(--muted); }
.sidebar-room-hash { color: var(--muted); font-weight: 700; }
.sidebar-room.is-active .sidebar-room-hash { color: inherit; }
.sidebar-room-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-unread {
    flex: 0 0 auto; min-width: 20px; padding: 1px 6px; border-radius: 999px;
    background: var(--accent); color: #fff; font-size: .7rem; font-weight: 750; text-align: center;
}
.sidebar-empty { padding: 6px 10px; color: var(--muted); font-size: .85rem; }
.sidebar-global-bottom {
    flex: 0 0 auto;
    display: flex; flex-direction: column; gap: 2px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.sidebar-profile { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 8px 10px; }
.sidebar-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-strong); font-weight: 750;
}
.sidebar-profile-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sidebar-profile-text strong, .sidebar-profile-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile-text small { color: var(--muted); font-size: .74rem; }
.sidebar-link { padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: .88rem; font-weight: 600; }
.sidebar-link:hover { background: var(--surface-soft); text-decoration: none; }
.sidebar-link.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.sidebar-close { display: none; }

/* ----- main area for regular pages (dashboard, billing, …) */
.main.app-main { flex: 1 1 auto; min-width: 0; max-width: none; margin: 0; overflow-y: auto; padding: 22px 28px 40px; }
.app-main > :not(.app-mobile-bar) { max-width: 1120px; margin-left: auto; margin-right: auto; }
.app-mobile-bar { display: none; }
.app-backdrop { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(16, 20, 40, .38); }

/* ----- room page: center chat pane + right settings sidebar */
.room-page .main.app-main { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.room-page .app-main > .alert { max-width: none; margin: 10px 16px 0; flex: 0 0 auto; }
.chat.room-shell {
    flex: 1 1 auto;
    flex-direction: row;
    min-height: 0;
    height: auto;
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.chat-pane { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--surface); }
.chat-header {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 10px;
    min-height: 56px; padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.chat-header-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
.chat-header-title h1 { min-width: 0; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-title .badge { flex: 0 0 auto; white-space: nowrap; }
.chat-header-menu, .chat-header-info { display: none; }
.badge-closed  { background: var(--danger-soft); color: var(--danger); }
.badge-stealth { background: #eef1f8; color: #3d4f86; }
.messages-container { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.room-page .messages > .msg { flex-shrink: 0; }
.room-page .attachment-preview { flex: 0 0 auto; }
.room-page .composer { gap: 8px; padding: 10px 12px; }
.room-page .reminders-panel { top: 66px; }

/* composer (i) tooltip – replaces the old verbose hint text */
.composer-help { flex: 0 0 auto; align-self: center; }
.composer-help-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; padding: 0;
    border: 1.5px solid var(--muted); border-radius: 50%;
    background: transparent; color: var(--muted);
    font: italic 700 .8rem/1 Georgia, "Times New Roman", serif;
    cursor: help;
}
.composer-help-btn:hover, .composer-help-btn:focus-visible, .composer-help.is-open .composer-help-btn { border-color: var(--accent); color: var(--accent); }
.composer-help-tip {
    position: absolute;
    left: 12px;
    bottom: calc(100% + 8px);
    z-index: 45;
    width: min(380px, calc(100% - 24px));
    padding: 10px 12px;
    border-radius: 10px;
    background: #1e2330;
    color: #e8ebf3;
    box-shadow: 0 8px 24px rgba(16, 20, 40, .22);
    font-size: .78rem;
    line-height: 1.45;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity .12s ease, transform .12s ease, visibility .12s;
    pointer-events: none;
}
.composer-help:hover .composer-help-tip,
.composer-help:focus-within .composer-help-tip,
.composer-help.is-open .composer-help-tip { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.composer-help-tip ul { margin: 0; padding-left: 1.1rem; }
.composer-help-tip li { margin: .2rem 0; line-height: 1.45; }
.composer-help-tip strong { color: #fff; }
.composer-help-tip .kbd { border-color: transparent; }

/* ----- right: room details & settings */
.sidebar-room-settings {
    width: 300px;
    flex: 0 0 300px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-left: 1px solid var(--border);
    background: var(--surface-soft);
}
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding-bottom: 12px; }
.side-title { min-width: 0; }
.side-title h2 { font-size: 1.05rem; overflow-wrap: anywhere; }
.sidebar-room-settings .invite { align-items: stretch; padding-bottom: 14px; }
.sidebar-room-settings .invite-row { flex-direction: column; align-items: stretch; }
.sidebar-room-settings .invite-row input { width: 100%; max-width: none; }
.sidebar-room-settings .invite-expiry { text-align: left; }
.side-section { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-top: 1px solid var(--border); }
.side-section h3 { font-size: .74rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side-section h3 .muted { font-weight: 600; text-transform: none; letter-spacing: 0; }
.side-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-status { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.side-status > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.side-status dt { font-size: .66rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--ai); }
.side-status dd {
    margin: 0; font-size: .86rem; color: var(--text); overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.side-status .side-tg.is-linked dd { color: var(--success); }
.side-stack { display: flex; flex-direction: column; gap: 10px; font-size: .86rem; }
.side-stack .usage-bar { display: block; width: 100%; margin-top: 6px; }
.sidebar-room-settings .hint { font-size: .8rem; }
.sidebar-room-settings .ai-privacy-form { display: flex; flex-direction: column; gap: 10px; }
.sidebar-room-settings select {
    width: 100%; max-width: 100%; padding: 9px 10px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
.sidebar-room-settings .kb-form { padding: 0; border-top: 0; background: transparent; }
.sidebar-room-settings .tg-form { margin: 0; background: var(--surface); }
.sidebar-room-settings .tg-form-head { flex-wrap: wrap; }
.sidebar-room-settings .role-suggestions { gap: 6px; }
.sidebar-room-settings .room-member-list li { padding: 6px 0; }
.sidebar-room-settings .room-delete { margin-top: 4px; }

/* ----- tablet: right sidebar becomes an off-canvas drawer */
@media (max-width: 1100px) {
    .chat-header-info { display: inline-flex; }
    .sidebar-room-settings {
        position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
        width: min(340px, 90vw);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform .2s ease, visibility .2s;
        box-shadow: -8px 0 24px rgba(16, 20, 40, .14);
    }
    .panel-open-room-settings .sidebar-room-settings { transform: none; visibility: visible; }
    .sidebar-room-settings .sidebar-close { display: inline-flex; }
    .panel-open-room-settings .app-backdrop { display: block; }
}

/* ----- mobile: left sidebar becomes an off-canvas drawer too */
@media (max-width: 768px) {
    .sidebar-global {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
        width: min(280px, 85vw);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform .2s ease, visibility .2s;
        box-shadow: 8px 0 24px rgba(16, 20, 40, .14);
    }
    .panel-open-sidebar-global .sidebar-global { transform: none; visibility: visible; }
    .sidebar-global .sidebar-close { display: inline-flex; }
    .panel-open-sidebar-global .app-backdrop { display: block; }

    .main.app-main { padding: 0 0 32px; }
    .app-main > :not(.app-mobile-bar) { margin-left: 14px; margin-right: 14px; }
    .app-mobile-bar {
        display: flex; align-items: center; gap: 10px;
        position: sticky; top: 0; z-index: 30;
        margin-bottom: 16px; padding: 10px 12px;
        border-bottom: 1px solid var(--border);
        background: var(--surface);
    }
    .room-page .app-mobile-bar { display: none; }
    .room-page .main.app-main { padding: 0; }
    .room-page .app-main > .chat { margin: 0; }
    .room-page .app-main > .alert { margin: 8px 10px 0; }
    .chat-header-menu { display: inline-flex; }
    .chat-header { padding: 8px 10px; gap: 8px; }
    .chat-header-title .badge-stealth { font-size: .66rem; padding: 2px 7px; }
    .room-page .attachment-preview { padding: 6px 12px; }
    .room-page .attachment-preview img { width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar-global, .sidebar-room-settings, .composer-help-tip { transition: none; }
}
