/* Scoped CRM presentation; standalone IOS MAGLINK 2027 stays unchanged. */
html[data-crm-workspace][data-magstyle] {
 --ios-picture-wallpaper:url("/assets/backgrounds/chat-light-v2.9c165d5edb6ad990c6469130aa0d2a27ea6ae9b78ca06b7739b2b08b646501f0.webp");--crm-surface:#fff;--crm-soft:#f5f8fc;--crm-ink:#15283f;--crm-muted:#667b94;--crm-line:#dce5ee;--crm-accent:#1768d1;--crm-selected:#e6f1ff;--crm-incoming:#f0f4f8;--crm-outgoing:#e1f6e9;
}
html[data-crm-workspace][data-magstyle][data-crm-theme=dark] {--ios-picture-wallpaper:url("/assets/backgrounds/chat-dark-v2.5e512c338236c97a1f0b8905ff927c8cc90f46b43c64ed5b6d700368a5644802.webp");--crm-surface:#192532;--crm-soft:#101923;--crm-ink:#edf3fa;--crm-muted:#9cabbc;--crm-line:#2b3b4d;--crm-accent:#73a9ff;--crm-selected:#203b59;--crm-incoming:#203244;--crm-outgoing:#164334;}
html[data-crm-workspace][data-magstyle] {
 --bg-app:var(--crm-surface);--bg-primary:var(--crm-surface);--bg-secondary:var(--crm-soft);--bg-modal:var(--crm-surface);--bg-hover:var(--crm-soft);--bg-input:var(--crm-soft);--bg-chat:var(--crm-surface);--chat-bg:var(--crm-surface);--chat-area-bg:var(--crm-surface);--sidebar-bg:var(--crm-surface);--sidebar-item-active-bg:var(--crm-selected);--sidebar-item-hover:var(--crm-soft);
 --bubble-in-text:var(--crm-ink);--bubble-out-text:var(--crm-ink);--bubble-in-border:transparent;--bubble-out-time:var(--crm-muted);--bubble-out-status:var(--crm-muted);--bubble-out-status-read:var(--crm-accent);--bg-header:var(--crm-surface);
 --text-primary:var(--crm-ink);--text-secondary:var(--crm-muted);--text-muted:var(--crm-muted);--accent:var(--crm-accent);--border:var(--crm-line);--border-light:var(--crm-line);--ios-page:var(--crm-surface);--ios-surface:var(--crm-surface);--composer-bg:var(--crm-surface);--composer-input-bg:var(--crm-surface);--composer-input-border:var(--crm-line);--bubble-in-bg:var(--crm-incoming);--bubble-out-bg:var(--crm-outgoing);--bubble-incoming:var(--crm-incoming);--bubble-outgoing:var(--crm-outgoing);--messages-max-width:100%;--max-bubble-width:min(82%,680px);--sidebar-width:264px;
}
/* CRM owns the visible viewport and safe areas outside this iframe. Its allocated
   height is authoritative even while Safari moves its bars or opens a keyboard. */
html[data-crm-workspace][data-magstyle],
html[data-crm-workspace][data-magstyle] body {height:100%;min-height:0;max-height:100%;overflow:hidden;}
html[data-crm-workspace][data-magstyle] body {background:var(--crm-surface);color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] #auth-screen {height:100%;min-height:0;max-height:100%;}
html[data-crm-workspace][data-magstyle] #app-screen.active {display:flex !important;position:fixed;inset:0;width:100%;height:100%;min-height:0;max-height:100%;padding:0;background:var(--crm-surface);}
html[data-crm-workspace][data-magstyle] #app-screen>.sidebar {position:relative;inset:auto;display:flex;flex:0 0 264px;width:264px;height:100%;border-right:1px solid var(--crm-line);background:var(--crm-surface);transform:none;box-shadow:none;}
html[data-crm-workspace][data-magstyle] #app-screen .sidebar-header {display:flex;align-items:center;justify-content:space-between;flex:0 0 56px;height:56px;min-height:56px;margin-bottom:0;padding:8px 16px;background:var(--crm-surface);}
html[data-crm-workspace][data-magstyle] #sidebar-burger-btn,html[data-crm-workspace][data-magstyle] .ios-style-sidebar-title,html[data-crm-workspace][data-magstyle] .sidebar-footer {display:none !important;}
html[data-crm-workspace][data-magstyle] .sidebar-brand {display:block;font-size:20px;letter-spacing:-.4px;font-weight:750;flex:1;text-align:left;color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .sidebar-brand span:first-child {color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .sidebar-brand span:last-child {color:var(--crm-accent);}
html[data-crm-workspace][data-magstyle] #new-chat-btn {width:36px;height:36px;min-height:36px;padding:8px;border:0;border-radius:6px;background:transparent;box-shadow:none;color:var(--crm-accent);}
html[data-crm-workspace][data-magstyle] .sidebar-search-row {margin:0 12px 8px;padding:7px 10px;background:var(--crm-soft);border:1px solid var(--crm-line);border-radius:6px;}
html[data-crm-workspace][data-magstyle] #search-input {font-size:13px;color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .chat-filters {display:flex;flex-wrap:nowrap;padding:4px 12px 8px;gap:6px;border-bottom:1px solid var(--crm-line);overflow-x:auto;scrollbar-width:none;}
html[data-crm-workspace][data-magstyle] .chat-filter-pill {font-size:11px;padding:7px 9px;border-radius:5px;flex:0 0 auto;white-space:nowrap;}
html[data-crm-workspace][data-magstyle] .chat-filter-pill.active {background:var(--crm-selected);color:var(--crm-accent);}
html[data-crm-workspace][data-magstyle] .chat-list {padding:6px;}
html[data-crm-workspace][data-magstyle] .chat-item,html[data-crm-workspace][data-magstyle] .chat-item.active {margin:0 0 2px;padding:12px 9px;border:0;border-radius:7px;min-height:76px;background:transparent;}
html[data-crm-workspace][data-magstyle] .chat-item:hover {background:var(--crm-soft);}
html[data-crm-workspace][data-magstyle] .chat-item.active {background:var(--crm-selected);}
html[data-crm-workspace][data-magstyle] .chat-item .avatar {width:40px;height:40px;flex:0 0 40px;font-size:14px;}
html[data-crm-workspace][data-magstyle] .chat-name {font-size:13px;font-weight:600;}
html[data-crm-workspace][data-magstyle] .chat-preview {font-size:12px;color:var(--crm-muted);}
html[data-crm-workspace][data-magstyle] .chat-time {font-size:10px;color:var(--crm-muted);}
html[data-crm-workspace][data-magstyle] #app-screen .tab-bar {position:relative;inset:auto;display:flex;flex:0 0 auto;min-height:48px;margin:0;padding:4px 4px calc(4px + var(--crm-frame-safe-bottom,0px));border-radius:0;border:0;border-top:1px solid var(--crm-line);box-shadow:none;background:var(--crm-surface);}
html[data-crm-workspace][data-magstyle] .tab-item {min-height:40px;border-radius:5px;gap:3px;}
html[data-crm-workspace][data-magstyle] .tab-item span {font-size:9px;}
html[data-crm-workspace][data-magstyle] .tab-item svg {width:18px;height:18px;}
html[data-crm-workspace][data-magstyle] #chat-area {position:relative;inset:auto;display:flex;flex:1 1 0;min-width:0;width:auto;min-height:0;height:100%;background:var(--crm-surface);transform:none;border:0;box-shadow:none;}
html[data-crm-workspace][data-magstyle] #chat-area::before {display:block;}
html[data-crm-workspace][data-magstyle] .chat-header {position:relative;top:auto;min-height:60px;height:60px;padding:8px 14px;border-bottom:1px solid var(--crm-line);background:var(--crm-surface);gap:10px;backdrop-filter:none;}
html[data-crm-workspace][data-magstyle] .chat-header .avatar {width:36px;height:36px;flex:0 0 36px;}
html[data-crm-workspace][data-magstyle] .chat-header-name {font-size:15px;font-weight:650;color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .chat-header-status {font-size:11px;color:var(--crm-muted);}
html[data-crm-workspace][data-magstyle] .chat-header .icon-btn {width:34px;height:38px;min-width:34px;color:var(--crm-accent);}
html[data-crm-workspace][data-magstyle] .crm-context-button {font-size:11px;white-space:nowrap;width:auto !important;padding:6px;}
/* Project actions already live in the CRM toolbar and chat header. Do not reserve another row. */
html[data-crm-workspace][data-magstyle] .crm-project-chip {flex:0 0 auto;display:none;margin:10px 16px 0;padding:9px 12px;border:1px solid var(--crm-line);border-radius:6px;background:var(--crm-soft);color:var(--crm-accent);font-size:12px;line-height:1.4;font-family:inherit;text-align:left;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
html[data-crm-workspace][data-magstyle] .crm-project-chip[hidden] {display:none;}
html[data-crm-workspace][data-magstyle] .messages-container {position:relative;inset:auto;flex:1 1 0;min-height:0;background:transparent;padding:12px 0;}
html[data-crm-workspace][data-magstyle] .messages-inner {padding:0 12px;width:100%;}
html[data-crm-workspace][data-magstyle] .message:is(.incoming,.outgoing):not(.call-log-message):not(.system-message) {padding-inline:0;}
html[data-crm-workspace][data-magstyle] .bubble {border-radius:12px;padding:9px 12px 7px;box-shadow:none;color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .message.incoming .bubble {background:var(--crm-incoming);color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .message.outgoing .bubble {background:var(--crm-outgoing);color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .bubble-text {font-size:14px;line-height:1.5;}
html[data-crm-workspace][data-magstyle] .message .bubble .bubble-text {color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .bubble-time {color:var(--crm-muted);}
html[data-crm-workspace][data-magstyle] .composer {position:relative;inset:auto;min-height:66px;height:auto;flex:0 0 auto;gap:8px;padding:10px 14px calc(10px + var(--crm-frame-safe-bottom,0px));border-top:1px solid var(--crm-line);background:var(--crm-surface);}
html[data-crm-workspace][data-magstyle] .composer-input-wrap {background:var(--crm-surface);border:1px solid var(--crm-line);border-radius:22px;box-shadow:none;}
html[data-crm-workspace][data-magstyle] .composer textarea {font-size:14px;color:var(--crm-ink);}
html[data-crm-workspace][data-magstyle] .composer-btn {width:40px;height:40px;min-width:40px;border-radius:8px;background:transparent;box-shadow:none;color:var(--crm-accent);}
html[data-crm-workspace][data-magstyle] .composer-btn.action-btn:not(.is-mic) {background:#07864f;color:#fff;border-radius:50%;}
html[data-crm-workspace][data-magstyle] .attach-menu {position:fixed !important;inset:auto !important;left:var(--crm-attach-left,12px) !important;bottom:var(--crm-attach-bottom,72px) !important;width:220px;max-width:calc(100vw - 24px);max-height:65dvh;overflow:auto;padding:6px;border:1px solid var(--crm-line);border-radius:8px;background:var(--crm-surface);color:var(--crm-ink);box-shadow:0 10px 36px #10263c22;transform:none !important;animation:none !important;}
html[data-crm-workspace][data-magstyle] .attach-option {min-height:40px;padding:10px 12px;border:0;border-radius:5px;color:var(--crm-ink);background:transparent;font-size:13px;line-height:1.4;font-family:inherit;text-align:left;cursor:pointer;}
html[data-crm-workspace][data-magstyle] .crm-attach-option {display:block;width:100%;color:var(--crm-accent);}
html[data-crm-workspace][data-magstyle] .attach-option:hover {background:var(--crm-selected);}
html[data-crm-workspace][data-magstyle] .auth-card {background:var(--crm-surface);color:var(--crm-ink);border-color:var(--crm-line);box-shadow:none;max-width:400px;}
html[data-crm-workspace][data-magstyle] .auth-bg {display:none;}
@media(min-width:701px) {html[data-crm-workspace][data-magstyle] #back-btn {display:none;} }
@media(max-width:700px) {
 html[data-crm-workspace][data-magstyle] #app-screen>.sidebar {flex:1 1 auto;width:100%;max-width:100%;height:100%;}
 html[data-crm-workspace][data-magstyle] #app-screen:not(.chat-open)>#chat-area {display:none;}
 html[data-crm-workspace][data-magstyle] #app-screen.chat-open>.sidebar {display:none;}
 html[data-crm-workspace][data-magstyle] #app-screen.chat-open>#chat-area {display:flex;width:100%;height:100%;}
 html[data-crm-workspace][data-magstyle] #app-screen .sidebar-header {padding:8px 12px;}
 html[data-crm-workspace][data-magstyle] .chat-header {min-height:56px;height:auto;padding:6px;gap:4px;}
 html[data-crm-workspace][data-magstyle] #back-btn {display:flex;min-width:36px;}
 html[data-crm-workspace][data-magstyle] .chat-header .avatar {display:none;}
 html[data-crm-workspace][data-magstyle] .chat-header-name {font-size:14px;}
 html[data-crm-workspace][data-magstyle] .chat-header .icon-btn {width:34px;min-width:34px;}
 html[data-crm-workspace][data-magstyle] .crm-context-button {display:none;}
 html[data-crm-workspace][data-magstyle] .crm-project-chip {margin:8px 10px 0;padding:9px 10px;font-size:11px;}
 html[data-crm-workspace][data-magstyle] .messages-inner {padding:0 8px;}
 html[data-crm-workspace][data-magstyle] .bubble-text {font-size:15px;}
 html[data-crm-workspace][data-magstyle] .composer {padding:8px 8px calc(8px + var(--crm-frame-safe-bottom,0px));gap:5px;min-height:62px;}
 html[data-crm-workspace][data-magstyle] .composer textarea {font-size:16px;}
 html[data-crm-workspace][data-magstyle] #app-screen .tab-bar {min-height:44px;padding:3px 3px calc(3px + var(--crm-frame-safe-bottom,0px));}
 html[data-crm-workspace][data-magstyle] #search-input {font-size:16px;}
}

/* CRM owns app navigation; no standalone switcher shadow inside its workspace. */
html[data-crm-workspace][data-magstyle] :is(#app-switch-drawer,#app-switch-backdrop) {display:none!important;box-shadow:none!important;}
