:root {
    --brand: #008069;
    --brand-dark: #006b58;
    --header-bg: #008069;
    --app-bg: #d9dbd5;
    --chat-bg: #efeae2;
    --surface: #fff;
    --surface-soft: #f7f9fa;
    --surface-muted: #f0f2f5;
    --input-bg: #fff;
    --text: #111b21;
    --muted: #667781;
    --mine: #d9fdd3;
    --theirs: #fff;
    --line: #e2e7e9;
    --icon: #54656f;
    --link: #027eb5;
    --notice-bg: #ffeecd;
    --notice-text: #54656f;
    --notice-icon: #8a6d1d;
    --date-bg: rgba(255, 255, 255, .9);
    --file-bg: rgba(11, 20, 26, .055);
    --soft-line: rgba(11, 20, 26, .1);
    --soft-hover: rgba(11, 20, 26, .055);
    --wallpaper-mark: rgba(80, 92, 88, .055);
    --wallpaper-mark-soft: rgba(80, 92, 88, .025);
    --bubble-shadow: 0 1px .5px rgba(11, 20, 26, .13);
    --shell-shadow: 0 2px 32px rgba(11, 20, 26, .22);
    --overlay: rgba(11, 20, 26, .12);
    --field-border: #b7c1c7;
    --menu-text: #3b4a54;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --viewport-height: 100dvh;
    --viewport-top: 0px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --brand: #00a884;
    --brand-dark: #008f72;
    --header-bg: #202c33;
    --app-bg: #111b21;
    --chat-bg: #0b141a;
    --surface: #202c33;
    --surface-soft: #111b21;
    --surface-muted: #202c33;
    --input-bg: #2a3942;
    --text: #e9edef;
    --muted: #8696a0;
    --mine: #005c4b;
    --theirs: #202c33;
    --line: #2a3942;
    --icon: #aebac1;
    --link: #53bdeb;
    --notice-bg: #182229;
    --notice-text: #ffd279;
    --notice-icon: #ffd279;
    --date-bg: rgba(24, 34, 41, .94);
    --file-bg: rgba(255, 255, 255, .075);
    --soft-line: rgba(255, 255, 255, .09);
    --soft-hover: rgba(255, 255, 255, .07);
    --wallpaper-mark: rgba(255, 255, 255, .035);
    --wallpaper-mark-soft: rgba(255, 255, 255, .018);
    --bubble-shadow: 0 1px .5px rgba(0, 0, 0, .38);
    --shell-shadow: 0 2px 32px rgba(0, 0, 0, .5);
    --overlay: rgba(0, 0, 0, .42);
    --field-border: #3b4a54;
    --menu-text: #d1d7db;
}

* { box-sizing: border-box; }
html, body {
    position: fixed;
    inset: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
}
html { color-scheme: light; background: var(--app-bg); }
body {
    color: var(--text);
    background: linear-gradient(180deg, var(--header-bg) 0 126px, var(--app-bg) 126px 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { display: block; width: 100%; height: 100%; fill: currentColor; }
[hidden] { display: none !important; }

.app-shell {
    position: fixed;
    top: var(--viewport-top);
    right: 0;
    left: 0;
    width: 100%;
    max-width: 760px;
    height: 100vh;
    height: var(--viewport-height);
    margin: 0 auto;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
    background: var(--chat-bg);
    box-shadow: var(--shell-shadow);
}

.chat-header {
    min-width: 0;
    min-height: calc(60px + var(--safe-top));
    padding: calc(7px + var(--safe-top)) 8px 7px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    background: var(--header-bg);
    z-index: 30;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .08);
}
.icon-button {
    width: 40px;
    height: 40px;
    padding: 9px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: inherit;
    background: transparent;
    cursor: pointer;
}
.icon-button:active { background: rgba(255, 255, 255, .13); }
.header-back { width: 34px; padding: 7px; flex: 0 0 34px; }
.clinic-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--brand);
    background: var(--surface-muted);
    border: 1px solid rgba(255, 255, 255, .45);
    font-size: 18px;
    font-weight: 700;
}
.clinic-avatar img { width: 100%; height: 100%; object-fit: cover; }
.clinic-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.clinic-info strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; line-height: 21px; font-weight: 600; }
.clinic-info span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; line-height: 17px; color: rgba(255,255,255,.86); }
.install-button {
    width: auto;
    max-width: 126px;
    height: 38px;
    padding: 4px 9px 4px 4px;
    flex: 0 1 auto;
    border-radius: 20px;
    gap: 6px;
    background: rgba(255,255,255,.14);
}
.install-brand {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--brand);
    background: #fff;
    font-size: 14px;
    font-weight: 800;
}
.install-brand img { width: 100%; height: 100%; object-fit: cover; }
.install-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; font-weight: 700; }
.theme-button { width: 38px; height: 38px; padding: 8px; flex: 0 0 38px; }
.theme-icon { width: 22px; height: 22px; }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
.secure-indicator { width: 28px; height: 28px; padding: 5px; flex: 0 0 28px; color: rgba(255,255,255,.88); }

.connection-banner {
    min-height: 34px;
    padding: 7px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--notice-text);
    background: var(--notice-bg);
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    z-index: 24;
}
.connection-banner svg { width: 17px; height: 17px; flex: 0 0 17px; }

.system-screen {
    grid-row: 3;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    color: var(--muted);
    background: var(--surface-soft);
    text-align: center;
}
.loader { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.system-screen p { max-width: 340px; margin: 16px 0 0; font-size: 14px; line-height: 1.45; }
.retry-button { margin-top: 14px; padding: 10px 18px; border: 0; border-radius: 22px; color: #fff; background: var(--brand); font-weight: 600; cursor: pointer; }

.chat-screen {
    grid-row: 3;
    min-width: 0;
    min-height: 0;
    padding: 10px 8px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    overflow-anchor: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    background-color: var(--chat-bg);
    background-image:
        radial-gradient(circle at 24px 21px, var(--wallpaper-mark) 0 1.2px, transparent 1.4px),
        radial-gradient(circle at 8px 9px, var(--wallpaper-mark) 0 1px, transparent 1.2px),
        linear-gradient(45deg, transparent 46%, var(--wallpaper-mark-soft) 47% 53%, transparent 54%);
    background-size: 32px 32px, 25px 25px, 42px 42px;
}
.privacy-note {
    width: fit-content;
    max-width: min(92%, 460px);
    margin: 2px auto 12px;
    padding: 6px 10px;
    border-radius: 7px;
    color: var(--notice-text);
    background: var(--notice-bg);
    box-shadow: var(--bubble-shadow);
    font-size: 10.8px;
    line-height: 15px;
    text-align: center;
}
.privacy-note span { color: var(--notice-icon); margin-right: 3px; }
.message-list { display: flex; flex-direction: column; gap: 2px; }
.date-separator {
    align-self: center;
    margin: 8px 0 7px;
    padding: 6px 12px;
    border-radius: 7px;
    color: var(--muted);
    background: var(--date-bg);
    box-shadow: var(--bubble-shadow);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}
.message-row { width: 100%; min-width: 0; display: flex; padding: 0 4px; }
.message-row.in { justify-content: flex-end; }
.message-row.out, .message-row.system { justify-content: flex-start; }
.bubble {
    max-width: min(86%, 560px);
    min-width: 74px;
    padding: 6px 8px 4px;
    position: relative;
    border-radius: 8px;
    color: var(--text);
    background: var(--theirs);
    box-shadow: var(--bubble-shadow);
    font-size: 14.2px;
    line-height: 19px;
    overflow-wrap: anywhere;
}
.message-row.in .bubble { margin-right: 4px; background: var(--mine); border-top-right-radius: 2px; }
.message-row.out .bubble { margin-left: 4px; border-top-left-radius: 2px; }
.message-row.in .bubble::after {
    content: "";
    position: absolute;
    top: 0;
    right: -7px;
    border-top: 8px solid var(--mine);
    border-right: 8px solid transparent;
}
.message-row.out .bubble::before {
    content: "";
    position: absolute;
    top: 0;
    left: -7px;
    border-top: 8px solid var(--theirs);
    border-left: 8px solid transparent;
}
.bubble-text { white-space: pre-wrap; }
.bubble-text strong { font-weight: 650; }
.bubble-text em { font-style: italic; }
.bubble-text s { text-decoration-thickness: 1px; }
.bubble a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.message-meta { min-height: 14px; margin: 2px 0 -1px 12px; display: flex; justify-content: flex-end; align-items: center; gap: 3px; color: var(--muted); font-size: 10.5px; line-height: 12px; }
.message-status { color: #53bdeb; font-size: 12px; letter-spacing: -4px; padding-right: 4px; font-weight: 700; }
.message-status.pending { color: #8696a0; letter-spacing: 0; padding-right: 0; }
.message-status.failed { color: #e53935; letter-spacing: 0; padding-right: 0; }
.message-media { display: block; width: 100%; max-width: 380px; max-height: 440px; object-fit: cover; border-radius: 6px; margin-bottom: 4px; background: var(--surface-muted); }
.message-audio { display: block; width: min(290px, 72vw); height: 42px; margin: 2px 0; }
.file-card { min-width: 230px; padding: 9px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; border-radius: 6px; color: var(--text) !important; background: var(--file-bg); text-decoration: none !important; }
.file-icon { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #7e57c2; font-size: 10px; font-weight: 700; }
.quick-replies { margin: 7px -8px -4px; display: flex; flex-direction: column; border-top: 1px solid var(--soft-line); }
.quick-replies button { min-height: 40px; padding: 9px 12px; border: 0; border-top: 1px solid var(--soft-line); color: var(--brand); background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; }
.quick-replies button:first-child { border-top: 0; }
.quick-replies button:active { background: var(--soft-hover); }
.quick-replies.quick-replies-cart {
    margin: 8px 0 2px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    border-top: 0;
}
.quick-replies.quick-replies-cart button {
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid var(--soft-line);
    border-radius: 19px;
    color: var(--brand);
    background: var(--surface-soft);
    font-size: 12.5px;
    line-height: 16px;
}
.quick-replies.quick-replies-cart button:first-child { border-top: 1px solid var(--soft-line); }
.quick-replies.quick-replies-cart button:nth-child(3):last-child { grid-column: 1 / -1; }
.quick-replies.quick-replies-cart button:active { transform: scale(.97); background: var(--soft-hover); }
.quick-replies.quick-replies-options,
.quick-replies.quick-replies-schedule {
    margin: 8px 0 2px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    border-top: 0;
}
.quick-replies.quick-replies-options button,
.quick-replies.quick-replies-schedule button {
    min-height: 34px;
    padding: 6px 3px;
    overflow: hidden;
    border: 1px solid var(--soft-line);
    border-radius: 18px;
    color: var(--brand);
    background: var(--surface-soft);
    font-size: 12px;
    line-height: 16px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.quick-replies.quick-replies-options {
    grid-template-columns: repeat(var(--quick-option-columns, 4), minmax(0, 1fr));
}
.quick-replies.quick-replies-options button:first-child,
.quick-replies.quick-replies-schedule button:first-child { border-top: 1px solid var(--soft-line); }
.quick-replies.quick-replies-options button:active,
.quick-replies.quick-replies-schedule button:active { transform: scale(.97); background: var(--soft-hover); }
.quick-replies.quick-replies-schedule .quick-reply-time {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    letter-spacing: .1px;
}
.quick-replies.quick-replies-schedule .schedule-date-label {
    grid-column: 1 / -1;
    margin: 3px 2px -1px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 650;
    line-height: 16px;
    text-transform: capitalize;
}
.quick-replies.quick-replies-schedule .schedule-date-label:first-child { margin-top: 0; }
.quick-replies.quick-replies-schedule .quick-reply-more {
    grid-column: 1 / -1;
    min-height: 38px;
    margin-top: 1px;
    border-color: var(--brand);
    color: #fff;
    background: var(--brand);
    font-size: 13px;
}
.quick-replies.quick-replies-schedule .quick-reply-more:active { background: var(--brand); filter: brightness(.94); }
.quick-replies.quick-replies-cities {
    margin: 8px 0 2px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    border-top: 0;
}
.quick-replies.quick-replies-cities .quick-reply-city {
    min-height: 42px;
    padding: 7px 9px;
    border: 1px solid var(--soft-line);
    border-radius: 12px;
    color: var(--brand);
    background: var(--surface-soft);
    font-size: 12.5px;
    font-weight: 650;
    line-height: 16px;
    white-space: normal;
    overflow-wrap: anywhere;
}
.quick-replies.quick-replies-cities .quick-reply-city:first-child { border-top: 1px solid var(--soft-line); }
.quick-replies.quick-replies-cities .quick-reply-city:active { transform: scale(.97); background: var(--soft-hover); }
.quick-replies.quick-replies-cities .quick-reply-city-more {
    grid-column: 1 / -1;
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid var(--brand);
    border-radius: 19px;
    color: #fff;
    background: var(--brand);
    font-size: 12.5px;
    font-weight: 700;
}
.quick-replies.quick-replies-cities .quick-reply-city-more:active { background: var(--brand); filter: brightness(.94); }
.typing {
    width: fit-content;
    max-width: 260px;
    min-height: 36px;
    margin: 4px 0 2px 8px;
    padding: 8px 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 8px 8px 8px 2px;
    color: var(--muted);
    background: var(--theirs);
    box-shadow: var(--bubble-shadow);
}
.typing span { width: 6px; height: 6px; border-radius: 50%; background: #8696a0; animation: pulse 1.1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
.typing em { margin-left: 5px; font-size: 11px; font-style: normal; }
.empty-state { max-width: 320px; margin: 22px auto; padding: 10px 13px; border-radius: 7px; color: var(--muted); background: var(--date-bg); box-shadow: var(--bubble-shadow); font-size: 12px; line-height: 17px; text-align: center; }

.composer {
    grid-row: 4;
    width: 100%;
    min-width: 0;
    min-height: calc(60px + var(--safe-bottom));
    padding: 7px 7px calc(7px + var(--safe-bottom));
    display: flex;
    align-items: flex-end;
    gap: 6px;
    position: relative;
    z-index: 32;
    background: var(--surface-muted);
}
.composer-pill {
    max-width: calc(100% - 52px);
    min-width: 0;
    min-height: 46px;
    flex: 1;
    display: flex;
    align-items: flex-end;
    border-radius: 24px;
    background: var(--input-bg);
}
.composer-action { width: 42px; height: 46px; flex: 0 0 42px; padding: 11px; align-self: flex-end; color: var(--icon); }
.composer-action:active { background: var(--soft-hover); }
.composer textarea {
    min-width: 0;
    min-height: 46px;
    max-height: 116px;
    flex: 1;
    padding: 12px 4px 10px;
    resize: none;
    overflow-y: auto;
    touch-action: manipulation;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    font-size: 15.5px;
    line-height: 22px;
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.upload-status {
    position: absolute;
    right: 7px;
    bottom: calc(100% + 6px);
    left: 7px;
    z-index: 38;
    padding: 10px 11px 9px;
    overflow: hidden;
    border: 1px solid var(--soft-line);
    border-radius: 12px;
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 5px 18px rgba(11,20,26,.18);
}
.upload-status-main { min-width: 0; display: flex; align-items: center; gap: 9px; }
.upload-status-indicator {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border: 2px solid color-mix(in srgb, var(--brand) 25%, transparent);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .85s linear infinite;
}
.upload-status-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.upload-status-copy strong { overflow: hidden; font-size: 12.5px; font-weight: 600; line-height: 17px; text-overflow: ellipsis; white-space: nowrap; }
.upload-status-copy > span { overflow: hidden; color: var(--muted); font-size: 11.5px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.upload-retry {
    min-height: 32px;
    padding: 6px 12px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 18px;
    color: #fff;
    background: var(--brand);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.upload-retry:disabled { opacity: .5; cursor: default; }
.upload-progress { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 4px; background: var(--surface-muted); }
.upload-progress > span { width: 0; height: 100%; display: block; border-radius: inherit; background: var(--brand); transition: width .16s ease; }
.upload-status.is-analyzing .upload-progress > span { width: 34%; animation: upload-indeterminate 1.15s ease-in-out infinite; }
.upload-status.is-success .upload-status-indicator { border-color: var(--brand); background: var(--brand); animation: none; }
.upload-status.is-success .upload-status-indicator::after { content: ''; width: 8px; height: 4px; margin: 5px 0 0 4px; display: block; transform: rotate(-45deg); border-bottom: 2px solid #fff; border-left: 2px solid #fff; }
.upload-status.is-error .upload-status-indicator { position: relative; border-color: #d92d20; background: #d92d20; animation: none; }
.upload-status.is-error .upload-status-indicator::after { content: '!'; position: absolute; inset: -2px 0 0; color: #fff; font-size: 13px; font-weight: 800; line-height: 20px; text-align: center; }
.round-button {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    padding: 12px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: var(--brand);
    box-shadow: 0 1px 2px rgba(11,20,26,.2);
    cursor: pointer;
}
.round-button:active { transform: scale(.96); filter: brightness(.95); }
.mic-button { padding: 11px; }
.send-button { padding: 12px 11px 12px 13px; }
.attach-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
.attach-menu {
    width: min(318px, calc(100vw - 30px));
    padding: 17px 14px 15px;
    position: absolute;
    left: 14px;
    bottom: calc(64px + var(--safe-bottom));
    z-index: 42;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 8px 32px rgba(11,20,26,.24);
    transform-origin: left bottom;
    animation: menu-in .15s ease-out;
}
.attach-menu button { padding: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; color: var(--menu-text); background: transparent; font-size: 12px; cursor: pointer; }
.attach-kind { width: 48px; height: 48px; padding: 13px; display: grid; place-items: center; border-radius: 50%; color: #fff; box-shadow: 0 2px 6px rgba(11,20,26,.15); }
.document-kind { background: #7e57c2; }
.camera-kind { background: #e91e63; }
.gallery-kind { background: #9c27b0; }

.recording-bar {
    grid-row: 4;
    width: 100%;
    min-width: 0;
    min-height: calc(60px + var(--safe-bottom));
    padding: 7px 8px calc(7px + var(--safe-bottom));
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    background: var(--surface-muted);
    z-index: 35;
}
.recording-delete { color: #e53935; }
.recording-delete:active { background: rgba(229,57,53,.08); }
.recording-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #e53935; animation: pulse .9s infinite; }
.recording-bar strong { min-width: 42px; color: #e53935; font-size: 13px; font-variant-numeric: tabular-nums; }
.recording-label { min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.send-recording { padding: 12px 11px 12px 13px; }

.app-shell.is-public-home .header-back,
.app-shell.is-public-home .install-button { display: none !important; }
.public-home {
    grid-row: 3;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    background-color: var(--chat-bg);
    background-image:
        radial-gradient(circle at 24px 21px, var(--wallpaper-mark) 0 1.2px, transparent 1.4px),
        radial-gradient(circle at 8px 9px, var(--wallpaper-mark) 0 1px, transparent 1.2px),
        linear-gradient(45deg, transparent 46%, var(--wallpaper-mark-soft) 47% 53%, transparent 54%);
    background-size: 32px 32px, 25px 25px, 42px 42px;
}
.public-home-thread {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 18px 14px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.public-home-date {
    width: max-content;
    margin: 0 auto 18px;
    padding: 5px 11px;
    border-radius: 7px;
    color: var(--muted);
    background: var(--date-bg);
    box-shadow: var(--bubble-shadow);
    font-size: 11.5px;
    line-height: 16px;
}
.public-home-bubble {
    position: relative;
    width: min(92%, 430px);
    margin: 0 auto 18px 0;
    padding: 11px 13px 9px;
    border-radius: 0 9px 9px 9px;
    color: var(--text);
    background: var(--theirs);
    box-shadow: var(--bubble-shadow);
}
.public-home-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    border-top: 9px solid var(--theirs);
    border-left: 9px solid transparent;
}
.public-home-sender { display: block; margin-bottom: 4px; color: var(--brand); font-size: 12px; font-weight: 700; }
.public-home-bubble h1 { margin: 0 0 9px; font-size: 19px; line-height: 25px; font-weight: 650; }
.public-home-bubble p { margin: 0 0 9px; font-size: 14px; line-height: 20px; }
.public-home-bubble time { display: block; margin-top: -2px; color: var(--muted); font-size: 10.5px; line-height: 14px; text-align: right; }
.public-home-guide {
    width: min(96%, 450px);
    margin: 0 auto;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-color: color-mix(in srgb, var(--brand) 28%, var(--line));
    border-radius: 14px;
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 5px 18px rgba(11, 20, 26, .1);
}
.public-home-guide-icon {
    width: 44px;
    height: 44px;
    padding: 10px;
    flex: 0 0 44px;
    border-radius: 50%;
    color: #fff;
    background: var(--brand);
}
.public-home-guide-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.public-home-guide-copy strong { color: var(--text); font-size: 14px; line-height: 19px; }
.public-home-guide-copy span { color: var(--muted); font-size: 12.5px; line-height: 17px; }
.public-home-privacy {
    max-width: 430px;
    margin: 16px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 16px;
    text-align: center;
}
.public-home-privacy svg { width: 15px; height: 15px; flex: 0 0 15px; color: var(--brand); }
.public-home-composer {
    min-width: 0;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--surface-muted);
    border-top: 1px solid var(--line);
}
.public-home-composer-field {
    min-width: 0;
    min-height: 46px;
    padding: 13px 16px;
    flex: 1;
    overflow: hidden;
    border-radius: 24px;
    color: var(--muted);
    background: var(--input-bg);
    font-size: 13.5px;
    line-height: 20px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.public-home-composer-action {
    width: 46px;
    height: 46px;
    padding: 11px;
    flex: 0 0 46px;
    border-radius: 50%;
    color: #fff;
    background: var(--brand);
}

.verification-screen {
    grid-row: 3;
    min-height: 0;
    padding: 24px 16px;
    display: grid;
    place-items: center;
    overflow-y: auto;
    background: var(--surface-soft);
}
.security-card { width: min(410px, 100%); padding: 26px 20px 22px; border-radius: 15px; background: var(--surface); box-shadow: var(--bubble-shadow); text-align: center; }
.security-icon { width: 62px; height: 62px; margin: 0 auto 14px; padding: 16px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--brand); }
.security-card h1 { margin: 0 0 8px; font-size: 21px; font-weight: 600; }
.security-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 20px; }
.security-primary { width: 100%; min-height: 44px; padding: 10px 16px; border: 0; border-radius: 23px; color: #fff; background: var(--brand); font-weight: 600; cursor: pointer; }
.security-primary:disabled { opacity: .55; cursor: default; }
.verification-code-area { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.verification-code-area label { color: var(--menu-text); font-size: 13px; font-weight: 600; text-align: left; }
.verification-code-area input { width: 100%; padding: 11px 10px; border: 1px solid var(--field-border); border-radius: 9px; outline: 0; color: var(--text); background: var(--input-bg); font-size: 25px; font-weight: 700; letter-spacing: .32em; text-align: center; }
.verification-code-area input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.security-link { min-height: 38px; padding: 7px; border: 0; color: var(--brand); background: transparent; font-weight: 600; cursor: pointer; }
.security-link:disabled { color: #a0abb2; cursor: default; }
.security-card .verification-status { min-height: 20px; margin: 13px 0 0; color: var(--menu-text); font-size: 13px; font-weight: 600; }
.security-card .verification-status.error { color: #b42318; }
.security-card .security-help { margin: 15px 0 0; color: #8696a0; font-size: 11.5px; line-height: 16px; }

.modal { position: fixed; inset: 0; z-index: 70; padding: 18px; display: grid; place-items: center; background: rgba(11,20,26,.72); }
.modal-card { width: min(430px, 100%); max-height: 86vh; padding: 18px; overflow: auto; border-radius: 14px; background: var(--surface); box-shadow: 0 16px 50px rgba(0,0,0,.3); }
.modal-card h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.preview-body { min-height: 90px; display: grid; place-items: center; color: var(--muted); overflow-wrap: anywhere; }
.preview-body img { max-width: 100%; max-height: 55vh; border-radius: 8px; object-fit: contain; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button { min-width: 84px; padding: 9px 15px; border: 0; border-radius: 21px; color: var(--brand); background: transparent; font-weight: 600; cursor: pointer; }
.modal-actions .primary { color: #fff; background: var(--brand); }
.toast { position: fixed; left: 50%; bottom: calc(78px + var(--safe-bottom)); z-index: 90; max-width: 88%; padding: 10px 14px; transform: translateX(-50%); border-radius: 8px; color: #fff; background: rgba(17,27,33,.94); box-shadow: 0 8px 25px rgba(0,0,0,.25); font-size: 13px; line-height: 18px; text-align: center; }
.is-disabled { opacity: .55; pointer-events: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.82); } 50% { opacity: 1; transform: scale(1); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes upload-indeterminate { from { transform: translateX(-110%); } to { transform: translateX(300%); } }

@media (min-width: 761px) {
    .app-shell {
        top: calc(var(--viewport-top) + 18px);
        right: 18px;
        left: 18px;
        width: auto;
        height: calc(100vh - 36px);
        height: min(calc(var(--viewport-height) - 36px), 920px);
        border-radius: 10px;
    }
    .chat-header { min-height: 62px; padding-top: 7px; border-radius: 10px 10px 0 0; }
    .chat-screen { padding-right: 22px; padding-left: 22px; }
    .bubble { max-width: min(74%, 560px); }
}

@media (max-width: 360px) {
    .chat-header { gap: 5px; }
    .header-back { width: 30px; flex-basis: 30px; }
    .clinic-avatar { width: 39px; height: 39px; flex-basis: 39px; }
    .install-button { width: 38px; min-width: 38px; padding: 4px; flex-basis: 38px; }
    .install-label { display: none; }
    .secure-indicator { display: none; }
    .composer { gap: 5px; padding-right: 5px; padding-left: 5px; }
    .composer-action { width: 38px; flex-basis: 38px; padding: 10px; }
    .round-button { width: 44px; height: 44px; flex-basis: 44px; }
}

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