:root {
    --brand: #3157D5;
    --brand-dark: #2447BC;
    --brand-soft: color-mix(in srgb, var(--brand) 12%, #fff);
    --chat-bg: #EDEDED;
    --panel: #FFFFFF;
    --panel-soft: #F7F7F7;
    --line: #E5E5E5;
    --ink: #111111;
    --muted: #8C8C8C;
    --success: #07C160;
    --user-bubble: #95EC69;
    --user-bubble-border: #7DDB55;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --composer-h: 0px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    color: var(--ink);
    background: #E8ECF2;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
    overflow: hidden;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.global-notice { position: fixed; top: 0; left: 50%; z-index: 200; max-width: min(520px, calc(100% - 24px)); padding: 8px 14px; border-radius: 0 0 10px 10px; color: #7A4E00; background: #FFF1C2; box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateX(-50%); font-size: 12px; line-height: 1.45; }
.messenger-app { position: relative; width: min(1240px, calc(100% - 32px)); height: min(920px, calc(100dvh - 32px)); margin: 16px auto; display: grid; grid-template-columns: 288px minmax(0, 1fr); overflow: hidden; border: 1px solid #E2E8F0; border-radius: 20px; background: #fff; box-shadow: 0 24px 64px rgba(15, 23, 42, .12), 0 0 0 1px rgba(255,255,255,.6) inset; }

/* Desktop contact/navigation rail */
.desktop-sidebar { min-width: 0; padding: 22px 16px 16px; display: flex; flex-direction: column; border-right: 1px solid #EEF1F5; background: linear-gradient(180deg, #FAFBFC 0%, #F5F7FA 100%); }
.sidebar-school { padding: 0 8px 18px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid rgba(0,0,0,.06); }
.sidebar-school > img, .sidebar-school > span { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 11px; display: grid; place-items: center; object-fit: contain; color: #fff; background: var(--brand); font-size: 18px; font-weight: 800; box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 28%, transparent); }
.sidebar-school div { min-width: 0; display: grid; }
.sidebar-school strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.sidebar-school small { color: var(--muted); font-size: 11px; }
.sidebar-profile { margin: 16px 0 12px; padding: 18px 14px; border: 1px solid #E8ECF2; border-radius: var(--radius-lg); text-align: center; background: #fff; box-shadow: 0 4px 14px rgba(15,23,42,.04); }
.sidebar-avatar { width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 14px; display: grid; place-items: center; overflow: hidden; color: #fff; background: var(--brand); font-size: 24px; font-weight: 800; }
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-profile > strong { font-size: 16px; }
.sidebar-profile > p { min-height: 18px; margin: 3px 0 12px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.sidebar-profile > button { width: 100%; min-height: 38px; border: 0; border-radius: 10px; color: #fff; background: var(--brand); font-size: 13px; font-weight: 700; transition: background .15s, transform .15s; }
.sidebar-profile > button:hover { background: var(--brand-dark); }
.sidebar-profile > button:active { transform: scale(.98); }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav > button { width: 100%; min-height: 56px; padding: 8px 10px; display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 8px; border: 0; border-radius: 12px; text-align: left; background: transparent; transition: background .15s; }
.sidebar-nav > button:hover { background: rgba(255,255,255,.85); }
.sidebar-nav > button.active { background: #fff; box-shadow: 0 2px 10px rgba(15,23,42,.05); }
.sidebar-nav > button.active strong { color: var(--brand); }
.sidebar-nav > button > span { font-size: 18px; text-align: center; }
.sidebar-nav > button > div { min-width: 0; display: grid; }
.sidebar-nav strong { font-size: 13px; }
.sidebar-nav small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.sidebar-trust { margin-top: auto; padding: 12px 11px; border-radius: 12px; color: #64748B; background: #fff; border: 1px solid #EEF1F5; }
.sidebar-trust strong { font-size: 11px; color: #475569; }
.sidebar-trust p { margin: 4px 0 0; font-size: 10px; line-height: 1.6; }

/* Conversation frame */
.conversation-panel { min-width: 0; min-height: 0; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; background: var(--chat-bg); }
.conversation-header { min-height: 64px; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(0,0,0,.06); background: rgba(255,255,255,.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.header-person { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 10px; }
.header-avatar { display: none; width: 40px; height: 40px; flex: 0 0 auto; overflow: hidden; border-radius: 10px; place-items: center; color: #fff; background: var(--brand); font-weight: 800; }
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-person > div:last-child { min-width: 0; }
.header-person h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 650; }
.header-person p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.header-person p i { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 25%, transparent); }
.conversation-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.conversation-actions button { min-width: 40px; min-height: 40px; height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; transition: background .15s; }
.conversation-actions button:hover { background: #F0F0F0; }
.conversation-actions button span { margin-left: 4px; font-size: 12px; }

.chat-feed { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 0 20px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; background: var(--chat-bg); }
.chat-feed::-webkit-scrollbar, .info-panel::-webkit-scrollbar, .contact-drawer::-webkit-scrollbar { width: 6px; }
.chat-feed::-webkit-scrollbar-thumb, .info-panel::-webkit-scrollbar-thumb, .contact-drawer::-webkit-scrollbar-thumb { border-radius: 6px; background: #C8C8C8; }
.date-divider { width: min(760px, calc(100% - 32px)); margin: 0 auto 16px; text-align: center; }
.date-divider span { padding: 3px 8px; border-radius: 6px; color: #888; background: rgba(0,0,0,.05); font-size: 11px; }
.chat-message { width: min(760px, calc(100% - 32px)); margin: 0 auto 16px; display: flex; align-items: flex-start; gap: 10px; animation: msg-in .18s ease; }
.chat-message.user { flex-direction: row-reverse; }
.chat-message > div:last-child { min-width: 0; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.message-avatar { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 10px; display: grid; place-items: center; overflow: hidden; color: #fff; background: var(--brand); font-size: 12px; font-weight: 800; }
.senior-message-avatar { background: #3A3A3A; }
.user .message-avatar { background: #5A5A5A; }
.sender-name { margin: -2px 0 4px; color: #999; font-size: 11px; }
.message-bubble { position: relative; max-width: min(540px, 72vw); padding: 10px 13px; border: 1px solid rgba(0,0,0,.04); border-radius: 4px 12px 12px 12px; color: #1A1A1A; background: #fff; font-size: 15px; line-height: 1.65; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.04); overflow: hidden; }
.message-bubble:has(.message-media) { max-width: min(400px, 78vw); padding-bottom: 10px; }
.bot .message-bubble::before { content: ""; position: absolute; left: -5px; top: 12px; width: 10px; height: 10px; border-left: 1px solid rgba(0,0,0,.04); border-bottom: 1px solid rgba(0,0,0,.04); background: #fff; transform: rotate(45deg); }
.user .message-bubble { border-color: var(--user-bubble-border); border-radius: 12px 4px 12px 12px; background: var(--user-bubble); }
.user .message-bubble::before { content: ""; position: absolute; right: -5px; top: 12px; width: 10px; height: 10px; border-top: 1px solid var(--user-bubble-border); border-right: 1px solid var(--user-bubble-border); background: var(--user-bubble); transform: rotate(45deg); }
.chat-message.error-message .message-bubble { border-color: #FECACA; background: #FEF2F2; color: #991B1B; }
.chat-message.error-message .message-bubble::before { border-color: #FECACA; background: #FEF2F2; }
.message-retry { margin-top: 8px; min-height: 32px; padding: 0 12px; border: 1px solid #FECACA; border-radius: 8px; color: #B91C1C; background: #fff; font-size: 12px; font-weight: 650; }
.chat-message small { display: block; margin: 4px 2px 0; color: #A3A3A3; font-size: 10px; }
.user small { text-align: right; }
.typing .message-bubble { display: flex; align-items: center; gap: 8px; padding: 12px 14px; min-width: 72px; }
.typing .message-bubble .typing-dots { display: flex; gap: 4px; }
.typing .message-bubble i { width: 6px; height: 6px; border-radius: 50%; background: #999; animation: typing 1.2s infinite; }
.typing .message-bubble i:nth-child(2) { animation-delay: .15s; }
.typing .message-bubble i:nth-child(3) { animation-delay: .3s; }
.typing-label { color: #888; font-size: 12px; }
@keyframes typing { 50% { opacity: .35; transform: translateY(-3px); } }

/* Trustworthy rich messages */
.rich-message-wrap { min-width: 0; width: min(410px, calc(100% - 47px)); }
.contact-message-card, .topic-message-card, .material-message-card { overflow: hidden; border: 1px solid #E8ECF2; border-radius: var(--radius-lg); background: #fff; box-shadow: 0 6px 20px rgba(15,23,42,.05); }
.contact-message-card { padding: 15px 15px 0; }
.contact-card-head { display: flex; align-items: center; gap: 10px; }
.contact-card-avatar { width: 48px; height: 48px; flex: 0 0 auto; overflow: hidden; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--brand); font-size: 19px; font-weight: 800; }
.contact-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.contact-card-head > div:last-child { min-width: 0; }
.contact-card-head strong { font-size: 15px; }
.contact-card-head p { margin: 2px 0 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.contact-card-bio { margin: 12px 0; color: #555; font-size: 13px; line-height: 1.65; }
.contact-card-line { margin: 0 0 10px; padding: 10px 12px; display: grid; grid-template-columns: 48px 1fr; border-radius: 10px; background: #F7F8FA; border: 1px solid #EEF1F5; font-size: 12px; }
.contact-card-line span { color: var(--muted); }
.contact-message-card > button, .material-message-card > button { width: 100%; min-height: 42px; border: 0; border-radius: 10px; color: #fff; background: var(--brand); font-size: 13px; font-weight: 700; transition: background .15s; }
.contact-message-card > button:hover, .material-message-card > button:hover { background: var(--brand-dark); }
.contact-message-card footer { margin: 13px -15px 0; padding: 9px 15px; border-top: 1px solid #F0F0F0; color: #999; font-size: 10px; }
.topic-message-card { padding: 14px; }
.topic-message-card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.topic-message-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topic-message-grid button { min-width: 0; min-height: 56px; padding: 8px; display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 6px; border: 1px solid #EEF1F5; border-radius: 12px; text-align: left; background: #FAFBFC; transition: border-color .15s, background .15s, transform .15s; }
.topic-message-grid button:hover { border-color: color-mix(in srgb, var(--brand) 35%, #EEF1F5); background: var(--brand-soft); }
.topic-message-grid button:active { transform: scale(.98); background: #EEE; }
.topic-message-grid button > span { font-size: 18px; }
.topic-message-grid button div { min-width: 0; display: grid; }
.topic-message-grid strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.topic-message-grid small { color: #999; font-size: 10px; }
.material-message-card { padding: 14px; }
.material-message-card ul { margin: 0 0 12px; padding: 0; display: grid; gap: 8px; list-style: none; }
.material-message-card li { display: flex; align-items: center; gap: 8px; color: #444; font-size: 12px; padding: 8px 10px; border-radius: 10px; background: #F7F8FA; }
.chat-disclaimer { width: min(760px, calc(100% - 32px)); margin: 20px auto 0; color: #A3A3A3; text-align: center; font-size: 10px; line-height: 1.5; }

/* Inline media inside chat bubbles */
.message-bubble .message-text + .message-media { margin-top: 10px; }
.message-bubble .message-media + .message-text { margin-top: 10px; }
.message-media { display: grid; gap: 6px; margin-top: 4px; max-width: min(320px, 100%); }
.message-media.single { grid-template-columns: 1fr; }
.message-media.dual { grid-template-columns: 1fr 1fr; max-width: min(360px, 100%); }
.message-media.multi { grid-template-columns: 1fr 1fr; max-width: min(360px, 100%); }
.message-media-image {
    display: block; width: 100%; padding: 0; margin: 0; border: 0;
    border-radius: 10px; overflow: hidden; background: #E8E8E8; cursor: zoom-in;
    aspect-ratio: 4 / 3; max-height: 280px;
}
.message-media.single .message-media-image { aspect-ratio: 16 / 10; max-height: 260px; }
.message-media-image img { width: 100%; height: 100%; object-fit: cover; display: block; vertical-align: middle; }
.message-media-video { width: 100%; border-radius: 10px; overflow: hidden; background: #000; }
.message-media-video video { width: 100%; max-height: 260px; display: block; border-radius: 10px; background: #000; }

/* Source footnote (collapsible) */
.source-box {
    max-width: min(540px, 100%); margin-top: 6px; padding: 0;
    border: 0; border-radius: 0; background: transparent;
}
.source-box > summary {
    list-style: none; cursor: pointer; color: #999; font-size: 10px;
    user-select: none; padding: 2px 0;
}
.source-box > summary::-webkit-details-marker { display: none; }
.source-box > summary::before { content: "› "; display: inline-block; transition: transform .15s; }
.source-box[open] > summary::before { transform: rotate(90deg); }
.source-box[open] > summary { margin-bottom: 4px; }
.source-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    color: #888; font-size: 10px; padding: 2px 0;
}
.source-item small { margin: 0; flex: 0 0 auto; color: #aaa; }
.source-image { width: 58px; height: 48px; margin: 7px 5px 0 0; padding: 0; overflow: hidden; border: 0; border-radius: 5px; background: #DDD; cursor: zoom-in; }
.source-image img { width: 100%; height: 100%; object-fit: cover; }
.source-video { width: 100%; max-width: 280px; margin: 7px 0 0; border-radius: 8px; background: #000; display: block; }

/* Suggestions and composer */
.quick-suggestions { min-width: 0; padding: 8px 14px 6px; border-top: 1px solid rgba(0,0,0,.04); background: rgba(255,255,255,.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.quick-list { width: min(760px, 100%); margin: auto; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.quick-list::-webkit-scrollbar { display: none; }
.quick-list button {
    min-height: 34px; flex: 0 0 auto; max-width: 220px; padding: 6px 12px; overflow: hidden;
    border: 1px solid #E5E5E5; border-radius: 999px; color: #444; background: #fff;
    text-overflow: ellipsis; white-space: nowrap; font-size: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03); transition: border-color .15s, background .15s;
}
.quick-list button:hover { border-color: color-mix(in srgb, var(--brand) 40%, #E5E5E5); background: var(--brand-soft); color: var(--brand); }
.composer-area {
    position: relative; padding: 10px 14px calc(10px + var(--safe-bottom) + var(--kb-offset, 0px));
    display: flex; align-items: flex-end; gap: 8px;
    border-top: 1px solid rgba(0,0,0,.06); background: rgba(247,247,247,.96);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.composer-more {
    width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: 50%;
    background: #fff; color: #555; font-size: 26px; font-weight: 300; line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,.06); transition: background .15s, transform .15s;
}
.composer-more:active { transform: scale(.96); }
.composer-input {
    width: 0; min-width: 0; flex: 1 1 0; min-height: 40px; margin-right: 0; padding: 9px 12px;
    border: 0; border-radius: 20px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.composer-input textarea {
    width: 100%; min-width: 0; min-height: 22px; max-height: 112px; padding: 0; resize: none;
    border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 15px; line-height: 1.55;
}
.send-button {
    position: static; flex: 0 0 auto; min-width: 56px; height: 40px; padding: 0 14px;
    border: 0; border-radius: 20px; color: #fff; background: var(--brand);
    font-size: 13px; font-weight: 700; transition: opacity .15s, background .15s, transform .15s;
}
.send-button:hover:not(:disabled) { background: var(--brand-dark); }
.send-button:active:not(:disabled) { transform: scale(.97); }
.send-button:disabled { opacity: .45; }
.send-button.is-ready { box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 30%, transparent); }
.composer-area > p { display: none; }

/* Side information and contact sheets */
.panel-overlay { position: fixed; inset: 0; z-index: 80; visibility: hidden; opacity: 0; background: rgba(15,23,42,.4); transition: .2s; }
.panel-overlay.open { visibility: visible; opacity: 1; }
.info-panel, .contact-drawer {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 90; width: min(380px, 94vw);
    padding: 20px 20px calc(20px + var(--safe-bottom)); overflow-y: auto;
    background: #fff; border-left: 1px solid #EEF1F5;
    box-shadow: -16px 0 48px rgba(15,23,42,.12); transform: translateX(105%); transition: transform .24s ease;
}
.contact-drawer { position: fixed; }
.info-panel.open, .contact-drawer.open { transform: none; }
.info-panel > header, .contact-drawer > header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 4px; }
.info-panel header small, .contact-drawer header small { color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.info-panel header h2, .contact-drawer header h2 { margin: 2px 0 0; font-size: 20px; font-weight: 750; }
.info-panel header button, .contact-drawer header button {
    width: 36px; height: 36px; border: 0; border-radius: 50%; background: #F3F4F6; color: #555; font-size: 22px;
    display: grid; place-items: center; transition: background .15s;
}
.info-panel header button:hover, .contact-drawer header button:hover { background: #E5E7EB; }
.info-section { padding: 16px 0; border-bottom: 1px solid #F0F0F0; }
.info-section h3 { margin: 0 0 12px; color: #94A3B8; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.info-school-row { display: flex; align-items: center; gap: 12px; }
.info-school-row > div { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; overflow: hidden; color: #fff; background: var(--brand); font-weight: 800; }
.info-school-row img { width: 100%; height: 100%; object-fit: cover; }
.info-school-row p { margin: 0; display: grid; gap: 2px; }
.info-school-row small { color: var(--muted); }
.info-materials { margin: 0; padding: 0; list-style: none; color: #444; font-size: 13px; display: grid; gap: 8px; }
.info-materials li { padding: 10px 12px; border-radius: 10px; background: #F7F8FA; }
.info-certificates { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.info-certificate { width: 100%; padding: 10px 8px 8px; display: flex; flex-direction: column; align-items: center; gap: 7px; border: 1px solid #E8E8E8; border-radius: 12px; text-align: center; background: #fff; transition: transform .15s, box-shadow .15s, border-color .15s; }
.info-certificate:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.08); border-color: var(--brand); }
.info-certificate img { width: 100%; height: 68px; object-fit: contain; border-radius: 4px; }
.info-certificate span { width: 100%; font-size: 11px; color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-share-section { text-align: center; }
.page-share-section > img { width: 150px; height: 150px; margin: auto; padding: 8px; border: 1px solid #EEE; border-radius: 12px; background: #fff; }
.page-share-section code { margin: 10px 0; display: block; overflow: hidden; color: #777; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.page-share-section button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; color: #fff; background: var(--brand); font-size: 12px; font-weight: 700; }
.page-share-section p { color: #999; font-size: 11px; }

.drawer-section-label { margin: 18px 0 8px; color: #94A3B8; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.drawer-profile { margin: 16px 0 8px; padding: 14px; display: flex; align-items: center; gap: 12px; border-radius: 14px; background: #F7F8FA; border: 1px solid #EEF1F5; }
.drawer-profile > div { width: 50px; height: 50px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--brand); font-size: 18px; font-weight: 800; overflow: hidden; flex: 0 0 auto; }
.drawer-profile > div img { width: 100%; height: 100%; object-fit: cover; }
.drawer-profile p { margin: 0; display: grid; min-width: 0; }
.drawer-profile small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-qr { padding: 16px 0; border-top: 1px solid #F0F0F0; text-align: center; }
.drawer-qr.group { border-top: 1px solid #F0F0F0; }
.drawer-qr h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; }
.drawer-qr img { width: 100%; max-width: 240px; aspect-ratio: 1 / 1; margin: auto; display: block; object-fit: contain; border-radius: 12px; background: #FAFAFA; padding: 8px; border: 1px solid #F0F0F0; }
.drawer-qr p { color: var(--muted); font-size: 11px; margin: 8px 0 0; }
.drawer-copy {
    width: 100%; min-height: 48px; margin-bottom: 8px; padding: 0 14px;
    display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 8px;
    border: 1px solid #EEF1F5; border-radius: 12px; text-align: left; background: #FAFBFC;
    transition: border-color .15s, background .15s;
}
.drawer-copy:hover { border-color: color-mix(in srgb, var(--brand) 35%, #EEF1F5); background: #fff; }
.drawer-copy:active { background: #F3F4F6; }
.drawer-copy span { color: var(--muted); font-size: 12px; }
.drawer-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.drawer-copy em { color: var(--brand); font-size: 12px; font-style: normal; font-weight: 700; }
.drawer-safe-note { margin-top: 16px; padding: 12px; border-radius: 10px; color: #77520A; background: #FFF8E6; font-size: 11px; line-height: 1.55; }

.image-lightbox { position: fixed; inset: 0; z-index: 130; visibility: hidden; opacity: 0; padding: 55px 18px 25px; display: grid; place-items: center; background: rgba(0,0,0,.9); transition: .18s; }
.image-lightbox.open { visibility: visible; opacity: 1; }
.image-lightbox img { max-width: min(900px, 94vw); max-height: 80vh; border-radius: 8px; object-fit: contain; }
.image-lightbox > button:first-child { position: absolute; top: calc(14px + var(--safe-top)); right: 18px; width: 42px; height: 42px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.15); font-size: 24px; }
.image-lightbox p { position: absolute; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); margin: 0; max-width: 90vw; color: rgba(255,255,255,.9); font-size: 13px; text-align: center; }
.image-lightbox .lb-prev,
.image-lightbox .lb-next { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.15); font-size: 28px; line-height: 1; }
.image-lightbox .lb-prev { left: 12px; }
.image-lightbox .lb-next { right: 12px; }
.toast {
    position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom)); z-index: 150;
    padding: 10px 16px; border-radius: 999px; color: #fff; background: rgba(17,17,17,.88);
    box-shadow: 0 8px 24px rgba(0,0,0,.18); opacity: 0; transform: translate(-50%, 10px);
    transition: .18s; pointer-events: none; font-size: 13px; font-weight: 500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Tablet and phone: full-height familiar messenger */
@media (max-width: 820px) {
    body { background: var(--chat-bg); }
    .messenger-app { width: 100vw; max-width: 100vw; height: 100dvh; height: 100svh; margin: 0; grid-template-columns: minmax(0, 1fr); border: 0; border-radius: 0; box-shadow: none; }
    .desktop-sidebar { display: none; }
    .conversation-header { min-width: 0; overflow: hidden; min-height: calc(56px + var(--safe-top)); padding: calc(8px + var(--safe-top)) 12px 8px; }
    .header-avatar { display: grid; }
    .header-person h1 { max-width: 54vw; font-size: 15px; }
    .conversation-actions button { min-width: 40px; height: 40px; padding: 0 8px; font-size: 16px; }
    .conversation-actions button:first-child { display: none; }
    .conversation-actions button span { display: none; }
    .chat-feed { padding-top: 12px; padding-bottom: 12px; }
    .date-divider, .chat-message, .chat-disclaimer { width: calc(100% - 20px); }
    .message-bubble { max-width: min(78vw, 480px); font-size: 15px; }
    .message-media, .message-media.dual, .message-media.multi { max-width: 100%; }
    .message-media.single .message-media-image { max-height: 220px; }
    .rich-message-wrap { width: min(370px, calc(100% - 46px)); }
    .quick-suggestions { padding-inline: 10px; }
    .quick-list button { min-height: 36px; font-size: 12px; }
    .composer-area { width: 100%; max-width: 100%; min-width: 0; overflow: hidden; padding: 8px 10px calc(8px + var(--safe-bottom)); gap: 8px; }
    .composer-more { width: 40px; height: 40px; flex-basis: 40px; }
    .composer-input { min-height: 40px; padding: 9px 12px; }
    .composer-input textarea { font-size: 16px; }
    .send-button { height: 40px; min-width: 56px; font-size: 14px; }
    .info-panel, .contact-drawer { position: fixed; width: min(100vw, 100%); max-width: 100%; border-left: 0; border-radius: 16px 16px 0 0; top: auto; height: min(88dvh, 720px); padding-top: 16px; }
    .info-panel::before, .contact-drawer::before {
        content: ""; display: block; width: 36px; height: 4px; margin: 0 auto 14px;
        border-radius: 999px; background: #D4D4D4;
    }
    .info-panel > header, .contact-drawer > header { margin-top: -4px; }
}

@media (max-width: 430px) {
    .message-avatar { width: 34px; height: 34px; border-radius: 9px; font-size: 11px; }
    .chat-message { gap: 8px; margin-bottom: 14px; }
    .rich-message-wrap { width: calc(100% - 42px); }
    .contact-message-card, .topic-message-card, .material-message-card { width: 100%; }
    .topic-message-grid { gap: 6px; }
    .topic-message-grid button { min-height: 52px; padding: 7px 6px; }
    .contact-card-bio { font-size: 12px; }
    .conversation-actions button:first-child { padding-inline: 5px; }
}

@media (hover: none) {
    button:hover { transform: none !important; }
    .topic-message-grid button:hover { background: #FAFBFC; border-color: #EEF1F5; }
    .quick-list button:hover { background: #fff; border-color: #E5E5E5; color: #444; }
}

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