:root {
    color-scheme: dark;
    --canvas: #0a0d16;
    --surface: #101522;
    --surface-raised: #151c2b;
    --surface-soft: #1a2334;
    --surface-hover: #202b3f;
    --line: rgba(184, 204, 237, .12);
    --line-strong: rgba(184, 204, 237, .22);
    --text: #f2f5fb;
    --text-soft: #c5cedd;
    --muted: #8894a8;
    --muted-strong: #a8b4c7;
    --blue: #6faeff;
    --blue-strong: #3f8dff;
    --blue-soft: rgba(79, 147, 255, .16);
    --green: #67d8af;
    --red: #ff8c98;
    --amber: #ffcc75;
    --shadow: 0 22px 64px rgba(0, 0, 0, .28);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--canvas);
    color: var(--text);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 72% -15%, rgba(57, 115, 214, .18), transparent 32rem),
        radial-gradient(circle at -12% 50%, rgba(64, 165, 144, .08), transparent 30rem),
        var(--canvas);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .52; }

.app-shell {
    display: grid;
    grid-template-columns: minmax(250px, 284px) minmax(440px, 1fr) minmax(264px, 320px);
    min-height: 100vh;
}

.sidebar, .context-rail {
    min-height: 0;
    background: rgba(13, 18, 29, .78);
    backdrop-filter: blur(22px);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 28px 20px 18px;
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    display: grid;
    grid-template-columns: repeat(3, 6px);
    align-items: end;
    gap: 3px;
    width: 35px;
    height: 35px;
    padding: 9px 8px;
    background: linear-gradient(145deg, #81b8ff, #4c77db);
    border-radius: 11px;
    box-shadow: 0 10px 24px rgba(62, 125, 226, .25);
}
.brand-mark span { display: block; border-radius: 4px; background: #fff; }
.brand-mark span:nth-child(1) { height: 7px; opacity: .75; }
.brand-mark span:nth-child(2) { height: 15px; }
.brand-mark span:nth-child(3) { height: 10px; opacity: .9; }

.eyebrow {
    margin: 0 0 5px;
    color: var(--blue);
    font-size: .66rem;
    font-weight: 770;
    letter-spacing: .125em;
    line-height: 1.1;
}

.brand h1, .room-header h2, .context-pane h2, dialog h2, .account-card h2, .section-heading h2 {
    margin: 0;
    letter-spacing: -.035em;
}
.brand h1 { font-size: 1.12rem; font-weight: 720; }
.brand-copy { margin: -9px 2px 0; color: var(--muted); font-size: .8rem; line-height: 1.55; }

.account-card {
    padding: 14px;
    background: linear-gradient(150deg, rgba(37, 52, 77, .72), rgba(20, 27, 41, .82));
    border: 1px solid rgba(170, 196, 238, .14);
    border-radius: 17px;
    box-shadow: inset 0 1px rgba(255,255,255,.025);
}

.account-heading, .section-heading, .pane-heading, .subsection-heading, .room-title-row, .room-header-actions,
.dialog-heading, .dialog-actions, .inline-add, .composer-actions, .message-head, .member-row, .friend-row {
    display: flex;
    align-items: center;
}

.account-heading { gap: 10px; }
.account-heading > div:nth-child(2) { min-width: 0; flex: 1; }
.account-heading h2 { overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 32px;
    height: 32px;
    color: #edf5ff;
    font-size: .78rem;
    font-weight: 800;
    background: linear-gradient(135deg, #386da7, #764f9c);
    border: 1px solid rgba(255,255,255,.17);
    border-radius: 10px;
}

.icon-button {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--text-soft);
    font-size: 1.34rem;
    line-height: 1;
    background: transparent;
    border: 0;
    border-radius: 9px;
}
.icon-button:hover { background: var(--surface-hover); color: var(--text); }
.icon-button.subtle { width: 29px; height: 29px; color: var(--muted); font-size: .95rem; }

input, select, textarea {
    width: 100%;
    color: var(--text);
    background: rgba(7, 10, 17, .42);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
input, select { min-height: 39px; padding: 9px 10px; }
textarea { padding: 12px 13px; resize: none; }
input:hover, select:hover, textarea:hover { border-color: rgba(151, 188, 239, .35); }
input:focus, select:focus, textarea:focus {
    background: rgba(8, 13, 22, .7);
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(82, 152, 255, .15);
    outline: 0;
}

.profile-name-input { margin-top: 13px; font-weight: 660; }
.inline-label { display: block; margin: 11px 0 4px; color: var(--muted-strong); font-size: .69rem; font-weight: 720; letter-spacing: .03em; }
.account-card select { min-height: 34px; padding: 6px 8px; font-size: .78rem; }

.text-action, .danger-link {
    padding: 5px 0;
    color: var(--blue);
    font-size: .76rem;
    font-weight: 730;
    text-align: left;
    background: transparent;
    border: 0;
}
.text-action:hover { color: #a4cbff; text-decoration: underline; }

.identity-stack { display: grid; gap: 3px; margin-top: 11px; }
.identity-label { color: var(--muted); font-size: .61rem; font-weight: 760; letter-spacing: .11em; }
.identity-value {
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    color: #b9d8ff;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .73rem;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: transparent;
    border: 0;
}
.identity-value.copyable:hover { color: #e5f1ff; text-decoration: underline; }
.identity-status, .identity-date { color: var(--muted); font-size: .68rem; line-height: 1.35; }
.identity-status { color: var(--green); }

.nav-actions { display: grid; gap: 3px; }
.nav-button {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 39px;
    padding: 8px 9px;
    color: var(--text-soft);
    font-size: .79rem;
    font-weight: 620;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
}
.nav-button:hover { background: rgba(80, 111, 156, .12); border-color: rgba(133, 170, 221, .11); color: var(--text); }
.nav-icon { width: 18px; color: #9fcaff; font-size: 1.04rem; text-align: center; }

.rooms-section { display: grid; min-height: 0; gap: 11px; }
.section-heading { justify-content: space-between; gap: 12px; }
.section-heading h2 { font-size: .98rem; }
.room-actions { display: flex; gap: 5px; }
.compact-button, .header-button, .outline-button {
    min-height: 34px;
    padding: 7px 10px;
    color: var(--text-soft);
    font-size: .73rem;
    font-weight: 720;
    white-space: nowrap;
    background: var(--surface-soft);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
}
.compact-button:hover, .header-button:hover, .outline-button:hover { background: var(--surface-hover); color: var(--text); border-color: rgba(170, 203, 246, .36); }
.primary-compact { color: #fff; background: #377fd7; border-color: #5b9eea; }
.primary-compact:hover { background: #4a90e5; }

.room-list {
    display: grid;
    gap: 4px;
    min-height: 0;
    max-height: 31vh;
    overflow: auto;
    padding-right: 2px;
}
.room-list::-webkit-scrollbar, .chat-box::-webkit-scrollbar, dialog::-webkit-scrollbar { width: 7px; height: 7px; }
.room-list::-webkit-scrollbar-thumb, .chat-box::-webkit-scrollbar-thumb, dialog::-webkit-scrollbar-thumb { background: rgba(143, 169, 203, .23); border-radius: 20px; }
.room-list button {
    width: 100%;
    padding: 10px 9px;
    color: var(--text-soft);
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
}
.room-list button:hover, .room-list button[aria-current="page"] { background: var(--blue-soft); border-color: rgba(104, 166, 255, .21); }
.room-list-name { display: block; overflow: hidden; color: var(--text); font-size: .81rem; font-weight: 710; text-overflow: ellipsis; white-space: nowrap; }
.room-list-meta { display: block; margin-top: 4px; color: var(--muted); font-size: .67rem; }
.empty-rooms { margin: 2px 0; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.sidebar-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 11px;
    color: var(--muted);
    font-size: .68rem;
    border-top: 1px solid var(--line);
}
.connection-status { display: flex; align-items: center; min-width: 0; gap: 7px; }
.connection-status #connection-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legal-links { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.legal-links a { color: inherit; font-weight: 650; text-decoration: none; }
.legal-links a:hover, .legal-links a:focus-visible { color: var(--text-soft); text-decoration: underline; }
.presence-dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 3px rgba(103,216,175,.12); }

.chat-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 100vh;
    padding: 30px clamp(22px, 4vw, 58px) 20px;
}
.room-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.room-title-wrap { min-width: 0; }
.room-title-row { flex-wrap: wrap; gap: 8px; }
.room-header h2 { overflow: hidden; font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.room-subtitle { margin: 8px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.room-header-actions { flex: 0 0 auto; gap: 7px; }
.header-button { min-height: 36px; background: rgba(26, 36, 53, .76); }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 8px;
    color: #b7d7ff;
    font-size: .65rem;
    font-weight: 750;
    letter-spacing: .02em;
    background: rgba(64, 125, 196, .16);
    border: 1px solid rgba(98, 156, 224, .25);
    border-radius: 999px;
}
.badge.accent { color: #ccefe4; background: rgba(54, 143, 111, .14); border-color: rgba(95, 199, 158, .25); }

.status { min-height: 1.35em; margin: 13px 0 6px; color: #a6c9f5; font-size: .77rem; }
.status.error, .form-error { color: var(--red); }

.chat-box {
    min-height: 280px;
    overflow: auto;
    padding: 16px 3px 20px 0;
    scroll-behavior: smooth;
}
.empty-state {
    display: grid;
    place-items: center;
    min-height: 260px;
    padding: 28px;
    color: var(--muted);
    font-size: .88rem;
    line-height: 1.55;
    text-align: center;
    background: rgba(18, 25, 38, .3);
    border: 1px dashed rgba(157, 184, 221, .21);
    border-radius: 16px;
}

.message {
    width: min(760px, 94%);
    margin: 0 0 13px;
    padding: 12px 14px;
    background: rgba(25, 34, 51, .78);
    border: 1px solid rgba(142, 170, 207, .14);
    border-radius: 5px 15px 15px 15px;
    box-shadow: 0 7px 22px rgba(1, 4, 10, .11);
}
.message.is-self { margin-left: auto; background: linear-gradient(145deg, rgba(35, 83, 139, .55), rgba(26, 51, 88, .65)); border-radius: 15px 5px 15px 15px; }
.message-head { justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.message-author { overflow: hidden; font-size: .78rem; font-weight: 790; text-overflow: ellipsis; white-space: nowrap; }
.message-unique { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .61rem; }
.message-body { margin: 0; overflow-wrap: anywhere; color: #e8eef8; font-size: .91rem; line-height: 1.52; white-space: pre-wrap; }
.message-meta { margin: 7px 0 0; color: var(--muted); font-size: .65rem; }
.message[data-color="sky"] .message-author { color: #7fc4ff; }
.message[data-color="violet"] .message-author { color: #c6a5ff; }
.message[data-color="rose"] .message-author { color: #ff9cad; }
.message[data-color="amber"] .message-author { color: #ffd17d; }
.message[data-color="mint"] .message-author { color: #82e6bf; }
.message[data-color="coral"] .message-author { color: #ffae8c; }
.message[data-color="slate"] .message-author { color: #c4ccda; }
.message[data-color="indigo"] .message-author { color: #9ba9ff; }

.message-form {
    display: grid;
    gap: 8px;
    padding-top: 14px;
    background: linear-gradient(to bottom, transparent, rgba(10,13,22,.86) 25%);
    border-top: 1px solid var(--line);
}
.message-form textarea { min-height: 48px; max-height: 150px; line-height: 1.4; }
.composer-actions { justify-content: space-between; gap: 12px; }
.composer-hint { color: var(--muted); font-size: .66rem; }
kbd { padding: 1px 4px; color: var(--muted-strong); font-family: inherit; font-size: .62rem; background: rgba(181, 204, 235, .08); border: 1px solid rgba(181, 204, 235, .13); border-radius: 4px; }
.send-button {
    min-height: 34px;
    padding: 7px 13px;
    color: #fff;
    font-size: .76rem;
    font-weight: 780;
    background: linear-gradient(135deg, #4c94ec, #3378d8);
    border: 1px solid #73adf0;
    border-radius: 9px;
    box-shadow: 0 8px 20px rgba(39, 108, 202, .2);
}
.send-button:hover:not(:disabled) { background: linear-gradient(135deg, #62a5f4, #4388e6); }

.context-rail {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 22px 18px;
    border-left: 1px solid var(--line);
}
.mobile-context-close { display: none; }
.context-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: rgba(32, 43, 62, .66); border-radius: 10px; }
.context-tab {
    min-height: 31px;
    padding: 5px;
    color: var(--muted-strong);
    font-size: .7rem;
    font-weight: 710;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
}
.context-tab.is-active { color: var(--text); background: rgba(99, 143, 205, .22); border-color: rgba(127, 169, 226, .12); }
.context-pane { min-height: 0; padding: 22px 2px 0; overflow: auto; }
.context-pane h2 { font-size: 1.1rem; }
.context-pane > p:not(.eyebrow) { color: var(--muted-strong); font-size: .8rem; line-height: 1.6; }
.detail-list { display: grid; gap: 9px; margin: 20px 0; }
.detail-list div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { margin-bottom: 4px; color: var(--muted); font-size: .62rem; font-weight: 730; letter-spacing: .08em; text-transform: uppercase; }
.detail-list dd { margin: 0; color: var(--text-soft); font-size: .78rem; }
.danger-link { color: var(--red); }
.pane-heading { justify-content: space-between; gap: 10px; }
.pane-heading h2 { font-size: 1rem; }

.member-list, .friend-list, .ai-user-list { display: grid; gap: 7px; margin-top: 14px; }
.member-row, .friend-row, .ai-user-row {
    gap: 8px;
    padding: 9px;
    background: rgba(32, 43, 62, .5);
    border: 1px solid rgba(174, 198, 231, .1);
    border-radius: 10px;
}
.member-row, .friend-row { justify-content: space-between; }
.member-identity, .friend-identity { min-width: 0; }
.member-name, .friend-name { display: block; overflow: hidden; color: var(--text-soft); font-size: .76rem; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.member-id, .friend-id { display: block; margin-top: 2px; overflow: hidden; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .61rem; text-overflow: ellipsis; white-space: nowrap; }
.role-chip, .friend-status { flex: 0 0 auto; padding: 3px 6px; color: #a8d1ff; font-size: .6rem; font-weight: 750; background: rgba(76, 137, 212, .16); border-radius: 999px; text-transform: capitalize; }
.role-chip.host { color: #ffe1a2; background: rgba(192, 135, 50, .16); }
.role-chip.moderator { color: #b7e6d4; background: rgba(60, 145, 112, .16); }
.assistant-boundary { display: flex; gap: 10px; margin: 18px 0; padding: 11px; background: rgba(48, 68, 99, .43); border: 1px solid rgba(117, 159, 217, .17); border-radius: 12px; }
.assistant-boundary p { margin: 0; color: #b7c4d8; font-size: .73rem; line-height: 1.45; }
.mini-orb { display: grid; flex: 0 0 auto; place-items: center; width: 25px; height: 25px; color: #b6ddff; font-size: .8rem; background: rgba(90, 150, 237, .18); border-radius: 9px; }
.outline-button { width: 100%; color: #b9d8ff; background: transparent; }

dialog {
    width: min(640px, calc(100vw - 30px));
    max-height: calc(100dvh - 30px);
    padding: 0;
    overflow: auto;
    color: var(--text);
    background: #121a29;
    border: 1px solid rgba(150, 184, 231, .27);
    border-radius: 18px;
    box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.025) inset;
}
dialog::backdrop { background: rgba(2, 5, 11, .7); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 13px; padding: 22px; }
.dialog-heading { align-items: flex-start; justify-content: space-between; gap: 15px; }
.dialog-heading h2 { font-size: 1.35rem; }
dialog label { color: var(--text-soft); font-size: .77rem; font-weight: 710; }
dialog fieldset { display: grid; gap: 10px; min-width: 0; padding: 0; margin: 0; border: 0; }
dialog fieldset:disabled { opacity: .65; }
.muted, .form-help { color: var(--muted); font-size: .72rem; font-weight: 500; line-height: 1.45; }
.form-help { margin: -6px 0 1px; }
.password-fields { display: grid; gap: 3px; }
.checkbox-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
    background: rgba(31, 44, 65, .64);
    border: 1px solid rgba(150, 183, 224, .13);
    border-radius: 11px;
}
.checkbox-row input { width: auto; min-height: auto; margin: 3px 0 0; }
.checkbox-row strong { display: block; color: var(--text-soft); font-size: .77rem; }
.checkbox-row small { display: block; margin-top: 4px; color: var(--muted); font-size: .68rem; font-weight: 450; line-height: 1.4; }
.permission-note { margin: 0; padding: 10px; color: #ffdc9a; font-size: .75rem; line-height: 1.45; background: rgba(167, 112, 29, .14); border: 1px solid rgba(241, 183, 88, .22); border-radius: 10px; }
.settings-subsection { padding-top: 4px; border-top: 1px solid var(--line); }
.subsection-heading { justify-content: space-between; gap: 12px; margin-top: 12px; }
.subsection-heading h3 { margin: 0; font-size: .88rem; letter-spacing: -.01em; }
.ai-user-row { display: flex; align-items: center; justify-content: space-between; }
.ai-user-row span { color: var(--text-soft); font-size: .74rem; font-weight: 690; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.row-button { min-height: 27px; padding: 4px 6px; color: #c3dcfa; font-size: .62rem; font-weight: 710; background: rgba(69, 99, 139, .32); border: 1px solid rgba(137, 175, 225, .18); border-radius: 7px; }
.row-button:hover { background: rgba(94, 133, 189, .32); }
.row-button.danger { color: #ffb8bf; background: rgba(156, 55, 72, .17); border-color: rgba(240, 115, 133, .2); }
.inline-add { gap: 7px; margin-top: 9px; }
.inline-add input { min-width: 0; }
.settings-members { max-height: 240px; overflow: auto; }
.danger-zone { padding: 10px; color: var(--muted-strong); background: rgba(101, 36, 52, .12); border: 1px solid rgba(210, 102, 119, .15); border-radius: 10px; }
.danger-zone summary { color: #ffb2bd; font-size: .75rem; font-weight: 750; cursor: pointer; }
.danger-zone p { margin: 9px 0; font-size: .7rem; line-height: 1.45; }
.danger-button { min-height: 32px; padding: 6px 10px; color: #fff0f2; font-size: .7rem; font-weight: 750; background: #a13b50; border: 1px solid #ce657a; border-radius: 8px; }
.danger-button:hover { background: #b94a61; }
.form-error { min-height: 1.25em; margin: 0; font-size: .76rem; }
.dialog-actions { justify-content: flex-end; gap: 8px; margin-top: 2px; }
.button {
    min-height: 37px;
    padding: 8px 12px;
    color: var(--text);
    font-size: .76rem;
    font-weight: 750;
    border: 1px solid transparent;
    border-radius: 9px;
}
.button.primary { background: #3d85df; border-color: #67a7ee; }
.button.primary:hover:not(:disabled) { background: #5196eb; }
.button.secondary { color: var(--text-soft); background: var(--surface-soft); border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled) { background: var(--surface-hover); }
.wide { width: 100%; margin-top: 2px; }

.browse-results { display: grid; gap: 8px; min-height: 50px; }
.browse-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; background: rgba(27, 38, 56, .62); border: 1px solid rgba(150, 184, 230, .13); border-radius: 12px; }
.browse-card h3 { margin: 0; color: var(--text); font-size: .84rem; }
.browse-card p { margin: 4px 0 0; color: var(--muted); font-size: .68rem; }
.browse-card button { flex: 0 0 auto; }

.account-summary { padding: 11px; color: var(--text-soft); font-size: .76rem; line-height: 1.5; background: rgba(45, 65, 96, .38); border: 1px solid rgba(137, 178, 235, .16); border-radius: 11px; }
.account-panel { display: grid; gap: 8px; padding: 13px; background: rgba(24, 33, 49, .55); border: 1px solid rgba(162, 188, 224, .12); border-radius: 12px; }
.account-panel h3 { margin: 0; font-size: .88rem; }
.account-panel p { margin: 0 0 3px; color: var(--muted-strong); font-size: .72rem; line-height: 1.48; }
.warning-copy { color: #ffcf8f !important; }
.google-button { min-height: 37px; padding: 8px 11px; color: var(--text-soft); font-size: .75rem; font-weight: 730; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.18); border-radius: 9px; }
.google-button:hover { background: rgba(255,255,255,.09); color: #fff; }

.friend-list { max-height: 320px; overflow: auto; }
.friend-status { color: #b4d7ff; }
.friend-status.incoming { color: #ffd38b; background: rgba(187, 133, 43, .16); }
.metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric-card { padding: 13px; background: rgba(32, 44, 65, .64); border: 1px solid rgba(157, 187, 225, .12); border-radius: 11px; }
.metric-card span { display: block; color: var(--muted); font-size: .64rem; font-weight: 730; letter-spacing: .04em; text-transform: uppercase; }
.metric-card strong { display: block; margin-top: 6px; color: var(--text); font-size: 1.25rem; }

.mobile-nav { display: none; }
.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; }

@media (max-width: 1190px) {
    .app-shell { grid-template-columns: minmax(236px, 270px) minmax(0, 1fr); }
    .context-rail { display: none; }
    .context-rail.is-mobile-open {
        position: fixed;
        z-index: 30;
        top: max(16px, env(safe-area-inset-top));
        right: 16px;
        bottom: max(16px, env(safe-area-inset-bottom));
        left: auto;
        display: grid;
        grid-template-rows: auto auto minmax(0, 1fr);
        width: min(420px, calc(100vw - 32px));
        min-height: min(560px, calc(100dvh - 32px));
        padding: 14px;
        background: rgba(15, 21, 34, .98);
        border: 1px solid rgba(156, 190, 235, .22);
        border-radius: 18px;
        box-shadow: 0 26px 82px rgba(0, 0, 0, .48);
    }
    .context-rail.is-mobile-open::before {
        position: fixed;
        z-index: -1;
        inset: 0;
        content: '';
        background: rgba(2, 5, 11, .58);
        backdrop-filter: blur(3px);
    }
    .context-rail.is-mobile-open .mobile-context-close {
        display: inline-grid;
        justify-self: end;
        margin: -3px -3px 6px 0;
    }
    .context-rail.is-mobile-open .context-pane { padding-top: 16px; }
    .chat-panel { padding-right: clamp(22px, 4vw, 56px); }
}

@media (max-width: 760px) {
    body { padding-bottom: 64px; }
    .app-shell { display: block; min-height: 100dvh; }
    .sidebar { gap: 14px; min-height: auto; padding: 17px 15px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand-copy, .nav-actions { display: none; }
    .account-card { display: none; }
    .brand h1 { font-size: 1rem; }
    .rooms-section { gap: 8px; }
    .section-heading { align-items: center; }
    .room-list { display: flex; max-width: calc(100vw - 30px); max-height: none; overflow-x: auto; overflow-y: hidden; }
    .room-list button { flex: 0 0 160px; }
    .empty-rooms { font-size: .68rem; }
    .sidebar-footer { display: none; }
    .chat-panel { min-height: calc(100dvh - 186px); padding: 17px 15px 12px; }
    .room-header { gap: 13px; padding-bottom: 14px; }
    .room-header h2 { font-size: 1.38rem; }
    .room-header-actions { gap: 5px; }
    .header-button { padding: 6px 8px; font-size: .68rem; }
    .room-subtitle { font-size: .71rem; }
    .chat-box { min-height: 0; padding-top: 12px; }
    .message { width: 97%; padding: 10px 11px; }
    .message-body { font-size: .86rem; }
    .composer-hint { display: none; }
    .composer-actions { justify-content: flex-end; }
    .message-form { padding-top: 9px; }
    .mobile-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 10;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 1px;
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
        background: rgba(13, 18, 29, .94);
        border-top: 1px solid var(--line);
        backdrop-filter: blur(18px);
    }
    .mobile-nav button { min-height: 42px; padding: 4px; color: var(--muted-strong); font-size: .62rem; font-weight: 700; background: transparent; border: 0; border-radius: 8px; }
    .mobile-nav button:hover, .mobile-nav button:focus-visible { color: var(--text); background: rgba(99, 143, 205, .16); }
    dialog { width: min(620px, calc(100vw - 18px)); max-height: calc(100dvh - 18px); border-radius: 14px; }
    dialog form { gap: 11px; padding: 17px; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
    .room-title-row { align-items: flex-start; flex-direction: column; gap: 5px; }
    .room-header { align-items: stretch; flex-direction: column; }
    .room-header-actions { display: grid; grid-template-columns: 1fr 1.3fr; }
    .header-button { width: 100%; }
    .room-list button { flex-basis: 145px; }
    .dialog-actions .button { flex: 1; }
}

/* Public policy pages use the same Relay visual language without loading the chat application. */
body.legal-page {
    min-height: 100dvh;
    padding: clamp(18px, 4vw, 48px);
}
.legal-shell {
    width: min(920px, 100%);
    margin: 0 auto;
}
.legal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}
.legal-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
}
.legal-brand .brand-mark { flex: 0 0 auto; }
.legal-brand-copy { display: grid; gap: 2px; }
.legal-brand-name { color: var(--text); font-size: .94rem; font-weight: 790; letter-spacing: -.015em; }
.legal-brand-tagline { color: var(--muted); font-size: .72rem; }
.legal-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.legal-nav a {
    min-height: 34px;
    padding: 8px 10px;
    color: var(--text-soft);
    font-size: .74rem;
    font-weight: 710;
    text-decoration: none;
    background: rgba(26, 35, 52, .72);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
}
.legal-nav a:hover, .legal-nav a:focus-visible, .legal-nav a[aria-current="page"] {
    color: var(--text);
    background: var(--blue-soft);
    border-color: rgba(112, 172, 249, .42);
}
.legal-card {
    padding: clamp(23px, 5vw, 54px);
    background: linear-gradient(150deg, rgba(24, 33, 50, .94), rgba(13, 18, 30, .93));
    border: 1px solid rgba(157, 188, 231, .18);
    border-radius: 22px;
    box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, .025);
}
.legal-card h1, .legal-card h2, .legal-card h3 { color: var(--text); letter-spacing: -.035em; }
.legal-card h1 { max-width: 690px; margin: 0; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.06; }
.legal-intro { max-width: 680px; margin: 17px 0 0; color: var(--muted-strong); font-size: clamp(.92rem, 1.7vw, 1.04rem); line-height: 1.65; }
.legal-meta { margin: 14px 0 0; color: var(--muted); font-size: .73rem; }
.legal-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    margin: 30px 0 10px;
}
.legal-fact {
    min-width: 0;
    padding: 13px;
    background: rgba(44, 64, 95, .35);
    border: 1px solid rgba(135, 176, 233, .14);
    border-radius: 13px;
}
.legal-fact strong { display: block; color: #b9daff; font-size: .68rem; letter-spacing: .075em; text-transform: uppercase; }
.legal-fact span { display: block; margin-top: 7px; color: var(--text-soft); font-size: .78rem; line-height: 1.48; }
.legal-content { margin-top: 30px; }
.legal-section { padding: 25px 0; border-top: 1px solid var(--line); }
.legal-section h2 { margin: 0; font-size: clamp(1.17rem, 2.3vw, 1.45rem); }
.legal-section h3 { margin: 18px 0 0; font-size: .93rem; }
.legal-section p, .legal-section li { color: var(--muted-strong); font-size: .88rem; line-height: 1.68; }
.legal-section p { margin: 12px 0 0; }
.legal-section ul { display: grid; gap: 8px; padding-left: 21px; margin: 13px 0 0; }
.legal-section li::marker { color: var(--blue); }
.legal-note {
    margin-top: 16px !important;
    padding: 13px 14px;
    color: #c9d9ed !important;
    background: rgba(57, 91, 141, .16);
    border: 1px solid rgba(119, 170, 235, .18);
    border-radius: 12px;
}
.legal-content a, .legal-footer a { color: #9fcbff; text-underline-offset: 3px; }
.legal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    margin-top: 22px;
    color: var(--muted);
    font-size: .72rem;
}
.legal-footer a { color: var(--text-soft); }

@media (max-width: 620px) {
    body.legal-page { padding: 14px; }
    .legal-header { align-items: flex-start; flex-direction: column; margin-bottom: 14px; }
    .legal-nav { justify-content: flex-start; }
    .legal-card { padding: 23px 19px; border-radius: 17px; }
    .legal-facts { grid-template-columns: 1fr; margin-top: 24px; }
    .legal-section { padding: 21px 0; }
    .legal-section p, .legal-section li { font-size: .84rem; }
}

