:root {
    --bg: #eceef1;
    --surface: #ffffff;
    --surface-2: #f4f5f7;
    --hover: #f0f1f4;
    --selected: #eef0f3;
    --line: #e7e9ed;
    --ink: #1f2023;
    --ink-2: #5d6168;
    --ink-3: #9a9ea6;
    --accent: #ffdb4d;
    --accent-hover: #ffd21f;
    --accent-soft: #fff2bf;
    --link: #1a6dd8;
    --danger: #e5484d;
    --brand: #ff0000;
    --radius: 16px;
    --rail-w: 60px;
    --sidebar-w: 300px;
    --shadow: 0 12px 40px rgba(20, 24, 31, .16);
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; flex: none; }
a { color: var(--link); }
[hidden], .hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }

.spinner {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid rgba(0, 0, 0, .08); border-top-color: var(--ink-2);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot { position: fixed; inset: 0; display: grid; place-items: center; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 16px; border-radius: 10px; border: 0;
    background: var(--surface-2); font-weight: 500; transition: background .15s;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: #1b1b1b; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d63c41; }
.btn-block { width: 100%; }
.btn-link { background: none; color: var(--ink-2); height: auto; padding: 8px; }
.btn-link:hover { background: none; color: var(--ink); text-decoration: underline; }

.icon-btn {
    display: inline-grid; place-items: center; width: 32px; height: 32px;
    border: 0; border-radius: 8px; background: none; color: var(--ink-2);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.input {
    width: 100%; height: 42px; padding: 0 14px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--surface); outline: none;
}
.input:focus { border-color: #c9ccd2; box-shadow: 0 0 0 3px rgba(255, 219, 77, .45); }

/* Login */
.login {
    min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 32px 16px;
    background: radial-gradient(900px 500px at 80% -10%, #fff3c4 0%, transparent 60%), var(--bg);
}
.login-card {
    width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px;
    padding: 32px 28px 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, .06); text-align: center;
}
.login-brand h1 { margin: 12px 0 4px; font-size: 22px; font-weight: 650; }
.login-brand p { margin: 0 0 22px; }
.login-logo { width: 44px; height: 48px; }
.login-checking { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 0; }
.login-profile { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.login-avatar {
    width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-soft); font-size: 22px; font-weight: 600; margin-bottom: 8px;
}
.login-profile-name { font-size: 17px; font-weight: 600; }
.login-profile-phone { margin-bottom: 16px; }
.login-tabs { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.login-tab { flex: 1; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--ink-2); font-weight: 500; }
.login-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.login-panel { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.login-panel p { margin: 0; }
.login-panel[data-panel="phone"] { width: 100%; align-items: stretch; }
.phone-field { position: relative; display: flex; width: 100%; align-items: stretch; text-align: left; }
.phone-dial { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; }
.phone-dial::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: .55; }
.phone-flag { font-size: 18px; line-height: 1; }
.phone-code { font-variant-numeric: tabular-nums; }
.phone-field > .input { border-radius: 0 10px 10px 0; }
.phone-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 280px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 30; overflow: hidden; }
.phone-search { flex: 0 0 auto; width: calc(100% - 16px); margin: 8px; height: 40px; min-height: 40px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 14px; background: var(--surface); color: var(--ink); }
.phone-search::-webkit-search-decoration, .phone-search::-webkit-search-cancel-button { -webkit-appearance: none; }
.phone-menu-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding-bottom: 6px; }
.phone-option { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 8px 12px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; text-align: left; }
.phone-option .name { flex: 1; }
.phone-option .dial { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.phone-option:hover, .phone-option.active { background: var(--hover); }
.phone-wait { padding: 12px 14px; border-radius: 12px; background: #fff4c2; border: 1px solid #f0d56a; color: #1b1b1b; font-size: 14.5px; font-weight: 650; line-height: 1.35; }
.login-as {
    align-self: stretch; width: 100%; height: 36px; margin-top: 0; padding: 0 16px;
    border: 0; border-radius: 10px; background: var(--accent); color: #1b1b1b;
    font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.login-as:hover { background: var(--accent-hover); color: #1b1b1b; }
.qr-box {
    position: relative;
    width: 232px; height: 232px; display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.qr-box > #login-qr img, .qr-box > #login-qr canvas, .qr-box > #login-qr svg { width: 100% !important; height: auto !important; display: block; }
.qr-expired-hint { line-height: 1.45; }
.qr-box.is-expired { background: #f3f4f6; }
.qr-box.is-expired > #login-qr canvas,
.qr-box.is-expired > #login-qr img,
.qr-box.is-expired > #login-qr svg { filter: grayscale(1); opacity: 0.34; }
.qr-expired-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0;
    padding: 18px;
    border: 0;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.92);
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.qr-expired-overlay[hidden] { display: none !important; }
.qr-expired-overlay:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.qr-expired-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.qr-expired-title {
    color: rgba(0, 0, 0, 0.88);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.45;
    text-align: center;
}
.qr-expired-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: auto;
    margin-top: 2px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: #1677ff;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.45;
    box-shadow: none;
}
.qr-expired-icon {
    display: inline-grid;
    place-items: center;
    width: 14px;
    height: 14px;
    background: transparent;
    color: currentColor;
}
.qr-expired-icon svg {
    width: 14px;
    height: 14px;
    display: block;
    transition: transform .3s ease;
}
.qr-expired-overlay:hover .qr-expired-action { background: none; color: #4096ff; }
.qr-expired-overlay:hover .qr-expired-icon svg { transform: rotate(-180deg); }
.login-status { min-height: 0; margin: 14px 0 0; }
.login-status:empty { margin: 0; }
.login-error { margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.login-foot { --ink-faint: var(--ink-3); margin-top: 22px; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.login-back { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 14px 0 8px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; box-shadow: 0 1px 2px rgba(20, 24, 31, .04); }
.login-back svg { width: 16px; height: 16px; color: var(--ink-2); }
.login-back:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.login-foot .lang-picker-trigger { height: 36px; padding: 0 12px; background: #fff; color: var(--ink); border-color: var(--line); font-size: 14px; font-weight: 600; max-width: 168px; }

/* App shell */
.app { display: flex; height: 100vh; height: 100dvh; padding: 8px 8px 8px 0; }
.rail {
    width: var(--rail-w); flex: none; display: flex; flex-direction: column; align-items: center;
    padding: 6px 0 4px;
}
.rail-logo { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px; }
.rail-logo img { width: 26px; height: 28px; }
.rail-services { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.rail-item {
    position: relative; display: grid; place-items: center; width: 40px; height: 40px;
    border-radius: 12px; color: #4a4e55; text-decoration: none; transition: background .15s, color .15s;
}
.rail-item svg { width: 28px; height: 28px; }
.rail-item:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
.rail-item.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 4px rgba(0, 0, 0, .06); }
.rail-item .tip {
    position: absolute; left: 48px; top: 50%; transform: translateY(-50%); white-space: nowrap;
    background: #2a2c31; color: #fff; font-size: 12px; padding: 4px 9px; border-radius: 6px;
    opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 30;
}
.rail-item:hover .tip { opacity: 1; }
.rail-bottom { margin-top: auto; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rail-avatar, .user-avatar {
    width: 34px; height: 34px; flex: none; border-radius: 50%; border: 0; padding: 0; overflow: hidden;
    display: grid; place-items: center; background: var(--accent-soft);
    font-size: 13px; font-weight: 600; color: #5a4700;
}
.rail-avatar img, .user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar { width: 44px; height: 44px; font-size: 16px; }
.user-menu-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.user-menu-who { min-width: 0; }
.user-menu {
    position: absolute; left: 46px; bottom: 0; width: 230px; background: var(--surface);
    border-radius: 14px; box-shadow: var(--shadow); padding: 12px; z-index: 40;
}
.user-menu-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-sub { margin: 0; }
.user-menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0;
    border-radius: 8px; background: none; text-align: left;
}
.user-menu-item:hover { background: var(--hover); }
.user-menu-item svg { width: 18px; height: 18px; color: var(--ink-2); }

.workspace {
    flex: 1; min-width: 0; display: flex; background: var(--surface); border-radius: var(--radius);
    overflow: hidden; box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); flex: none; display: flex; flex-direction: column;
    border-right: 1px solid var(--line); padding: 16px 12px 8px; min-height: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 12px; }
.sidebar-head h2 { margin: 0; font-size: 20px; font-weight: 650; }
.sidebar-head-actions { display: flex; align-items: center; gap: 2px; }
.search {
    display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin-bottom: 10px;
    background: var(--surface-2); border-radius: 10px; color: var(--ink-3);
}
.search svg { width: 16px; height: 16px; }
.search-input { flex: 1; min-width: 0; border: 0; outline: none; background: none; }
.btn-new { width: 100%; height: 38px; margin-bottom: 12px; }
.note-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.note-item {
    display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px;
    cursor: pointer; margin-bottom: 2px; user-select: none;
}
.note-item:hover { background: var(--hover); }
.note-item.active { background: var(--selected); }
.note-item-main { flex: 1; min-width: 0; }
.note-item-title {
    display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13.5px;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.note-item-title span { overflow: hidden; text-overflow: ellipsis; }
.note-item-title svg { width: 13px; height: 13px; color: #e0a800; }
.note-item-meta { display: flex; gap: 6px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.note-item-date { color: var(--ink-3); flex: none; }
.note-item-snippet { overflow: hidden; text-overflow: ellipsis; }
.note-item-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-2); }
.list-empty { padding: 16px 8px; text-align: center; }

.footer {
    display: flex; justify-content: space-between; align-items: center; padding: 10px 20px 10px 36px;
    font-size: 12px; color: var(--ink-3);
}
.footer a { color: var(--ink-3); text-decoration: none; }
.footer a:hover { color: var(--ink); }
.footer-right { display: flex; align-items: center; gap: 12px; }
.lang-btn { border: 0; background: none; color: var(--ink-3); font-size: 12px; padding: 2px 4px; border-radius: 4px; text-transform: none; }
.lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--ink); background: var(--hover); }
.lang-btn-mobile { display: none; }
.lang-menu {
    position: fixed; z-index: 90; width: 210px; max-height: min(360px, calc(100vh - 24px));
    overflow: auto; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.lang-option {
    display: flex; align-items: center; width: 100%; text-align: left; border: 0; background: none;
    padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--ink);
}
.lang-option:hover { background: var(--hover); }
.lang-option.active { background: var(--accent-soft); font-weight: 600; }

/* Link popover */
.link-pop {
    position: fixed; z-index: 50; display: flex; align-items: center; gap: 6px; max-width: 360px;
    background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); padding: 6px 6px 6px 12px;
}
.link-pop a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.link-pop-open { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; flex: none; color: var(--ink-2) !important; }
.link-pop-open:hover { background: var(--hover); }
.link-pop-open svg { width: 16px; height: 16px; }

/* Lightbox */
.lightbox {
    position: fixed; inset: 0; z-index: 60; background: rgba(12, 13, 15, .92);
    display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: calc(100vw - 140px); max-height: calc(100vh - 110px); object-fit: contain; border-radius: 4px; }
.lightbox-top {
    position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; color: #d6d8dc;
}
.lightbox-actions { display: flex; gap: 4px; }
.lb-btn, .lb-nav {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0;
    background: rgba(255, 255, 255, .08); color: #fff;
}
.lb-btn:hover, .lb-nav:hover { background: rgba(255, 255, 255, .18); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; }
.lb-prev { left: 20px; }
.lb-next { right: 20px; }

/* Dialog + toast */
.dialog-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(15, 17, 20, .35); display: grid; place-items: center; padding: 16px; }
.dialog { width: 100%; max-width: 360px; background: var(--surface); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.dialog p { margin: 0 0 20px; font-size: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
    background: #25272c; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
    box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

.mobile-only { display: none; }

@media (max-width: 1100px) {
    :root { --sidebar-w: 260px; }
    .thumb { width: 110px; height: 110px; }
}

@media (max-width: 760px) {
    .app { padding: 0; }
    .rail { display: none; }
    .workspace { border-radius: 0; }
    .sidebar { width: 100%; border-right: 0; }
    .editor { display: none; }
    .app.show-editor .sidebar { display: none; }
    .app.show-editor .editor { display: flex; }
    .mobile-only { display: inline-grid; }
    .toolbar { padding: 8px 8px 6px; gap: 2px; overflow-x: auto; }
    .save-state { display: none; }
    .editor-inner { padding: 6px 16px 32px; }
    .footer { display: none; }
    .lang-btn-mobile { display: inline-flex; align-items: center; height: 32px; padding: 0 8px; }
    .thumb { width: calc((100vw - 48px) / 3); height: calc((100vw - 48px) / 3); }
    .thumb-del { opacity: 1; }
    .lightbox img { max-width: 100vw; max-height: calc(100vh - 140px); }
    .lb-nav { top: auto; bottom: 20px; transform: none; }
}

#login .login-error, .login .login-error { margin: 10px 0 0; color: #c62828; background: #fde5e5; border-radius: 10px; padding: 10px; font-size: 13px; line-height: 1.45; }
#login .login-error:empty, .login .login-error:empty { display: none; padding: 0; margin: 0; background: transparent; }
#login .phone-wait, .login .phone-wait { padding: 12px 14px; border-radius: 12px; background: #fff4c2; border: 1px solid #f0d56a; color: #1b1b1b; font-size: 14.5px; font-weight: 650; line-height: 1.35; }
#login .phone-wait[hidden], .login .phone-wait[hidden] { display: none !important; }

/* ---------- Atlayo Chat ---------- */
:root {
    --sidebar-w: 360px;
    --chat-bg: #eef0f3;
    --bubble-in: #ffffff;
    --bubble-out: #dcf7d2;
    --bubble-out-meta: #4f8a4a;
    --tick-seen: #2f9be8;
    --green: #2fbf71;
}

.app { padding: 8px 8px 8px 0; }

.sidebar { padding: 14px 10px 0; }
.sidebar-head { padding: 0 6px 10px; }
.sidebar-head-actions { gap: 8px; }
.conn-dot {
    width: 9px; height: 9px; border-radius: 50%; background: #f5a524;
    box-shadow: 0 0 0 3px rgba(245, 165, 36, .2); animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
.sidebar .search { margin: 0 4px 8px; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.e2ee-banner {
    display: flex; align-items: center; gap: 10px; margin: 0 4px 8px; padding: 10px 12px;
    border: 0; border-radius: 12px; background: #e9f8ef; color: #1d5b3a; text-align: left; font-size: 13px; line-height: 1.35;
}
.e2ee-banner svg { width: 18px; height: 18px; flex: none; color: var(--green); }
.e2ee-banner-text { flex: 1; min-width: 0; }
.e2ee-banner-action { font-weight: 650; white-space: nowrap; }
.e2ee-banner-action:empty { display: none; }
.e2ee-banner:hover { background: #dff4e7; }
.e2ee-banner.is-warning { background: #fff4d6; color: #6b4e00; cursor: default; }
.e2ee-banner.is-warning svg { color: #c08a00; }

.chat-list { list-style: none; margin: 0; padding: 0 2px; overflow-y: auto; flex: 1; min-height: 0; }
.chat-list:empty { flex: none; }
.list-loading { display: grid; place-items: center; padding: 32px 0; }
.chat-item {
    display: flex; gap: 12px; align-items: center; padding: 9px 10px; border-radius: 12px;
    cursor: pointer; user-select: none; outline: none;
}
.chat-item:hover, .chat-item:focus-visible { background: var(--hover); }
.chat-item.active { background: #e3f6ea; }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-top, .chat-item-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-item-name {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px;
    font-weight: 600; font-size: 14.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.chat-kind { width: 15px; height: 15px; color: var(--ink-2); }
.chat-item-time { flex: none; font-size: 12px; color: var(--ink-3); }
.chat-item-preview {
    flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink-2);
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.chat-item-preview.locked { color: var(--ink-3); font-style: italic; }
.lock-ico { width: 12px; height: 12px; margin-right: 4px; vertical-align: -1px; color: var(--ink-3); }
.typing-text { color: var(--green); font-weight: 500; }
.badge {
    flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: var(--green); color: #fff; font-size: 12px; font-weight: 650; display: grid; place-items: center;
}
.pin-ico { width: 14px; height: 14px; color: var(--ink-3); flex: none; }
.sidebar-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 8px 10px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); margin-top: auto;
}

.avatar {
    position: relative; width: 48px; height: 48px; flex: none; border-radius: 50%; overflow: hidden;
    display: grid; place-items: center; font-weight: 650; font-size: 16px; letter-spacing: .02em;
}
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: inherit; }
.avatar svg { width: 24px; height: 24px; }

img.emoji { width: 1.25em; height: 1.25em; vertical-align: -.25em; margin: 0 .03em; display: inline-block; }
img.emoji-jumbo { width: 48px; height: 48px; vertical-align: middle; margin: 0 2px; }
.chat-item img.emoji { width: 17px; height: 17px; vertical-align: -3px; }

/* Conversation */
.conversation { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.conv-head {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 64px;
    background: var(--surface); border-bottom: 1px solid var(--line); z-index: 2;
}
.conv-avatar { width: 42px; height: 42px; font-size: 15px; }
.conv-who { flex: 1; min-width: 0; }
.conv-name { font-weight: 650; font-size: 15.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-status { font-size: 12.5px; color: var(--ink-3); min-height: 18px; }
.conv-status.is-online, .conv-status.is-typing { color: var(--green); }
.conv-e2ee { color: var(--green); display: inline-grid; place-items: center; width: 32px; height: 32px; }
.conv-e2ee svg { width: 20px; height: 20px; }

.messages-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.messages {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 6% 10px; overscroll-behavior: contain;
    background: transparent;
}
.messages-top { display: flex; justify-content: center; min-height: 4px; }
.small-spin { width: 22px; height: 22px; margin: 8px 0; }
.messages-list { display: flex; flex-direction: column; max-width: 920px; margin: 0 auto; }
.conv-loading { display: grid; place-items: center; padding: 60px 0; }
.conv-start { display: flex; justify-content: center; padding: 40px 0; }
.conv-start span { background: rgba(255, 255, 255, .85); padding: 8px 14px; border-radius: 12px; color: var(--ink-2); font-size: 13px; text-align: center; max-width: 340px; }

.day-sep { position: sticky; top: 0; z-index: 1; display: flex; justify-content: center; margin: 10px 0 6px; pointer-events: none; }
.day-sep span {
    background: rgba(255, 255, 255, .92); color: var(--ink-2); font-size: 12.5px; font-weight: 600;
    padding: 4px 12px; border-radius: 999px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.service-msg { display: flex; justify-content: center; margin: 6px 0; }
.service-msg span { background: rgba(0, 0, 0, .06); color: var(--ink-2); font-size: 12.5px; padding: 4px 12px; border-radius: 999px; text-align: center; }

.msg { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; max-width: 100%; }
.msg.first { margin-top: 8px; }
.msg.out { justify-content: flex-end; }
.msg-avatar { width: 32px; height: 32px; font-size: 12px; }
.msg-avatar-gap { width: 32px; flex: none; }
.bubble {
    position: relative; max-width: min(560px, 76%); padding: 6px 9px 6px 11px; border-radius: 14px;
    background: var(--bubble-in); box-shadow: 0 1px 1px rgba(0, 0, 0, .06); min-width: 72px;
    word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--bubble-out); }
.msg.in.last .bubble { border-bottom-left-radius: 4px; }
.msg.out.last .bubble { border-bottom-right-radius: 4px; }
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px rgba(47, 191, 113, .55); } }
.msg-sender { font-size: 13px; font-weight: 650; margin-bottom: 1px; }
.msg-body { font-size: 14.5px; line-height: 1.42; white-space: normal; }
.msg-body a { color: var(--link); text-decoration: none; }
.msg-body a:hover { text-decoration: underline; }
.msg-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: rgba(0, 0, 0, .06); padding: 1px 4px; border-radius: 4px; }
.spoiler { background: #8e9196; color: transparent; border-radius: 4px; cursor: pointer; transition: all .2s; }
.spoiler.revealed { background: rgba(0, 0, 0, .06); color: inherit; }
.msg-meta {
    float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -4px 10px;
    font-size: 11.5px; color: var(--ink-3); line-height: 1; white-space: nowrap; user-select: none;
}
.msg.out .msg-meta { color: var(--bubble-out-meta); }
.edited { font-style: italic; margin-right: 2px; }
.ticks { display: inline-flex; align-items: center; color: inherit; }
.ticks svg { height: 11px; }
.ticks .tick-1 { width: 14px; }
.ticks .tick-2 { width: 18px; }
.ticks .tick-clock { width: 12px; height: 12px; }
.ticks.seen { color: var(--tick-seen); }
.ticks.failed { width: 15px; height: 15px; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 700; justify-content: center; font-size: 11px; }
.msg.pending .bubble { opacity: .92; }

.msg-locked { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-style: italic; }
.msg-locked svg { width: 14px; height: 14px; }
.msg-note { color: var(--ink-2); }

.quote {
    display: block; width: 100%; text-align: left; margin: 2px 0 4px; padding: 4px 8px; border: 0;
    border-left: 3px solid var(--green); border-radius: 6px; background: rgba(47, 191, 113, .1); cursor: pointer;
    font-size: 13px; line-height: 1.3; max-height: 52px; overflow: hidden;
}
.msg.out .quote { background: rgba(0, 0, 0, .05); }
.quote-name { display: block; font-weight: 650; color: #1f8a52; }
.quote-text { display: block; color: var(--ink-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Bare bubbles: stickers, emoji-only */
.msg.bare .bubble { background: none; box-shadow: none; padding: 0; min-width: 0; }
.msg.bare .msg-meta { float: none; display: flex; justify-content: flex-end; margin: 2px 4px 0; padding: 3px 7px; border-radius: 10px; background: rgba(255, 255, 255, .85); width: max-content; margin-left: auto; }
.msg.bare .quote { background: rgba(255, 255, 255, .9); }
dotlottie-wc.sticker { display: block; width: 168px; height: 168px; }

/* Media */
.media { position: relative; display: block; border-radius: 10px; overflow: hidden; background: rgba(0, 0, 0, .06); margin: 2px 0 4px; max-width: 100%; }
.media-img { width: 320px; max-height: 420px; cursor: zoom-in; }
.media-img:not([style]) { min-height: 120px; }
.media img, .media video { display: block; width: 100%; height: 100%; object-fit: cover; max-height: 420px; }
.media-video { width: 340px; }
.media-video video { object-fit: contain; background: #000; height: auto; }
.media img:not([src]) { visibility: hidden; }
.is-loading::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px;
    border-radius: 50%; border: 3px solid rgba(255, 255, 255, .6); border-top-color: var(--ink-2); animation: spin .8s linear infinite;
}
.media.is-broken::before { content: "🔒"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; opacity: .6; }
.msg.media-only .bubble { padding: 3px; }
.msg.media-only .media { margin: 0; border-radius: 11px; }
.msg.media-only .msg-meta {
    position: absolute; right: 9px; bottom: 9px; margin: 0; float: none; padding: 3px 6px; border-radius: 8px;
    background: rgba(0, 0, 0, .45); color: #fff;
}
.voice { display: block; width: 280px; max-width: 100%; height: 40px; margin: 2px 0; }
.file-card {
    position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 4px; margin: 2px 0;
    color: inherit !important; text-decoration: none !important; cursor: pointer; min-width: 200px;
}
.file-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; flex: none; }
.file-icon svg { width: 20px; height: 20px; }
.file-meta { min-width: 0; display: flex; flex-direction: column; }
.file-name { font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 260px; }
.file-size { font-size: 12px; color: var(--ink-3); }
.card-link { display: flex; gap: 10px; align-items: center; padding: 4px 2px; color: inherit !important; text-decoration: none !important; }
.card-ico { font-size: 22px; }
.checklist ul { list-style: none; margin: 6px 0 0; padding: 0; }
.checklist li { display: flex; gap: 8px; align-items: center; padding: 2px 0; }
.checklist .tick { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--ink-3); display: grid; place-items: center; font-size: 11px; color: #fff; flex: none; }
.checklist li.done .tick { background: var(--green); border-color: var(--green); }
.checklist li.done { color: var(--ink-3); text-decoration: line-through; }

.to-bottom {
    position: absolute; right: 22px; bottom: 16px; width: 44px; height: 44px; border-radius: 50%; border: 0;
    background: var(--surface); color: var(--ink-2); box-shadow: 0 2px 10px rgba(0, 0, 0, .15); display: grid; place-items: center; z-index: 3;
}
.to-bottom-count { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; }

.conv-empty { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2); text-align: center; padding: 24px; }
.conv-empty > svg { width: 72px; height: 72px; margin-bottom: 6px; }
.conv-empty p { margin: 0; font-size: 15px; }
.conv-empty-e2ee { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px !important; }
.conv-empty-e2ee svg { width: 13px; height: 13px; }
.conversation.no-chat .conv-empty { display: flex; }
.conversation.no-chat .conv-head, .conversation.no-chat .composer, .conversation.no-chat .messages { visibility: hidden; }

/* Composer */
.composer { position: relative; padding: 8px 6% 12px; background: transparent; }
.composer > * { max-width: 920px; margin-left: auto; margin-right: auto; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-input-wrap {
    flex: 1; min-width: 0; display: flex; align-items: flex-end; background: var(--surface);
    border-radius: 22px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); padding: 0 6px 0 14px;
}
.composer-input {
    flex: 1; min-width: 0; border: 0; outline: none; resize: none; background: none; padding: 11px 0;
    line-height: 1.4; font-size: 15px; max-height: 180px;
}
.composer-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); flex: none; }
.composer-btn svg { width: 22px; height: 22px; }
.composer-btn.active, .composer-btn:hover { color: var(--green); background: var(--surface); }
.send-btn {
    width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center;
    background: var(--green); color: #fff; box-shadow: 0 1px 3px rgba(47, 191, 113, .4); transition: transform .12s, opacity .12s;
}
.send-btn svg { width: 20px; height: 20px; margin-left: 2px; }
.send-btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.send-btn:not(:disabled):active { transform: scale(.94); }
.composer-note { text-align: center; padding: 12px; color: var(--ink-2); background: var(--surface); border-radius: 14px; font-size: 13.5px; }
.reply-bar {
    display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 8px 8px 8px 12px; margin-bottom: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.reply-bar > svg { width: 20px; height: 20px; color: var(--green); }
.reply-bar-body { flex: 1; min-width: 0; border-left: 3px solid var(--green); padding-left: 8px; }
.reply-bar-name { font-size: 13px; font-weight: 650; color: #1f8a52; }
.reply-bar-text { font-size: 13px; color: var(--ink-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Emoji & sticker picker */
.picker {
    position: absolute; left: max(6%, 8px); bottom: calc(100% - 4px); width: 360px; height: 420px; max-height: calc(100vh - 180px);
    display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); z-index: 20; overflow: hidden;
    margin: 0;
}
.picker-tabs { display: flex; gap: 4px; padding: 8px 8px 0; }
.picker-tab { flex: 1; height: 32px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-weight: 600; }
.picker-tab.active { background: var(--surface-2); color: var(--ink); }
.picker-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.picker-search { margin: 8px 8px 4px; }
.emoji-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 6px 6px; position: relative; }
.emoji-section h4 { margin: 8px 4px 4px; font-size: 12px; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-btn { aspect-ratio: 1; border: 0; background: none; border-radius: 8px; display: grid; place-items: center; padding: 4px; }
.emoji-btn:hover { background: var(--hover); }
.emoji-btn img { width: 28px; height: 28px; }
.emoji-cats { display: flex; justify-content: space-around; border-top: 1px solid var(--line); padding: 4px; }
.emoji-cat { width: 34px; height: 30px; border: 0; background: none; border-radius: 8px; display: grid; place-items: center; color: var(--ink-3); }
.emoji-cat:hover { background: var(--hover); }
.emoji-cat img, .emoji-cat svg { width: 20px; height: 20px; }
.picker-loading { display: grid; place-items: center; padding: 40px 0; grid-column: 1 / -1; }
.picker-empty { padding: 24px; text-align: center; }
.sticker-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px; align-content: start; }
.sticker-btn { aspect-ratio: 1; border: 0; background: none; border-radius: 12px; padding: 4px; display: grid; place-items: center; }
.sticker-btn:hover { background: var(--hover); }
.sticker-btn dotlottie-wc { width: 100%; height: 100%; display: block; pointer-events: none; }

/* Message menu */
.msg-menu {
    position: fixed; z-index: 85; min-width: 180px; background: var(--surface); border-radius: 12px;
    box-shadow: var(--shadow); padding: 6px;
}
.msg-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 14px; }
.msg-menu-item:hover { background: var(--hover); }
.msg-menu-item svg { width: 18px; height: 18px; color: var(--ink-2); }
.msg-menu-item.danger { color: var(--danger); }
.msg-menu-item.danger svg { color: var(--danger); }

.user-menu { position: fixed; left: 0; top: 0; bottom: auto; z-index: 86; }

/* PIN modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 75; background: rgba(15, 17, 20, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 26px 24px 20px; box-shadow: var(--shadow); text-align: center; }
.pin-icon { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; background: #e9f8ef; color: var(--green); display: grid; place-items: center; }
.pin-icon svg { width: 26px; height: 26px; }
.modal h3 { margin: 0 0 6px; font-size: 18px; font-weight: 650; }
.modal p { margin: 0 0 16px; font-size: 13.5px; line-height: 1.45; }
.pin-fields { display: flex; flex-direction: column; gap: 8px; }
.pin-input { text-align: center; font-size: 22px; letter-spacing: .35em; height: 50px; font-variant-numeric: tabular-nums; }
.pin-input::placeholder { letter-spacing: normal; font-size: 15px; }
.pin-input:focus { box-shadow: 0 0 0 3px rgba(47, 191, 113, .3); border-color: #9fdcb9; }
.pin-remember { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 12px 0 0; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.pin-remember input { width: 16px; height: 16px; accent-color: var(--green); }
.pin-error { margin: 10px 0 0 !important; color: #c62828; background: #fde5e5; border-radius: 10px; padding: 8px 10px; font-size: 13px !important; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; height: 42px; }
.modal .btn-primary { background: var(--green); color: #fff; }
.modal .btn-primary:hover { background: #29a965; }
.modal .btn-primary:disabled { opacity: .6; cursor: default; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.lightbox-close { position: absolute; top: 14px; right: 16px; }
.lightbox img { max-width: calc(100vw - 80px); max-height: calc(100vh - 80px); }


/* Chat backgrounds, same set as the Android app. Patterns: Hero Patterns by Steve Schoger (CC BY 4.0); cat and dog doodles: Maria Letta, Mega Doodles Pack (CC BY-SA 4.0). */
.conversation:not(.no-chat), .bg-swatch[data-bg="food"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.22'%3E%3Cpath d='M24.37 16c.2.65.39 1.32.54 2H21.17l1.17 2.34.45.9-.24.11V28a5 5 0 0 1-2.23 8.94l-.02.06a8 8 0 0 1-7.75 6h-20a8 8 0 0 1-7.74-6l-.02-.06A5 5 0 0 1-17.45 28v-6.76l-.79-1.58-.44-.9.9-.44.63-.32H-20a23.01 23.01 0 0 1 44.37-2zm-36.82 2a1 1 0 0 0-.44.1l-3.1 1.56.89 1.79 1.31-.66a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .86.02l2.88-1.27a3 3 0 0 1 2.43 0l2.88 1.27a1 1 0 0 0 .85-.02l3.1-1.55-.89-1.79-1.42.71a3 3 0 0 1-2.56.06l-2.77-1.23a1 1 0 0 0-.4-.09h-.01a1 1 0 0 0-.4.09l-2.78 1.23a3 3 0 0 1-2.56-.06l-2.3-1.15a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1L.9 19.22a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1l-2.21 1.11a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01zm0-2h-4.9a21.01 21.01 0 0 1 39.61 0h-2.09l-.06-.13-.26.13h-32.31zm30.35 7.68l1.36-.68h1.3v2h-36v-1.15l.34-.17 1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0l1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0L2.26 23h2.59l1.36.68a3 3 0 0 0 2.56.06l1.67-.74h3.23l1.67.74a3 3 0 0 0 2.56-.06zM-13.82 27l16.37 4.91L18.93 27h-32.75zm-.63 2h.34l16.66 5 16.67-5h.33a3 3 0 1 1 0 6h-34a3 3 0 1 1 0-6zm1.35 8a6 6 0 0 0 5.65 4h20a6 6 0 0 0 5.66-4H-13.1z'/%3E%3Cpath id='path6_fill-copy' d='M284.37 16c.2.65.39 1.32.54 2H281.17l1.17 2.34.45.9-.24.11V28a5 5 0 0 1-2.23 8.94l-.02.06a8 8 0 0 1-7.75 6h-20a8 8 0 0 1-7.74-6l-.02-.06a5 5 0 0 1-2.24-8.94v-6.76l-.79-1.58-.44-.9.9-.44.63-.32H240a23.01 23.01 0 0 1 44.37-2zm-36.82 2a1 1 0 0 0-.44.1l-3.1 1.56.89 1.79 1.31-.66a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .9 0l2.21-1.1a3 3 0 0 1 2.69 0l2.2 1.1a1 1 0 0 0 .86.02l2.88-1.27a3 3 0 0 1 2.43 0l2.88 1.27a1 1 0 0 0 .85-.02l3.1-1.55-.89-1.79-1.42.71a3 3 0 0 1-2.56.06l-2.77-1.23a1 1 0 0 0-.4-.09h-.01a1 1 0 0 0-.4.09l-2.78 1.23a3 3 0 0 1-2.56-.06l-2.3-1.15a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1l-2.21 1.11a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01a1 1 0 0 0-.44.1l-2.21 1.11a3 3 0 0 1-2.69 0l-2.2-1.1a1 1 0 0 0-.45-.11h-.01zm0-2h-4.9a21.01 21.01 0 0 1 39.61 0h-2.09l-.06-.13-.26.13h-32.31zm30.35 7.68l1.36-.68h1.3v2h-36v-1.15l.34-.17 1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0l1.36-.68h2.59l1.36.68a3 3 0 0 0 2.69 0l1.36-.68h2.59l1.36.68a3 3 0 0 0 2.56.06l1.67-.74h3.23l1.67.74a3 3 0 0 0 2.56-.06zM246.18 27l16.37 4.91L278.93 27h-32.75zm-.63 2h.34l16.66 5 16.67-5h.33a3 3 0 1 1 0 6h-34a3 3 0 1 1 0-6zm1.35 8a6 6 0 0 0 5.65 4h20a6 6 0 0 0 5.66-4H246.9z'/%3E%3Cpath d='M159.5 21.02A9 9 0 0 0 151 15h-42a9 9 0 0 0-8.5 6.02 6 6 0 0 0 .02 11.96A8.99 8.99 0 0 0 109 45h42a9 9 0 0 0 8.48-12.02 6 6 0 0 0 .02-11.96zM151 17h-42a7 7 0 0 0-6.33 4h54.66a7 7 0 0 0-6.33-4zm-9.34 26a8.98 8.98 0 0 0 3.34-7h-2a7 7 0 0 1-7 7h-4.34a8.98 8.98 0 0 0 3.34-7h-2a7 7 0 0 1-7 7h-4.34a8.98 8.98 0 0 0 3.34-7h-2a7 7 0 0 1-7 7h-7a7 7 0 1 1 0-14h42a7 7 0 1 1 0 14h-9.34zM109 27a9 9 0 0 0-7.48 4H101a4 4 0 1 1 0-8h58a4 4 0 0 1 0 8h-.52a9 9 0 0 0-7.48-4h-42z'/%3E%3Cpath d='M39 115a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm6-8a6 6 0 1 1-12 0 6 6 0 0 1 12 0zm-3-29v-2h8v-6H40a4 4 0 0 0-4 4v10H22l-1.33 4-.67 2h2.19L26 130h26l3.81-40H58l-.67-2L56 84H42v-6zm-4-4v10h2V74h8v-2h-8a2 2 0 0 0-2 2zm2 12h14.56l.67 2H22.77l.67-2H40zm13.8 4H24.2l3.62 38h22.36l3.62-38z'/%3E%3Cpath d='M129 92h-6v4h-6v4h-6v14h-3l.24 2 3.76 32h36l3.76-32 .24-2h-3v-14h-6v-4h-6v-4h-8zm18 22v-12h-4v4h3v8h1zm-3 0v-6h-4v6h4zm-6 6v-16h-4v19.17c1.6-.7 2.97-1.8 4-3.17zm-6 3.8V100h-4v23.8a10.04 10.04 0 0 0 4 0zm-6-.63V104h-4v16a10.04 10.04 0 0 0 4 3.17zm-6-9.17v-6h-4v6h4zm-6 0v-8h3v-4h-4v12h1zm27-12v-4h-4v4h3v4h1v-4zm-6 0v-8h-4v4h3v4h1zm-6-4v-4h-4v8h1v-4h3zm-6 4v-4h-4v8h1v-4h3zm7 24a12 12 0 0 0 11.83-10h7.92l-3.53 30h-32.44l-3.53-30h7.92A12 12 0 0 0 130 126z'/%3E%3Cpath d='M212 86v2h-4v-2h4zm4 0h-2v2h2v-2zm-20 0v.1a5 5 0 0 0-.56 9.65l.06.25 1.12 4.48a2 2 0 0 0 1.94 1.52h.01l7.02 24.55a2 2 0 0 0 1.92 1.45h4.98a2 2 0 0 0 1.92-1.45l7.02-24.55a2 2 0 0 0 1.95-1.52L224.5 96l.06-.25a5 5 0 0 0-.56-9.65V86a14 14 0 0 0-28 0zm4 0h6v2h-9a3 3 0 1 0 0 6H223a3 3 0 1 0 0-6H220v-2h2a12 12 0 1 0-24 0h2zm-1.44 14l-1-4h24.88l-1 4h-22.88zm8.95 26l-6.86-24h18.7l-6.86 24h-4.98zM150 242a22 22 0 1 0 0-44 22 22 0 0 0 0 44zm24-22a24 24 0 1 1-48 0 24 24 0 0 1 48 0zm-28.38 17.73l2.04-.87a6 6 0 0 1 4.68 0l2.04.87a2 2 0 0 0 2.5-.82l1.14-1.9a6 6 0 0 1 3.79-2.75l2.15-.5a2 2 0 0 0 1.54-2.12l-.19-2.2a6 6 0 0 1 1.45-4.46l1.45-1.67a2 2 0 0 0 0-2.62l-1.45-1.67a6 6 0 0 1-1.45-4.46l.2-2.2a2 2 0 0 0-1.55-2.13l-2.15-.5a6 6 0 0 1-3.8-2.75l-1.13-1.9a2 2 0 0 0-2.5-.8l-2.04.86a6 6 0 0 1-4.68 0l-2.04-.87a2 2 0 0 0-2.5.82l-1.14 1.9a6 6 0 0 1-3.79 2.75l-2.15.5a2 2 0 0 0-1.54 2.12l.19 2.2a6 6 0 0 1-1.45 4.46l-1.45 1.67a2 2 0 0 0 0 2.62l1.45 1.67a6 6 0 0 1 1.45 4.46l-.2 2.2a2 2 0 0 0 1.55 2.13l2.15.5a6 6 0 0 1 3.8 2.75l1.13 1.9a2 2 0 0 0 2.5.8zm2.82.97a4 4 0 0 1 3.12 0l2.04.87a4 4 0 0 0 4.99-1.62l1.14-1.9a4 4 0 0 1 2.53-1.84l2.15-.5a4 4 0 0 0 3.09-4.24l-.2-2.2a4 4 0 0 1 .97-2.98l1.45-1.67a4 4 0 0 0 0-5.24l-1.45-1.67a4 4 0 0 1-.97-2.97l.2-2.2a4 4 0 0 0-3.09-4.25l-2.15-.5a4 4 0 0 1-2.53-1.84l-1.14-1.9a4 4 0 0 0-5-1.62l-2.03.87a4 4 0 0 1-3.12 0l-2.04-.87a4 4 0 0 0-4.99 1.62l-1.14 1.9a4 4 0 0 1-2.53 1.84l-2.15.5a4 4 0 0 0-3.09 4.24l.2 2.2a4 4 0 0 1-.97 2.98l-1.45 1.67a4 4 0 0 0 0 5.24l1.45 1.67a4 4 0 0 1 .97 2.97l-.2 2.2a4 4 0 0 0 3.09 4.25l2.15.5a4 4 0 0 1 2.53 1.84l1.14 1.9a4 4 0 0 0 5 1.62l2.03-.87zM152 207a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm6 2a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm-11 1a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm-6 0a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm3-5a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm-8 8a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm3 6a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm0 6a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm4 7a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm5-2a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm5 4a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm4-6a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm6-4a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm-4-3a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm4-3a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm-5-4a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm-24 6a1 1 0 1 1 2 0 1 1 0 0 1-2 0zm16 5a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm7-5a7 7 0 1 1-14 0 7 7 0 0 1 14 0zm86-29a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm19 9a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm-14 5a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm-25 1a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm5 4a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm9 0a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm15 1a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm12-2a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm-11-14a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm-19 0a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm6 5a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm-25 15c0-.47.01-.94.03-1.4a5 5 0 0 1-1.7-8 3.99 3.99 0 0 1 1.88-5.18 5 5 0 0 1 3.4-6.22 3 3 0 0 1 1.46-1.05 5 5 0 0 1 7.76-3.27A30.86 30.86 0 0 1 246 184c6.79 0 13.06 2.18 18.17 5.88a5 5 0 0 1 7.76 3.27 3 3 0 0 1 1.47 1.05 5 5 0 0 1 3.4 6.22 4 4 0 0 1 1.87 5.18 4.98 4.98 0 0 1-1.7 8c.02.46.03.93.03 1.4v1h-62v-1zm.83-7.17a30.9 30.9 0 0 0-.62 3.57 3 3 0 0 1-.61-4.2c.37.28.78.49 1.23.63zm1.49-4.61c-.36.87-.68 1.76-.96 2.68a2 2 0 0 1-.21-3.71c.33.4.73.75 1.17 1.03zm2.32-4.54c-.54.86-1.03 1.76-1.49 2.68a3 3 0 0 1-.07-4.67 3 3 0 0 0 1.56 1.99zm1.14-1.7c.35-.5.72-.98 1.1-1.46a1 1 0 1 0-1.1 1.45zm5.34-5.77c-1.03.86-2 1.79-2.9 2.77a3 3 0 0 0-1.11-.77 3 3 0 0 1 4-2zm42.66 2.77c-.9-.98-1.87-1.9-2.9-2.77a3 3 0 0 1 4.01 2 3 3 0 0 0-1.1.77zm1.34 1.54c.38.48.75.96 1.1 1.45a1 1 0 1 0-1.1-1.45zm3.73 5.84c-.46-.92-.95-1.82-1.5-2.68a3 3 0 0 0 1.57-1.99 3 3 0 0 1-.07 4.67zm1.8 4.53c-.29-.9-.6-1.8-.97-2.67.44-.28.84-.63 1.17-1.03a2 2 0 0 1-.2 3.7zm1.14 5.51c-.14-1.21-.35-2.4-.62-3.57.45-.14.86-.35 1.23-.63a2.99 2.99 0 0 1-.6 4.2zM275 214a29 29 0 0 0-57.97 0h57.96zM72.33 198.12c-.21-.32-.34-.7-.34-1.12v-12h-2v12a4.01 4.01 0 0 0 7.09 2.54c.57-.69.91-1.57.91-2.54v-12h-2v12a1.99 1.99 0 0 1-2 2 2 2 0 0 1-1.66-.88zM75 176c.38 0 .74-.04 1.1-.12a4 4 0 0 0 6.19 2.4A13.94 13.94 0 0 1 84 185v24a6 6 0 0 1-6 6h-3v9a5 5 0 1 1-10 0v-9h-3a6 6 0 0 1-6-6v-24a14 14 0 0 1 14-14 5 5 0 0 0 5 5zm-17 15v12a1.99 1.99 0 0 0 1.22 1.84 2 2 0 0 0 2.44-.72c.21-.32.34-.7.34-1.12v-12h2v12a3.98 3.98 0 0 1-5.35 3.77 3.98 3.98 0 0 1-.65-.3V209a4 4 0 0 0 4 4h16a4 4 0 0 0 4-4v-24c.01-1.53-.23-2.88-.72-4.17-.43.1-.87.16-1.28.17a6 6 0 0 1-5.2-3 7 7 0 0 1-6.47-4.88A12 12 0 0 0 58 185v6zm9 24v9a3 3 0 1 0 6 0v-9h-6z'/%3E%3Cpath d='M-17 191a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm19 9a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2H3a1 1 0 0 1-1-1zm-14 5a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm-25 1a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm5 4a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm9 0a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm15 1a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm12-2a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2H4zm-11-14a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm-19 0a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2h-2zm6 5a1 1 0 0 1 1-1h2a1 1 0 0 1 0 2h-2a1 1 0 0 1-1-1zm-25 15c0-.47.01-.94.03-1.4a5 5 0 0 1-1.7-8 3.99 3.99 0 0 1 1.88-5.18 5 5 0 0 1 3.4-6.22 3 3 0 0 1 1.46-1.05 5 5 0 0 1 7.76-3.27A30.86 30.86 0 0 1-14 184c6.79 0 13.06 2.18 18.17 5.88a5 5 0 0 1 7.76 3.27 3 3 0 0 1 1.47 1.05 5 5 0 0 1 3.4 6.22 4 4 0 0 1 1.87 5.18 4.98 4.98 0 0 1-1.7 8c.02.46.03.93.03 1.4v1h-62v-1zm.83-7.17a30.9 30.9 0 0 0-.62 3.57 3 3 0 0 1-.61-4.2c.37.28.78.49 1.23.63zm1.49-4.61c-.36.87-.68 1.76-.96 2.68a2 2 0 0 1-.21-3.71c.33.4.73.75 1.17 1.03zm2.32-4.54c-.54.86-1.03 1.76-1.49 2.68a3 3 0 0 1-.07-4.67 3 3 0 0 0 1.56 1.99zm1.14-1.7c.35-.5.72-.98 1.1-1.46a1 1 0 1 0-1.1 1.45zm5.34-5.77c-1.03.86-2 1.79-2.9 2.77a3 3 0 0 0-1.11-.77 3 3 0 0 1 4-2zm42.66 2.77c-.9-.98-1.87-1.9-2.9-2.77a3 3 0 0 1 4.01 2 3 3 0 0 0-1.1.77zm1.34 1.54c.38.48.75.96 1.1 1.45a1 1 0 1 0-1.1-1.45zm3.73 5.84c-.46-.92-.95-1.82-1.5-2.68a3 3 0 0 0 1.57-1.99 3 3 0 0 1-.07 4.67zm1.8 4.53c-.29-.9-.6-1.8-.97-2.67.44-.28.84-.63 1.17-1.03a2 2 0 0 1-.2 3.7zm1.14 5.51c-.14-1.21-.35-2.4-.62-3.57.45-.14.86-.35 1.23-.63a2.99 2.99 0 0 1-.6 4.2zM15 214a29 29 0 0 0-57.97 0h57.96z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
.conversation:not(.no-chat)[data-chat-bg="none"], .bg-swatch[data-bg="none"] { background-image: none; }
.conversation:not(.no-chat)[data-chat-bg="cats"], .bg-swatch[data-bg="cats"] { background-image: url("/assets/chat-bg/cats.svg"); }
.conversation:not(.no-chat)[data-chat-bg="dogs"], .bg-swatch[data-bg="dogs"] { background-image: url("/assets/chat-bg/dogs.svg"); }
.conversation:not(.no-chat)[data-chat-bg="jigsaw"], .bg-swatch[data-bg="jigsaw"] { background-image: url("/assets/chat-bg/jigsaw.svg"); }
.conversation:not(.no-chat)[data-chat-bg="circuit"], .bg-swatch[data-bg="circuit"] { background-image: url("/assets/chat-bg/circuit.svg"); }
.conversation:not(.no-chat)[data-chat-bg="leaf"], .bg-swatch[data-bg="leaf"] { background-image: url("/assets/chat-bg/leaf.svg"); }
.conversation:not(.no-chat)[data-chat-bg="anchors"], .bg-swatch[data-bg="anchors"] { background-image: url("/assets/chat-bg/anchors.svg"); }
.conversation:not(.no-chat)[data-chat-bg="bubbles"], .bg-swatch[data-bg="bubbles"] { background-image: url("/assets/chat-bg/bubbles.svg"); }
.conversation:not(.no-chat)[data-chat-bg="charlie"], .bg-swatch[data-bg="charlie"] { background-image: url("/assets/chat-bg/charlie.svg"); }
.conversation:not(.no-chat)[data-chat-bg="autumn"], .bg-swatch[data-bg="autumn"] { background-image: url("/assets/chat-bg/autumn.svg"); }
.conversation:not(.no-chat)[data-chat-bg="hideout"], .bg-swatch[data-bg="hideout"] { background-image: url("/assets/chat-bg/hideout.svg"); }
.conversation:not(.no-chat)[data-chat-bg="wiggle"], .bg-swatch[data-bg="wiggle"] { background-image: url("/assets/chat-bg/wiggle.svg"); }
.conversation:not(.no-chat)[data-chat-bg="piano"], .bg-swatch[data-bg="piano"] { background-image: url("/assets/chat-bg/piano.svg"); }
.conversation:not(.no-chat)[data-chat-bg="leaves2"], .bg-swatch[data-bg="leaves2"] { background-color: #fff; background-image: url("/assets/chat-bg/leaves2.svg"); }
.conversation:not(.no-chat)[data-chat-bg="geometry"], .bg-swatch[data-bg="geometry"] { background-color: #fff; background-image: url("/assets/chat-bg/geometry.svg"); }
.conversation:not(.no-chat)[data-chat-bg="halloween"], .bg-swatch[data-bg="halloween"] { background-color: #fff; background-image: url("/assets/chat-bg/halloween.svg"); }
.conversation:not(.no-chat)[data-chat-bg="stars"], .bg-swatch[data-bg="stars"] { background-color: #fff; background-image: url("/assets/chat-bg/stars.svg"); }
.conversation:not(.no-chat)[data-chat-bg="leaves"], .bg-swatch[data-bg="leaves"] { background-color: #fff; background-image: url("/assets/chat-bg/leaves.svg"); }
.conversation:not(.no-chat)[data-chat-bg="circles"], .bg-swatch[data-bg="circles"] { background-color: #fff; background-image: url("/assets/chat-bg/circles.svg"); }
.conversation:not(.no-chat)[data-chat-bg="pebbles"], .bg-swatch[data-bg="pebbles"] { background-color: #fff; background-image: url("/assets/chat-bg/pebbles.svg"); }
.conversation:not(.no-chat)[data-chat-bg="chess"], .bg-swatch[data-bg="chess"] { background-color: #fff; background-image: url("/assets/chat-bg/chess.svg"); }
.conversation:not(.no-chat)[data-chat-bg="valentine"], .bg-swatch[data-bg="valentine"] { background-color: #fff; background-image: url("/assets/chat-bg/valentine.svg"); }
.conversation:not(.no-chat)[data-chat-bg="wave"], .bg-swatch[data-bg="wave"] { background-color: #fff; background-image: url("/assets/chat-bg/wave.svg"); }
.conversation:not(.no-chat)[data-chat-bg="xmas"], .bg-swatch[data-bg="xmas"] { background-color: #fff; background-image: url("/assets/chat-bg/xmas.svg"); }
.conversation:not(.no-chat)[data-chat-bg="bricks"], .bg-swatch[data-bg="bricks"] { background-color: #fff; background-image: url("/assets/chat-bg/bricks.svg"); }
.conversation:not(.no-chat)[data-chat-bg="bricks_orange"], .bg-swatch[data-bg="bricks_orange"] { background-color: #fff; background-image: url("/assets/chat-bg/bricks_orange.svg"); }
.conversation:not(.no-chat)[data-chat-bg="bricks_pale"], .bg-swatch[data-bg="bricks_pale"] { background-color: #fff; background-image: url("/assets/chat-bg/bricks_pale.svg"); }

.badge.badge-dot { min-width: 12px; width: 12px; height: 12px; padding: 0; }
dotlottie-wc.sticker { cursor: pointer; }

/* Background picker */
.modal.bg-sheet { max-width: 560px; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px 10px; overflow-y: auto; padding: 2px; }
.bg-option { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.bg-swatch {
    width: 100%; aspect-ratio: 1; border-radius: 14px; border: 2px solid var(--line); background-color: var(--chat-bg);
    background-repeat: repeat; background-size: auto; box-sizing: border-box;
}
.bg-option:hover .bg-swatch { border-color: #9fdcb9; }
.bg-option.selected .bg-swatch { border-color: var(--green); box-shadow: 0 0 0 2px rgba(47, 191, 113, .25); }
.bg-option.selected .bg-name { color: var(--green); font-weight: 650; }
.profile-action-value { margin-left: auto; color: var(--ink-3); font-size: 13.5px; }

/* Clickable conversation header */
.conv-profile {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 4px 8px 4px 4px;
    margin: -4px 0; border-radius: 12px; text-align: left; color: inherit; font: inherit; cursor: pointer;
}
.conv-profile:hover { background: var(--hover); }
.conv-name { display: flex; align-items: center; gap: 6px; }
.conv-name > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-muted { width: 15px; height: 15px; color: var(--ink-3); flex: none; }

/* Attach menu */
.attach-menu {
    position: absolute; left: max(6%, 8px); bottom: calc(100% - 4px); width: 230px; margin: 0;
    background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 6px; z-index: 20;
}
.attach-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 7px 8px; border-radius: 10px; font-size: 14.5px; text-align: left; }
.attach-item:hover { background: var(--hover); }
.attach-ico { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: grid; place-items: center; flex: none; }
.attach-ico svg { width: 18px; height: 18px; }

/* Drag & drop */
.drop-overlay {
    position: absolute; inset: 0; z-index: 30; padding: 16px; background: rgba(238, 240, 243, .82); backdrop-filter: blur(2px);
    display: grid; pointer-events: none;
}
.drop-overlay > div {
    border: 2.5px dashed var(--green); border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; color: var(--green); font-size: 18px; font-weight: 650; background: rgba(255, 255, 255, .6);
}
.drop-overlay svg { width: 46px; height: 46px; }

/* Uploads */
.msg.uploading .bubble { min-width: 220px; }
.msg.uploading .media { opacity: .75; }
.upload-bar { display: flex; flex-direction: column; gap: 5px; padding: 6px 2px 0; }
.upload-label { font-size: 12px; color: var(--ink-3); }
.upload-track { height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .08); overflow: hidden; }
.upload-fill { display: block; height: 100%; background: var(--green); border-radius: 2px; transition: width .2s; }
.msg.failed .msg-body { white-space: pre-line; color: var(--ink-2); }

/* Cards */
.contact-card[role="button"] { cursor: pointer; }
.card-avatar { width: 40px; height: 40px; font-size: 15px; flex: none; }
.checklist li[data-check] { cursor: pointer; border-radius: 6px; }
.checklist li[data-check]:hover .tick { border-color: var(--green); }
.composer-note .btn-link { border: 0; background: none; color: var(--green); font-weight: 650; padding: 0 4px; cursor: pointer; font: inherit; }

/* Sheets: contact picker, checklist editor */
.modal.sheet { max-width: 420px; text-align: left; padding: 16px; display: flex; flex-direction: column; gap: 10px; max-height: min(640px, calc(100dvh - 32px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h3 { margin: 0; }
.contact-list { list-style: none; margin: 0 -8px; padding: 0; overflow-y: auto; min-height: 120px; flex: 1; }
.contact-row { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 8px; border-radius: 12px; text-align: left; }
.contact-row:hover, .contact-row:focus-visible { background: var(--hover); }
.contact-avatar { width: 40px; height: 40px; flex: none; }
.contact-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.contact-name { font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.contact-phone { font-size: 12.5px; }
.contact-badge { color: var(--green); display: grid; }
.contact-badge svg { width: 18px; height: 18px; }
.contact-empty { padding: 28px 8px; text-align: center; }
.checklist-items { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 340px; }
.checklist-row { display: flex; align-items: center; gap: 8px; }
.checklist-row .tick { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--ink-3); flex: none; }
.checklist-row .input { flex: 1; min-width: 0; }
.checklist-row .icon-btn { width: 32px; height: 32px; flex: none; }
.checklist-add { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; border: 0; background: none; color: var(--green); font-weight: 600; padding: 4px 2px; }
.checklist-add svg { width: 18px; height: 18px; }

/* Profile panel */
.workspace { position: relative; }
.profile-panel {
    width: 360px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); min-height: 0;
}
.profile-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 61px; border-bottom: 1px solid var(--line); }
.profile-head-title { font-weight: 650; font-size: 15.5px; }
.profile-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.profile-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px 14px; text-align: center; }
.profile-avatar { width: 112px; height: 112px; font-size: 38px; margin-bottom: 8px; }
.profile-avatar svg { width: 48px; height: 48px; }
.profile-name { margin: 0; font-size: 19px; font-weight: 650; word-break: break-word; }
.profile-sub { font-size: 13.5px; }
.profile-info { margin: 0 12px 8px; background: var(--surface-2); border-radius: 14px; padding: 4px 14px; }
.profile-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 14px; }
.profile-row + .profile-row { border-top: 1px solid var(--line); }
.profile-row > span:last-child { text-align: right; word-break: break-all; }
.profile-actions { display: flex; flex-direction: column; padding: 0 8px 8px; }
.profile-action { display: flex; align-items: center; gap: 14px; border: 0; background: none; padding: 11px 12px; border-radius: 12px; font-size: 14.5px; text-align: left; }
.profile-action:hover { background: var(--hover); }
.profile-action svg { width: 20px; height: 20px; color: var(--ink-2); }
.profile-action.danger, .profile-action.danger svg { color: var(--danger); }
.profile-tabs { position: sticky; top: 0; z-index: 2; display: flex; gap: 2px; padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.profile-tab { flex: 1; border: 0; background: none; padding: 12px 4px 10px; font-weight: 600; font-size: 13.5px; color: var(--ink-3); border-bottom: 2.5px solid transparent; }
.profile-tab.active { color: var(--green); border-bottom-color: var(--green); }
.profile-pane { min-height: 200px; }
.profile-loading, .profile-empty { padding: 40px 16px; display: grid; place-items: center; text-align: center; font-size: 13.5px; }
.profile-more { display: grid; place-items: center; min-height: 40px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; }
.media-tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: #d9dde3; overflow: hidden; cursor: pointer; }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.media-tile.enc:not(:has(img[src])) { background: #d9dde3 linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .5) 50%, transparent 70%) 0 0 / 200% 100%; animation: shimmer 1.2s linear infinite; }
.media-tile.is-broken { animation: none; }
.tile-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, .18); }
.tile-play svg { width: 30px; height: 30px; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .4)); }
@keyframes shimmer { to { background-position: -200% 0; } }
.profile-list { list-style: none; margin: 0; padding: 6px; }
.profile-item {
    display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 8px; border-radius: 12px;
    text-align: left; color: inherit; text-decoration: none; min-width: 0;
}
button.profile-item:hover, a.profile-item:hover { background: var(--hover); }
.profile-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-item-main .file-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; font-size: 14px; }
.profile-item .small { font-size: 12px; }
.profile-link { display: flex; align-items: center; gap: 2px; }
.profile-link .profile-item { flex: 1; }
.link-icon { background: #4f8ef7; }
.link-url { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.member-avatar { width: 40px; height: 40px; flex: none; }
.role-badge { font-size: 11.5px; font-weight: 650; color: var(--green); background: rgba(47, 191, 113, .12); padding: 3px 8px; border-radius: 999px; flex: none; }

@media (max-width: 1100px) {
    :root { --sidebar-w: 320px; }
    .messages, .composer { padding-left: 3%; padding-right: 3%; }
    .profile-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 40; box-shadow: -8px 0 24px rgba(0, 0, 0, .12); }
}

@media (max-width: 760px) {
    .app { padding: 0; height: 100dvh; }
    .rail { display: none; }
    .workspace { border-radius: 0; }
    .sidebar { width: 100%; border-right: 0; padding-top: max(12px, env(safe-area-inset-top)); }
    .sidebar .rail-avatar { width: 32px; height: 32px; }
    .conversation { display: none; }
    .app.show-chat .sidebar { display: none; }
    .app.show-chat .conversation { display: flex; }
    .mobile-only { display: inline-grid; }
    .conv-head { padding: 8px 8px; padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; min-height: 56px; }
    .messages { padding: 8px 8px 6px; }
    .composer { padding: 6px 8px max(8px, env(safe-area-inset-bottom)); }
    .bubble { max-width: 84%; }
    .media-img, .media-video { width: 240px; }
    .picker { left: 8px; right: 8px; width: auto; height: 50vh; }
    .attach-menu { left: 8px; }
    .profile-panel { width: 100%; border-left: 0; }
    .profile-head { padding-top: max(10px, env(safe-area-inset-top)); }
    .conv-profile { gap: 8px; }
    .emoji-grid { grid-template-columns: repeat(8, 1fr); }
    .sidebar-foot { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .to-bottom { right: 12px; }
}
@media (min-width: 761px) {
    .mobile-only { display: none !important; }
}
