/* ==========================================
   AVERAGE ATOMIC MASS CALCULATOR
   ========================================== */
.aac-wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
.aac-wrapper { font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 820px; width: 100%; margin: 24px auto; color: #1e293b; padding: 0 16px; }

/* Calculator Hero */
.calculator-hero { text-align: center; padding: 16px 0 8px; margin-bottom: 0; }
.calculator-hero h1 { 
    font-size: 1.75rem; 
    font-weight: 800; 
    margin-bottom: 12px; 
    background: linear-gradient(135deg, #5b21b6, #8b5cf6); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
    background-clip: text; 
    line-height: 1.2; 
    letter-spacing: -0.02em; 
}
.calculator-hero p { 
    font-size: 1rem; 
    color: #64748b; 
    max-width: 600px; 
    margin: 0 auto; 
    line-height: 1.6; 
    padding: 0 10px; 
}

/* Main Grid */
.aac-wrapper .calc-main-grid { display: grid; grid-template-columns: 2fr 3fr; gap: 24px; margin: 24px 0; }
.aac-wrapper .left-panel, .aac-wrapper .right-panel { background: #ffffff; border: 1px solid #f1f5f9; border-radius: 16px; padding: 24px; min-height: 400px; width: 100%; min-width: 0; }
.aac-wrapper .left-panel h2, .aac-wrapper .right-panel h2 { font-size: 0.875rem; font-weight: 700; color: #0f172a; text-transform: uppercase; letter-spacing: 0.05em; }
.aac-wrapper .left-panel h2 { margin-bottom: 20px; }

/* Panel Header */
.aac-wrapper .panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; }
.aac-wrapper .panel-header h2 { margin-bottom: 0; }

/* Element Dropdown */
.aac-wrapper .element-dropdown-wrapper { position: relative; margin-bottom: 20px; }
.aac-wrapper .element-trigger { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid #e2e8f0; border-radius: 10px; background: white; cursor: pointer; transition: all 0.2s; min-height: 48px; width: 100%; }
.aac-wrapper .element-trigger:hover { border-color: #8b5cf6; }
.aac-wrapper .element-trigger::after { content: '▼'; font-size: 0.6rem; color: #94a3b8; margin-left: 8px; }
.aac-wrapper .element-selected-name { font-weight: 600; color: #0f172a; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aac-wrapper .element-options { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: white; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); z-index: 100; display: none; max-height: 400px; overflow-y: auto; }
.aac-wrapper .element-options.open { display: block; }
.aac-wrapper .element-search { width: 100%; padding: 12px 14px; border: none; border-bottom: 1px solid #e2e8f0; font-size: 0.875rem; outline: none; font-family: inherit; }
.aac-wrapper .element-search:focus { background: #faf5ff; }
.aac-wrapper .element-option { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid #f8fafc; }
.aac-wrapper .element-option:hover { background: #f5f3ff; }
.aac-wrapper .element-option-name { font-size: 0.875rem; color: #0f172a; font-weight: 500; }
.aac-wrapper .element-option-symbol { font-size: 0.8125rem; color: #64748b; font-weight: 600; }
.aac-wrapper .element-info { padding: 12px 14px; background: #faf5ff; border-radius: 8px; margin-bottom: 20px; font-size: 0.875rem; color: #5b21b6; display: none; }
.aac-wrapper .element-info.visible { display: block; }
.aac-wrapper .element-info strong { color: #4c1d95; }

/* Formula Card */
.aac-wrapper .formula-wrapper { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; width: 100%; }
.aac-wrapper .formula-heading { font-size: 0.75rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; }
.aac-wrapper .formula-wrapper .katex { font-size: 1.4rem; }
.aac-wrapper .param-desc { font-size: 0.75rem; color: #64748b; line-height: 1.5; max-width: 100%; word-wrap: break-word; }

/* Segmented Control */
.aac-wrapper .segmented-control { display: inline-flex; background: #f1f5f9; border-radius: 8px; padding: 3px; border: 1px solid #e2e8f0; flex-shrink: 0; }
.aac-wrapper .segmented-btn { padding: 6px 12px; font-size: 0.75rem; font-weight: 600; color: #64748b; background: transparent; border: none; border-radius: 6px; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.aac-wrapper .segmented-btn.active { background: #5b21b6; color: white; box-shadow: 0 1px 3px rgba(91, 33, 182, 0.2); }
.aac-wrapper .segmented-btn:not(.active):hover { color: #5b21b6; }

/* Isotope Table */
.aac-wrapper .isotope-table-wrapper { margin-bottom: 20px; overflow-x: auto; }
.aac-wrapper .isotope-table { width: 100%; border-collapse: separate; border-spacing: 0; background: white; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; }
.aac-wrapper .isotope-table thead th { background: #f8fafc; padding: 12px 10px; text-align: left; font-size: 0.7rem; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid #e2e8f0; }
.aac-wrapper .isotope-table thead th:first-child { width: 36px; text-align: center; padding: 12px 6px; }
.aac-wrapper .isotope-table thead th:nth-child(2) { width: 90px; }
.aac-wrapper .isotope-table thead th:last-child { width: 36px; }
.aac-wrapper .isotope-table tbody td { padding: 6px; border-bottom: 1px solid #f1f5f9; }
.aac-wrapper .isotope-table tbody tr:last-child td { border-bottom: none; }
.aac-wrapper .isotope-table tbody tr:nth-child(even) { background: #fafafa; }
.aac-wrapper .isotope-table .row-number { text-align: center; font-weight: 600; color: #64748b; font-size: 0.875rem; padding: 6px; }

/* Input Fields */
.aac-wrapper .isotope-table input { 
    width: 100%; 
    padding: 11px 12px; 
    border: 1px solid #e2e8f0; 
    border-radius: 6px; 
    font-size: 0.9375rem; 
    font-family: inherit; 
    outline: none; 
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}
.aac-wrapper .isotope-table input:focus { 
    border-color: #8b5cf6; 
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12); 
}
.aac-wrapper .isotope-table .remove-btn { 
    background: none; 
    border: none; 
    color: #94a3b8; 
    cursor: pointer; 
    font-size: 1.25rem; 
    padding: 8px 10px; 
    border-radius: 6px; 
    transition: all 0.2s;
    line-height: 1;
}
.aac-wrapper .isotope-table .remove-btn:hover { color: #ef4444; background: #fef2f2; }
.aac-wrapper .abundance-unit { 
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* Action Buttons */
.aac-wrapper .action-buttons { display: flex; gap: 8px; margin-bottom: 20px; }
.aac-wrapper .add-btn { 
    flex: 1; 
    padding: 12px 14px; 
    background: #f5f3ff; 
    color: #5b21b6; 
    border: 1px solid #e9d5ff; 
    border-radius: 8px; 
    font-weight: 600; 
    font-size: 0.875rem; 
    cursor: pointer; 
    transition: all 0.2s; 
    font-family: inherit; 
}
.aac-wrapper .add-btn:hover:not(:disabled) { background: #ede9fe; border-color: #8b5cf6; }
.aac-wrapper .add-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Validation Bar */
.aac-wrapper .validation-bar { 
    padding: 12px 16px; 
    border-radius: 8px; 
    font-size: 0.875rem; 
    font-weight: 600; 
    display: none; 
    align-items: center; 
    gap: 10px;
    margin-bottom: 20px;
}
.aac-wrapper .validation-bar.visible { display: flex; }
.aac-wrapper .validation-bar.valid { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.aac-wrapper .validation-bar.invalid { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.aac-wrapper .validation-bar.warning { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }
.aac-wrapper .validation-icon { font-size: 1.125rem; }

/* Result Box */
.aac-wrapper .result-box { 
    background: #faf5ff; 
    border: 2px solid #e9d5ff; 
    border-radius: 12px; 
    padding: 28px 20px; 
    text-align: center;
}
.aac-wrapper .result-label { font-size: 0.75rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.aac-wrapper .result-value { font-size: 2.25rem; font-weight: 800; color: #5b21b6; line-height: 1.2; }
.aac-wrapper .result-unit { font-size: 1.125rem; color: #7c3aed; font-weight: 600; margin-left: 6px; }
.aac-wrapper .result-placeholder { font-size: 1rem; color: #94a3b8; font-weight: 500; font-style: italic; }

/* ==========================================
   ARTICLE CONTENT STYLES (Purple Theme)
   ========================================== */
.article-content { line-height: 1.7; color: #334155; }
.article-content h2 { font-size: 1.5rem; font-weight: 700; margin-top: 48px; margin-bottom: 16px; color: #0f172a; letter-spacing: -0.01em; }
.article-content h3 { font-size: 1.25rem; font-weight: 700; margin-top: 32px; margin-bottom: 12px; color: #1e293b; }
.article-content h4 { font-size: 1.0625rem; font-weight: 700; margin-top: 24px; margin-bottom: 10px; color: #5b21b6; }
.article-content p { margin-bottom: 16px; font-size: 1rem; }
.article-content ul, .article-content ol { margin-bottom: 16px; padding-left: 24px; }
.article-content li { margin-bottom: 8px; }
.article-content strong { color: #0f172a; font-weight: 600; }
.article-content a { color: #5b21b6; text-decoration: underline; text-underline-offset: 2px; }
.article-content a:hover { color: #8b5cf6; }

/* Tables — Premium Purple Design */
.article-content table { 
    width: 100%; 
    border-collapse: collapse; 
    margin: 20px 0 28px; 
    font-size: 0.875rem; 
    background: #fff; 
    border: 1px solid #e2e8f0; 
    border-radius: 10px; 
    overflow: hidden; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.article-content th { 
    background: linear-gradient(135deg, #5b21b6, #8b5cf6); 
    color: white; 
    font-weight: 600; 
    padding: 14px 16px; 
    text-align: left; 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    border: none;
}
.article-content td { 
    padding: 12px 16px; 
    border-bottom: 1px solid #f1f5f9; 
    color: #475569; 
}
.article-content tr:nth-child(even) { background: #faf5ff; }
.article-content tr:nth-child(odd) { background: #ffffff; }
.article-content tr:hover td { 
    background: #f3e8ff; 
    transition: background 0.2s; 
}
.article-content tr:last-child td { border-bottom: none; }

/* Compact table variant */
.article-content table.compact { font-size: 0.825rem; }
.article-content table.compact th,
.article-content table.compact td { padding: 10px 12px; }

/* Formula Block (Purple Accent) */
.article-content .formula-block { 
    background: #faf5ff; 
    border: 1px solid #e9d5ff; 
    border-left: 4px solid #8b5cf6; 
    border-radius: 0 10px 10px 0; 
    padding: 24px; 
    margin: 24px 0; 
    text-align: center; 
    overflow-x: auto; 
}

/* Example Block (Purple Accent) */
.article-content .example-block { 
    background: #faf5ff; 
    border-left: 4px solid #8b5cf6; 
    border-radius: 0 10px 10px 0; 
    padding: 16px 20px; 
    margin: 20px 0; 
}
.article-content .example-block h4 { 
    margin-top: 0; 
    font-size: 0.9375rem; 
    font-weight: 700; 
    color: #5b21b6; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
}
.article-content .example-block ol { padding-left: 20px; margin-bottom: 0; }
.article-content .example-block li { margin-bottom: 10px; }
.article-content .example-block p { margin-bottom: 8px; }

/* FAQ Items */
.article-content .faq-item { border-bottom: 1px solid #e2e8f0; padding: 20px 0; }
.article-content .faq-item:last-child { border-bottom: none; }
.article-content .faq-item h3 { margin-top: 0; color: #5b21b6; font-size: 1.125rem; }
.article-content .faq-item p:last-child { margin-bottom: 0; }

/* Sources List */
.article-content .sources-list { list-style: none; padding: 0; counter-reset: source-counter; }
.article-content .sources-list li { margin-bottom: 12px; padding-left: 30px; position: relative; counter-increment: source-counter; }
.article-content .sources-list li::before { content: '[' counter(source-counter) ']'; position: absolute; left: 0; color: #8b5cf6; font-weight: 700; }
.article-content .sources-list a { color: #5b21b6; text-decoration: none; font-weight: 600; border-bottom: 1px dashed #8b5cf6; }
.article-content .sources-list a:hover { color: #4c1d95; border-bottom-style: solid; }

/* Superscript Citations */
.article-content sup { font-size: 0.75em; color: #8b5cf6; font-weight: 700; }
.article-content sup a { color: #8b5cf6; text-decoration: none; border-bottom: none; }

/* KaTeX */
.article-content .katex { font-size: 1.1em; }
.article-content .katex-display { margin: 20px 0; overflow-x: auto; overflow-y: hidden; }

/* Article Content Responsive */
@media (max-width: 768px) {
    .article-content { padding: 24px 8px 48px; }
    .article-content h2 { font-size: 1.375rem; margin-top: 32px; }
    .article-content h3 { font-size: 1.125rem; }
    .article-content h4 { font-size: 1rem; }
    .article-content p, .article-content li { font-size: 0.95rem; }
    .article-content table { font-size: 0.8rem; }
    .article-content th, .article-content td { padding: 10px 12px; }
}

/* Calculator Responsive */
@media (max-width: 768px) {
    .aac-wrapper .calc-main-grid { grid-template-columns: 1fr; gap: 20px; }
    .aac-wrapper .left-panel, .aac-wrapper .right-panel { padding: 20px; min-height: auto; }
    .calculator-hero h1 { font-size: 1.75rem; }
    .aac-wrapper .panel-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .aac-wrapper .result-value { font-size: 1.75rem; }
    .aac-wrapper .isotope-table input { font-size: 0.875rem; padding: 10px 10px; }
}
@media (min-width: 769px) {
    .aac-wrapper .left-panel, .aac-wrapper .right-panel { box-shadow: 0 10px 40px -10px rgba(0,0,0,0.08); }
    .calculator-hero h1 { font-size: 2.25rem; }
    .calculator-hero p { padding: 0; }
}