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

:root {
    --sab: env(safe-area-inset-bottom);
    --sat: env(safe-area-inset-top);
}

body {
    font-family: 'Epilogue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f6f8f7;
    color: #122017;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(120deg, #38e07b, #16a34a);
    color: white;
    padding: 16px;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
    box-shadow: 0 10px 30px rgba(9, 38, 27, 0.25);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 110px;
    /* Space for fixed input container */
    display: flex;
    flex-direction: column;
    gap: 18px;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

.message {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    gap: 14px;
}

.message.assistant {
    align-items: flex-start;
}

.assistant-avatar {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #38e07b;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    box-shadow: 0 10px 20px rgba(56, 224, 123, 0.35);
}

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

.assistant-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.assistant-name {
    font-size: 16px;
    font-weight: 700;
    color: #122017;
    margin: 0;
}

.assistant-tagline {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #627b6c;
    margin: 0;
}

.assistant-bubble {
    background: #eef5f0;
    color: #1d2a24;
    padding: 16px 20px;
    border-radius: 18px;
    border-top-left-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(18, 32, 23, 0.05);
    line-height: 1.5;
    word-break: break-word;
    max-width: 100%;
}

.assistant-attachments {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.assistant-tabs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.assistant-tabs-header {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.assistant-tab-button {
    border: none;
    border-radius: 999px;
    background: rgba(18, 32, 23, 0.08);
    color: #1d2a24;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 18px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.assistant-tab-button.active {
    background: #122017;
    color: #ffffff;
}

.assistant-tab-button:focus-visible {
    outline: 2px solid #38e07b;
    outline-offset: 2px;
}

.assistant-tab-button[hidden] {
    display: none;
}

.assistant-tabs-body {
    width: 100%;
}

.assistant-tab-content {
    display: none;
    width: 100%;
}

.assistant-tab-content.active {
    display: block;
}

.assistant-carousel {
    background: #ffffff;
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 30px 60px rgba(16, 45, 33, 0.12);
    position: relative;
}

.assistant-carousel-header {
    font-size: 15px;
    font-weight: 600;
    color: #627b6c;
    margin-bottom: 12px;
}

.assistant-carousel-body {
    position: relative;
}

.assistant-carousel-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    scroll-behavior: smooth;
}

.assistant-carousel-track::-webkit-scrollbar {
    display: none;
}

.carousel-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(18, 32, 23, 0.8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 5;
    opacity: 0.9;
}

.carousel-button[disabled] {
    opacity: 0;
    pointer-events: none;
}

.carousel-button.prev {
    left: -12px;
}

.carousel-button.next {
    right: -12px;
}

@media (max-width: 640px) {
    .carousel-button {
        display: none;
    }
}

.product-card {
    background: #fdfdfc;
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px rgba(18, 32, 23, 0.06);
    min-width: 240px;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 35px rgba(18, 32, 23, 0.2);
}

.product-card-media {
    width: calc(100% - 32px);
    margin: 16px 16px 12px;
    border-radius: 16px;
    background-color: #d1e7d7;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    aspect-ratio: 4 / 3;
}

.product-card-media.has-carousel {
    background: #f8fbf7;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-media-carousel {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding: 12px;
    width: 100%;
    touch-action: pan-x;
}

.product-media-carousel::-webkit-scrollbar {
    height: 6px;
}

.product-media-carousel::-webkit-scrollbar-thumb {
    background: rgba(18, 32, 23, 0.15);
    border-radius: 999px;
}

.product-media-item {
    position: relative;
    flex: 0 0 180px;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(18, 32, 23, 0.08);
    overflow: hidden;
    scroll-snap-align: center;
}

.product-media-item img,
.product-media-item video {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.product-media-item audio {
    display: none;
}

.product-media-item video {
    background: #000;
}

.product-media-controls {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
}

.product-media-control {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(18, 32, 23, 0.75);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.product-media-control:hover {
    background: rgba(18, 32, 23, 0.9);
}

.product-media-control .material-symbols-outlined {
    font-size: 18px;
}

.product-media-audio {
    min-height: 140px;
}

.product-audio-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 12px 48px;
    text-align: center;
    color: #122017;
}

.product-audio-visual .material-symbols-outlined {
    font-size: 32px;
    color: #16a34a;
}

.product-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 16px 16px;
}

.product-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.product-card-name {
    font-size: 16px;
    font-weight: 700;
    color: #122017;
    margin: 0;
}

.product-card-desc {
    font-size: 13px;
    color: #4b5d52;
    margin: 0;
}

.product-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #122017;
}

.product-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    background: #38e07b;
}

.product-card-cta {
    margin-top: 8px;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #16a34a;
}

.product-card-cta .material-symbols-outlined {
    font-size: 18px;
}

.product-service-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.product-service-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    background: rgba(18, 32, 23, 0.08);
    color: #122017;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
}

.product-service-badge .material-symbols-outlined {
    font-size: 14px;
}

.product-location {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4b5d52;
    margin-top: 6px;
}

.product-location .material-symbols-outlined {
    font-size: 16px;
    color: #38e07b;
}

.product-more-locations {
    margin-top: 4px;
    border: none;
    background: none;
    color: #16a34a;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.product-more-locations:hover {
    text-decoration: underline;
}

.business-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 35px rgba(18, 32, 23, 0.12);
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.business-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 40px rgba(18, 32, 23, 0.18);
}

.business-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.business-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #eef5f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #122017;
    font-size: 26px;
}

.business-card-name {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #122017;
}

.badge-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.badge-pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-pill.medical {
    background: #e0f2fe;
    color: #075985;
}

.badge-pill.recreational {
    background: #fef3c7;
    color: #92400e;
}

.badge-pill.delivery {
    background: #dcfce7;
    color: #065f46;
}

.business-card-details {
    font-size: 13px;
    color: #4b5d52;
    line-height: 1.4;
}

.business-stack {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.business-stack::-webkit-scrollbar {
    display: none;
}

.business-card {
    min-width: 260px;
}

.business-card-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}

.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 15, 10, 0.6);
    backdrop-filter: blur(10px);
    display: none;
    align-items: flex-start; /* Start from top - more reliable cross-browser */
    justify-content: center;
    padding: 24px;
    z-index: 2000;
    overflow-y: auto; /* Overlay scrolls if card is taller than viewport */
    -webkit-overflow-scrolling: touch;
}

.detail-overlay.active {
    display: flex;
}

.detail-card {
    width: min(420px, 90vw);
    background: #ffffff;
    border-radius: 28px;
    padding: 28px;
    box-shadow: 0 30px 70px rgba(7, 18, 12, 0.35);
    position: relative;
    /* Card doesn't scroll - overlay scrolls instead */
    overflow: visible;
    /* Use margin auto for vertical centering when space available */
    margin-top: auto;
    margin-bottom: auto;
    /* Ensure card shrinks to fit content, not viewport */
    flex-shrink: 0;
}

.detail-media-container {
    margin: -28px -28px 20px -28px;
    border-radius: 28px 28px 0 0;
    overflow: hidden;
    background: #f8fbf7;
}

.detail-media-container .product-media-carousel {
    padding: 0;
    gap: 0;
}

.detail-media-container .product-media-item {
    width: 100%;
    min-width: 100%;
}

.detail-media-container .product-media-item img,
.detail-media-container .product-media-item video {
    max-height: 400px;
    width: 100%;
    object-fit: cover;
    border-radius: 0;
}

.detail-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.detail-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #122017;
}

.detail-subtitle {
    font-size: 14px;
    color: #4b5d52;
    margin-bottom: 16px;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.detail-tag {
    background: #eef5f0;
    color: #1d2a24;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.detail-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.detail-meta-row {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: #122017;
}

.detail-businesses {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0 8px;
}

.detail-business {
    border: 1px solid #e6ebe7;
    border-radius: 14px;
    padding: 12px;
}

.detail-business-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.detail-business-meta {
    font-size: 12px;
    color: #4b5d52;
    margin-top: 4px;
}

.detail-business-link {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #16a34a;
    font-weight: 600;
    text-decoration: none;
}

.detail-business-link:hover {
    text-decoration: underline;
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-bottom: 4px; /* Extra space at bottom for button shadow */
}

.detail-button {
    flex: 1;
    border: none;
    border-radius: 999px;
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.detail-button.primary {
    background: #38e07b;
    color: #0d140f;
    box-shadow: 0 18px 35px rgba(56, 224, 123, 0.35);
}

.detail-button.secondary {
    background: #eef5f0;
    color: #122017;
}

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

.user-bubble {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    background: linear-gradient(120deg, #38e07b, #16a34a);
    color: white;
    font-weight: 600;
    box-shadow: 0 12px 24px rgba(22, 163, 74, 0.25);
}

.detected-location {
    align-self: flex-start;
    background: #ecfdf5;
    color: #047857;
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(4, 120, 87, 0.12);
}

/* Product Cards - Enhanced */
.products-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.result-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.result-header {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.result-header:hover {
    background: #f9fafb;
}

.strain-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.strain-badge.indica {
    background: #e0e7ff;
    color: #4338ca;
}

.strain-badge.sativa {
    background: #fef3c7;
    color: #d97706;
}

.strain-badge.hybrid {
    background: #d1fae5;
    color: #059669;
}

.result-header h4 {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.business-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon {
    font-size: 18px;
    cursor: help;
}

.icon.delivery:hover::after,
.icon.mail:hover::after {
    content: attr(title);
    position: absolute;
    background: #1f2937;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-top: 24px;
    margin-left: -60px;
    z-index: 10;
}

/* Map popup for store locations */
.icon.dispensary {
    position: relative;
    cursor: pointer;
}

.map-popup {
    display: none;
    position: fixed;
    top: auto;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: white;
    border: 2px solid #10b981;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    min-width: 250px;
    max-width: 300px;
    max-width: min(300px, 90vw);
    right: auto;
}

/* Show popup on hover */
.icon.dispensary:hover .map-popup {
    display: block;
}

/* Adjust position when near edges */
@media (max-width: 768px) {
    .map-popup {
        left: 5vw;
        right: 5vw;
        transform: none;
        max-width: none;
        width: auto;
    }
}

.map-popup-address {
    font-size: 13px;
    color: #374151;
    margin-bottom: 8px;
    padding: 8px;
    background: #f3f4f6;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: all;
}

.map-popup-address:hover {
    background: #e5e7eb;
}

.map-popup-map {
    width: 100%;
    height: 150px;
    border-radius: 8px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 12px;
}

.icon.open-now {
    background: #10b981;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.result-details {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.result-details.expanded {
    max-height: 200px;
    padding: 0 16px 16px;
}

.price-info {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

.effects {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.business-info {
    background: #f9fafb;
    padding: 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.business-info strong {
    font-size: 14px;
    color: #111827;
}

.distance {
    font-size: 13px;
    color: #6b7280;
}

.view-details {
    background: #22c55e;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.view-details:hover {
    background: #16a34a;
}

/* Suggestions */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.suggestion {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion:hover {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
}

.chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: white;
    border-top: 1px solid #e5e7eb;
    z-index: 1000;
    /* Ensure visibility in iframe */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    align-items: center;
}

.chat-input {
    flex: 1;
    min-width: 0; /* Allow shrinking in flexbox */
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
}

.chat-input:focus {
    border-color: #22c55e;
}

.send-button {
    flex-shrink: 0; /* Don't shrink */
    padding: 12px 24px;
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.send-button:hover {
    background: #16a34a;
}

.send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* New Chat Button */
.new-chat-btn {
    padding: 10px;
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    min-width: 42px; /* Prevent shrinking */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.new-chat-btn:hover {
    background: #f9fafb;
    border-color: #22c55e;
    color: #22c55e;
}

.new-chat-btn:active {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
}

.new-chat-btn .material-symbols-outlined {
    font-size: 20px;
}

/* New Chat Wrapper (for popup positioning) */
.new-chat-wrapper {
    position: relative;
}

/* Past Conversations Popup - now at body level for better positioning */
.past-conversations-popup {
    position: fixed;
    bottom: 90px; /* Above input container on desktop */
    left: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 280px;
    max-height: 350px;
    overflow-y: auto;
    display: none;
    z-index: 10001;
}

.past-conversations-popup.active {
    display: block;
}

.past-conversations-popup::-webkit-scrollbar {
    width: 6px;
}

.past-conversations-popup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.past-conversations-popup::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.past-conv-new-chat {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: #22c55e;
    color: white;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.past-conv-new-chat:hover {
    background: #16a34a;
}

.past-conv-new-chat .material-symbols-outlined {
    font-size: 18px;
}

.past-conv-empty {
    padding: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.past-conv-date {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
}

.past-conv-item {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.past-conv-item:hover {
    background: #f9fafb;
}

.past-conv-item.active {
    background: #ecfdf5;
}

.past-conv-item:last-child {
    border-bottom: none;
}

.past-conv-preview {
    flex: 1;
    font-size: 13px;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.past-conv-item.active .past-conv-preview {
    color: #059669;
    font-weight: 500;
}

.past-conv-delete {
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #9ca3af;
    opacity: 0;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.past-conv-item:hover .past-conv-delete {
    opacity: 1;
}

.past-conv-delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

.past-conv-delete .material-symbols-outlined {
    font-size: 16px;
}

/* History Settings */
.history-settings {
    position: relative;
}

.history-settings-btn {
    padding: 10px;
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    min-width: 42px; /* Prevent shrinking */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.history-settings-btn:hover {
    background: #f9fafb;
    border-color: #6b7280;
}

.history-settings-btn .material-symbols-outlined {
    font-size: 20px;
}

.history-settings-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    min-width: 200px;
    max-height: calc(100vh - 120px); /* Limit height to available space */
    max-height: calc(100svh - 120px); /* Use small viewport for mobile */
    overflow-y: auto; /* Scroll when content exceeds available space */
    display: none;
    z-index: 100;
}

.history-settings-menu.active {
    display: block;
}

.history-settings-item {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.history-settings-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-settings-item:first-child {
    padding-top: 0;
}

.history-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
}

.history-toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #22c55e;
    cursor: pointer;
}

.clear-history-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: #fef2f2;
    color: #dc2626;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.clear-history-btn:hover {
    background: #fee2e2;
}

.clear-history-btn .material-symbols-outlined {
    font-size: 18px;
}

.storage-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
}

.storage-label {
    flex-shrink: 0;
}

.storage-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.storage-fill {
    height: 100%;
    background: #22c55e;
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

.storage-fill.warning {
    background: #f59e0b;
}

.storage-fill.critical {
    background: #dc2626;
}

.storage-text {
    flex-shrink: 0;
    min-width: 50px;
    text-align: right;
}

/* Privacy Notice */
.privacy-notice {
    margin-top: 4px;
}

.privacy-notice-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #6b7280;
    transition: all 0.15s;
}

.privacy-notice-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.privacy-notice-btn .material-symbols-outlined {
    font-size: 18px;
}

.privacy-notice-content {
    display: none;
    padding: 10px;
    margin-top: 8px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    font-size: 12px;
    color: #92400e;
    line-height: 1.5;
}

.privacy-notice-content.active {
    display: block;
}

.privacy-notice-content p {
    margin: 0 0 8px 0;
}

.privacy-notice-content p:last-child {
    margin-bottom: 0;
}

.privacy-notice-content ul {
    margin: 4px 0 0 0;
    padding-left: 20px;
}

.privacy-notice-content li {
    margin: 2px 0;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f4f6;
    border-top-color: #22c55e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error-message {
    background: #fee;
    color: #c00;
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
}

