:root {
    color-scheme: light;
    --sidebar: #f4f4f2;
    --surface: #ffffff;
    --surface-soft: #f6f6f4;
    --ink: #232321;
    --muted: #767671;
    --line: #e8e8e4;
    --accent: #ea6a3b;
    --accent-dark: #d7582d;
    --shadow: 0 14px 40px rgba(31, 31, 28, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--surface);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, textarea { font: inherit; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
    width: 272px;
    flex: 0 0 272px;
    display: flex;
    flex-direction: column;
    padding: 18px 12px 12px;
    background: var(--sidebar);
    border-right: 1px solid rgba(0,0,0,.03);
}
.brand-row { height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 18px; font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { width: 29px; height: 29px; display: grid; place-items: center; color: white; border-radius: 9px; background: linear-gradient(145deg, #f28a5d, var(--accent)); box-shadow: 0 5px 12px rgba(234,106,59,.22); }
.brand-mark svg { width: 19px; height: 19px; stroke-width: 1.9; }
.icon-button, .tool-button { display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; border-radius: 9px; transition: background .18s, color .18s, transform .18s; }
.icon-button { width: 38px; height: 38px; }
.icon-button:hover, .tool-button:hover { background: rgba(0,0,0,.055); }
.icon-button:active, .tool-button:active { transform: scale(.95); }
.sidebar-close { display: none; }

.new-chat-button {
    height: 45px;
    margin: 19px 3px 16px;
    padding: 0 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e0e0dc;
    border-radius: 11px;
    background: rgba(255,255,255,.72);
    cursor: pointer;
    font-size: 14px;
    font-weight: 550;
    transition: all .18s ease;
}
.new-chat-button:hover { border-color: #d1d1cb; background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.04); }
.new-chat-button svg { width: 18px; }
.new-chat-button span { margin-left: auto; }
.new-chat-button kbd { margin-left: auto; padding: 2px 6px; color: #979791; background: #efefec; border-radius: 5px; font: 11px/1.5 inherit; }

.friends-nav-link { height: 40px; margin: -6px 3px 16px; padding: 0 11px; display: flex; align-items: center; gap: 10px; color: #4d4d49; border-radius: 9px; text-decoration: none; font-size: 13px; font-weight: 550; }
.messages-nav-link { margin-top: -14px; }
.friends-nav-link:hover { color: var(--ink); background: #e9e9e5; }
.friends-nav-link svg { width: 18px; }
.friends-nav-link span { flex: 1; }
.friends-nav-badge { min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; color: white; border-radius: 999px; background: var(--accent); font-size: 10px; }

.history { flex: 1; overflow-y: auto; padding: 0 1px 20px; scrollbar-width: thin; scrollbar-color: #d8d8d2 transparent; }
.history-group + .history-group { margin-top: 22px; }
.history-label { margin: 0 10px 8px; color: #999992; font-size: 11px; font-weight: 650; letter-spacing: .03em; }
.history-item { position: relative; display: flex; align-items: center; margin: 2px 0; border-radius: 9px; }
.history-select { min-width: 0; flex: 1; height: 39px; padding: 0 35px 0 11px; overflow: hidden; color: #4d4d49; background: transparent; border: 0; border-radius: 9px; cursor: pointer; text-align: left; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.history-item:hover, .history-item.active { background: #e9e9e5; }
.history-item.active .history-select { color: #242422; font-weight: 550; }
.history-menu { position: absolute; right: 5px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; color: #7b7b75; background: transparent; cursor: pointer; opacity: 0; }
.history-item:hover .history-menu, .history-item.active .history-menu { opacity: 1; }
.history-menu:hover { background: rgba(0,0,0,.06); }
.history-menu svg { width: 16px; }

.sidebar-footer { padding-top: 11px; border-top: 1px solid #e3e3df; }
.profile-card { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 10px; background: transparent; text-align: left; }
.profile-card:hover { background: #e9e9e5; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; font-size: 12px; font-weight: 650; }
.user-avatar { width: 32px; height: 32px; color: white; background: #3a6d72; }
.profile-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.profile-copy strong { font-size: 13px; font-weight: 600; }
.profile-copy small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.logout-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; color: #888882; background: transparent; cursor: pointer; }
.logout-button:hover { color: #c14932; background: rgba(193,73,50,.08); }
.logout-button svg { width: 17px; }

.chat-main { min-width: 0; flex: 1; display: flex; flex-direction: column; background: var(--surface); }
.topbar { height: 63px; flex: 0 0 63px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid rgba(0,0,0,.045); }
.menu-button { display: none; }
.model-picker { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-size: 14px; font-weight: 600; }
.model-picker:hover { background: var(--surface-soft); }
.model-picker svg { width: 16px; color: #777771; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #5eae75; box-shadow: 0 0 0 3px rgba(94,174,117,.1); }
.topbar-actions { display: flex; align-items: center; gap: 5px; }
.share-button { height: 36px; display: flex; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: white; cursor: pointer; font-size: 13px; font-weight: 550; }
.share-button:hover { background: var(--surface-soft); }
.share-button svg { width: 17px; }

.conversation { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.message-list { width: min(760px, calc(100% - 48px)); margin: 0 auto; padding: 45px 0 30px; }
.welcome { min-height: 100%; display: grid; place-items: center; padding: 30px 24px; }
.welcome-inner { width: min(720px, 100%); transform: translateY(-2vh); }
.welcome-mark { width: 46px; height: 46px; display: grid; place-items: center; margin: 0 auto 20px; color: white; border-radius: 15px; background: linear-gradient(145deg, #f28a5d, var(--accent)); box-shadow: 0 9px 25px rgba(234,106,59,.24); }
.welcome-mark svg { width: 27px; height: 27px; }
.welcome h1 { margin: 0; text-align: center; font-family: Georgia, "Songti SC", serif; font-size: clamp(28px, 4vw, 38px); font-weight: 500; letter-spacing: -.035em; }
.welcome p { margin: 12px 0 32px; color: var(--muted); text-align: center; font-size: 14px; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.suggestion { min-height: 82px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 13px; background: white; cursor: pointer; text-align: left; transition: border-color .18s, box-shadow .18s, transform .18s; }
.suggestion:hover { border-color: #d2d2cd; box-shadow: var(--shadow); transform: translateY(-1px); }
.suggestion strong { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.suggestion span { color: #8a8a84; font-size: 12px; line-height: 1.5; }

.message { display: flex; gap: 15px; margin-bottom: 31px; animation: message-in .24s ease both; }
@keyframes message-in { from { opacity: 0; transform: translateY(7px); } }
.message-avatar { width: 31px; height: 31px; margin-top: 1px; color: white; }
.message-avatar.assistant { border-radius: 10px; background: linear-gradient(145deg, #f28a5d, var(--accent)); }
.message-avatar.assistant svg { width: 19px; height: 19px; }
.message-avatar.user { background: #3a6d72; }
.message-body { min-width: 0; flex: 1; padding-top: 4px; }
.message-role { margin: 0 0 8px; font-size: 13px; font-weight: 650; }
.message-content { color: #393936; font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.message-actions { display: flex; gap: 3px; margin-top: 10px; opacity: 0; transition: opacity .18s; }
.message:hover .message-actions { opacity: 1; }
.message-action { width: 28px; height: 28px; display: grid; place-items: center; color: #82827c; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.message-action:hover { background: var(--surface-soft); }
.message-action.delete-message:hover { color: #bf3a2b; background: #fdecea; }
.message-action svg { width: 16px; }
.typing { display: inline-flex; align-items: center; gap: 4px; height: 22px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #8c8c86; animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .14s; }
.typing i:nth-child(3) { animation-delay: .28s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

.composer-area { flex: 0 0 auto; padding: 10px 24px 12px; background: linear-gradient(to top, #fff 78%, rgba(255,255,255,.88), rgba(255,255,255,0)); }
.composer-wrap { width: min(760px, 100%); margin: 0 auto; }
.composer { padding: 12px 12px 10px 16px; border: 1px solid #deded9; border-radius: 18px; background: white; box-shadow: 0 8px 28px rgba(33,33,29,.07); transition: border-color .18s, box-shadow .18s; }
.composer:focus-within { border-color: #c9c9c3; box-shadow: 0 10px 34px rgba(33,33,29,.1); }
.composer textarea { width: 100%; max-height: 160px; min-height: 29px; display: block; padding: 3px 3px 4px 0; resize: none; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: 14px; line-height: 1.55; overflow-y: auto; }
.composer textarea::placeholder { color: #9a9a94; }
.composer-tools { min-height: 33px; display: flex; align-items: end; justify-content: space-between; margin-top: 4px; }
.left-tools { display: flex; align-items: center; gap: 3px; }
.tool-button { width: 32px; height: 32px; border: 0; color: #777771; }
.tool-button svg { width: 19px; }
.tool-button.labeled { width: auto; grid-auto-flow: column; gap: 6px; padding: 0 9px; font-size: 12px; }
.send-button { width: 34px; height: 34px; display: grid; place-items: center; color: white; border: 0; border-radius: 11px; background: var(--accent); cursor: pointer; transition: background .18s, transform .18s, opacity .18s; }
.send-button:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.send-button:disabled { opacity: .28; cursor: default; }
.send-button svg { width: 19px; stroke-width: 2.1; }
.disclaimer { margin: 8px 0 0; color: #a0a09a; text-align: center; font-size: 10px; }

.toast { position: fixed; left: 50%; bottom: 115px; z-index: 20; padding: 9px 14px; color: white; border-radius: 9px; background: rgba(35,35,33,.9); box-shadow: var(--shadow); font-size: 12px; transform: translate(-50%, 10px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.mobile-overlay { display: none; }

.auth-body { min-height: 100%; background: #f7f7f5; }
.auth-shell { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 38px 20px 24px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; color: var(--ink); text-decoration: none; font-size: 20px; font-weight: 700; letter-spacing: -.025em; }
.auth-card { width: min(440px, 100%); padding: 38px 38px 32px; border: 1px solid #e5e5e0; border-radius: 20px; background: rgba(255,255,255,.94); box-shadow: 0 20px 60px rgba(35,35,31,.07); }
.auth-heading { margin-bottom: 27px; text-align: center; }
.auth-heading > span { display: inline-block; margin-bottom: 11px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.auth-heading h1 { margin: 0 0 9px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; letter-spacing: -.03em; }
.auth-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label:not(.check-row) { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 600; }
.auth-form input[type="text"], .auth-form input[type="email"], .auth-form input[type="password"] { width: 100%; height: 45px; padding: 0 13px; border: 1px solid #deded9; border-radius: 10px; outline: none; background: white; font-size: 14px; font-weight: 400; transition: border-color .18s, box-shadow .18s; }
.auth-form input:focus { border-color: #c48870; box-shadow: 0 0 0 3px rgba(234,106,59,.1); }
.auth-form input::placeholder { color: #aaa9a4; }
.check-row { display: flex; align-items: center; gap: 8px; color: #686863; font-size: 12px; cursor: pointer; }
.check-row input { accent-color: var(--accent); }
.field-error { margin: -8px 0 0; color: #c14932; font-size: 11px; }
.auth-submit { height: 45px; margin-top: 3px; border: 0; border-radius: 10px; color: white; background: var(--ink); cursor: pointer; font-size: 13px; font-weight: 650; transition: background .18s, transform .18s; }
.auth-submit:hover { background: #3b3b37; transform: translateY(-1px); }
.auth-switch { margin: 23px 0 0; color: #777771; text-align: center; font-size: 12px; }
.auth-switch a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.auth-footer { margin: 22px 0 0; color: #999993; font-size: 11px; }

.friends-body { min-height: 100%; background: #f7f7f5; }
.friends-header { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1120px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(16px); }
.friends-header-actions { display: flex; align-items: center; gap: 16px; }
.friends-current-user { color: var(--muted); font-size: 12px; }
.friends-chat-link { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: white; text-decoration: none; font-size: 12px; font-weight: 600; }
.friends-chat-link:hover { background: var(--surface-soft); }
.friends-chat-link svg { width: 17px; }
.friends-page { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 80px; }
.friends-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.friends-heading .eyebrow { display: block; margin-bottom: 8px; color: var(--accent-dark); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.friends-heading h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(34px, 5vw, 48px); font-weight: 500; letter-spacing: -.045em; }
.friends-heading p { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.friends-count-card { min-width: 112px; padding: 15px 18px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 8px 28px rgba(33,33,29,.04); }
.friends-count-card strong { font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.friends-count-card span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.friends-alert { margin-bottom: 16px; padding: 12px 15px; border: 1px solid; border-radius: 10px; font-size: 13px; }
.friends-alert.success { color: #2f6b43; border-color: #bfddc8; background: #eff8f1; }
.friends-alert.notice { color: #755a21; border-color: #ead9a4; background: #fff9e8; }
.friend-card { border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 12px 38px rgba(35,35,31,.045); overflow: hidden; }
.friend-search-card { margin-bottom: 18px; padding: 18px; }
.friend-search { height: 48px; display: flex; align-items: center; gap: 11px; padding-left: 14px; border: 1px solid #deded9; border-radius: 12px; background: #fbfbfa; transition: border-color .18s, box-shadow .18s; }
.friend-search:focus-within { border-color: #c48870; box-shadow: 0 0 0 3px rgba(234,106,59,.09); }
.friend-search svg { width: 19px; color: #8a8a84; }
.friend-search input { min-width: 0; flex: 1; height: 100%; border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; }
.friend-search button { height: 36px; margin-right: 6px; padding: 0 17px; color: white; border: 0; border-radius: 9px; background: var(--ink); cursor: pointer; font-size: 12px; font-weight: 650; }
.friend-search button:hover { background: #3b3b37; }
.friend-results-heading { display: flex; justify-content: space-between; padding: 20px 2px 9px; color: #555550; font-size: 12px; }
.friend-results-heading small { color: var(--muted); }
.friends-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.friend-card-heading { min-height: 77px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px 15px; border-bottom: 1px solid var(--line); }
.friend-card-heading h2 { margin: 0 0 5px; font-size: 15px; font-weight: 700; }
.friend-card-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.request-badge { min-width: 25px; height: 25px; display: grid; place-items: center; padding: 0 8px; color: white; border-radius: 999px; background: var(--accent); font-size: 11px; font-weight: 700; }
.friend-list { padding: 6px 10px; }
.friend-row { min-height: 67px; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 11px; }
.friend-row + .friend-row { border-top: 1px solid #f0f0ed; border-top-left-radius: 0; border-top-right-radius: 0; }
.friend-row:hover { background: #fafaf8; }
.friend-avatar { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: white; border-radius: 50%; background: #3a6d72; font-size: 13px; font-weight: 700; }
.friend-avatar.warm { background: var(--accent); }
.friend-avatar.muted { background: #888882; }
.friend-identity { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.friend-identity strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.friend-identity small { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.friend-actions { display: flex; align-items: center; gap: 5px; }
.friend-actions form { margin: 0; }
.friend-button { height: 31px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 10px; font-weight: 650; white-space: nowrap; }
.friend-button:disabled { opacity: .55; cursor: wait; }
.friend-button-link { display: inline-flex; align-items: center; text-decoration: none; }
.friend-button.primary { color: white; background: var(--ink); }
.friend-button.primary:hover { background: #3b3b37; }
.friend-button.subtle { color: #65655f; border-color: var(--line); background: white; }
.friend-button.subtle:hover { background: var(--surface-soft); }
.friend-button.danger { color: #a44230; background: transparent; }
.friend-button.danger:hover { background: rgba(193,73,50,.08); }
.friend-status { padding: 6px 9px; color: #777771; border-radius: 7px; background: var(--surface-soft); font-size: 10px; font-weight: 600; }
.friend-status.accepted { color: #3a704a; background: #edf7f0; }
.friend-empty { padding: 31px 18px; color: #999993; text-align: center; font-size: 11px; }
.friend-empty.compact { padding: 22px 12px; }
.all-friends-card .friend-list { min-height: 80px; }
.friend-list-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.friend-list-columns .friend-empty { grid-column: 1 / -1; }

.dm-body { height: 100%; overflow: hidden; background: #f7f7f5; }
.dm-shell { height: 100dvh; display: flex; }
.dm-sidebar { width: 320px; flex: 0 0 320px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #f4f4f2; }
.dm-brand-row { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid rgba(0,0,0,.04); }
.dm-back-link { color: var(--accent-dark); font-size: 11px; font-weight: 650; text-decoration: none; }
.dm-back-link:hover { text-decoration: underline; }
.dm-sidebar-heading { padding: 25px 20px 14px; }
.dm-sidebar-heading h1 { margin: 0 0 5px; font-family: Georgia, serif; font-size: 25px; font-weight: 500; letter-spacing: -.035em; }
.dm-sidebar-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.dm-friend-list { min-height: 0; flex: 1; padding: 5px 10px 18px; overflow-y: auto; }
.dm-friend-item { min-height: 64px; display: flex; align-items: center; gap: 11px; padding: 9px 10px; color: var(--ink); border-radius: 12px; text-decoration: none; transition: background .16s; }
.dm-friend-item:hover, .dm-friend-item.active { background: #e8e8e4; }
.dm-friend-item.active { box-shadow: inset 3px 0 var(--accent); }
.dm-friend-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.dm-friend-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.dm-friend-copy small { margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.dm-unread { min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; color: white; border-radius: 999px; background: var(--accent); font-size: 9px; font-weight: 700; }
.dm-no-friends { padding: 30px 16px; color: var(--muted); text-align: center; font-size: 12px; }
.dm-no-friends a { color: var(--accent-dark); font-weight: 650; }
.dm-sidebar-footer { padding: 13px 16px; border-top: 1px solid var(--line); }
.dm-sidebar-footer a { display: flex; align-items: center; gap: 7px; color: #65655f; text-decoration: none; font-size: 11px; }
.dm-sidebar-footer svg { width: 16px; }
.dm-main { min-width: 0; flex: 1; display: flex; flex-direction: column; background: white; }
.dm-topbar { height: 68px; flex: 0 0 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); }
.dm-active-person { display: flex; align-items: center; gap: 11px; }
.dm-active-person > span:last-child { display: flex; flex-direction: column; }
.dm-active-person strong { font-size: 13px; }
.dm-active-person small { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: var(--muted); font-size: 10px; }
.dm-active-person small i { width: 6px; height: 6px; border-radius: 50%; background: #5eae75; }
.dm-manage-link { color: var(--muted); font-size: 11px; text-decoration: none; }
.dm-manage-link:hover { color: var(--ink); }
.dm-topbar-actions { display: flex; align-items: center; gap: 14px; }
.dm-sound-toggle { width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); border: 0; border-radius: 9px; background: transparent; cursor: pointer; transition: color .15s, background .15s; }
.dm-sound-toggle:hover { color: var(--ink); background: #f2f2ef; }
.dm-sound-toggle svg { width: 17px; height: 17px; }
.dm-sound-toggle .dm-sound-off { display: none; }
.dm-sound-toggle.muted .dm-sound-on { display: none; }
.dm-sound-toggle.muted .dm-sound-off { display: block; }
.dm-sound-toggle.muted { color: #b3b2ac; }
.dm-messages { min-height: 0; flex: 1; padding: 28px max(24px, calc((100% - 760px) / 2)); overflow-y: auto; scroll-behavior: smooth; }
.dm-main { position: relative; }
.dm-scroll-bottom { position: absolute; left: 50%; bottom: 104px; z-index: 15; width: 40px; height: 40px; display: grid; place-items: center; color: #4b4b45; border: 1px solid rgba(31, 31, 28, .08); border-radius: 50%; background: rgba(255, 255, 255, .97); box-shadow: 0 10px 26px rgba(31, 31, 28, .16); cursor: pointer; transform: translateX(-50%); transition: background .16s, transform .16s, box-shadow .16s; }
.dm-scroll-bottom[hidden] { display: none; }
.dm-scroll-bottom:hover { background: white; transform: translateX(-50%) translateY(-2px); box-shadow: 0 14px 30px rgba(31, 31, 28, .2); }
.dm-scroll-bottom svg { width: 18px; height: 18px; }
.dm-scroll-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; color: white; border-radius: 999px; background: var(--accent); font-size: 9px; font-weight: 700; line-height: 1; }
.dm-scroll-count[hidden] { display: none; }
.chat-main { position: relative; }
.chat-scroll-bottom { bottom: 104px; }

/* Long messages collapse until expanded */
.dm-message-content.is-clamped { max-height: 200px; overflow: hidden; }
.message-content.is-clamped { max-height: 220px; overflow: hidden; }
.dm-expand { display: inline-block; margin-top: 7px; padding: 0; color: var(--accent-dark); border: 0; background: transparent; font-size: 11px; font-weight: 650; cursor: pointer; }
.dm-expand:hover { text-decoration: underline; }
.dm-message.own .dm-expand { color: #ffe3d7; }
.message-expand { margin-top: 9px; }

/* Clickable links inside chat messages */
.chat-link { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.chat-link:hover { color: #b04a25; }
.dm-message.own .chat-link { color: #ffe9df; }
.dm-message.own .chat-link:hover { color: #fff; }

/* Large screens: use the extra width, and anchor short chats to the bottom */
@media (min-width: 1280px) {
    .dm-messages { padding-left: max(24px, calc((100% - 900px) / 2)); padding-right: max(24px, calc((100% - 900px) / 2)); }
    .dm-composer-area { padding-left: max(24px, calc((100% - 900px) / 2)); padding-right: max(24px, calc((100% - 900px) / 2)); }
    .dm-bubble { max-width: min(70%, 640px); }
    .message-list { width: min(860px, calc(100% - 48px)); }
    .composer-wrap { width: min(860px, 100%); }
    .dm-message-content { font-size: 13.5px; }
}

.dm-messages { display: flex; flex-direction: column; }
.dm-messages > article:first-of-type { margin-top: auto; }
.conversation { display: flex; flex-direction: column; }
.conversation > .message-list { margin-top: auto; }

/* Forward to a friend */
.forward-modal { position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(22,22,19,.5); backdrop-filter: blur(2px); }
.forward-modal[hidden] { display: none; }
.forward-card { width: min(360px, 100%); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden; border-radius: 16px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.forward-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.forward-head strong { font-size: 13px; }
.forward-close { width: 28px; height: 28px; color: var(--muted); border: 0; border-radius: 8px; background: transparent; font-size: 18px; line-height: 1; cursor: pointer; }
.forward-close:hover { color: var(--ink); background: #f0f0ed; }
.forward-list { overflow-y: auto; padding: 6px; }
.forward-empty { margin: 0; padding: 26px 16px; color: var(--muted); text-align: center; font-size: 12px; }
.forward-friend { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; color: var(--ink); border: 0; border-radius: 10px; background: transparent; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.forward-friend:hover { background: #f4f4f2; }
.forward-friend:disabled { opacity: .5; cursor: default; }
.forward-avatar { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; border-radius: 50%; background: linear-gradient(145deg, #f28a5d, var(--accent)); font-size: 12px; font-weight: 700; }
.dm-message { display: flex; flex-direction: column; align-items: flex-start; margin: 8px 0; animation: message-in .2s ease both; }
.dm-message.own { align-items: flex-end; }
.dm-bubble { max-width: min(72%, 560px); padding: 10px 13px; color: #353531; border-radius: 5px 15px 15px 15px; background: #f0f0ed; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.dm-message.own .dm-bubble { color: white; border-radius: 15px 5px 15px 15px; background: var(--accent); }
.dm-message-content + .dm-attachment { margin-top: 9px; }
.dm-attachment { min-width: 210px; max-width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 10px; color: inherit; border: 1px solid rgba(37,37,33,.1); border-radius: 10px; background: rgba(255,255,255,.65); text-decoration: none; }
.dm-message.own .dm-attachment { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.14); }
.dm-attachment:hover { background: rgba(255,255,255,.9); }
.dm-message.own .dm-attachment:hover { background: rgba(255,255,255,.22); }
.dm-attachment-icon { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; background: rgba(0,0,0,.07); font-size: 18px; }
.dm-attachment-icon svg { width: 16px; height: 16px; stroke-width: 1.7; }
.dm-attachment--missing { opacity: .7; cursor: default; }
.dm-attachment--missing small { opacity: .85; }
.dm-attachment > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.dm-attachment strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 600; }
.dm-attachment small { margin-top: 2px; opacity: .7; font-size: 9px; }
.dm-message time { margin: 4px 4px 0; color: #aaa9a3; font-size: 8px; }
.dm-conversation-empty { height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--muted); text-align: center; }
.dm-conversation-empty strong { color: var(--ink); font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.dm-conversation-empty span { margin-top: 7px; font-size: 11px; }
.dm-composer-area { flex: 0 0 auto; padding: 12px max(24px, calc((100% - 760px) / 2)) 14px; }
.dm-file-selection { margin: 0 7px 7px; padding: 7px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink); border-radius: 10px; background: #f0f0ed; font-size: 11px; }
.dm-file-selection[hidden] { display: none; }
.dm-file-selection span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-file-selection button { padding: 0; color: var(--muted); border: 0; background: transparent; font-size: 18px; cursor: pointer; }
.dm-composer { display: flex; align-items: end; gap: 10px; padding: 9px 9px 9px 14px; border: 1px solid #deded9; border-radius: 16px; box-shadow: 0 7px 24px rgba(33,33,29,.06); }
.dm-composer:focus-within { border-color: #c9c9c3; }
.dm-composer textarea { min-height: 26px; max-height: 130px; flex: 1; padding: 4px 0; resize: none; color: var(--ink); border: 0; outline: 0; font: 13px/1.5 inherit; }
.dm-attach { width: 28px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; color: var(--muted); cursor: pointer; }
.dm-attach:hover { color: var(--accent); }
.dm-attach svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.dm-composer button { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; color: white; border: 0; border-radius: 11px; background: var(--accent); cursor: pointer; }
.dm-composer button:disabled { opacity: .3; cursor: default; }
.dm-composer button svg { width: 18px; }
.dm-composer-area > p { margin: 7px 0 0; color: #aaa9a3; text-align: center; font-size: 9px; }
.dm-empty-state { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 30px; text-align: center; }
.dm-empty-icon { width: 54px; height: 54px; display: grid; place-items: center; color: white; border-radius: 17px; background: linear-gradient(145deg, #f28a5d, var(--accent)); box-shadow: 0 9px 25px rgba(234,106,59,.22); }
.dm-empty-icon svg { width: 29px; height: 29px; }
.dm-empty-state h1 { margin: 20px 0 8px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.dm-empty-state p { margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 760px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(290px, 88vw); transform: translateX(-102%); box-shadow: 18px 0 50px rgba(0,0,0,.15); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close, .menu-button { display: grid; }
    .mobile-overlay { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(0,0,0,.28); opacity: 0; pointer-events: none; transition: opacity .25s; }
    .mobile-overlay.open { opacity: 1; pointer-events: auto; }
    .topbar { padding: 0 12px; }
    .model-picker { margin-right: auto; }
    .topbar-actions .icon-button { display: none; }
    .share-button span { display: none; }
    .share-button { width: 38px; padding: 0; justify-content: center; }
    .message-list { width: calc(100% - 30px); padding-top: 30px; }
    .message { gap: 11px; margin-bottom: 25px; }
    .message-content { font-size: 14px; }
    .composer-area { padding: 8px 10px 9px; }
    .suggestion-grid { grid-template-columns: 1fr; }
    .suggestion:nth-child(n+3) { display: none; }
    .welcome-inner { transform: none; }
    .auth-card { padding: 30px 24px 26px; }
    .friends-header { padding: 0 16px; }
    .friends-current-user { display: none; }
    .friends-chat-link { width: 39px; padding: 0; justify-content: center; font-size: 0; }
    .friends-page { width: min(100% - 24px, 620px); padding: 35px 0 55px; }
    .friends-heading { align-items: center; }
    .friends-heading p { max-width: 230px; line-height: 1.5; }
    .friends-count-card { min-width: 86px; padding: 12px 14px; }
    .friends-grid, .friend-list-columns { grid-template-columns: 1fr; }
    .friend-row { flex-wrap: wrap; }
    .friend-actions { width: 100%; padding-left: 49px; }
    .friend-search-card { padding: 12px; }
    .dm-sidebar { width: 88px; flex-basis: 88px; }
    .dm-brand-row { justify-content: center; padding: 0; }
    .dm-brand-row .brand > span:last-child, .dm-back-link, .dm-sidebar-heading, .dm-friend-copy, .dm-unread, .dm-sidebar-footer { display: none; }
    .dm-friend-list { padding: 10px; }
    .dm-friend-item { justify-content: center; padding: 9px; }
    .dm-friend-item.active { box-shadow: inset 3px 0 var(--accent); }
    .dm-topbar { padding: 0 14px; }
    .dm-manage-link { display: none; }
    .dm-messages { padding: 20px 14px; }
    .dm-bubble { max-width: 86%; }
    .dm-composer-area { padding: 9px 10px 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------------ */
/* Chat attachments: inline images, drag & drop, lightbox, previewer   */
/* ------------------------------------------------------------------ */

.dm-attachment { width: 100%; font: inherit; text-align: left; cursor: pointer; appearance: none; }
.dm-message-content + .dm-attachment { margin-top: 9px; }
.dm-message-content + .dm-image-button, .dm-message-content + .dm-media { margin-top: 8px; }

.dm-image-button { display: block; max-width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: 12px; background: transparent; cursor: zoom-in; line-height: 0; }
.dm-image-button img { display: block; width: auto; max-width: min(320px, 100%); max-height: 260px; height: auto; border: 1px solid rgba(37, 37, 33, .1); border-radius: 12px; object-fit: cover; background: #ededeb; transition: transform .18s ease, box-shadow .18s ease; }
.dm-image-button:hover img { transform: scale(1.012); box-shadow: 0 8px 22px rgba(28, 28, 24, .14); }
.dm-message.own .dm-image-button img { border-color: rgba(255, 255, 255, .38); }

.dm-bubble--media { max-width: min(72%, 560px); padding: 0; background: transparent; }
.dm-message.own .dm-bubble--media { padding: 0; background: transparent; }

.dm-media { display: block; width: 330px; max-width: 100%; max-height: 260px; border-radius: 12px; background: #111; }
.dm-media--audio { width: 330px; height: 54px; max-width: 100%; border-radius: 12px; background: transparent; }

.dm-file-thumb { width: 22px; height: 22px; flex: 0 0 auto; object-fit: cover; border-radius: 6px; background: #deded9; }
.dm-file-selection { justify-content: flex-start; }
.dm-file-selection #dm-file-name { flex: 1; }
.dm-file-selection button { flex: 0 0 auto; }

.dm-drop-overlay { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(247, 247, 245, .82); backdrop-filter: blur(4px); pointer-events: none; }
body.dm-dragging .dm-drop-overlay { display: flex; }
body.dm-dragging { cursor: copy; }
.dm-drop-card { padding: 34px 46px; text-align: center; border: 2.5px dashed rgba(234, 106, 59, .55); border-radius: 20px; background: rgba(255, 255, 255, .86); box-shadow: 0 24px 60px rgba(31, 31, 28, .12); }
.dm-drop-card strong { display: block; color: var(--accent-dark); font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.dm-drop-card span { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }

.dm-toast { position: fixed; left: 50%; bottom: 26px; z-index: 95; max-width: min(520px, calc(100vw - 32px)); padding: 9px 16px; color: white; border-radius: 999px; background: rgba(35, 35, 33, .92); font-size: 12px; text-align: center; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.dm-toast.show { opacity: 1; transform: translate(-50%, 0); }

body.dm-modal-open { overflow: hidden; }

.dm-lightbox { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 34px; background: rgba(16, 16, 14, .88); backdrop-filter: blur(3px); cursor: zoom-out; }
.dm-lightbox[hidden] { display: none; }
.dm-lightbox img { max-width: min(96vw, 1500px); max-height: 92vh; width: auto; height: auto; border-radius: 8px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); cursor: zoom-out; }
.dm-lightbox-close { position: absolute; top: 16px; right: 18px; width: 38px; height: 38px; color: white; border: 1px solid rgba(255, 255, 255, .28); border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 22px; line-height: 1; cursor: pointer; }
.dm-lightbox-close:hover { background: rgba(255, 255, 255, .2); }

.dm-preview { position: fixed; inset: 0; z-index: 85; display: flex; align-items: center; justify-content: center; padding: 26px; background: rgba(22, 22, 19, .55); backdrop-filter: blur(2px); }
.dm-preview[hidden] { display: none; }
.dm-preview-card { width: min(940px, 100%); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; border-radius: 16px; background: var(--surface); box-shadow: 0 34px 90px rgba(0, 0, 0, .32); }
.dm-preview-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dm-preview-badge { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; color: var(--accent-dark); border-radius: 9px; background: #fdece4; font-size: 8px; font-weight: 800; letter-spacing: .02em; }
.dm-preview-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.dm-preview-meta strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.dm-preview-meta small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.dm-preview-action { flex: 0 0 auto; padding: 7px 11px; color: #56564f; border: 1px solid #deded9; border-radius: 9px; background: #fbfbf9; font-size: 10px; font-weight: 600; text-decoration: none; cursor: pointer; }
.dm-preview-action:hover { border-color: #c9c9c3; background: white; }
.dm-preview-action--primary { color: white; border-color: transparent; background: var(--accent); }
.dm-preview-action--primary:hover { color: white; background: var(--accent-dark); }
.dm-preview-close { width: 30px; height: 30px; flex: 0 0 auto; color: var(--muted); border: 0; border-radius: 8px; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; }
.dm-preview-close:hover { color: var(--ink); background: #f0f0ed; }
.dm-preview-body { min-height: 260px; flex: 1; overflow: auto; background: var(--surface-soft); }
.dm-preview-body iframe { width: 100%; height: min(72vh, 720px); display: block; border: 0; background: white; }
.dm-preview-body > img { display: block; max-width: 100%; margin: 0 auto; }
.dm-preview-body video { display: block; width: 100%; max-height: 70vh; background: #000; }
.dm-preview-body audio { display: block; width: min(520px, 100%); margin: 40px auto; }
.dm-preview-note { margin: 0; padding: 8px 14px; color: var(--muted); border-top: 1px solid var(--line); background: white; font-size: 10px; }
.dm-preview-loading { margin: 0; padding: 40px; color: var(--muted); text-align: center; font-size: 12px; }
.dm-preview-text { margin: 0; padding: 18px 20px; color: #35352f; background: white; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.dm-preview-fallback { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 54px 24px; text-align: center; }
.dm-preview-fallback strong { font-family: Georgia, serif; font-size: 18px; font-weight: 500; }
.dm-preview-fallback span { max-width: 380px; color: var(--muted); font-size: 11px; }
.dm-preview-fallback a { margin-top: 8px; }

@media (max-width: 760px) {
    .dm-preview { padding: 0; }
    .dm-preview-card { width: 100%; height: 100%; max-height: none; border-radius: 0; }
    .dm-preview-head { flex-wrap: wrap; }
    .dm-preview-action { padding: 6px 9px; font-size: 9px; }
    .dm-preview-save { order: 3; }
    .dm-preview-body iframe { height: 68vh; }
    .dm-lightbox { padding: 12px; }
}

/* Main chat (Sage) attachments */
.message-content + .dm-image-button,
.message-content + .dm-attachment,
.message-content + .dm-media { margin-top: 9px; }
.message-attachment-slot:empty { display: none; }
.composer-wrap .dm-file-selection { margin: 0 0 8px; }
.chat-main .dm-image-button img { max-width: min(360px, 100%); }

/* Direct message meta row: time + copy */
.dm-message-meta { display: flex; align-items: center; gap: 5px; margin: 4px 4px 0; }
.dm-message.own .dm-message-meta { flex-direction: row-reverse; }
.dm-message-meta time { margin: 0; }
.dm-copy, .dm-delete, .dm-forward { width: 22px; height: 22px; display: grid; place-items: center; padding: 0; color: #b3b2ac; border: 0; border-radius: 6px; background: transparent; cursor: pointer; opacity: 0; transition: opacity .15s, background .15s, color .15s; }
.dm-message:hover .dm-copy, .dm-copy:focus-visible,
.dm-message:hover .dm-forward, .dm-forward:focus-visible,
.dm-message:hover .dm-delete, .dm-delete:focus-visible { opacity: 1; }
.dm-copy:hover, .dm-forward:hover { color: var(--ink); background: #f0f0ed; }
.dm-delete:hover { color: #bf3a2b; background: #fdecea; }
.dm-copy.copied { color: #3f8f5a; opacity: 1; }
.dm-read-status { color: #a9a9a2; font-size: 9px; letter-spacing: .02em; }
.dm-read-status.is-read { color: #4c9d68; }
.dm-copy svg, .dm-delete svg, .dm-forward svg { width: 13px; height: 13px; }
@media (hover: none) { .dm-copy, .dm-delete, .dm-forward { opacity: .7; } }

/* Inline images: soft blurred colour border */
.dm-image-button { position: relative; display: inline-block; max-width: 100%; padding: 4px; overflow: hidden; border: 0; border-radius: 16px; background: rgba(120,120,110,.08); cursor: zoom-in; line-height: 0; isolation: isolate; }
.dm-image-glow { position: absolute; inset: -12px; z-index: 0; background-size: cover; background-position: center; filter: blur(14px) saturate(1.6); opacity: .6; transform: scale(1.08); pointer-events: none; }
.dm-image-button img { position: relative; z-index: 1; border-radius: 12px; border: 1px solid rgba(255,255,255,.45); box-shadow: 0 8px 22px rgba(20,20,16,.18); }
.dm-message.own .dm-image-button img { border-color: rgba(255,255,255,.55); }
.dm-message.own .dm-image-button { background: rgba(255,255,255,.12); }

/* Group list in the messages sidebar */
.dm-groups { padding: 0 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.dm-groups-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 6px; color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.dm-groups-head button { border: 0; background: transparent; color: var(--accent-dark); font-size: 10px; font-weight: 700; letter-spacing: .02em; cursor: pointer; text-transform: none; }

/* Group unread badge: keep it a small pill and respect [hidden] */
.dm-unread[hidden] { display: none !important; }
.dm-sidebar-heading h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dm-sidebar-heading h1 .dm-unread { flex: 0 0 auto; width: auto; min-width: 20px; display: inline-grid; }

/* Group header members dropdown */
.dm-active-person { position: relative; }
.dm-group-title { display: inline-flex; align-items: center; gap: 5px; padding: 0; color: inherit; border: 0; background: transparent; font: inherit; cursor: pointer; }
.dm-group-title strong { font-size: 13px; }
.dm-group-title svg { width: 14px; height: 14px; color: var(--muted); }
.dm-group-title:hover svg { color: var(--ink); }
.dm-members-menu { position: absolute; top: calc(100% + 10px); left: 40px; z-index: 40; width: 240px; max-height: 300px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 18px 44px rgba(31,31,28,.16); }
.dm-members-menu[hidden] { display: none; }
.dm-members-menu-title { margin: 4px 8px 8px; color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.dm-members-row { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px; font-size: 12px; }
.dm-members-row:hover { background: #f4f4f2; }
.dm-members-row em { margin-left: auto; color: var(--muted); font-size: 10px; font-style: normal; }
.friend-avatar.small { width: 24px; height: 24px; font-size: 10px; }

/* Online / offline presence dots */
.friend-avatar { position: relative; }
.presence-dot { position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: #c9c9c3; border: 2px solid #fff; box-sizing: content-box; }
.presence-dot.online { background: #46b06b; }
.dm-friend-item.active .presence-dot { border-color: #e8e8e4; }
.dm-active-person .presence-dot { border-color: #fff; }

/* Tone down the inline-image backdrop (keep just a thin blurred edge) */
.dm-image-button { padding: 3px; background: transparent; border-radius: 13px; }
.dm-image-glow { inset: 0; opacity: .28; filter: blur(8px) saturate(1.25); transform: none; }
.dm-image-button img { box-shadow: none; border-color: rgba(0, 0, 0, .1); }
.dm-message.own .dm-image-button { background: transparent; }
.dm-message.own .dm-image-button img { border-color: rgba(255, 255, 255, .35); }

/* Inline images: 1px border only (blurred backdrop removed) */
.dm-image-glow { display: none; }
.dm-image-button { padding: 0; background: transparent; border-radius: 12px; }
.dm-image-button img { border: 1px solid rgba(0, 0, 0, .12); border-radius: 12px; box-shadow: none; }
.dm-message.own .dm-image-button { background: transparent; }
.dm-message.own .dm-image-button img { border-color: rgba(255, 255, 255, .38); }

/* Inline images: plain 1px border, wrapper hugs the image */
.dm-image-glow { display: none !important; }
.dm-image-button { display: inline-block; width: fit-content; max-width: 100%; padding: 0; background: transparent; border-radius: 12px; }
.dm-image-button img { display: block; width: auto; max-width: min(320px, 100%); max-height: 260px; height: auto; border: 1px solid rgba(0, 0, 0, .12); border-radius: 12px; box-shadow: none; }
.dm-message.own .dm-image-button img { border-color: rgba(255, 255, 255, .38); }
.chat-main .dm-image-button img { max-width: min(360px, 100%); }

/* Own image messages: hug the right edge, never leave a wide empty card */
.dm-bubble--media { width: fit-content; max-width: 100%; padding: 0; background: transparent; }
.dm-message.own .dm-bubble--media { align-self: flex-end; }
.dm-image-button { margin: 0; }
.dm-message.own .dm-image-button { margin-left: auto; }
.dm-image-button img { max-width: min(300px, 100%); }

/* Force own image messages to the right edge */
.dm-message.own { align-items: flex-end !important; }
.dm-message.own .dm-bubble--media { margin-left: auto !important; margin-right: 0 !important; }
.dm-message.own .dm-image-button { margin-left: auto !important; margin-right: 0 !important; }
.dm-image-button img { max-width: 280px !important; max-height: 230px !important; }

/* Unread badge inside the group title */
.dm-group-title .dm-unread { margin-left: 2px; }
