/* ============================================
   MARV Widget — Premium UI Design System
   MARV — Surface Intelligence
   ============================================ */

/* ---- Design Tokens ---- */
#marv-widget {
    /* Brand — Magicman Brand Guidelines */
    --marv-primary: #13294B;
    --marv-primary-light: #1E3A5F;
    --marv-primary-dark: #0D1B33;
    --marv-secondary: #93C847;
    --marv-secondary-light: #A8D462;
    --marv-secondary-dark: #7AB035;
    --marv-accent: #93C847;

    /* Semantic — decision types */
    --marv-success: #22C55E;
    --marv-warning: #F59E0B;
    --marv-info: #3B82F6;
    --marv-danger: #DC2626;
    --marv-neutral: #6B7280;

    /* Surfaces */
    --marv-bg-primary: #FFFFFF;
    --marv-bg-secondary: #F8F9FB;
    --marv-bg-chat: #F8F9FB;
    --marv-border: #E1E5EB;
    --marv-border-light: #F8F9FB;

    /* Typography */
    --marv-font-body: 'Source Sans Pro', Helvetica, Arial, sans-serif;
    --marv-text-primary: #13294B;
    --marv-text-secondary: #3C5575;
    --marv-text-muted: #596F8B;

    /* Spacing (4px base) */
    --marv-space-xs: 4px;
    --marv-space-sm: 8px;
    --marv-space-md: 16px;
    --marv-space-lg: 24px;
    --marv-space-xl: 32px;
    --marv-space-2xl: 48px;

    /* Radius — 4px brand standard */
    --marv-radius-sm: 0.25rem;
    --marv-radius-md: 0.25rem;
    --marv-radius-lg: 0.25rem;
    --marv-radius-xl: 0.25rem;
    --marv-radius-full: 9999px;

    /* Shadows */
    --marv-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --marv-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --marv-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --marv-shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.16);

    /* Transitions — brand standard easing */
    --marv-transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --marv-transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --marv-transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: var(--marv-font-body);
    font-size: 15px;
    line-height: 1.5;
    color: var(--marv-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Launcher (floating logo button) ---- */
.marv-launcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--marv-radius-full);
    box-shadow: var(--marv-shadow-lg);
    transition: transform var(--marv-transition-fast), box-shadow var(--marv-transition-fast);
    outline: none;
}
.marv-launcher[hidden] { display: none !important; }
.marv-launcher:hover,
.marv-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--marv-shadow-xl);
}
.marv-launcher:focus-visible {
    outline: 2px solid var(--marv-secondary);
    outline-offset: 3px;
}
.marv-launcher:active {
    transform: translateY(0);
}
.marv-launcher-logo {
    width: 100%;
    height: 100%;
    border-radius: var(--marv-radius-full);
    pointer-events: none;
    user-select: none;
    display: block;
}
.marv-launcher-tooltip {
    position: absolute;
    bottom: 50%;
    left: calc(100% + 12px);
    transform: translateY(50%);
    white-space: nowrap;
    background: var(--marv-primary);
    color: #fff;
    font-family: var(--marv-font-body);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    padding: 8px 12px;
    border-radius: var(--marv-radius-md);
    box-shadow: var(--marv-shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--marv-transition-fast), transform var(--marv-transition-fast);
}
.marv-launcher-tooltip::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--marv-primary);
}
.marv-launcher:hover .marv-launcher-tooltip,
.marv-launcher:focus-visible .marv-launcher-tooltip,
.marv-launcher.marv-show-tooltip .marv-launcher-tooltip {
    opacity: 1;
    transform: translateY(50%) translateX(2px);
}

.marv-widget-panel[hidden] { display: none !important; }

/* Screen-reader only utility */
.marv-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Widget Container ---- */
.marv-widget-container {
    width: 420px;
    max-width: calc(100vw - 24px);
    max-height: 680px;
    background: var(--marv-bg-primary);
    border-radius: var(--marv-radius-xl);
    box-shadow: var(--marv-shadow-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--marv-border);
}

/* ---- Header ---- */
.marv-widget-header {
    background: var(--marv-primary);
    color: white;
    padding: var(--marv-space-md) var(--marv-space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.marv-header-info {
    display: flex;
    align-items: center;
    gap: var(--marv-space-sm);
}

.marv-header-info h3 {
    font-weight: 600;
    font-size: 15px;
    margin: 0;
    letter-spacing: 0.2px;
}

.marv-status-dot {
    width: 10px;
    height: 10px;
    background: var(--marv-secondary);
    border-radius: var(--marv-radius-full);
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(147, 200, 71, 0.5);
}

.marv-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: var(--marv-space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--marv-radius-sm);
    transition: background var(--marv-transition-fast);
    opacity: 0.7;
}

.marv-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

.marv-close-btn:focus-visible {
    outline: 2px solid var(--marv-secondary);
    outline-offset: 2px;
}

/* ---- Content Area ---- */
.marv-widget-content {
    padding: var(--marv-space-lg) var(--marv-space-md);
    overflow-y: auto;
    flex: 1;
    background: var(--marv-bg-chat);
    display: flex;
    flex-direction: column;
    gap: var(--marv-space-md);
    scroll-behavior: smooth;
}

.marv-widget-content::-webkit-scrollbar {
    width: 5px;
}

.marv-widget-content::-webkit-scrollbar-track {
    background: transparent;
}

.marv-widget-content::-webkit-scrollbar-thumb {
    background: var(--marv-border);
    border-radius: 3px;
}

.marv-widget-content::-webkit-scrollbar-thumb:hover {
    background: var(--marv-text-muted);
}

/* ---- Chat Container ---- */
.marv-chat-container {
    display: flex;
    flex-direction: column;
    gap: var(--marv-space-md);
    padding-bottom: var(--marv-space-sm);
}

/* ---- Messages ---- */
.marv-message {
    display: flex;
    gap: var(--marv-space-sm);
    animation: marvFadeInUp 300ms ease-out both;
    align-items: flex-end;
}

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

/* Bot Messages (left) */
.marv-message-bot {
    justify-content: flex-start;
}

.marv-message-bot .marv-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(19, 41, 75, 0.3);
}

.marv-message-bot .marv-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.marv-message-bot .marv-message-bubble {
    background: white;
    border-radius: 4px 4px 4px 0;
    padding: 14px 18px;
    max-width: 70%;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #f0f0f0;
}

/* User Messages (right) */
.marv-message-user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.marv-message-user .marv-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--marv-primary-light) 0%, var(--marv-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    box-shadow: 0 2px 8px rgba(19, 41, 75, 0.3);
}

.marv-message-user .marv-message-avatar svg {
    width: 20px;
    height: 20px;
}

.marv-message-user .marv-message-bubble {
    background: linear-gradient(135deg, var(--marv-primary-light) 0%, var(--marv-primary) 100%);
    color: white;
    border-radius: 4px 4px 0 4px;
    padding: 14px 18px;
    max-width: 70%;
    box-shadow: 0 2px 12px rgba(19, 41, 75, 0.3);
}

/* Message Content */
.marv-message-text {
    margin: 0;
    line-height: 1.55;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.marv-message-text strong {
    font-weight: 600;
}

/* ---- Input Area ---- */
.marv-input-area {
    display: flex;
    flex-direction: column;
    gap: var(--marv-space-sm);
    margin-top: var(--marv-space-sm);
    padding: 0 40px;
}

.marv-input,
.marv-textarea,
.marv-select {
    width: 100%;
    padding: 12px var(--marv-space-md);
    border: 2px solid var(--marv-border);
    border-radius: var(--marv-radius-md);
    font-size: 14px;
    font-family: var(--marv-font-body);
    transition: border-color var(--marv-transition-fast), box-shadow var(--marv-transition-fast);
    background: var(--marv-bg-primary);
    color: var(--marv-text-primary);
    min-height: 48px;
}

.marv-input::placeholder,
.marv-textarea::placeholder {
    color: var(--marv-text-muted);
}

.marv-input:focus,
.marv-textarea:focus,
.marv-select:focus {
    outline: none;
    border-color: var(--marv-secondary);
    box-shadow: 0 0 0 3px rgba(147, 200, 71, 0.15);
}

.marv-input:focus-visible,
.marv-textarea:focus-visible,
.marv-select:focus-visible {
    outline: none;
    border-color: var(--marv-secondary);
    box-shadow: 0 0 0 3px rgba(147, 200, 71, 0.15);
}

.marv-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.55;
}

.marv-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* ---- Buttons ---- */
.marv-btn-group {
    display: flex;
    gap: var(--marv-space-sm);
}

.marv-btn,
.marv-btn-primary,
.marv-btn-secondary {
    padding: 12px 20px;
    border-radius: var(--marv-radius-md);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--marv-font-body);
    cursor: pointer;
    transition: all var(--marv-transition-fast);
    border: none;
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--marv-space-sm);
    min-height: 48px;
    text-decoration: none;
}

.marv-btn,
.marv-btn-primary {
    background: var(--marv-primary);
    color: white;
    box-shadow: var(--marv-shadow-sm);
}

.marv-btn:hover,
.marv-btn-primary:hover {
    background: var(--marv-primary-light);
    transform: translateY(-1px);
    box-shadow: var(--marv-shadow-md);
}

.marv-btn:active,
.marv-btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--marv-shadow-sm);
}

.marv-btn:focus-visible,
.marv-btn-primary:focus-visible {
    outline: 2px solid var(--marv-secondary);
    outline-offset: 2px;
}

.marv-btn:disabled,
.marv-btn-primary:disabled {
    background: var(--marv-text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.5;
}

.marv-btn-accent {
    background: var(--marv-secondary);
    color: white;
}

.marv-btn-accent:hover {
    background: var(--marv-secondary-dark);
}

.marv-btn-secondary {
    background: var(--marv-bg-primary);
    color: var(--marv-text-secondary);
    border: 2px solid var(--marv-border);
    box-shadow: none;
}

.marv-btn-secondary:hover {
    background: var(--marv-bg-secondary);
    border-color: var(--marv-primary-light);
    color: var(--marv-primary);
}

.marv-btn-secondary:active {
    background: var(--marv-border-light);
}

.marv-btn-secondary:focus-visible {
    outline: 2px solid var(--marv-secondary);
    outline-offset: 2px;
}

/* ---- Upload Area ---- */
.marv-upload-area {
    border: 2px dashed var(--marv-border);
    border-radius: var(--marv-radius-md);
    padding: var(--marv-space-lg) var(--marv-space-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--marv-transition-fast);
    background: var(--marv-bg-primary);
}

.marv-upload-area:hover,
.marv-upload-area-active {
    border-color: var(--marv-secondary);
    background: rgba(147, 200, 71, 0.04);
}

.marv-upload-area:focus-visible {
    outline: 2px solid var(--marv-secondary);
    outline-offset: 2px;
}

.marv-upload-area svg {
    color: var(--marv-primary-light);
    margin-bottom: var(--marv-space-sm);
}

.marv-upload-area p {
    margin: 0;
    color: var(--marv-text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* ---- Image Preview Grid ---- */
.marv-image-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--marv-space-sm);
    margin: var(--marv-space-sm) 0;
}

.marv-image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--marv-radius-sm);
    overflow: hidden;
    border: 2px solid var(--marv-border);
    background: var(--marv-bg-secondary);
    animation: marvFadeIn 200ms ease-out both;
}

@keyframes marvFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.marv-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.marv-image-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: var(--marv-danger);
    color: white;
    border: 2px solid white;
    border-radius: var(--marv-radius-full);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--marv-shadow-sm);
    transition: all var(--marv-transition-fast);
}

.marv-image-remove:hover {
    background: #B91C1C;
    transform: scale(1.1);
}

.marv-image-remove:focus-visible {
    outline: 2px solid var(--marv-danger);
    outline-offset: 2px;
}

/* ---- Info / Guidance Cards ---- */
.marv-info-card {
    background: var(--marv-bg-primary);
    border-radius: var(--marv-radius-md);
    padding: var(--marv-space-md);
    box-shadow: var(--marv-shadow-sm);
    border: 1px solid var(--marv-border);
}

.marv-info-card h4 {
    margin: 0 0 var(--marv-space-sm) 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--marv-text-primary);
}

.marv-info-card p {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--marv-text-secondary);
}

/* Photo guidance card */
.marv-guidance-card {
    background: rgba(147, 200, 71, 0.06);
    border-left: 3px solid var(--marv-secondary);
    padding: 14px;
    border-radius: 0 var(--marv-radius-sm) var(--marv-radius-sm) 0;
    margin: var(--marv-space-sm) 0;
}

.marv-guidance-card .marv-guidance-title {
    margin: 0 0 var(--marv-space-sm) 0;
    font-weight: 600;
    color: var(--marv-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.marv-guidance-card ul {
    margin: 0;
    padding-left: 18px;
    color: var(--marv-text-secondary);
    font-size: 13px;
    line-height: 1.8;
}

.marv-guidance-card .marv-guidance-tip {
    margin: var(--marv-space-sm) 0 0 0;
    font-size: 12px;
    color: var(--marv-text-muted);
    font-style: italic;
}

/* ---- Validation Sections ---- */
.marv-validation-section {
    background: var(--marv-bg-secondary);
    border-radius: var(--marv-radius-sm);
    padding: 12px 14px;
    margin: var(--marv-space-sm) 0;
    border: 1px solid var(--marv-border);
}

.marv-validation-section.damage {
    background: #FFFBEB;
    border-left: 3px solid var(--marv-warning);
    border-color: #FCD34D;
}

.marv-validation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--marv-space-sm);
}

.marv-validation-section h5 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--marv-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.marv-validation-section p {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--marv-text-primary);
}

.marv-validation-display {
    padding: var(--marv-space-sm) 12px;
    background: var(--marv-bg-primary);
    border-radius: var(--marv-radius-sm);
    line-height: 1.55;
    border: 1px solid var(--marv-border-light);
}

/* ---- Fixture Questions ---- */
.marv-fixture-questions {
    margin-top: var(--marv-space-md);
    padding: var(--marv-space-md);
    background: #FFFBEB;
    border-left: 3px solid var(--marv-warning);
    border-radius: 0 var(--marv-radius-sm) var(--marv-radius-sm) 0;
}

.marv-fixture-questions h5 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 700;
    color: #92400E;
    display: flex;
    align-items: center;
    gap: var(--marv-space-sm);
}

.marv-fixture-questions > p {
    margin: 0 0 12px 0;
    font-size: 12px;
    color: #78350F;
}

/* ---- Size Estimate ---- */
.marv-size-estimate {
    border-radius: var(--marv-radius-sm);
    padding: 12px;
    margin-top: var(--marv-space-md);
    border: 2px solid;
}

.marv-size-estimate-high {
    background: #F0FDF4;
    border-color: #86EFAC;
    color: #166534;
}

.marv-size-estimate-medium {
    background: #FFFBEB;
    border-color: #FCD34D;
    color: #92400E;
}

.marv-size-estimate-low {
    background: #FEF2F2;
    border-color: #FCA5A5;
    color: #991B1B;
}

.marv-size-header {
    display: flex;
    align-items: center;
    gap: var(--marv-space-sm);
    margin-bottom: var(--marv-space-sm);
    font-weight: 600;
    font-size: 13px;
}

.marv-size-details {
    font-size: 13px;
    line-height: 1.6;
}

.marv-size-details p {
    margin: 0 0 4px 0;
}

.marv-size-note {
    margin: 6px 0 0 0;
    font-style: italic;
    font-size: 12px;
    opacity: 0.85;
}

/* ---- Form Groups ---- */
.marv-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: var(--marv-space-sm) 0;
}

.marv-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--marv-text-secondary);
}

/* Inline validation error */
.marv-input-error {
    border-color: var(--marv-danger) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

.marv-error-message {
    color: var(--marv-danger);
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

/* ---- Edit Button ---- */
.marv-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--marv-bg-primary);
    border: 1px solid var(--marv-border);
    border-radius: var(--marv-radius-sm);
    color: var(--marv-text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--marv-font-body);
    cursor: pointer;
    transition: all var(--marv-transition-fast);
}

.marv-edit-btn:hover {
    background: var(--marv-bg-secondary);
    border-color: var(--marv-primary);
    color: var(--marv-primary);
}

.marv-edit-btn:focus-visible {
    outline: 2px solid var(--marv-secondary);
    outline-offset: 2px;
}

.marv-edit-btn svg {
    width: 12px;
    height: 12px;
}

/* ---- Summary Card ---- */
.marv-summary-card {
    background: var(--marv-bg-primary);
    border-radius: var(--marv-radius-md);
    overflow: hidden;
    box-shadow: var(--marv-shadow-sm);
    border: 1px solid var(--marv-border);
    margin: var(--marv-space-sm) 0;
}

.marv-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px var(--marv-space-md);
    background: var(--marv-bg-secondary);
    border-bottom: 1px solid var(--marv-border);
}

.marv-summary-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--marv-text-primary);
}

.marv-summary-content {
    padding: var(--marv-space-md);
}

.marv-summary-display {
    color: var(--marv-text-secondary);
    line-height: 1.55;
    font-size: 13px;
}

.marv-summary-edit {
    display: flex;
    flex-direction: column;
    gap: var(--marv-space-sm);
}

.marv-summary-textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--marv-border);
    border-radius: var(--marv-radius-sm);
    font-family: var(--marv-font-body);
    font-size: 13px;
    line-height: 1.55;
    resize: vertical;
    min-height: 72px;
    color: var(--marv-text-primary);
}

.marv-summary-textarea:focus {
    outline: none;
    border-color: var(--marv-secondary);
    box-shadow: 0 0 0 3px rgba(147, 200, 71, 0.15);
}

.marv-summary-actions {
    display: flex;
    gap: var(--marv-space-sm);
    justify-content: flex-end;
}

.marv-summary-actions .marv-btn-primary,
.marv-summary-actions .marv-btn-secondary {
    width: auto;
    padding: 6px 14px;
    font-size: 13px;
    flex: 0;
    min-height: 36px;
}

/* ---- Confirmation Summary ---- */
.marv-confirmation-summary {
    background: rgba(147, 200, 71, 0.06);
    border-left: 3px solid var(--marv-secondary);
    padding: 12px;
    border-radius: 0 var(--marv-radius-sm) var(--marv-radius-sm) 0;
    margin: var(--marv-space-sm) 0;
}

.marv-confirmation-summary p {
    margin: 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--marv-text-primary);
}

/* ---- Decision Card (Results Step) ---- */
.marv-decision-card {
    border-radius: var(--marv-radius-lg);
    overflow: hidden;
    background: var(--marv-bg-primary);
    box-shadow: var(--marv-shadow-md);
    margin: var(--marv-space-sm) 0;
    border: 1px solid var(--marv-border);
    animation: marvScaleIn 400ms ease-out both;
}

@keyframes marvScaleIn {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.marv-decision-accent {
    height: 4px;
    width: 100%;
}

.marv-decision-header {
    padding: var(--marv-space-lg) var(--marv-space-md) var(--marv-space-md);
    display: flex;
    align-items: flex-start;
    gap: var(--marv-space-md);
}

.marv-decision-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--marv-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.marv-decision-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5;
}

.marv-decision-title-group {
    flex: 1;
    min-width: 0;
}

.marv-decision-title-group h3 {
    margin: 0 0 4px 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--marv-text-primary);
    line-height: 1.3;
}

.marv-decision-subtitle {
    margin: 0;
    font-size: 13px;
    color: var(--marv-text-secondary);
    line-height: 1.4;
}

.marv-decision-body {
    padding: 0 var(--marv-space-md) var(--marv-space-md);
}

/* Confidence Badge */
.marv-confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--marv-radius-full);
    font-size: 12px;
    font-weight: 600;
    background: var(--marv-bg-secondary);
    border: 1px solid var(--marv-border);
    color: var(--marv-text-secondary);
    margin-bottom: var(--marv-space-md);
}

.marv-confidence-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--marv-radius-full);
}

/* Price Display */
.marv-price-estimate {
    text-align: center;
    padding: var(--marv-space-md);
    margin: var(--marv-space-md) 0;
    border-radius: var(--marv-radius-md);
    border: 2px solid;
}

.marv-price-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.marv-price-value {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4px;
}

.marv-price-note {
    font-size: 13px;
    font-weight: 500;
}

/* Price variants */
.marv-price-success {
    background: #F0FDF4;
    border-color: #86EFAC;
}
.marv-price-success .marv-price-label { color: #166534; }
.marv-price-success .marv-price-value { color: #15803D; }
.marv-price-success .marv-price-note { color: #16A34A; }

.marv-price-warning {
    background: #FFFBEB;
    border-color: #FCD34D;
}
.marv-price-warning .marv-price-label { color: #92400E; }
.marv-price-warning .marv-price-value { color: #B45309; }
.marv-price-warning .marv-price-note { color: #B45309; }

.marv-price-info {
    background: #EFF6FF;
    border-color: #93C5FD;
}
.marv-price-info .marv-price-label { color: #1E40AF; }
.marv-price-info .marv-price-value { color: #1D4ED8; }
.marv-price-info .marv-price-note { color: #2563EB; }

.marv-price-danger {
    background: #FEF2F2;
    border-color: #FCA5A5;
}
.marv-price-danger .marv-price-label { color: #991B1B; }
.marv-price-danger .marv-price-value { color: var(--marv-danger); font-size: 22px; }
.marv-price-danger .marv-price-note { color: #B91C1C; }

.marv-price-neutral {
    background: var(--marv-bg-secondary);
    border-color: var(--marv-border);
}
.marv-price-neutral .marv-price-label { color: var(--marv-text-secondary); }
.marv-price-neutral .marv-price-value { color: var(--marv-neutral); font-size: 20px; }
.marv-price-neutral .marv-price-note { color: var(--marv-neutral); }

/* Triage Badges */
.marv-triage-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--marv-space-sm);
    margin: var(--marv-space-md) 0;
}

.marv-badge {
    background: var(--marv-bg-secondary);
    padding: 6px 12px;
    border-radius: var(--marv-radius-sm);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--marv-border);
    color: var(--marv-text-secondary);
}

.marv-badge strong {
    color: var(--marv-text-primary);
}

/* Reasons List */
.marv-reasons {
    margin-top: var(--marv-space-md);
}

.marv-reasons h4 {
    margin: 0 0 var(--marv-space-sm) 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--marv-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.marv-reasons ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.marv-reasons li {
    margin-bottom: 6px;
    color: var(--marv-text-secondary);
    line-height: 1.5;
    font-size: 13px;
    padding-left: 18px;
    position: relative;
}

.marv-reasons li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: var(--marv-radius-full);
    background: var(--marv-secondary);
}

/* Results Actions */
.marv-results-actions {
    display: flex;
    flex-direction: column;
    gap: var(--marv-space-sm);
    margin-top: var(--marv-space-md);
}

.marv-results-actions .marv-btn-primary {
    width: 100%;
}

.marv-results-actions .marv-btn-secondary {
    flex: 1;
}

.marv-results-secondary-row {
    display: flex;
    gap: var(--marv-space-sm);
}

.marv-btn-primary svg,
.marv-btn-secondary svg {
    flex-shrink: 0;
}

/* ---- Customer Form ---- */
.marv-customer-form {
    background: var(--marv-bg-primary);
    padding: var(--marv-space-md);
    border-radius: var(--marv-radius-md);
    border: 1px solid var(--marv-border);
}

.marv-customer-form .marv-form-group {
    margin-bottom: var(--marv-space-md);
}

.marv-customer-form .marv-form-group:last-of-type {
    margin-bottom: 0;
}

.marv-customer-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--marv-text-secondary);
    margin-bottom: 5px;
}

.marv-privacy-note {
    font-size: 12px;
    color: var(--marv-text-muted);
    line-height: 1.5;
    margin-top: var(--marv-space-md);
    padding: var(--marv-space-sm) 12px;
    background: var(--marv-bg-secondary);
    border-radius: var(--marv-radius-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--marv-space-sm);
}

.marv-checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--marv-space-sm);
    font-weight: 400 !important;
    cursor: pointer;
    font-size: 13px;
}

.marv-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--marv-primary);
}

.marv-terms-link {
    background: none;
    border: none;
    color: var(--marv-primary);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    font-weight: 600;
    font-family: var(--marv-font-body);
}

.marv-terms-link:hover {
    color: var(--marv-primary-light);
}

/* ---- Confirmation Card ---- */
.marv-confirmation-card {
    background: var(--marv-bg-primary);
    border-radius: var(--marv-radius-lg);
    overflow: hidden;
    box-shadow: var(--marv-shadow-md);
    border: 1px solid var(--marv-border);
    animation: marvScaleIn 400ms ease-out both;
}

.marv-confirmation-header {
    text-align: center;
    padding: var(--marv-space-xl) var(--marv-space-lg) var(--marv-space-lg);
    background: var(--marv-bg-secondary);
    border-bottom: 1px solid var(--marv-border);
}

.marv-confirmation-header h2 {
    margin: var(--marv-space-md) 0 var(--marv-space-sm) 0;
    color: var(--marv-text-primary);
    font-size: 20px;
    font-weight: 700;
}

.marv-confirmation-header p {
    margin: 0;
    color: var(--marv-text-muted);
    font-size: 13px;
}

.marv-confirmation-body {
    padding: var(--marv-space-lg);
}

.marv-confirmation-section {
    margin-bottom: var(--marv-space-lg);
}

.marv-confirmation-section:last-child {
    margin-bottom: 0;
}

.marv-confirmation-section h4 {
    margin: 0 0 var(--marv-space-sm) 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--marv-text-primary);
    display: flex;
    align-items: center;
    gap: var(--marv-space-sm);
}

/* Detail rows */
.marv-detail-row {
    display: flex;
    padding: var(--marv-space-sm) 0;
    border-bottom: 1px solid var(--marv-border-light);
}

.marv-detail-row:last-child {
    border-bottom: none;
}

.marv-detail-label {
    font-weight: 600;
    color: var(--marv-text-muted);
    min-width: 100px;
    font-size: 13px;
}

.marv-detail-value {
    color: var(--marv-text-primary);
    flex: 1;
    font-size: 13px;
}

.marv-confirmation-actions {
    display: flex;
    gap: var(--marv-space-sm);
    margin-top: var(--marv-space-lg);
    padding-top: var(--marv-space-lg);
    border-top: 1px solid var(--marv-border);
}

/* Next steps list */
.marv-next-steps {
    margin: 0;
    padding-left: 20px;
    color: var(--marv-text-secondary);
    line-height: 2;
    font-size: 13px;
}

/* Success checkmark animation */
.marv-success-check {
    width: 56px;
    height: 56px;
    margin: 0 auto;
}

.marv-success-check svg {
    width: 56px;
    height: 56px;
}

.marv-check-circle {
    stroke: var(--marv-secondary);
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: marvDrawCircle 600ms ease-out 200ms forwards;
}

.marv-check-mark {
    stroke: var(--marv-secondary);
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: marvDrawCheck 400ms ease-out 700ms forwards;
}

@keyframes marvDrawCircle {
    to { stroke-dashoffset: 0; }
}

@keyframes marvDrawCheck {
    to { stroke-dashoffset: 0; }
}

/* ---- Loading State ---- */
.marv-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--marv-space-2xl) var(--marv-space-lg);
    text-align: center;
}

.marv-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--marv-border);
    border-top-color: var(--marv-primary);
    border-radius: var(--marv-radius-full);
    animation: marvSpin 0.8s linear infinite;
    margin-bottom: var(--marv-space-sm);
}

@keyframes marvSpin {
    to { transform: rotate(360deg); }
}

.marv-loading p {
    margin: 0;
    color: var(--marv-text-muted);
    font-size: 13px;
    font-weight: 500;
}

/* ---- Error State ---- */
.marv-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--marv-space-2xl) var(--marv-space-lg);
    text-align: center;
}

.marv-error svg {
    margin-bottom: var(--marv-space-sm);
    color: var(--marv-danger);
}

.marv-error p {
    margin: 0 0 var(--marv-space-md) 0;
    color: var(--marv-text-secondary);
    font-size: 13px;
}

/* ---- Typing Indicator ---- */
.marv-typing {
    display: flex;
    gap: 5px;
    padding: 14px 16px;
    align-items: center;
}

.marv-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--marv-text-muted);
    border-radius: var(--marv-radius-full);
    animation: marvTypingBounce 1.4s infinite ease-in-out;
}

.marv-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.marv-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* ---- Analysis Loader ---- */
.marv-analysis-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--marv-space-sm);
    padding: var(--marv-space-md);
}

.marv-analysis-spinner {
    position: relative;
    width: 40px;
    height: 40px;
    animation: marvSpinnerSpin 1.4s linear infinite;
}

.marv-analysis-spinner svg {
    display: block;
    width: 40px;
    height: 40px;
}

.marv-spinner-track {
    stroke: var(--marv-border);
}

.marv-spinner-path {
    stroke: var(--marv-secondary);
    stroke-linecap: round;
    stroke-dasharray: 90 125;
    stroke-dashoffset: 0;
    transform-origin: center;
    animation: marvSpinnerDash 1.4s ease-in-out infinite;
}

@keyframes marvSpinnerSpin {
    100% { transform: rotate(360deg); }
}

@keyframes marvSpinnerDash {
    0% {
        stroke-dasharray: 1 125;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90 125;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90 125;
        stroke-dashoffset: -124;
    }
}

.marv-analysis-text {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--marv-text-primary);
}

.marv-analysis-progress {
    width: 100%;
    height: 3px;
    background: var(--marv-border);
    border-radius: 2px;
    overflow: hidden;
}

.marv-progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--marv-secondary) 0%, var(--marv-secondary-light) 50%, var(--marv-secondary) 100%);
    background-size: 200% 100%;
    animation: marvProgressSlide 1.5s linear infinite;
}

@keyframes marvProgressSlide {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* ---- Debug Details ---- */
.marv-debug-details {
    margin-top: var(--marv-space-sm);
    padding: var(--marv-space-sm);
    background: var(--marv-bg-secondary);
    border: 1px solid var(--marv-border);
    border-radius: var(--marv-radius-sm);
}

.marv-debug-details summary {
    cursor: pointer;
    font-size: 11px;
    color: var(--marv-text-muted);
    font-weight: 600;
}

.marv-debug-details summary:hover {
    color: var(--marv-text-secondary);
}

.marv-debug-pre {
    margin: var(--marv-space-sm) 0 0 0;
    padding: var(--marv-space-sm);
    background: var(--marv-primary-dark);
    color: #F1F5F9;
    border-radius: var(--marv-radius-sm);
    font-size: 11px;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ---- Accordion ---- */
.marv-accordion-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px var(--marv-space-md);
    background: var(--marv-bg-primary);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--marv-font-body);
    color: var(--marv-text-primary);
    transition: background var(--marv-transition-fast);
}

.marv-accordion-btn:hover {
    background: var(--marv-bg-secondary);
}

.marv-accordion-btn:focus-visible {
    outline: 2px solid var(--marv-secondary);
    outline-offset: -2px;
}

.marv-accordion-icon {
    transition: transform var(--marv-transition-normal);
    color: var(--marv-text-muted);
}

.marv-accordion-content {
    padding: var(--marv-space-md);
    border-top: 1px solid var(--marv-border);
    background: var(--marv-bg-secondary);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 640px) {
    #marv-widget {
        bottom: 16px;
        left: 16px;
        right: auto;
        top: auto;
    }
    #marv-widget:has(.marv-widget-panel:not([hidden])) {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
    }
    .marv-launcher-tooltip {
        /* On narrow screens, place tooltip above the button to avoid overflow */
        bottom: calc(100% + 10px);
        left: 50%;
        transform: translateX(-50%);
    }
    .marv-launcher-tooltip::before {
        top: 100%;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        border: 6px solid transparent;
        border-top-color: var(--marv-primary);
    }
    .marv-launcher:hover .marv-launcher-tooltip,
    .marv-launcher:focus-visible .marv-launcher-tooltip,
    .marv-launcher.marv-show-tooltip .marv-launcher-tooltip {
        transform: translateX(-50%) translateY(-2px);
    }

    .marv-widget-container {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        height: 100%;
    }

    .marv-widget-header {
        padding: var(--marv-space-md);
        border-radius: 0;
    }

    .marv-widget-content {
        flex: 1;
        max-height: none;
        padding: var(--marv-space-md);
    }

    .marv-image-preview {
        grid-template-columns: repeat(2, 1fr);
    }

    .marv-message-bot .marv-message-bubble,
    .marv-message-user .marv-message-bubble {
        max-width: 85%;
    }

    .marv-input-area {
        padding: 0 var(--marv-space-md);
    }

    .marv-detail-row {
        flex-direction: column;
        gap: 2px;
    }

    .marv-detail-label {
        min-width: auto;
    }

    .marv-price-value {
        font-size: 28px;
    }

    .marv-confirmation-header {
        padding: var(--marv-space-lg) var(--marv-space-md) var(--marv-space-md);
    }

    .marv-confirmation-body {
        padding: var(--marv-space-md);
    }

    .marv-confirmation-actions {
        flex-direction: column;
    }

    .marv-results-secondary-row {
        flex-direction: column;
    }

    .marv-triage-badges {
        gap: 6px;
    }

}

@media (max-width: 360px) {
    .marv-message-bot .marv-message-avatar,
    .marv-message-user .marv-message-avatar {
        width: 30px;
        height: 30px;
    }
}

/* ============================================
   Accessibility — Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Custom Confirm Dialog ---- */
.marv-confirm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    border-radius: var(--marv-radius-lg);
}

.marv-confirm-dialog {
    background: var(--marv-bg-primary);
    border-radius: var(--marv-radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: var(--marv-space-lg);
    max-width: 320px;
    width: 90%;
    font-family: var(--marv-font-body);
}

.marv-confirm-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--marv-primary);
    margin-bottom: var(--marv-space-sm);
}

.marv-confirm-message {
    font-size: 14px;
    color: var(--marv-text-secondary);
    line-height: 1.5;
    margin-bottom: var(--marv-space-md);
}

.marv-confirm-buttons {
    display: flex;
    gap: var(--marv-space-sm);
    justify-content: flex-end;
}

.marv-confirm-btn {
    padding: 8px 18px;
    border-radius: var(--marv-radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--marv-font-body);
    cursor: pointer;
    border: none;
    transition: all var(--marv-transition-fast);
}

.marv-confirm-cancel {
    background: var(--marv-bg-secondary);
    color: var(--marv-text-secondary);
    border: 1px solid var(--marv-border);
}

.marv-confirm-cancel:hover {
    background: var(--marv-border-light);
}

.marv-confirm-ok {
    background: var(--marv-primary);
    color: #fff;
}

.marv-confirm-ok:hover {
    opacity: 0.9;
}
