@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #f7fbff;
    --primary-blue: #2f80ed;
    --text-dark: #212121;
    --text-muted: #8d8d8d;
    --bubble-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    height: 100vh;
    height: 100dvh; /* dynamic viewport: excludes mobile browser chrome + shrinks for keyboard */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Main Container matching Desktop layout */
.chat-container {
    width: 100%;
    max-width: 1280px;
    height: 100vh;
    height: 100dvh;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 20px 40px;
    background-color: var(--bg-main);
}

/* Start Screen Greeting Layout */
.start-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-main);
    z-index: 10;
    transition: opacity 0.5s ease, visibility 0.5s;
    padding: 40px;
}

.start-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.greeting-text {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 40px;
    text-align: center;
    animation: fadeInDown 0.6s ease;
}

.greeting-text span.highlight {
    color: #f4c542;
}

.large-input-box {
    width: 100%;
    max-width: 872px;
    height: 152px;
    border: 2px solid var(--primary-blue);
    border-radius: 20px;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 16px;
    position: relative;
    box-shadow: 0 8px 24px rgba(47, 128, 237, 0.1);
    animation: fadeInUp 0.6s ease;
    transition: var(--transition-smooth);
}

.large-input-box:focus-within {
    box-shadow: 0 12px 32px rgba(47, 128, 237, 0.2);
}

.large-textarea {
    width: 100%;
    flex: 1;
    border: none;
    outline: none;
    font-size: 18px;
    font-family: inherit;
    resize: none;
    color: var(--text-dark);
}

.large-textarea::placeholder {
    color: #a8a8a8;
}

.large-input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

/* Attachment plus buttons popups */
.plus-container {
    position: relative;
}

.plus-popup {
    position: absolute;
    bottom: 60px;
    left: 0;
    width: 180px;
    background-color: var(--primary-blue);
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition-smooth);
}

.plus-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.plus-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    transition: var(--transition-smooth);
}

.plus-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Virtual Try On menu lock (no try-on product available): the entry is
   disabled and visibly muted so it reads as inaccessible, not just inert. */
.plus-item:disabled,
.plus-item-mobile:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.plus-item img, .plus-item svg {
    width: 20px;
    height: 20px;
}

/* Chat Main Layout */
.chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s;
}

.chat-main.visible {
    opacity: 1;
    visibility: visible;
}

/* Top Header */
.chat-header {
    display: flex;
    justify-content: space-between; /* left slot = bot identity, right slot = status */
    align-items: center;
    height: 60px;
    padding-bottom: 10px;
    gap: 12px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.status-text {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    -webkit-user-select: none;
    user-select: none;
}

/* Connection-state dot (6.1.5): color is driven by the connected/reconnecting/
   disconnected class via currentColor, so the glow + pulse ring follow the state. */
.status-dot {
    width: 12px;
    height: 12px;
    background-color: currentColor;
    border-radius: 50%;
    position: relative;
    color: #2ecc71;
    box-shadow: 0 0 8px currentColor;
}
.status-dot.connected { color: #2ecc71; }
.status-dot.reconnecting { color: #f59e0b; }
.status-dot.disconnected { color: #ef4444; }

.status-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid currentColor;
    border-radius: 50%;
    animation: pulse 2s infinite;
    opacity: 0;
}
.status-dot.disconnected::after { animation: none; }
.status-dot.reconnecting::after { animation: pulse 1s infinite; }

/* ---- Chat-header bot identity (driven by applyAgentCustomization) ----
   Left slot = avatar + name; right slot = the existing status-indicator. */
.chat-identity {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0; /* lets .bot-name truncate instead of pushing the status off-edge */
}
/* Initial-letter fallback only (no logo set / broken logo URL). A configured
   logo renders as a bare img.bot-logo — no circle, no background wrapper. */
.bot-avatar {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background-color: var(--primary-blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.bot-avatar--initial { background-color: var(--primary-blue); }
.bot-logo {
    flex: 0 0 auto;
    height: 36px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    display: block;
}
.bot-initial {
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    line-height: 1;
    text-transform: uppercase;
    -webkit-user-select: none;
    user-select: none;
}
.bot-name {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}

@keyframes pulse {
    0% {
        transform: scale(0.9);
        opacity: 1;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Chat History Window */
.chat-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain; /* stop pull-to-refresh / scroll chaining on mobile */
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar for Chat History */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(47, 128, 237, 0.2);
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(47, 128, 237, 0.4);
}

/* Message Rows */
.message-row {
    display: flex;
    width: 100%;
    animation: fadeInUp 0.4s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot {
    justify-content: flex-start;
}

/* Bubbles */
.message-bubble {
    max-width: 80%;
    width: fit-content;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    font-size: 1.1rem;
    line-height: 1.6;
    position: relative;
    box-shadow: var(--bubble-shadow);
}

.user .message-bubble {
    background-color: var(--primary-blue);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 20px 5px 20px 20px;
    font-weight: 500;
}

/* Direct Virtual Try-On "request" bubble (user side). A structured action card,
   NOT prose: signals the user picked a product + photo in the try-on modal.
   Deliberately breaks the solid-blue user fill to tie visually to the catalog /
   try-on system (#e8f0fe header + --primary-blue accents + white body) -- the
   same language as the catalog cards / "Lihat Semua Produk" chip. The right-
   aligned tail (20px 5px 20px 20px) is preserved so it still reads as the user's
   turn, never as a bot bubble. */
.user .message-bubble.tryon-request--catalog {
    background-color: #ffffff;
    color: var(--text-dark);
    padding: 0;
    overflow: hidden;
    border-radius: 20px 5px 20px 20px;
    border: 1px solid rgba(47, 128, 237, 0.18);
    box-shadow: var(--bubble-shadow);
    max-width: 300px;
    width: fit-content;
    font-weight: 400;
}
.tryon-request--catalog .tryon-request-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background-color: #e8f0fe;
    border-bottom: 1px solid rgba(47, 128, 237, 0.12);
}
.tryon-request--catalog .tryon-request-iconwrap {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--primary-blue);
}
.tryon-request--catalog .tryon-request-iconwrap img {
    width: 16px;
    height: 16px;
    display: block;
    --stroke-0: #ffffff; /* star reads white inside the filled blue badge */
}
.tryon-request--catalog .tryon-request-headtext {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.tryon-request--catalog .tryon-request-eyebrow {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary-blue);
}
.tryon-request--catalog .tryon-request-action {
    font-size: 11px;
    color: var(--text-muted, #8d8d8d);
}
/* Body becomes a column: the product->photo circle row on top, the product-name
   caption below. (The old 64px SQUARE thumbnail + the header selfie are gone --
   the right-hand photo circle is now the single source of truth for the user
   photo.) */
.tryon-request--catalog .tryon-request-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px;
}
/* Stale square thumbnail must never render alongside the new circles. */
.tryon-request--catalog .tryon-request-pic { display: none; }

/* Two-circle placement row: (PRODUCT) -> (PHOTO), arrow between. Bottom padding
   leaves room for the absolutely-positioned tiny labels under each circle. */
.tryon-request--catalog .tryon-request-circles {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 4px 20px;
}
/* Shared circle: 64px round. NO overflow:hidden here (would clip the label that
   sits just below) -- the inner <img> clips itself via border-radius:50%. */
.tryon-request--catalog .tryon-request-circle {
    position: relative;
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f3f5f8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
}
.tryon-request--catalog .tryon-request-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}
/* Photo (right) circle gets a primary-blue ring so it reads as "the you slot". */
.tryon-request--catalog .tryon-request-circle--photo {
    box-shadow: 0 2px 8px rgba(47, 128, 237, 0.28), 0 0 0 2px rgba(47, 128, 237, 0.45);
}
/* Null-product / null-photo placeholder: solid primary-blue disc + white star.
   tryon_star.svg reads white via --stroke-0 (same trick as the header badge). */
.tryon-request--catalog .tryon-request-circle-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--primary-blue);
}
.tryon-request--catalog .tryon-request-circle-ph--muted {
    background: #c9d4e2;
}
.tryon-request--catalog .tryon-request-circle-ph img {
    width: 28px;
    height: 28px;
    --stroke-0: #ffffff;
}
/* Tiny caption under each circle (Produk / Kamu). */
.tryon-request--catalog .tryon-request-circle-label {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .3px;
    color: var(--text-muted, #8d8d8d);
    white-space: nowrap;
}
/* Arrow connector: chevron in a small catalog-blue-tint pill. */
.tryon-request--catalog .tryon-request-arrow {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #e8f0fe;
    color: var(--primary-blue);
}
.tryon-request--catalog .tryon-request-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.35;
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    padding: 0 4px;
}
@media (max-width: 768px) {
    .user .message-bubble.tryon-request--catalog {
        max-width: 80%;
        border-radius: 16px 4px 16px 16px;
    }
    .tryon-request--catalog .tryon-request-circle { width: 56px; height: 56px; }
    .tryon-request--catalog .tryon-request-circle-ph img { width: 24px; height: 24px; }
    .tryon-request--catalog .tryon-request-arrow { width: 26px; height: 26px; }
    .tryon-request--catalog .tryon-request-arrow svg { width: 18px; height: 18px; }
}

.bot .message-bubble-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 85%;
}

.bot .message-bubble {
    background-color: #ffffff;
    color: var(--text-dark);
    padding: 20px 28px;
    border-radius: 5px 20px 20px 20px;
    font-weight: 400;
}

.bot .message-bubble p {
    margin-bottom: 12px;
}

.bot .message-bubble p:last-child {
    margin-bottom: 0;
}

/* User-attached image inside a chat bubble. Constrained on BOTH axes with auto
   dimensions so the whole photo shows at its true aspect ratio — never cropped
   or squeezed (gepeng), and never large enough to break the bubble layout. */
.attached-img {
    display: block;
    max-width: 240px;
    max-height: 320px;
    width: auto;
    height: auto;
    margin-top: 8px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* On the solid-color user bubble a faint border keeps the image edge legible. */
.user .attached-img {
    border: 2px solid rgba(255, 255, 255, 0.45);
}

/* --- Rendered markdown content inside bot bubbles --- */
.bot .message-bubble h1,
.bot .message-bubble h2,
.bot .message-bubble h3,
.bot .message-bubble h4 {
    line-height: 1.25;
    font-weight: 700;
    margin: 14px 0 8px;
}
.bot .message-bubble h1 { font-size: 1.5rem; }
.bot .message-bubble h2 { font-size: 1.3rem; }
.bot .message-bubble h3 { font-size: 1.15rem; }
.bot .message-bubble h4 { font-size: 1.05rem; }
.bot .message-bubble h1:first-child,
.bot .message-bubble h2:first-child,
.bot .message-bubble h3:first-child,
.bot .message-bubble h4:first-child { margin-top: 0; }

.bot .message-bubble ul,
.bot .message-bubble ol {
    margin: 0 0 12px;
    padding-left: 22px;
}
.bot .message-bubble li { margin-bottom: 4px; }

.bot .message-bubble blockquote {
    border-left: 3px solid var(--primary-blue);
    margin: 0 0 12px;
    padding: 4px 14px;
    color: #555;
    background-color: rgba(47, 128, 237, 0.05);
    border-radius: 0 8px 8px 0;
}

.bot .message-bubble hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 14px 0;
}

.bot .message-bubble a {
    color: var(--primary-blue);
    text-decoration: underline;
    word-break: break-word;
}

.bot .message-bubble code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9em;
    background-color: rgba(47, 128, 237, 0.1);
    color: #1b6fd1;
    padding: 2px 6px;
    border-radius: 6px;
}

.bot .message-bubble pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: 12px;
    overflow-x: auto;
    max-width: 100%;
    margin: 0 0 12px;
}
.bot .message-bubble pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 0.88em;
    border-radius: 0;
}

/* Tables: scroll-contained so any column count fits inside the bubble */
.bot .message-bubble .table-wrap {
    overflow-x: auto;
    max-width: 100%;
    margin: 0 0 12px;
}
.bot .message-bubble table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.bot .message-bubble thead th {
    background-color: rgba(47, 128, 237, 0.1);
    font-weight: 600;
}
.bot .message-bubble th,
.bot .message-bubble td {
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}
.bot .message-bubble tbody tr:nth-child(even) td {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Inline images inside bot content must never overflow the bubble */
.bot .message-bubble img { max-width: 100%; }

/* --- Typing indicator (three-dot loading bubble) --- */
.bot .message-bubble.typing-bubble {
    padding: 16px 22px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    display: inline-block;
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Disabled composer while the agent is processing. The + (Add Attachment) buttons
   are locked alongside Send so a turn can't be interrupted by opening an attach
   menu mid-processing -- they share the same disabled look for symmetry. */
.send-btn.disabled,
.send-btn:disabled,
.add-btn.disabled,
.add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.chat-input:disabled {
    background-color: #f3f5f8;
    cursor: not-allowed;
}

/* Attached file chip inside user messages (see .attached-img above for images). */
.attached-file-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 10px 16px;
    border-radius: 10px;
    margin-top: 8px;
}

.attached-file-icon {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

/* Action Controls (Copy, Reload) */
.message-actions {
    display: flex;
    gap: 12px;
    padding-left: 8px;
    align-items: center;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition-smooth);
    opacity: 0.6;
}

.action-btn:hover {
    opacity: 1;
    background-color: rgba(47, 128, 237, 0.1);
}

.action-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--text-dark);
    transition: var(--transition-smooth);
}

.action-btn.copy-btn.copied svg {
    fill: #2ecc71;
}

/* Catalog Scroll Container */
.catalog-container {
    background-color: var(--primary-blue);
    border-radius: 20px;
    padding: 18px;
    margin-top: 15px;
    width: 100%;
    overflow: hidden;
}

.catalog-track {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    scroll-behavior: smooth;
    align-items: center;
}

/* Custom Scrollbar for Catalog */
.catalog-track::-webkit-scrollbar {
    height: 6px;
}

.catalog-track::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.catalog-track::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 10px;
}

.catalog-track::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.7);
}

/* Product Card */
.product-card {
    flex: 0 0 163px;
    width: 163px;
    height: 164px;
    background-color: #ffffff;
    border-radius: 15px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-dark);
    transition: var(--transition-smooth);
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.product-image-wrapper {
    width: 100%;
    height: 90px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
    position: relative;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.product-card:hover .product-image {
    transform: scale(1.08);
}

.product-title {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    margin-bottom: 2px;
}

.product-price {
    font-size: 10px;
    font-weight: 500;
    color: var(--primary-blue);
    text-align: center;
}

/* "Lihat Lainnya" / "+1" Card */
.more-card {
    flex: 0 0 163px;
    width: 163px;
    height: 164px;
    border: 1.5px dashed rgba(255, 255, 255, 0.6);
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.more-card:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: #ffffff;
}

.more-icon-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 8px;
}

.more-title {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
}

.more-subtitle {
    font-size: 8px;
    opacity: 0.8;
}

/* Chat Input Area */
.chat-input-area {
    padding: 20px 0;
    display: flex;
    flex-direction: column; /* stack the quick-access rail above the input pill */
    align-items: center;
    justify-content: center;
    gap: 14px; /* rail <-> input pill spacing (was 10px; comfortable + consistent with the start screen) */
    position: relative; /* anchor for the #pending-preview attachment overlay */
}

/* Held-attachment preview: a floating chip ABOVE the input row. It overlays the
   bottom edge of the chat history without shoving the plus / input / send row
   sideways, and carries its own cancel (x) button so the user can drop the
   attachment before sending. JS only toggles `display`; everything else lives here. */
#pending-preview {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    margin: 0 auto 6px;
    width: calc(100% - 24px);
    max-width: 848px;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 8px 8px;
    background: #ffffff;
    border: 1px solid #e3e8ef;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
    z-index: 20;
    animation: pp-pop 0.18s ease-out;
}
@keyframes pp-pop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.pp-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    flex: 0 0 auto;
    background: #f3f5f8;
}
.pp-thumb--file {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #64748b;
    background: #e5e7eb;
}
.pp-label {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pp-remove {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #eef1f6;
    color: #475569;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition-smooth), color var(--transition-smooth);
}
.pp-remove:hover { background: #e03131; color: #fff; }
.pp-remove:focus-visible { outline: 2px solid var(--primary-blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    #pending-preview { animation: none; }
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 872px;
    height: 58px;
    border: 2px solid var(--primary-blue);
    border-radius: 36px;
    padding: 0 8px;
    background-color: #ffffff;
    box-shadow: 0 4px 10px rgba(47, 128, 237, 0.1);
    transition: var(--transition-smooth);
    position: relative;
}

.chat-input-wrapper:focus-within {
    box-shadow: 0 4px 18px rgba(47, 128, 237, 0.25);
    transform: translateY(-1px);
}

.add-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.add-btn:hover {
    background-color: rgba(47, 128, 237, 0.1);
}

/* No hover halo while the + button is locked (agent working / direct try-on). */
.add-btn.disabled:hover,
.add-btn:disabled:hover {
    background-color: transparent;
}

.add-btn img {
    width: 20px;
    height: 20px;
}

.chat-input {
    flex: 1;
    height: 100%;
    border: none;
    outline: none;
    padding: 0 16px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-dark);
}

.chat-input::placeholder {
    color: #a8a8a8;
}

.send-btn {
    background-color: var(--primary-blue);
    border: none;
    color: #ffffff;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-right: 4px;
}

.send-btn:hover {
    background-color: #1b6fd1;
    transform: scale(1.02);
}

/* ===== Quick-access chips (above the chat input) =====
   Tappable shortcuts that sit in the thumb zone, just above the input pill.
   Today: "Lihat Semua Produk" -- pushes the FULL catalog into the chat WITHOUT
   invoking the LLM (server-side WS bypass; see _catalog_all_frame). The chip
   wears the catalog's own blue identity (--primary-blue on a #e8f0fe tint) so it
   visually previews the blue carousel it summons -- a deliberate tie, not a
   generic gray pill. Built as a horizontal rail so more chips can be added. */
.quick-access {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 872px;          /* match the input pill width */
    overflow-x: auto;
    scrollbar-width: none;     /* Firefox */
    padding: 0 2px;
}
.quick-access::-webkit-scrollbar { display: none; }

/* Start-screen-only rail: the greeting screen stacks the rail directly above the
   large input box with no parent gap, so the chip<->input spacing lives here.
   The main-chat footer wears bare .quick-access and gets its spacing from the
   .chat-input-area flex gap instead -- the two mechanisms never overlap. */
.quick-access--start {
    margin-bottom: 14px;
}

.qa-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;          /* mobile touch-target floor (Apple 44pt / Material 48dp) */
    padding: 7px 16px 7px 7px;
    border: 1px solid rgba(47, 128, 237, 0.18);
    border-radius: 999px;
    background-color: #e8f0fe; /* catalog-blue tint */
    color: var(--text-dark);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-smooth);
    -webkit-user-select: none;
    user-select: none;
}

/* The filled blue badge holds the glyph; white stroke reads on the solid fill. */
.qa-chip-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--primary-blue);
    color: #ffffff;
}
.qa-chip-icon svg { width: 16px; height: 16px; }

.qa-chip-label { white-space: nowrap; }

.qa-chip:hover { background-color: rgba(47, 128, 237, 0.16); transform: translateY(-1px); }
.qa-chip:active { transform: scale(0.98); }
.qa-chip:focus-visible { outline: 2px solid var(--primary-blue); outline-offset: 2px; }
.qa-chip:disabled,
.qa-chip.disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Loading state while the catalog is being fetched: a spinner replaces the glyph. */
.qa-chip.loading { opacity: 0.9; cursor: progress; }
.qa-chip-spinner {
    display: block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: qa-chip-spin 0.7s linear infinite;
}
@keyframes qa-chip-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .qa-chip:hover, .qa-chip:active { transform: none; }
    .qa-chip-spinner { animation-duration: 1.6s; }
}

/* Product Detail Modal Style */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none; /* visibility would cut the card's transform animation short */
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--bg-main);
    width: 1119px;
    height: 661px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    position: relative;
    display: flex;
    overflow: hidden;
    animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Left details area */
.modal-left {
    flex: 1;
    padding: 32px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title-small {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.modal-title-small svg {
    width: 18px;
    height: 18px;
}

.modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.modal-close-btn img {
    width: 16px;
    height: 16px;
}

.modal-product-name {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.modal-product-price {
    font-size: 28px;
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: 24px;
}

.modal-description-box {
    background-color: #dee6ef;
    border-radius: 20px;
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
    margin-bottom: 24px;
}

/* Scrollbar inside description box */
.modal-description-box::-webkit-scrollbar {
    width: 8px;
}

.modal-description-box::-webkit-scrollbar-track {
    background: #c7cdd3;
    border-radius: 10px;
}

.modal-description-box::-webkit-scrollbar-thumb {
    background: #acb9c5;
    border-radius: 10px;
}

.modal-description-title {
    font-size: 15px;
    font-weight: 600;
    color: #656262;
    margin-bottom: 12px;
}

.modal-description-content {
    font-size: 13px;
    line-height: 1.6;
    color: #212121;
}

.modal-description-content p {
    margin-bottom: 10px;
}

.modal-description-content ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

/* ===== Product Details spec section (inside .modal-description-box) ===== */
/* Prefixed modal-details- to stay local to the description box and never
   collide with the frozen modal selectors. Reuses :root tokens + the panel
   greys so it reads as part of the existing design. */
.modal-details-section {
    margin-top: 18px;
}

/* Peer of .modal-description-title: identical treatment so "Product Details"
   sits as a sibling section label of "Product Description". */
.modal-details-title {
    font-size: 15px;
    font-weight: 600;
    color: #656262;
    margin-bottom: 12px;
}

/* The spec card: a semantic <dl> styled as a white sub-card on the #dee6ef
   panel with the reused 3px primary-blue left-accent and a faint lift. */
.modal-details-grid {
    margin: 0;
    background: #ffffff;
    border-radius: 12px;
    padding: 6px 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border-left: 3px solid var(--primary-blue);
}

/* Each row is its own 2-column grid (fixed 130px label column -> values align
   across rows). Self-contained rows avoid display:contents and stay styleable. */
.modal-details-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 6px 16px;
    padding: 8px 0;
}

.modal-details-row + .modal-details-row {
    border-top: 1px solid #e2e8f0;
}

.modal-details-label {
    margin: 0;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    line-height: 1.6;
    align-self: start;
}

.modal-details-value {
    margin: 0;            /* reset <dd> default margin-inline-start */
    color: var(--text-dark);
    font-weight: 600;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
    transition: var(--transition-smooth);
}

.modal-details-value:hover {
    color: var(--primary-blue);
}

.modal-select-btn {
    width: 100%;
    height: 60px;
    background: linear-gradient(90deg, #1ba0e2 0%, #2f80ed 100%);
    border: none;
    border-radius: 10px;
    color: #ffffff;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-select-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(47, 128, 237, 0.3);
}

/* ===== Virtual Try-On PHOTO CONFIRMATION popup ===== */
/* Stack ABOVE the tryon overlay. .modal-overlay is position:fixed + z-index:100
   + backdrop-filter => it creates a STACKING CONTEXT at root level 100. The
   mobile .tryon-phone-card's z-index:2000 is scoped INSIDE that context, so it
   cannot escape level 100. A sibling confirm overlay at 150 therefore beats
   the WHOLE tryon overlay (incl. the z-2000 phone card) on both desktop & mobile.
   150 (not 3000): 3000 is taken by .toast-container, which should stay on top
   of everything ("Kamera sedang bersiap" etc. must show over the popup). */
#tryon-confirm { z-index: 150; }

.tryon-confirm-card {
    background-color: var(--bg-main);
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 22px 22px 18px;
    animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.tryon-confirm-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
}
.tryon-confirm-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 40px; /* clear the X */
    margin-bottom: 4px;
}
.tryon-confirm-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--primary-blue);
}
.tryon-confirm-badge svg { width: 16px; height: 16px; fill: #ffffff; }
.tryon-confirm-body {
    margin: 4px 0 14px;
    padding-right: 40px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
}
/* Large photo preview. 4:5 portrait (face/hand try-on photos), object-fit cover. */
.tryon-confirm-preview {
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #eef3f9;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.10);
    margin-bottom: 14px;
}
.tryon-confirm-photo {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    max-height: 46vh;
    object-fit: cover;
    background: #dee6ef;
}
/* Product context strip: catalog-blue-tint + round thumb + primary-blue eyebrow. */
.tryon-confirm-product {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background-color: #e8f0fe;
    border-radius: 12px;
    margin-bottom: 18px;
}
.tryon-confirm-product-thumb {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.tryon-confirm-product-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}
.tryon-confirm-product-eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--primary-blue);
}
.tryon-confirm-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* Actions: Reject (secondary outline) + Accept reuses .modal-select-btn's blue
   gradient, shrunk to fit a 2-up row. */
.tryon-confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}
.tryon-confirm-actions .modal-select-btn {
    position: static; /* override the product-modal mobile rule (.modal-select-btn{position:absolute}) which this class also inherits */
    width: auto;
    flex: 1 1 auto;
    height: 50px;
    font-size: 15px;
    border-radius: 12px;
}
.tryon-confirm-reject {
    flex: 0 0 auto;
    min-width: 130px;
    height: 50px;
    padding: 0 16px;
    border-radius: 12px;
    border: 2px solid var(--primary-blue);
    background: #ffffff;
    color: var(--primary-blue);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.tryon-confirm-reject:hover { background: #e8f0fe; }
.tryon-confirm-reject:focus-visible,
.tryon-confirm-actions .modal-select-btn:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}
@media (max-width: 768px) {
    .tryon-confirm-card { width: calc(100vw - 24px); padding: 18px 16px 14px; }
    .tryon-confirm-photo { max-height: 40vh; }
    .tryon-confirm-actions { flex-direction: column-reverse; }
    .tryon-confirm-actions .modal-select-btn,
    .tryon-confirm-reject { width: 100%; min-width: 0; }
}

/* Right image area */
.modal-right {
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* === Catalog Detail: Multi-image Gallery === */
/* Fits entirely inside the existing .modal-right half. Reuses --primary-blue,
   rounded radii and shadows so nothing else about the modal design changes. */
.modal-gallery {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #eef3f9;
}

.gallery-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #ffffff;
}

.gallery-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.25s ease;
}

/* Side arrows (mirror the Try-On slider arrow styling) */
.gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background-color: rgba(255, 255, 255, 0.85);
    color: var(--primary-blue);
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    transition: var(--transition-smooth);
    z-index: 5;
}

.gallery-arrow:hover {
    background-color: #ffffff;
    color: #1b6fd1;
    transform: translateY(-50%) scale(1.08);
}

.gallery-prev { left: 16px; }
.gallery-next { right: 16px; }

.gallery-counter {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    background-color: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}

.gallery-empty {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #9aa6b2;
    font-size: 14px;
    font-weight: 500;
    background-color: #eef3f9;
    z-index: 4;
}

/* Bottom thumbnail strip (active state mirrors .tryon-item-circle.active) */
.gallery-thumbs {
    display: flex;
    gap: 10px;
    padding: 14px 18px;
    overflow-x: auto;
    background-color: #eef3f9;
    justify-content: center;
    align-items: center;
}

.gallery-thumbs::-webkit-scrollbar { height: 6px; }
.gallery-thumbs::-webkit-scrollbar-track { background: transparent; }
.gallery-thumbs::-webkit-scrollbar-thumb { background: rgba(47, 128, 237, 0.25); border-radius: 10px; }

.gallery-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    border: 2px solid transparent;
    padding: 0;
    background-color: #ffffff;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-thumb:hover { transform: translateY(-2px); }

.gallery-thumb.active {
    border-color: var(--primary-blue);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(47, 128, 237, 0.35);
}

/* Single (or zero) image: hide the navigation chrome */
.modal-gallery.single .gallery-arrow,
.modal-gallery.single .gallery-counter,
.modal-gallery.single .gallery-thumbs {
    display: none;
}

/* Zero images: show placeholder, hide main image */
.modal-gallery.empty .gallery-main-img { display: none; }
.modal-gallery.empty .gallery-stage { background-color: #eef3f9; }
.modal-gallery.empty .gallery-empty { display: flex; }

/* Camera Streaming modal */
.camera-modal-card {
    background-color: #000000;
    width: 504px;
    height: 600px;
    border-radius: 25px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.camera-viewport-box {
    width: 100%;
    flex: 1;
    background-color: #333333;
    position: relative;
    overflow: hidden;
}

.camera-stream {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls-bottom {
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #000000;
}

.shutter-btn-outer {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.shutter-btn-outer:hover {
    transform: scale(1.05);
}

.shutter-btn-inner {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 2px solid #000000;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shutter-btn-inner svg {
    width: 24px;
    height: 24px;
    fill: #000000;
}

/* Virtual Try On Specific CSS Phone Bezel */
.tryon-phone-card {
    background-color: #000000;
    width: 504px;
    height: 816px;
    border-radius: 25px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 8px solid #2b2b2b;
}

.tryon-viewport {
    width: 100%;
    height: 517px;
    background-color: #d9d9d9;
    position: relative;
    overflow: hidden;
}

/* Hand Detector Mask & SVG Bounding Box Overlays */
.tryon-mask-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 10;
}

.tryon-bbox-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 12;
}

.tryon-bbox-label {
    position: absolute;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    color: #35F53B;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 13;
}

.tryon-orientation-badge {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 14;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.tryon-orientation-badge.ready {
    background-color: rgba(40, 167, 69, 0.85);
    color: #ffffff;
    border: 1px solid rgba(53, 245, 59, 0.6);
}

.tryon-orientation-badge.warn {
    background-color: rgba(220, 53, 69, 0.85);
    color: #ffffff;
    border: 1px solid rgba(255, 153, 153, 0.6);
}

.shutter-btn-outer.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
    transform: none !important;
}


.tryon-bottom-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color: #000000;
}

/* Action row: camera shutter + upload-photo button, side by side. The upload
   button lets a user try-on from a FILE photo (e.g. my-hand.png) when there is
   no working camera (desktop / permission denied). */
.tryon-action-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
}
.tryon-upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.92;
    transition: var(--transition-smooth);
}
.tryon-upload-btn svg { width: 30px; height: 30px; fill: currentColor; }
.tryon-upload-btn span { font-size: 11px; letter-spacing: 0.5px; }
.tryon-upload-btn:hover { opacity: 1; color: var(--primary-blue); }

.tryon-product-slider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

.tryon-slider-arrow {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: var(--transition-smooth);
}

.tryon-slider-arrow:hover {
    color: var(--primary-blue);
}

.tryon-track-window {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 360px;
    justify-content: safe center;
    align-items: center;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 2px;
}
.tryon-track-window::-webkit-scrollbar { display: none; }

/* Product card in the Try-On slider: a clear image plus its (truncated) name. */
.tryon-item-card {
    flex: 0 0 auto;
    width: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border: 2px solid transparent;
    border-radius: 14px;
    background-color: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: var(--transition-smooth);
}
.tryon-item-card:hover { background-color: rgba(255, 255, 255, 0.12); }
.tryon-item-card.active {
    border-color: var(--primary-blue);
    background-color: rgba(47, 128, 237, 0.16);
    transform: translateY(-2px);
}
.tryon-item-card img {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    object-fit: cover;
    background-color: #ffffff;
}
.tryon-item-name {
    width: 100%;
    font-size: 11px;
    line-height: 1.25;
    color: #ffffff;
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}
.tryon-item-card.active .tryon-item-name { color: var(--primary-blue); }

.tryon-label {
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 4px;
}

.camera-placeholder-msg {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    font-weight: 500;
}

.camera-placeholder-msg svg {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
    fill: #8d8d8d;
}

/* Flip-camera button (shown only when the device has >= 2 cameras). */
.camera-flip-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 30;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-smooth), transform var(--transition-smooth);
}
.camera-flip-btn:hover { background: rgba(0, 0, 0, 0.7); transform: rotate(180deg); }
.camera-flip-btn:focus-visible { outline: 2px solid var(--primary-blue); outline-offset: 2px; }
.camera-flip-btn svg { width: 20px; height: 20px; fill: #ffffff; }
@media (prefers-reduced-motion: reduce) {
    .camera-flip-btn:hover { transform: none; }
}

/* Structured camera message (loading / permission / error) inside the viewport. */
.camera-placeholder-msg .camera-msg-icon svg {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
    fill: #b8b8b8;
}
.camera-msg-permission .camera-msg-icon svg,
.camera-msg-error .camera-msg-icon svg { fill: var(--primary-blue); }
.camera-placeholder-msg .camera-msg-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    text-align: center;
}
.camera-placeholder-msg .camera-msg-text {
    font-size: 13px;
    font-weight: 400;
    color: #c4c4c4;
    max-width: 280px;
    text-align: center;
    line-height: 1.45;
}
.camera-msg-retry {
    margin-top: 16px;
    padding: 9px 22px;
    border: none;
    border-radius: 999px;
    background: var(--primary-blue);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition-smooth);
}
.camera-msg-retry:hover { filter: brightness(1.08); }
.camera-msg-retry:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.plus-popup-mobile {
    display: none;
}

/* ==========================================================================
   Responsive & Mobile Styling System (Figma Spec Implementation)
   ========================================================================== */
@media (max-width: 768px) {
    /* 1. Global & Containers */
    body {
        padding: 0;
        margin: 0;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .chat-container {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
        height: 100vh;
        height: 100dvh;
    }

    /* 2. Start Screen Greeting Layout */
    .start-screen {
        padding: 24px 20px;
        justify-content: space-between;
    }
    
    .greeting-text {
        font-size: 32px;
        font-weight: 700;
        margin-top: auto;
        margin-bottom: auto;
        line-height: 1.3;
    }
    
    .large-input-box {
        height: 58px;
        border-radius: 36px;
        padding: 0;
        padding-left: 58px;  /* Spacing for plus button container */
        padding-right: 85px; /* Spacing for send button */
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-bottom: 20px;
        box-shadow: 0 4px 14px rgba(47, 128, 237, 0.12);
        border: 2px solid var(--primary-blue);
    }
    
    .large-textarea {
        height: 100%;
        line-height: 24px;
        font-size: 16px;
        padding: 16px 0;
        white-space: nowrap;
        overflow: hidden;
        resize: none;
    }
    
    .large-input-controls {
        position: static;
        margin-top: 0;
    }
    
    .large-input-box .plus-container {
        position: absolute;
        left: 8px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .large-input-box .send-btn {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        margin-right: 0;
        height: 42px;
        padding: 0 20px;
        line-height: 42px;
        display: flex;
        align-items: center;
    }

    /* 3. Plus Menu — top sheet (drops down from the top, swipe-down to close) */
    .plus-overlay {
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .plus-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    .plus-popup-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: 220px;
        background-color: var(--bg-main);
        border-radius: 24px 24px 0 0;
        transform: translateY(100%);                  /* parked below the viewport */
        transition: transform 0.38s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
        z-index: 1000;
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 36px 24px 24px 24px;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
        opacity: 0;
        pointer-events: none;
    }

    .plus-popup-mobile.active {
        opacity: 1;
        pointer-events: auto;
        /* transform is JS-driven: drops to translateY(0) on open, exits down on close */
    }
    
    /* Top handlebar drag-indicator for drawer */
    .plus-popup-mobile::before {
        content: "";
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 60px;
        height: 5px;
        border-radius: 10px;
        background-color: #e3e3e3;
    }
    
    .plus-popup-mobile-track {
        display: flex;
        flex-direction: row;
        gap: 12px;
        width: 100%;
        overflow-x: auto;
        padding: 10px 0;
        align-items: center;
    }
    
    .plus-popup-mobile-track::-webkit-scrollbar {
        display: none;
    }
    
    .plus-item-mobile {
        flex: 0 0 105px;
        width: 105px;
        height: 125px;
        background-color: #e8f0fe;
        border-radius: 20px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 12px;
        color: var(--text-dark);
        font-size: 11px;
        font-weight: 600;
        padding: 16px 8px;
        text-align: center;
        border: none;
        cursor: pointer;
        transition: var(--transition-smooth);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04);
    }
    
    .plus-item-mobile:hover {
        background-color: rgba(47, 128, 237, 0.12);
        transform: translateY(-2px);
    }
    
    .plus-item-mobile img {
        width: 32px;
        height: 32px;
        margin: 0 auto;
    }

    /* 4. Chat Main View */
    .chat-header {
        height: 48px;
        padding-bottom: 5px;
    }
    
    .chat-history {
        gap: 16px;
        padding: 12px 4px;
    }
    
    .message-bubble {
        max-width: 80%;
        font-size: 0.875rem;
        line-height: 1.45;
    }
    
    .user .message-bubble {
        padding: 10px 16px;
        border-radius: 16px 4px 16px 16px;
    }
    
    .bot .message-bubble-wrapper {
        max-width: 80%;
    }
    
    .bot .message-bubble {
        max-width: 100%;
        padding: 12px 16px;
        border-radius: 4px 16px 16px 16px;
    }

    .bot .message-bubble h1 { font-size: 1.2rem; }
    .bot .message-bubble h2 { font-size: 1.1rem; }
    .bot .message-bubble h3 { font-size: 1.0rem; }
    .bot .message-bubble h4 { font-size: 0.9rem; }
    .bot .message-bubble p { margin-bottom: 8px; }
    .bot .message-bubble ul,
    .bot .message-bubble ol {
        margin: 0 0 8px;
        padding-left: 18px;
    }
    .bot .message-bubble li { margin-bottom: 2px; }
    
    .chat-input-area {
        padding: 12px 0 max(6px, env(safe-area-inset-bottom)) 0;
    }
    
    .chat-input-wrapper {
        height: 52px;
        border-radius: 26px;
    }
    
    .chat-input {
        font-size: 15px;
        padding: 0 12px;
    }
    
    .chat-input-wrapper .send-btn {
        height: 38px;
        padding: 0 16px;
        border-radius: 19px;
        font-size: 14px;
    }

    /* 5. Product Catalog Carousel Inside Message */
    .catalog-container {
        padding: 12px;
        border-radius: 16px;
        margin-top: 10px;
    }
    
    .catalog-track {
        gap: 12px;
    }
    
    .product-card, .more-card {
        flex: 0 0 116px;
        width: 116px;
        height: 118px;
        border-radius: 12px;
        padding: 4px;
    }
    
    .product-image-wrapper {
        height: 64px;
        border-radius: 8px;
        margin-bottom: 4px;
    }
    
    .product-title {
        font-size: 9.5px;
        margin-bottom: 1px;
    }
    
    .product-price {
        font-size: 8.5px;
    }
    
    .more-icon-circle {
        width: 28px;
        height: 28px;
        font-size: 12px;
        margin-bottom: 4px;
    }
    
    .more-title {
        font-size: 9px;
    }
    
    .more-subtitle {
        font-size: 7px;
    }

    /* 6. Product Detail Bottom Sheet Modal (slides up from the bottom, swipe-down to close) */
    .modal-card {
        width: 100vw;
        height: 88vh;
        height: 88dvh;
        max-height: 88vh;
        max-height: 88dvh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        border-radius: 24px 24px 0 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transform: translateY(100%);                  /* parked below the viewport */
        transition: transform 0.38s cubic-bezier(0.25, 1, 0.5, 1);
        animation: none; /* cancel the base modalPop (forwards) so the JS transform drives the sheet */
        /* transform is JS-driven on open/close (openSheet/closeSheet). */
    }

    .modal-card::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 60px;
        height: 5px;
        border-radius: 10px;
        background-color: #e3e3e3;
        z-index: 100;
    }
    
    .modal-right {
        order: 1; /* Gallery on top */
        flex: 0 0 auto;
        height: 250px;
        width: 100%;
    }
    
    .modal-gallery {
        height: 100%;
    }
    
    .gallery-stage {
        height: 100%;
    }
    
    .gallery-arrow {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .gallery-prev { left: 8px; }
    .gallery-next { right: 8px; }
    
    .gallery-thumbs {
        padding: 8px;
        gap: 8px;
        background-color: #eef3f9;
        display: none; /* Hide thumbs strip on mobile to save vertical space */
    }
    
    .modal-left {
        order: 2; /* Content details at bottom */
        flex: 1;
        width: 100%;
        padding: 20px;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        height: calc(100% - 250px);
        padding-bottom: 90px; /* Space for fixed action button */
    }
    
    .modal-header {
        margin-bottom: 12px;
    }
    
    /* Reposition the close button to top-left overlaying the image */
    .modal-card .modal-close-btn {
        position: absolute;
        left: 12px;
        top: 12px;
        z-index: 101;
        background-color: rgba(0, 0, 0, 0.4);
        border-radius: 50%;
        width: 36px;
        height: 36px;
    }
    
    .modal-card .modal-close-btn img {
        filter: brightness(0) invert(1);
    }
    
    .modal-product-name {
        font-size: 24px;
        letter-spacing: 1px;
        margin-bottom: 6px;
    }
    
    .modal-product-price {
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .modal-description-box {
        flex: none;
        margin-bottom: 0;
    }
    
    .modal-select-btn {
        position: absolute;
        bottom: 16px;
        left: 16px;
        right: 16px;
        width: calc(100% - 32px);
        z-index: 10;
        box-shadow: 0 8px 24px rgba(47, 128, 237, 0.25);
    }

    /* 7. Fullscreen Camera & Virtual Try On Modals */
    .camera-modal-card, .tryon-phone-card {
        width: 100vw;
        /* Pin to the VISIBLE viewport, not the large layout viewport, so the
           shutter never hides behind the phone's home/gesture nav or the browser
           URL bar. --app-vv-* is driven by the visualViewport API in app.js; the
           dvh fallback covers browsers without visualViewport. */
        height: var(--app-vv-height, 100dvh);
        position: fixed;
        top: var(--app-vv-top, 0px);
        left: 0;
        right: 0;
        z-index: 2000;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
        background-color: #000000;
    }
    
    .camera-viewport-box, .tryon-viewport {
        flex: 1;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    #camera-modal .modal-close-btn, #tryon-modal .modal-close-btn {
        left: 20px !important;
        right: auto !important;
        top: 20px !important;
        background: rgba(0, 0, 0, 0.5) !important;
        z-index: 2100;
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }

    /* On mobile the close button moves to the top-left, so the flip button goes
       top-right to stay clear of it. */
    #camera-modal .camera-flip-btn, #tryon-modal .camera-flip-btn {
        left: auto;
        right: 20px;
        top: 20px;
        z-index: 2100;
    }
    
    .camera-controls-bottom, .tryon-bottom-controls {
        background-color: #000000;
        height: auto;
        /* Shutter stays clear of the phone's home/gesture nav: generous top room
           and a bottom pad sized by the device safe-area inset (with a 36px floor
           for devices that report 0). Content-driven height (flex-basis auto) so
           the camera/try-on viewport takes all remaining card height. */
        flex: 0 0 auto;
        padding: 32px 24px calc(36px + env(safe-area-inset-bottom));
    }
    
    /* Virtual Try On Specifics */
    .tryon-phone-card {
        border: none; /* remove bezel on mobile */
    }
    
    .tryon-viewport {
        /* Fill whatever the camera card leaves above the bottom controls (the
           shared .camera-viewport-box, .tryon-viewport rule already sets flex:1).
           min-height:0 lets it shrink so the shutter row is never pushed off-card. */
        height: auto;
        min-height: 0;
    }
    

    .tryon-product-slider {
        margin-bottom: 16px;
    }
    
    .tryon-track-window {
        max-width: 240px;
    }
}

/* ---- Toast notifications (non-blocking upload feedback) ---- */
/* Self-contained layer that floats above every modal/sheet. Reuses :root
   tokens plus the existing --bubble-shadow so it reads as part of the
   design system rather than a tacked-on widget. */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: calc(100% - 32px);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background-color: #ffffff;
    border: 1px solid rgba(47, 128, 237, 0.15);
    border-left: 4px solid var(--primary-blue);
    border-radius: 14px;
    box-shadow: var(--bubble-shadow), 0 8px 24px rgba(0, 0, 0, 0.08);
    color: var(--text-dark);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    fill: var(--primary-blue);
}

.toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.toast-message {
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-muted);
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    padding: 0 2px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.toast-close:hover {
    color: var(--text-dark);
}

@media (max-width: 768px) {
    .toast-container {
        top: 12px;
        width: calc(100% - 24px);
    }
}

/* --- Virtual try-on result bubble (generated image + disclaimer) --- */
.bot .message-bubble.tryon-bubble {
    padding: 12px;
    max-width: 420px;
}
.tryon-caption {
    padding: 4px 6px 8px;
    line-height: 1.45;
}
.tryon-caption p { margin: 0; }
.tryon-result-img {
    display: block;
    width: 100%;
    max-width: 396px;
    border-radius: 10px;
    background: #f3f5f8;
    object-fit: contain;
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}
.tryon-result-img:hover { opacity: 0.94; }
.tryon-result-img:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}
.tryon-disclaimer {
    margin-top: 8px;
    padding: 6px 8px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
    background: rgba(47, 128, 237, 0.06);
    border-left: 3px solid var(--primary-blue);
    border-radius: 4px;
}

/* "Generating your try-on…" bubble (slow ~1-3 min generation) */
.bot .message-bubble.tryon-generating {
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.tryon-generating-text {
    margin-left: 8px;
    font-size: 13px;
    color: var(--text-muted);
}
@media (max-width: 768px) {
    .bot .message-bubble.tryon-bubble { max-width: 100%; }
    .tryon-result-img { max-width: 100%; }
}

/* --- Image Lightbox (full-size view + download for bot-sent images) ---
   One reusable fullscreen overlay opened from any bot-sent image (today:
   Virtual Try-On results). Inherits the backdrop/active behavior from
   .modal-overlay; this block styles the stage, the full-res image, and the
   floating Download/Close bar. Both preview and download are client-side: the
   source <img> already carries the base64 data URL, so there is no backend
   round-trip and no new endpoint. */
.image-lightbox-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 16px 16px;
}
.image-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
}
.image-lightbox-bar {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10;
    display: flex;
    gap: 8px;
}
.image-lightbox-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.image-lightbox-btn:hover,
.image-lightbox-btn:focus-visible {
    background-color: rgba(0, 0, 0, 0.78);
    transform: scale(1.06);
    outline: none;
}
.image-lightbox-btn svg,
.image-lightbox-btn img {
    width: 20px;
    height: 20px;
}
.image-lightbox-btn svg path { fill: #ffffff; }
