html {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
}

header {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
   padding: calc(30px + env(safe-area-inset-top)) 20px 30px 20px;

    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.2em;
    margin: 0 0 8px 0;
    font-weight: 600;
}

header p {
    font-size: 1em;
    margin: 0;
    opacity: 0.95;
}

.info-banner {
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    color: #555;
    font-size: 0.95em;
    width: 100%;
    box-sizing: border-box;
    overflow-x: visible;
}

.info-banner-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 10px;
}

.info-banner strong {
    color: #1f1ff5;
}

.language-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 12px;
    background: #f5f7fa;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.85em;
}

.toggle-label:hover {
    background: #e8eaf6;
}

.toggle-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.toggle-label span {
    font-weight: 500;
    color: #555;
}

.voice-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.voice-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.voice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.voice-btn.listening {
    background: linear-gradient(135deg, #f44336 0%, #e91e63 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.voice-select {
    padding: 8px 12px;
    background: white;
    border: 2px solid #1f1ff5;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9em;
    color: #333;
    transition: all 0.2s;
}

.voice-select:hover {
    border-color: #4a0fb5;
    background: #f5f7fa;
}

.voice-select:focus {
    outline: none;
    border-color: #4a0fb5;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
}

section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

h3 {
    color: #333;
    margin: 0 0 20px 0;
    font-size: 1.3em;
    font-weight: 600;
}

.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: stretch;
}

input[type="text"] {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #1f1ff5;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primary {
    padding: 14px 28px;
    background: #1f1ff5;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #1414e0;
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 14px 28px;
    background: white;
    color: #1f1ff5;
    border: 2px solid #1f1ff5;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f0f3ff;
}

.btn-action {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 20px;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.results-box {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.symptom-item {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
}

.symptom-item:hover {
    background: #f5f5f5;
}

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

.symptom-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.symptom-details {
    font-size: 0.9em;
    color: #666;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0;
    min-height: 20px;
}

.tag {
    background: #1f1ff5;
    color: white;
    padding: 6px 14px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.tag .remove {
    cursor: pointer;
    font-weight: bold;
}

.tag.manual-tag {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: 2px dashed rgba(255,255,255,0.8);
}

.herb-list {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
}

.herb-card {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
}

.herb-card:hover {
    border-color: #1f1ff5;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.15);
}

.herb-card.selected {
    border-color: #1f1ff5;
    background: #f0f3ff;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.2);
}

.herb-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.herb-name {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tradition-badge {
    font-size: 0.7em;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
    display: inline-block;
}

.tradition-western {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac;
}

.tradition-chinese {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fda4af;
}

.tradition-ayurvedic {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.herb-chinese {
    color: #1f1ff5;
    font-size: 0.9em;
}

.herb-energetics {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    font-size: 0.9em;
}

.energetic-tag {
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 5px;
}

.herb-actions {
    color: #666;
    font-size: 0.95em;
    line-height: 1.5;
}

.herb-actions-section {
    margin-top: 12px;
    padding: 10px;
    background: #f8f9ff;
    border-left: 3px solid #1f1ff5;
    border-radius: 4px;
    color: #333;
    font-size: 0.95em;
    line-height: 1.6;
}

.herb-actions-section strong {
    color: #1f1ff5;
    display: inline-block;
    margin-right: 5px;
}

.herb-indications {
    margin-top: 10px;
    padding: 10px;
    background: #fff8f0;
    border-left: 3px solid #f5576c;
    border-radius: 4px;
    color: #333;
    font-size: 0.95em;
    line-height: 1.6;
}

.herb-indications strong {
    color: #f5576c;
    display: inline-block;
    margin-right: 5px;
}

.herb-complete-info {
    margin-top: 15px;
    padding-top: 15px;
    animation: slideDown 0.3s ease-out;
}

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

.complete-info-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e0e0e0, transparent);
    margin-bottom: 15px;
}

.info-section {
    margin-bottom: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    border-left: 3px solid #1f1ff5;
}

.info-section strong {
    color: #1f1ff5;
    display: block;
    margin-bottom: 6px;
    font-size: 0.95em;
}

.info-section p {
    margin: 0;
    color: #333;
    font-size: 0.9em;
    line-height: 1.6;
}

.warning-section {
    background: #fff9f0;
    border-left: 3px solid #dc2626;
}

.warning-section strong {
    color: #dc2626;
}

.btn-info {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-info:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-info.expanded {
    background: linear-gradient(135deg, #4a0fb5 0%, #1f1ff5 100%);
}

.preparation-method {
    margin-bottom: 25px;
}

.preparation-method label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.preparation-method select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}

.formula-details {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 25px;
}

.formula-herbs {
    margin-bottom: 25px;
}

.formula-herb-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.formula-herb-item:last-child {
    border-bottom: none;
}

.herb-info {
    flex: 1;
}

.herb-dose {
    font-weight: 600;
    color: #1f1ff5;
}

.dosing-instructions {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.dosing-instructions h3 {
    color: #1f1ff5;
    margin-bottom: 15px;
}

.instruction-list {
    list-style-position: inside;
    color: #333;
    line-height: 1.8;
}

.instruction-list li {
    margin-bottom: 8px;
}

.total-dose {
    background: #1f1ff5;
    color: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 20px;
}

.tab-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    max-width: 100%;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    flex-shrink: 0;
    white-space: nowrap;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #6a11cb;
    background: rgba(106, 17, 203, 0.05);
}

.tab-btn.active {
    color: #fff;
    background: linear-gradient(135deg, #6a11cb, #2575fc);
    border-bottom-color: transparent;
    border-radius: 20px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(106, 17, 203, 0.35);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
    margin: auto;
    flex-shrink: 0;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

/* Sticky header for modals */
.modal-sticky-header {
    background: white;
    border-bottom: 2px solid #f0f0f0;
}

/* Mobile optimization for modals */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 85vh;
        margin: 10px;
    }
    
    .modal-content h3 {
        font-size: 1.2em;
    }
    
    /* Fix input group button overlap on mobile */
    .input-group {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .input-group input[type="text"] {
        width: 100% !important;
        flex: none !important;
    }
    
    .input-group button {
        width: 100% !important;
        flex: none !important;
    }
    
    /* Fix Browse Herbs filter buttons cutoff on mobile */
    .filter-row {
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }
    
    .filter-row input[type="text"],
    .filter-row button {
        width: 100% !important;
        flex: none !important;
    }
    
    .filter-group {
        width: 100% !important;
    }
    
    /* Fix AI Consultant input/buttons cutoff on mobile */
    .ai-input-group {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .ai-input-group input[type="text"] {
        width: 100% !important;
        flex: none !important;
    }
    
    .ai-input-group button {
        width: 100% !important;
        flex: none !important;
    }
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6a11cb;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 25px;
}

.saved-formulas-section {
    padding: 20px;
}

.saved-formulas-list {
    display: grid;
    gap: 20px;
}

.saved-formula-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #f0f0f0;
    transition: all 0.2s;
}

.saved-formula-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-color: #6a11cb;
}

.saved-formula-card.expanded {
    border-color: #6a11cb;
    box-shadow: 0 4px 16px rgba(106, 17, 203, 0.15);
}

.formula-header {
    margin-bottom: 0;
    -webkit-tap-highlight-color: transparent;
}

.formula-header h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.2em;
}

.formula-meta {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 8px;
}

.formula-description {
    font-size: 0.95em;
    color: #555;
    margin: 8px 0;
    font-style: italic;
}

.formula-preview {
    font-size: 0.9em;
    color: #888;
    margin-top: 8px;
}

.formula-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-delete-formula {
    color: #d32f2f !important;
    border-color: #d32f2f !important;
}

.back-to-saved-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: linear-gradient(135deg, #6a11cb, #2575fc);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(106, 17, 203, 0.4);
    -webkit-tap-highlight-color: transparent;
}

.prep-selector {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.prep-selector label {
    font-weight: 500;
    color: #555;
}

.prep-selector select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
}

.dosage-adjustment-panel {
    background: linear-gradient(135deg, #f3e7ff 0%, #e8eaf6 100%);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid #d1c4e9;
}

.adjustment-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: start;
}

.adjustment-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.adjustment-group label {
    font-weight: 600;
    font-size: 0.9em;
    color: #5e35b1;
}

.weight-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.weight-control input[type="range"] {
    flex: 1 1 180px;
    min-width: 140px;
}

.weight-control #weightDisplay {
    min-width: 80px;
    font-weight: 600;
    flex: 0 0 auto;
}

.weight-control #weightUnit {
    flex: 0 0 auto;
    min-width: 72px;
    padding: 4px 8px;
}

.adjustment-group select,
.adjustment-group input[type="range"] {
    padding: 10px;
    border: 2px solid #b39ddb;
    border-radius: 6px;
    font-size: 0.95em;
    cursor: pointer;
    background: white;
}

.adjustment-group input[type="range"] {
    padding: 0;
    height: 10px;
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    background: linear-gradient(to right, #d1c4e9, #b39ddb);
    touch-action: none;
    margin: 12px 0;
}

.adjustment-group input[type="range"]::-webkit-slider-runnable-track {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, #d1c4e9, #b39ddb);
}

.adjustment-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #5e35b1;
    cursor: pointer;
    margin-top: -13px;
    box-shadow: 0 2px 8px rgba(94, 53, 177, 0.4);
    border: 3px solid white;
}

.adjustment-group input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(94, 53, 177, 0.6);
}

.adjustment-group input[type="range"]::-moz-range-track {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, #d1c4e9, #b39ddb);
    border: none;
}

.adjustment-group input[type="range"]::-moz-range-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #5e35b1;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(94, 53, 177, 0.4);
}

.adjustment-info {
    margin-top: 15px;
    padding: 12px;
    background: rgba(94, 53, 177, 0.1);
    border-radius: 6px;
    border-left: 4px solid #5e35b1;
    font-size: 0.9em;
    color: #5e35b1;
    font-weight: 500;
}

.interaction-analysis {
    background: linear-gradient(135deg, #f0f9ff 0%, #dbeafe 100%);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border: 2px solid #93c5fd;
}

.interaction-analysis h3 {
    margin: 0 0 15px 0;
    color: #0f766e;
}

.interaction-warnings {
    background: #ffebee;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #d32f2f;
}

.interaction-warnings ul {
    margin: 10px 0 0 20px;
    color: #b71c1c;
}

.interaction-synergies {
    background: #e8f5e9;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #166534;
}

.interaction-synergies ul {
    margin: 10px 0 0 20px;
    color: #14532d;
}

.interaction-warnings ul li,
.interaction-synergies ul li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.btn-substitute {
    flex: 1;
    padding: 10px;
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9em;
    transition: all 0.2s;
}

.btn-substitute:hover {
    background: linear-gradient(135deg, #29b6f6 0%, #0288d1 100%);
    transform: translateY(-2px);
}

.btn-print {
    flex: 1;
    padding: 10px;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9em;
    transition: all 0.2s;
}

.btn-print:hover {
    background: linear-gradient(135deg, #15803d 0%, #14532d 100%);
    transform: translateY(-2px);
}

.substitute-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.substitute-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.2s;
}

.substitute-card:hover {
    border-color: #2196f3;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.15);
}

.substitute-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.substitute-rank {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9em;
}

.substitute-header h4 {
    margin: 0;
    flex: 1;
    color: #333;
}

.substitute-energetics {
    color: #666;
    font-size: 0.9em;
    margin: 8px 0;
}

.substitute-reasons {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9em;
    margin: 10px 0;
    border-left: 4px solid #2196f3;
}

.substitute-actions {
    font-size: 0.9em;
    color: #555;
    margin-top: 10px;
}

.education-accordion {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.accordion-item {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s;
}

.accordion-item.active {
    border-color: #1f1ff5;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.accordion-header {
    width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #fff 100%);
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    transition: all 0.2s;
}

.accordion-header:hover {
    background: linear-gradient(135deg, #e8eaf6 0%, #f5f7fa 100%);
}

.accordion-icon {
    font-size: 1.5em;
    color: #1f1ff5;
    font-weight: 300;
    transition: transform 0.3s;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: white;
}

.edu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 25px;
}

.edu-card {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    transition: all 0.2s;
}

.edu-card:hover {
    border-color: #1f1ff5;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.edu-card h4 {
    margin: 0 0 12px 0;
    color: #1f1ff5;
    font-size: 1.1em;
}

.edu-card p {
    margin: 0;
    line-height: 1.7;
    color: #555;
    font-size: 0.95em;
}

.edu-card strong {
    color: #333;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 210px;
    background: white;
    border: 2px solid #1f1ff5;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s;
}

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

.autocomplete-item:hover {
    background: linear-gradient(135deg, #e8eaf6 0%, #f5f7fa 100%);
}

.autocomplete-item strong {
    color: #333;
    font-size: 0.95em;
}

.autocomplete-item small {
    color: #666;
    font-size: 0.85em;
    line-height: 1.4;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px;
}

.filter-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 2px solid #e9ecef;
}

.filter-row {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.filter-group label {
    font-weight: 500;
    font-size: 0.9em;
    color: #555;
}

.filter-group select {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95em;
    cursor: pointer;
    background: white;
}

.herb-count {
    margin-bottom: 20px;
    font-size: 1em;
    color: #666;
}

.herb-browser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.herb-browser-card {
    background: white;
    padding: 18px;
    border-radius: 10px;
    border: 2px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
}

.herb-browser-card:hover {
    border-color: #1f1ff5;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.herb-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.herb-card-header h4 {
    margin: 0 0 4px 0;
    color: #333;
    font-size: 1.1em;
}

.tradition-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
}

.tradition-badge.western {
    background: #f0fdf4;
    color: #166534;
}

.tradition-badge.chinese {
    background: #fff1f2;
    color: #9f1239;
}

.tradition-badge.ayurvedic {
    background: #f0fdfa;
    color: #0f766e;
}

.herb-energetics-compact {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #666;
}

.herb-energetics-compact span {
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
}

.herb-actions-compact {
    font-size: 0.9em;
    color: #555;
    line-height: 1.4;
}

.herb-actions-compact strong {
    color: #1f1ff5;
}

.compare-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.compare-selected {
    border-color: #1f1ff5 !important;
    background: #f0f3ff;
}

.comparison-grid {
    display: grid;
    gap: 20px;
}

.comparison-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.comparison-card h4 {
    color: #333;
    margin: 0 0 8px 0;
    font-size: 1.2em;
}

.comparison-section {
    margin: 15px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.comparison-section:last-child {
    border-bottom: none;
}

.comparison-section strong {
    color: #1f1ff5;
    display: block;
    margin-bottom: 6px;
}

.comparison-section p {
    margin: 0;
    color: #555;
    line-height: 1.5;
}

select {
    background: white;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.inventory-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.inventory-card:hover {
    border-color: #1f1ff5;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.inventory-herb-name {
    font-size: 1.1em;
    font-weight: 700;
    color: #333;
}

.inventory-stock-level {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2em;
    font-weight: 600;
}

.stock-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
}

.stock-good {
    background: #16a34a;
    color: white;
}

.stock-low {
    background: #dc2626;
    color: white;
}

.stock-out {
    background: #f44336;
    color: white;
}

.inventory-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.inventory-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inventory-detail-label {
    font-size: 0.75em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inventory-detail-value {
    font-weight: 600;
    color: #333;
}

.inventory-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.alert-banner {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.alert-warning {
    background: #eff6ff;
    border-left: 4px solid #dc2626;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
    color: #0c5460;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}

.form-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #1f1ff5;
}

.expiring-badge {
    background: #dc2626;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 600;
    margin-left: 8px;
}

.journal-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.journal-entry {
    background: white;
    border: 2px solid #e0e0e0;
    border-left: 6px solid #1f1ff5;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.journal-entry:hover {
    border-color: #1f1ff5;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.journal-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
}

.journal-date {
    font-size: 0.9em;
    color: #1f1ff5;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.journal-ratings {
    display: flex;
    gap: 15px;
}

.rating-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.rating-excellent {
    background: #16a34a;
    color: white;
}

.rating-good {
    background: #22c55e;
    color: white;
}

.rating-moderate {
    background: #7c3aed;
    color: #333;
}

.rating-slight {
    background: #dc2626;
    color: white;
}

.rating-none {
    background: #f44336;
    color: white;
}

.journal-content {
    margin-bottom: 15px;
}

.journal-content.collapsed {
    display: none;
}

.journal-field {
    margin-bottom: 12px;
}

.journal-label {
    font-size: 0.75em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}

.journal-value {
    color: #333;
    font-size: 0.95em;
    line-height: 1.5;
}

.journal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.analytics-panel {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.analytics-card {
    background: rgba(255, 255, 255, 0.15);
    padding: 15px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.analytics-value {
    font-size: 2em;
    font-weight: 700;
    margin: 8px 0;
}

.analytics-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.top-formulas-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.formula-rank-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.community-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.community-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.community-card:hover {
    border-color: #1f1ff5;
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.community-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.community-card-title {
    font-size: 1.2em;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.community-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
    color: #f39c12;
    font-weight: 600;
}

.community-creator {
    font-size: 0.85em;
    color: #1f1ff5;
    margin-bottom: 8px;
}

.community-description {
    color: #555;
    margin-bottom: 12px;
    line-height: 1.5;
}

.community-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: #888;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.community-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    margin-right: 5px;
}

.badge-western {
    background: #e8f5e9;
    color: #14532d;
}

.badge-chinese {
    background: #eff6ff;
    color: #0f766e;
}

.badge-ayurvedic {
    background: #f3e5f5;
    color: #6a1b9a;
}

.reminders-section {
    padding: 20px;
}

.reminder-stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.15);
    transition: all 0.3s ease;
}

.reminder-stat-card:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.reminder-stat-card h4 {
    margin: 0;
    color: #333;
    font-size: 1.1em;
}

.create-reminder-panel {
    background: linear-gradient(135deg, #f8f6ff 0%, #f0edff 100%);
    padding: 28px;
    border-radius: 16px;
    margin-bottom: 40px;
    border: 1px solid rgba(124, 77, 255, 0.15);
    box-shadow: 0 4px 15px rgba(124, 77, 255, 0.1);
}

.create-reminder-btn {
    margin-top: 8px;
    padding: 14px 28px !important;
    font-size: 1.05em !important;
    font-weight: 700 !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
    transition: all 0.3s ease !important;
}

.create-reminder-btn:hover {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
    transform: translateY(-2px);
}

.reminder-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.reminder-card:hover {
    border-color: #4a0fb5;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

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

.reminder-title {
    font-size: 1.1em;
    font-weight: 700;
    color: #333;
}

.reminder-time {
    font-size: 1.3em;
    font-weight: 700;
    color: #7c4dff;
}

.reminder-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.day-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.day-checkbox:hover {
    border-color: #7c4dff;
    background: #f5f5f5;
}

.day-checkbox input[type="checkbox"]:checked + label,
.day-checkbox:has(input[type="checkbox"]:checked) {
    border-color: #7c4dff;
    background: #ede7f6;
}

.schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-left: 4px solid #7c4dff;
    border-radius: 6px;
    margin-bottom: 10px;
}

.schedule-time {
    font-weight: 700;
    color: #7c4dff;
    font-size: 1.1em;
}

.adherence-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 10px;
}

.adherence-bar {
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}

.adherence-fill {
    height: 100%;
    background: linear-gradient(90deg, #16a34a, #22c55e);
    border-radius: 10px;
    transition: width 0.3s;
}

.reminder-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-daily {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-weekdays {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge-weekends {
    background: #eff6ff;
    color: #f57c00;
}

.badge-custom {
    background: #e8f5e9;
    color: #166534;
}

.btn-taken {
    background: #16a34a;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-taken:hover {
    background: #166534;
    transform: translateY(-2px);
}

.btn-skip {
    background: #dc2626;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-skip:hover {
    background: #f57c00;
    transform: translateY(-2px);
}

.btn-snooze {
    background: #9c27b0;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-snooze:hover {
    background: #7b1fa2;
    transform: translateY(-2px);
}

.btn-delete-reminder {
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.btn-delete-reminder:hover {
    background: #d32f2f;
}

.seasonal-section {
    padding: 20px;
}

.season-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.season-btn:hover {
    border-color: #1f1ff5;
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
}

.season-btn.active {
    border-color: #1f1ff5;
    background: linear-gradient(135deg, #1f1ff510, #4a0fb520);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.seasonal-herbs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.seasonal-herb-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s;
}

.seasonal-herb-card:hover {
    border-color: #1f1ff5;
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.seasonal-herb-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.seasonal-herb-name {
    font-size: 1.2em;
    font-weight: 700;
    color: #333;
}

.seasonal-herb-nature {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.nature-cool {
    background: #e3f2fd;
    color: #1976d2;
}

.nature-warm {
    background: #eff6ff;
    color: #f57c00;
}

.nature-hot {
    background: #ffebee;
    color: #d32f2f;
}

.nature-cold {
    background: #e0f2f1;
    color: #00796b;
}

.nature-neutral {
    background: #f5f5f5;
    color: #616161;
}

.seasonal-rationale {
    background: #f5f7fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid #1f1ff5;
}

.seasonal-benefits {
    font-size: 0.9em;
    color: #666;
    line-height: 1.6;
}

/* AI Consultant Chat Interface */
.ai-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: slideIn 0.3s ease-out;
}

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

.ai-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    flex-shrink: 0;
    background: #f5f7fa;
}

.ai-assistant .ai-message-avatar {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
}

.ai-user .ai-message-avatar {
    background: #e3f2fd;
}

.ai-message-content {
    flex: 1;
    background: #f5f7fa;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
}

.ai-assistant .ai-message-content {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8eaf6 100%);
    border: 1px solid #e0e0e0;
}

.ai-user .ai-message-content {
    background: #e3f2fd;
    border: 1px solid #90caf9;
}

.ai-message-header {
    font-weight: 700;
    color: #1f1ff5;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.ai-user .ai-message-header {
    color: #1976d2;
}

.save-to-journal-btn {
    margin-top: 12px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.save-to-journal-btn:hover {
    background: linear-gradient(135deg, #15803d 0%, #166534 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.save-to-journal-btn:disabled {
    cursor: default;
    transform: none;
    box-shadow: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ============================================
   SHOPPING INTEGRATION
   ============================================ */

.shopping-retailers {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.retailer-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.retailer-card:hover {
    border-color: #1f1ff5;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.retailer-card h4 {
    color: #333;
    font-size: 1.1em;
}

.retailer-card p {
    color: #666;
    line-height: 1.5;
}

.retailer-card a.btn-primary {
    padding: 10px 20px;
    font-size: 0.95em;
}

/* Mobile optimization for retailer cards */
@media (max-width: 768px) {
    .retailer-card {
        padding: 15px;
    }
    
    .retailer-card h4 {
        font-size: 1em;
    }
    
    .retailer-card p {
        font-size: 0.9em;
    }
    
    .retailer-card > div {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .retailer-card a.btn-primary {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   PWA ANIMATIONS
   ============================================ */

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 500px;
    pointer-events: all;
    animation: toastSlideIn 0.3s ease;
    border-left: 4px solid #1f1ff5;
}

.toast.success {
    border-left-color: #16a34a;
}

.toast.error {
    border-left-color: #f44336;
}

.toast.warning {
    border-left-color: #dc2626;
}

.toast.info {
    border-left-color: #2196f3;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.toast-message {
    font-size: 0.9em;
    color: #666;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.toast-close:hover {
    background: #f0f0f0;
    color: #333;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #1f1ff5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 16px;
    color: #1f1ff5;
    font-weight: 500;
}

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

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

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

.skeleton-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-text {
    height: 16px;
    width: 100%;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 40%;
}

/* ============================================
   OFFLINE INDICATOR
   ============================================ */

#offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f44336;
    color: white;
    padding: 12px 20px;
    text-align: center;
    z-index: 10002;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    font-weight: 500;
}

#offline-indicator.visible {
    transform: translateY(0);
}

#offline-indicator .status-icon {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   MOBILE TOUCH TARGET OPTIMIZATION
   ============================================ */

/* Ensure all interactive elements meet 44x44px minimum touch target */
@media (max-width: 768px) {
    .btn-primary, .btn-secondary, .btn-action,
    .btn-substitute, .btn-print,
    .btn-taken, .btn-skip, .btn-snooze {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 24px;
        margin: 4px;
    }
    
    .btn-sm, .btn-delete-reminder {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    /* Tab navigation */
    .tab {
        min-height: 48px;
        padding: 14px 16px !important;
    }
    
    /* Icon buttons */
    button[onclick*="delete"],
    button[onclick*="remove"],
    button[onclick*="close"],
    .close {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }
    
    /* Formula herb list buttons */
    .formula-herb button {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Comparison select buttons */
    .herb-select-btn {
        min-height: 44px;
        padding: 12px;
    }
    
    /* Input fields - easier to tap */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    select,
    textarea {
        min-height: 44px;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Checkboxes and radio buttons */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 24px;
        min-height: 24px;
        margin: 10px;
    }
    
    /* Better spacing for mobile */
    .herb-card,
    .seasonal-herb-card,
    .journal-entry,
    .reminder-card {
        margin-bottom: 16px;
    }
    
    /* Increase touch area for voice button */
    #speakBtn {
        min-width: 48px;
        min-height: 48px;
    }
    
    /* Toast notifications - better positioning on mobile */
    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: unset;
        width: 100%;
    }
}


/* Global Search Styles */
.global-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #1f1ff5;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    z-index: 1000;
    margin-top: 2px;
}

.global-search-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.global-search-item:hover {
    background: linear-gradient(135deg, #f5f7fa 0%, #e3f2fd 100%);
}

.global-search-item:last-child {
    border-bottom: none;
}

@keyframes highlight {
    0%, 100% { background: transparent; }
    50% { background: #eff6ff; transform: scale(1.02); }
}

/* Dark Mode Styles */
body.dark-mode {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.dark-mode .container {
    background: #16213e;
}

body.dark-mode header {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
}

body.dark-mode .info-banner {
    background: linear-gradient(135deg, #533483 0%, #3d2963 100%);
}

body.dark-mode .tab-btn {
    background: #1a1a2e;
    color: #e0e0e0;
    border-color: #2c3e50;
}

body.dark-mode .tab-btn.active {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
}

body.dark-mode .main-content {
    background: #16213e;
}

body.dark-mode .herb-card,
body.dark-mode .card,
body.dark-mode .modal-content {
    background: #0f3460;
    border-color: #2c3e50;
    color: #e0e0e0;
}

body.dark-mode .retailer-card {
    background: #0f3460;
    border-color: #2c3e50;
}

body.dark-mode .retailer-card h4 {
    color: #e0e0e0;
}

body.dark-mode .retailer-card p {
    color: #b0b0b0;
}

body.dark-mode .modal-sticky-header {
    background: #0f3460;
    border-bottom-color: #2c3e50;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: #1a1a2e;
    color: #e0e0e0;
    border-color: #2c3e50;
}

body.dark-mode .btn-primary {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
}

body.dark-mode .btn-secondary {
    background: #2c3e50;
    color: #e0e0e0;
}

body.dark-mode .safety-warnings {
    background: linear-gradient(135deg, #3d1e1e 0%, #4a2020 100%) !important;
}

body.dark-mode .global-search-dropdown {
    background: #0f3460;
    border-color: #1f1ff5;
}

body.dark-mode .global-search-item:hover {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* Favorite Star Button */
.favorite-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s;
}

.favorite-btn:hover {
    transform: scale(1.2);
}

/* Traditional Formulas Styles */
.traditional-formula-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.formula-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.formula-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
    border-color: #1f1ff5;
}

.formula-header h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.2em;
}

.formula-chinese {
    color: #666;
    font-size: 0.9em;
    margin: 5px 0;
}

.formula-tradition {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
    margin: 10px 0;
}

.formula-tradition.trad-western {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac;
}

.formula-tradition.trad-tcm {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fda4af;
}

.formula-tradition.trad-ayurveda {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.formula-description {
    color: #555;
    line-height: 1.6;
    margin: 15px 0;
    font-size: 0.95em;
}

.formula-indications {
    background: #eff6ff;
    border-left: 4px solid #dc2626;
    padding: 10px;
    margin: 12px 0;
    border-radius: 4px;
    font-size: 0.9em;
}

.formula-herbs {
    background: #e8f5e9;
    border-left: 4px solid #16a34a;
    padding: 10px;
    margin: 12px 0;
    border-radius: 4px;
    font-size: 0.9em;
    color: #14532d;
}

.formula-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.formula-detail-section {
    max-height: 600px;
    overflow-y: auto;
}

.herb-in-formula {
    transition: all 0.2s;
}

.herb-in-formula:hover {
    background: #f0f0f0 !important;
    transform: translateX(5px);
}

/* Dark mode formula styles */
body.dark-mode .formula-card {
    background: #0f3460;
    border-color: #2c3e50;
}

body.dark-mode .formula-header h4 {
    color: #e0e0e0;
}

body.dark-mode .formula-description {
    color: #c0c0c0;
}

body.dark-mode .formula-indications {
    background: rgba(255, 152, 0, 0.2);
    color: #93c5fd;
}

body.dark-mode .formula-herbs {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

body.dark-mode .herb-in-formula {
    background: #1a1a2e !important;
    border-left-color: #4a0fb5 !important;
}

body.dark-mode .herb-in-formula:hover {
    background: #16213e !important;
}

.prep-guides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.prep-guide-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid #1f1ff5;
    position: relative;
    overflow: hidden;
}

.prep-guide-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border-left-color: #4a0fb5;
}

.prep-guide-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #1f1ff5, #4a0fb5);
    opacity: 0;
    transition: opacity 0.3s;
}

.prep-guide-card:hover::before {
    opacity: 1;
}

.prep-guide-icon {
    font-size: 3em;
    margin-bottom: 10px;
    display: block;
}

.prep-guide-name {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.prep-guide-description {
    color: #666;
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 12px;
}

.prep-guide-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85em;
    color: #888;
}

.prep-guide-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.prep-guide-step {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 3px solid #1f1ff5;
}

.prep-guide-step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.prep-guide-step-number {
    background: linear-gradient(135deg, #1f1ff5, #4a0fb5);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.prep-guide-step-visual {
    font-size: 2em;
    flex-shrink: 0;
}

.prep-guide-step-title {
    font-weight: 600;
    color: #333;
    flex: 1;
}

.prep-guide-step-description {
    color: #555;
    line-height: 1.6;
}

.prep-guide-tips, .prep-guide-warnings, .prep-guide-equipment {
    background: #f0f4ff;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.prep-guide-tips {
    background: #e8f5e9;
    border-left: 4px solid #16a34a;
}

.prep-guide-warnings {
    background: #eff6ff;
    border-left: 4px solid #dc2626;
}

.prep-guide-equipment {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.prep-guide-list {
    list-style-position: inside;
    padding-left: 0;
    margin: 10px 0 0 0;
}

.prep-guide-list li {
    padding: 6px 0;
    line-height: 1.5;
    color: #555;
}

body.dark-mode .prep-guide-card {
    background: #1a1a2e;
    border-left-color: #4a0fb5;
}

body.dark-mode .prep-guide-name {
    color: #e0e0e0;
}

body.dark-mode .prep-guide-description {
    color: #aaa;
}

body.dark-mode .prep-guide-meta {
    color: #888;
}

body.dark-mode .prep-guide-step {
    background: #16213e;
    border-left-color: #4a0fb5;
}

body.dark-mode .prep-guide-step-title {
    color: #e0e0e0;
}

body.dark-mode .prep-guide-step-description {
    color: #aaa;
}

body.dark-mode .prep-guide-tips {
    background: rgba(76, 175, 80, 0.15);
    border-left-color: #16a34a;
}

body.dark-mode .prep-guide-warnings {
    background: rgba(255, 152, 0, 0.15);
    border-left-color: #dc2626;
}

body.dark-mode .prep-guide-equipment {
    background: rgba(33, 150, 243, 0.15);
    border-left-color: #2196f3;
}

body.dark-mode .prep-guide-list li {
    color: #aaa;
}

/* ============================================
   PRINT-OPTIMIZED FORMULA CARDS
   ============================================ */

@media print {
    /* Hide unnecessary elements when printing */
    header, nav, .tab-nav, button, .btn-primary, .btn-secondary, .btn-action,
    #toast-container, .loading-overlay, .global-search-container,
    .voice-controls, .language-toggles, .unit-toggle, #darkModeToggle {
        display: none !important;
    }
    
    /* Optimize page for printing */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .main-content {
        display: block !important;
        max-width: none !important;
    }
    
    .print-formula-card {
        page-break-inside: avoid;
        page-break-after: always;
        padding: 20px;
        border: 2px solid #333;
        margin-bottom: 30px;
    }
    
    .print-formula-card h2 {
        color: #333;
        border-bottom: 3px solid #1f1ff5;
        padding-bottom: 10px;
        margin-bottom: 15px;
    }
    
    .print-formula-card table {
        width: 100%;
        border-collapse: collapse;
        margin: 15px 0;
    }
    
    .print-formula-card th,
    .print-formula-card td {
        border: 1px solid #333;
        padding: 8px;
        text-align: left;
    }
    
    .print-formula-card th {
        background: #f0f0f0;
        font-weight: bold;
    }
}

/* Print preview modal styling */
.print-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.print-preview-content {
    background: white;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.print-preview-header {
    background: linear-gradient(135deg, #1f1ff5 0%, #4a0fb5 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.print-preview-body {
    padding: 30px;
}

.print-formula-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
}

.print-formula-header {
    border-bottom: 3px solid #1f1ff5;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.print-formula-header h2 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 2em;
}

.print-formula-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.print-meta-item {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #1f1ff5;
}

.print-meta-item strong {
    display: block;
    color: #1f1ff5;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.print-herb-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.print-herb-table th,
.print-herb-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}

.print-herb-table th {
    background: #1f1ff5;
    color: white;
    font-weight: 600;
}

.print-herb-table tr:nth-child(even) {
    background: #f9f9f9;
}

.print-instructions {
    background: #f0f9ff;
    border-left: 4px solid #7c3aed;
    padding: 20px;
    border-radius: 6px;
    margin: 20px 0;
}

.print-warnings {
    background: #ffebee;
    border-left: 4px solid #f44336;
    padding: 15px;
    border-radius: 6px;
    margin: 20px 0;
}

.print-footer {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
    text-align: center;
    font-size: 0.9em;
    color: #666;
}

/* ============================================
   TABLET OPTIMIZATION (iPad, etc)
   ============================================ */

@media (max-width: 1024px) and (min-width: 769px) {
    /* Compact header for tablets */
    header {
        padding: 15px 20px !important;
    }
    
    header h1 {
        font-size: 1.6em !important;
    }
    
    header p {
        font-size: 0.9em !important;
    }
    
    /* Info banner - much more compact */
    .info-banner {
        padding: 10px 15px !important;
    }
    
    .info-banner p {
        font-size: 0.85em !important;
        margin-bottom: 0 !important;
    }
    
    /* Make controls wrap but stay horizontal-ish */
    .info-banner > div {
        gap: 10px !important;
    }
    
    .voice-controls, .language-toggle {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    
    .voice-btn, .voice-select {
        padding: 6px 10px !important;
        font-size: 0.8em !important;
    }
    
    .toggle-label {
        padding: 5px 8px !important;
        font-size: 0.75em !important;
    }
    
    /* Tab navigation - sticky on tablets */
    .tab-nav {
        position: sticky;
        top: 0;
        background: white;
        z-index: 100;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .tab-btn {
        font-size: 0.85em !important;
        padding: 10px 12px !important;
    }
}

/* ============================================
   MOBILE HEADER AND INFO BANNER OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    body {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
    }
    
    .container {
        overflow-x: clip;
        padding: 0;
    }
    
    /* Compact header */
    header {
        padding: 10px 15px !important;
        width: 100%;
        box-sizing: border-box;
    }
    
    header h1 {
        font-size: 1.4em !important;
        margin-bottom: 5px !important;
    }
    
    header p {
        font-size: 0.8em !important;
    }
    
    /* Global search - full width on mobile */
    .global-search-container {
        min-width: 100% !important;
        max-width: 100% !important;
        margin-top: 10px;
    }
    
    /* Info banner - VERY compact */
    .info-banner {
        padding: 8px 12px !important;
        overflow-x: visible !important;
    }
    
    .info-banner > div {
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .info-banner p {
        font-size: 0.75em !important;
        text-align: center;
        width: 100%;
        display: none; /* Hide description text on mobile to save space */
    }
    
    /* Info banner controls - stack vertically on mobile */
    .info-banner-controls {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
        align-items: stretch !important;
    }
    
    .info-banner-controls > div,
    .info-banner-controls > button {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Voice and language controls - very compact */
    .voice-controls {
        flex-wrap: wrap !important;
        justify-content: center !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 4px !important;
    }
    
    .language-toggle {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px !important;
    }
    
    .unit-toggle {
        margin-left: 0 !important;
        padding-left: 0 !important;
        border-left: none !important;
        justify-content: center !important;
    }
    
    /* Make voice buttons smaller on mobile */
    .voice-btn {
        padding: 6px 10px !important;
        font-size: 0.75em !important;
    }
    
    .voice-select {
        padding: 6px 8px !important;
        font-size: 0.75em !important;
    }
    
    /* Toggle labels - much smaller */
    .toggle-label {
        padding: 4px 8px !important;
        font-size: 0.7em !important;
    }
    
    .toggle-label span {
        font-size: 0.8em !important;
    }
    
    /* Dark mode button */
    #darkModeToggle {
        margin-left: 0 !important;
        padding: 6px 10px !important;
        font-size: 0.75em !important;
    }
    
    /* Tab navigation - sticky and scrollable */
    .tab-nav {
        position: sticky;
        top: 0;
        background: white;
        z-index: 100;
        overflow-x: auto !important;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        width: 100%;
        max-width: 100vw;
        margin-bottom: 20px !important;
    }
    
    .tab-btn {
        font-size: 0.8em !important;
        padding: 8px 12px !important;
        display: inline-block;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }
}

/* Very small phones (under 480px) */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.3em !important;
    }
    
    header p {
        font-size: 0.78em !important;
        display: block;
    }
    
    /* Hide some less critical toggles on very small screens */
    .language-toggle label:last-child {
        display: none; /* Hide Sanskrit toggle */
    }
    
    .toggle-label span {
        /* Hide text, show only emoji/checkbox */
    }
    
    /* Fix narrow herb browser grid on iPhone */
    .herb-browser-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .seasonal-herbs-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Fix herb buttons being cut off on iPhone */
    .btn-mobile-fit {
        font-size: 0.85em !important;
        padding: 8px 12px !important;
        white-space: nowrap;
        flex: 0 1 auto !important;
    }
    
    .herb-button-row {
        gap: 6px !important;
    }
    
    /* Override flex behavior for substitute and print buttons on mobile */
    .btn-substitute.btn-mobile-fit,
    .btn-print.btn-mobile-fit {
        flex: 0 1 auto !important;
        padding: 8px 10px !important;
    }
    
    /* Fix Herb of the Week grid stacking on iPhone */
    .hotw-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Fix saved formula buttons wrapping on mobile */
    .formula-actions {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .formula-actions .btn-sm {
        font-size: 0.85em !important;
        padding: 8px 12px !important;
        flex: 0 1 auto !important;
        white-space: nowrap !important;
    }
    
    .saved-formula-card {
        padding: 15px !important;
    }
    
    /* Fix substitute modal on mobile */
    #substituteModal .modal-content {
        max-width: 95% !important;
        padding: 20px !important;
    }
    
    .substitute-card {
        padding: 15px !important;
    }
    
    .substitute-header {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .substitute-header h4 {
        font-size: 1.1em !important;
    }
    
    .substitute-rank {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.85em !important;
    }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay .modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    margin: auto;
    flex-shrink: 0;
}

.medical-disclaimer-footer {
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    padding: 20px 15%;
    text-align: center !important;
    font-size: 0.82em;
    color: #777;
    line-height: 1.6;
    margin-top: 40px;
}

.medical-disclaimer-footer p {
    text-align: center !important;
}

.medical-disclaimer-footer a {
    color: #1f1ff5;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

@media (max-width: 600px) {
    #askAIHeaderBtn {
        padding: 12px 22px;
        font-size: 0.95em;
    }
}

/* ============================================
   SCROLL TO TOP BUTTON
   ============================================ */

#scrollToTopBtn {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: 20px;
    z-index: 9000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6a11cb, #2575fc);
    color: #fff;
    border: none;
    font-size: 1.2em;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(106, 17, 203, 0.45);
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#scrollToTopBtn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#scrollToTopBtn:hover {
    background: linear-gradient(135deg, #7c3aed, #3b82f6);
    box-shadow: 0 6px 18px rgba(106, 17, 203, 0.55);
}

@media (max-width: 600px) {
    #scrollToTopBtn {
        width: 44px;
        height: 44px;
        font-size: 1.05em;
        right: 14px;
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}
