/* ═══════════════════════════════════════════════════════════════════════════
   SAVVY CHAT — World-class AI chat widget for Localworks
   Every pixel matters. Every interaction delights.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --savvy-primary: #FF8C00;
    --savvy-primary-light: #FFA940;
    --savvy-primary-dark: #E67E00;
    --savvy-navy: #1A1464;
    --savvy-navy-light: #2D2580;
    --savvy-bg: #ffffff;
    --savvy-surface: #f8f9fa;
    --savvy-border: #e9ecef;
    --savvy-text: #1a1a2e;
    --savvy-text-light: #6b7280;
    --savvy-user-bubble: #1A1464;
    --savvy-bot-bubble: #f0f2f5;
    --savvy-success: #10b981;
    --savvy-warning: #f59e0b;
    --savvy-error: #ef4444;
    --savvy-shadow: 0 8px 32px rgba(26, 20, 100, 0.12);
    --savvy-shadow-lg: 0 16px 48px rgba(26, 20, 100, 0.18);
    --savvy-radius: 16px;
    --savvy-radius-sm: 10px;
    --savvy-radius-xs: 6px;
    --savvy-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --savvy-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --savvy-z: 99990;
}

/* ─── FAB (Floating Action Button) ────────────────────────────────────── */

.savvy-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--savvy-primary), var(--savvy-primary-dark));
    border: none;
    cursor: pointer;
    z-index: var(--savvy-z);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(255, 140, 0, 0.35);
    transition: transform var(--savvy-transition), box-shadow var(--savvy-transition);
    outline: none;
}

.savvy-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(255, 140, 0, 0.45);
}

.savvy-fab:active {
    transform: scale(0.95);
}

.savvy-fab svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform var(--savvy-transition);
}

.savvy-fab .fab-mascot {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: contain;
    transition: transform var(--savvy-transition);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.savvy-fab:hover .fab-mascot {
    transform: scale(1.08);
}

.savvy-fab.open .icon-chat { display: none; }
.savvy-fab.open svg.icon-close { display: block; }
.savvy-fab:not(.open) .icon-chat { display: block; }
.savvy-fab:not(.open) svg.icon-close { display: none; }

.savvy-fab .fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(255, 140, 0, 0.25);
    animation: savvy-pulse 2s ease-out infinite;
}

.savvy-fab.open .fab-pulse { display: none; }

@keyframes savvy-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ─── Badge ──────────────────────────────────────────────────────────── */

.savvy-fab .fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: var(--savvy-error);
    border-radius: 50%;
    border: 2px solid white;
    font-size: 10px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: all var(--savvy-transition);
}

.savvy-fab .fab-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* ─── Chat Window ─────────────────────────────────────────────────────── */

.savvy-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-height: calc(100vh - 140px);
    height: 600px;
    background: var(--savvy-bg);
    border-radius: var(--savvy-radius);
    box-shadow: var(--savvy-shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: var(--savvy-z);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-family: var(--savvy-font);
}

.savvy-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ─── Header ──────────────────────────────────────────────────────────── */

.savvy-header {
    background: linear-gradient(135deg, var(--savvy-navy), var(--savvy-navy-light));
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.savvy-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--savvy-primary), var(--savvy-primary-light), var(--savvy-primary));
}

.savvy-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.savvy-header-avatar svg {
    width: 24px;
    height: 24px;
    fill: var(--savvy-primary);
}

.savvy-header-avatar .savvy-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: contain;
}

.savvy-header-info {
    flex: 1;
    min-width: 0;
}

.savvy-header-title {
    color: white;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.savvy-header-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.savvy-header-status .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--savvy-success);
    animation: savvy-status-pulse 2s ease-in-out infinite;
}

@keyframes savvy-status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.savvy-header-actions {
    display: flex;
    gap: 4px;
}

.savvy-header-actions button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--savvy-transition);
}

.savvy-header-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.savvy-header-actions button svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ─── Messages container ──────────────────────────────────────────────── */

.savvy-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--savvy-surface);
}

.savvy-messages::-webkit-scrollbar { width: 4px; }
.savvy-messages::-webkit-scrollbar-track { background: transparent; }
.savvy-messages::-webkit-scrollbar-thumb { background: var(--savvy-border); border-radius: 2px; }

/* ─── Message bubbles ─────────────────────────────────────────────────── */

.savvy-msg {
    max-width: 85%;
    animation: savvy-msg-in 0.3s ease-out;
}

@keyframes savvy-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.savvy-msg.user {
    align-self: flex-end;
}

.savvy-msg.bot {
    align-self: flex-start;
}

.savvy-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.savvy-msg.user .savvy-msg-bubble {
    background: var(--savvy-user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.savvy-msg.bot .savvy-msg-bubble {
    background: var(--savvy-bg);
    color: var(--savvy-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.savvy-msg-bubble strong { font-weight: 600; }
.savvy-msg-bubble em { font-style: italic; }
.savvy-msg-bubble a { color: var(--savvy-primary); text-decoration: underline; }

.savvy-msg-bubble ul, .savvy-msg-bubble ol {
    margin: 6px 0;
    padding-left: 18px;
}

.savvy-msg-bubble ul li, .savvy-msg-bubble ol li {
    margin: 2px 0;
}

.savvy-msg-time {
    font-size: 10px;
    color: var(--savvy-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.savvy-msg.user .savvy-msg-time { text-align: right; }

/* ─── Typing indicator ────────────────────────────────────────────────── */

.savvy-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--savvy-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    animation: savvy-msg-in 0.3s ease-out;
}

.savvy-typing.active { display: flex; align-items: center; gap: 8px; }

.savvy-typing-dots {
    display: flex;
    gap: 4px;
}

.savvy-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--savvy-primary);
    border-radius: 50%;
    animation: savvy-dot-bounce 1.4s ease-in-out infinite;
}

.savvy-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.savvy-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes savvy-dot-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.savvy-typing-text {
    font-size: 12px;
    color: var(--savvy-text-light);
    font-style: italic;
}

/* ─── Product carousel ────────────────────────────────────────────────── */

.savvy-products-wrap {
    position: relative;
}

.savvy-products-wrap .savvy-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--savvy-border);
    background: var(--savvy-bg);
    color: var(--savvy-text);
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    opacity: 0;
    transition: opacity 0.2s;
}
.savvy-products-wrap:hover .savvy-scroll-btn { opacity: 1; }
.savvy-products-wrap .savvy-scroll-btn:hover { background: var(--savvy-primary); color: #fff; }
.savvy-products-wrap .savvy-scroll-btn.left { left: -4px; }
.savvy-products-wrap .savvy-scroll-btn.right { right: -4px; }
.savvy-products-wrap .savvy-scroll-btn[disabled] { display: none; }

@media (max-width: 768px) {
    .savvy-products-wrap .savvy-scroll-btn { display: none; }
}

.savvy-products {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 8px 0;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.savvy-products::-webkit-scrollbar { height: 4px; }
.savvy-products::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); border-radius: 2px; }
.savvy-products::-webkit-scrollbar-thumb { background: var(--savvy-primary); border-radius: 2px; opacity: 0.5; }

.savvy-product-card {
    flex: 0 0 160px;
    scroll-snap-align: start;
    background: var(--savvy-bg);
    border-radius: var(--savvy-radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform var(--savvy-transition), box-shadow var(--savvy-transition);
    cursor: pointer;
    border: 1px solid var(--savvy-border);
}

.savvy-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.savvy-product-card .card-img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    background: #fafafa;
    padding: 8px;
}

.savvy-product-card .card-body {
    padding: 10px;
}

.savvy-product-card .card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--savvy-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.savvy-product-card .card-brand {
    font-size: 10px;
    color: var(--savvy-text-light);
    margin-bottom: 6px;
}

.savvy-product-card .card-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--savvy-primary-dark);
}

.savvy-product-card .card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.savvy-product-card .card-btn {
    flex: 1;
    padding: 6px 8px;
    border: none;
    border-radius: var(--savvy-radius-xs);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--savvy-transition);
    text-align: center;
}

.savvy-product-card .card-btn.primary {
    background: var(--savvy-primary);
    color: white;
}

.savvy-product-card .card-btn.primary:hover {
    background: var(--savvy-primary-dark);
}

.savvy-product-card .card-btn.secondary {
    background: var(--savvy-surface);
    color: var(--savvy-text);
    border: 1px solid var(--savvy-border);
}

.savvy-product-card .card-btn.secondary:hover {
    background: var(--savvy-border);
}

/* ─── Upsell section ──────────────────────────────────────────────────── */

.savvy-upsells {
    margin-top: 8px;
    padding: 10px;
    background: linear-gradient(135deg, #fff7ed, #fff3e0);
    border-radius: var(--savvy-radius-sm);
    border: 1px solid #fed7aa;
}

.savvy-upsells-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--savvy-primary-dark);
    margin-bottom: 8px;
}

.savvy-upsell-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: var(--savvy-radius-xs);
    cursor: pointer;
    transition: background var(--savvy-transition);
}

.savvy-upsell-item:hover { background: rgba(255, 140, 0, 0.08); }

.savvy-upsell-item img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: contain;
    background: white;
}

.savvy-upsell-item .upsell-info {
    flex: 1;
    min-width: 0;
}

.savvy-upsell-item .upsell-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.savvy-upsell-item .upsell-price {
    font-size: 11px;
    font-weight: 700;
    color: var(--savvy-primary-dark);
}

/* ─── Action chips / suggestions ──────────────────────────────────────── */

.savvy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.savvy-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--savvy-primary);
    background: transparent;
    color: var(--savvy-primary-dark);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--savvy-transition);
    white-space: nowrap;
}

.savvy-chip:hover {
    background: var(--savvy-primary);
    color: white;
    transform: translateY(-1px);
}

.savvy-chip.link {
    border-color: var(--savvy-navy);
    color: var(--savvy-navy);
}

.savvy-chip.link:hover {
    background: var(--savvy-navy);
    color: white;
}

.savvy-chip.loyalty {
    border-color: var(--savvy-success);
    color: #059669;
    background: #ecfdf5;
}

.savvy-chip.loyalty:hover {
    background: var(--savvy-success);
    color: white;
}

/* ─── Rich message cards ──────────────────────────────────────────────── */

.savvy-loyalty-card {
    background: linear-gradient(135deg, var(--savvy-navy), var(--savvy-navy-light));
    border-radius: var(--savvy-radius-sm);
    padding: 16px;
    color: white;
    margin-top: 8px;
}

.savvy-loyalty-card .lc-tier {
    font-size: 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.savvy-loyalty-card .lc-points {
    font-size: 14px;
    opacity: 0.8;
    margin-top: 4px;
}

.savvy-loyalty-card .lc-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    margin-top: 10px;
    overflow: hidden;
}

.savvy-loyalty-card .lc-bar-fill {
    height: 100%;
    background: var(--savvy-primary);
    border-radius: 3px;
    transition: width 1s ease;
}

.savvy-order-card {
    background: var(--savvy-bg);
    border: 1px solid var(--savvy-border);
    border-radius: var(--savvy-radius-sm);
    padding: 12px;
    margin-top: 6px;
}

.savvy-order-card .oc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.savvy-order-card .oc-number {
    font-weight: 700;
    font-size: 13px;
}

.savvy-order-card .oc-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.savvy-order-card .oc-status.processing { background: #fef3c7; color: #92400e; }
.savvy-order-card .oc-status.shipped { background: #dbeafe; color: #1d4ed8; }
.savvy-order-card .oc-status.delivered { background: #d1fae5; color: #065f46; }

/* ─── Welcome screen ─────────────────────────────────────────────────── */

.savvy-welcome {
    text-align: center;
    padding: 32px 20px 16px;
}

.savvy-welcome-emoji {
    font-size: 40px;
    margin-bottom: 12px;
}

.savvy-welcome h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--savvy-text);
    margin: 0 0 8px;
}

.savvy-welcome p {
    font-size: 13px;
    color: var(--savvy-text-light);
    margin: 0 0 20px;
    line-height: 1.5;
}

.savvy-welcome-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.savvy-welcome-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--savvy-bg);
    border: 1.5px solid var(--savvy-border);
    border-radius: var(--savvy-radius-sm);
    cursor: pointer;
    transition: all var(--savvy-transition);
    font-family: var(--savvy-font);
}

.savvy-welcome-btn:hover {
    border-color: var(--savvy-primary);
    background: #fff8f0;
    transform: translateY(-1px);
}

.savvy-welcome-btn .wb-icon {
    font-size: 20px;
}

.savvy-welcome-btn .wb-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--savvy-text);
}

/* ─── Input area ──────────────────────────────────────────────────────── */

.savvy-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--savvy-border);
    background: var(--savvy-bg);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.savvy-input {
    flex: 1;
    border: 1.5px solid var(--savvy-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--savvy-font);
    outline: none;
    background: var(--savvy-surface);
    transition: border-color var(--savvy-transition), box-shadow var(--savvy-transition);
    color: var(--savvy-text);
    min-width: 0;
}

.savvy-input:focus {
    border-color: var(--savvy-primary);
    box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.1);
    background: var(--savvy-bg);
}

.savvy-input::placeholder { color: #adb5bd; }

.savvy-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--savvy-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--savvy-transition);
    flex-shrink: 0;
}

.savvy-send-btn:hover {
    background: var(--savvy-primary-dark);
    transform: scale(1.05);
}

.savvy-send-btn:disabled {
    background: var(--savvy-border);
    cursor: not-allowed;
    transform: none;
}

.savvy-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ─── Powered by footer ───────────────────────────────────────────────── */

.savvy-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: var(--savvy-text-light);
    background: var(--savvy-bg);
    border-top: 1px solid var(--savvy-border);
}

.savvy-powered a {
    color: var(--savvy-primary);
    text-decoration: none;
    font-weight: 600;
}

/* ─── Proactive trigger bubble ────────────────────────────────────────── */

.savvy-proactive {
    position: fixed;
    bottom: 96px;
    right: 24px;
    background: var(--savvy-bg);
    border-radius: 16px 16px 4px 16px;
    padding: 12px 16px;
    max-width: 280px;
    box-shadow: var(--savvy-shadow);
    z-index: calc(var(--savvy-z) - 1);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    font-family: var(--savvy-font);
    font-size: 13px;
    color: var(--savvy-text);
    line-height: 1.4;
}

.savvy-proactive.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.savvy-proactive .proactive-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    color: var(--savvy-text-light);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

/* ─── Context indicator ───────────────────────────────────────────────── */

.savvy-context-bar {
    padding: 6px 14px;
    background: #fff8f0;
    border-bottom: 1px solid #fed7aa;
    font-size: 11px;
    color: var(--savvy-primary-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.savvy-context-bar svg { width: 12px; height: 12px; fill: var(--savvy-primary); }

/* ─── Mobile responsive ───────────────────────────────────────────────── */

/* ── Foldable / Small Tablet (481–768px) ──────────────────────────── */
@media (max-width: 768px) and (min-width: 481px) {
    .savvy-fab {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .savvy-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100vw;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .savvy-window.open {
        transform: translateY(0);
    }

    .savvy-proactive {
        bottom: 88px;
        right: 20px;
        left: 20px;
        max-width: none;
    }

    .savvy-product-card {
        flex: 0 0 150px;
    }

    .savvy-welcome-actions {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .savvy-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

/* ── Small Mobile (≤480px) ────────────────────────────────────────── */
@media (max-width: 480px) {
    .savvy-fab {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .savvy-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100vw;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .savvy-window.open {
        transform: translateY(0);
    }

    .savvy-proactive {
        bottom: 80px;
        right: 16px;
        left: 16px;
        max-width: none;
    }

    .savvy-product-card {
        flex: 0 0 140px;
    }

    .savvy-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .savvy-welcome-actions {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .savvy-welcome-btn {
        padding: 10px 6px;
    }

    .savvy-welcome-btn .wb-label {
        font-size: 11px;
    }
}

/* ── Tiny Mobile (≤360px) ─────────────────────────────────────────── */
@media (max-width: 360px) {
    .savvy-fab {
        bottom: 12px;
        right: 12px;
        width: 48px;
        height: 48px;
    }

    .savvy-fab .fab-mascot {
        width: 34px;
        height: 34px;
    }

    .savvy-header {
        padding: 12px 14px;
    }

    .savvy-header-title {
        font-size: 14px;
    }

    .savvy-product-card {
        flex: 0 0 130px;
    }

    .savvy-welcome h3 {
        font-size: 16px;
    }

    .savvy-welcome p {
        font-size: 12px;
    }
}

/* ── Safe Area (notched phones) ───────────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .savvy-input-area {
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }

        .savvy-fab {
            bottom: max(16px, env(safe-area-inset-bottom));
            right: max(16px, env(safe-area-inset-right));
        }
    }
}

/* ── Landscape Mobile ─────────────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    .savvy-window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .savvy-welcome {
        padding: 16px 20px 8px;
    }

    .savvy-welcome-emoji {
        font-size: 28px;
        margin-bottom: 6px;
    }
}

/* ─── Dark mode support ───────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    .savvy-window {
        --savvy-bg: #1a1a2e;
        --savvy-surface: #16162a;
        --savvy-border: #2d2d4a;
        --savvy-text: #e8e8f0;
        --savvy-text-light: #8b8ba0;
        --savvy-bot-bubble: #22223a;
    }
}

/* ─── Streaming cursor ────────────────────────────────────────────────── */

.savvy-streaming .savvy-msg-bubble::after {
    content: '▊';
    animation: savvy-cursor-blink 0.7s step-end infinite;
    color: var(--savvy-primary);
    font-weight: 100;
}

@keyframes savvy-cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ─── Search engine badge ─────────────────────────────────────────────── */

.savvy-engine-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

.savvy-engine-badge.es { background: #dbeafe; color: #1d4ed8; }
.savvy-engine-badge.sql { background: #e5e7eb; color: #6b7280; }

/* ─── Reduced motion ──────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .savvy-fab, .savvy-window, .savvy-msg, .savvy-chip, .savvy-product-card,
    .savvy-proactive, .savvy-typing-dots span {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
