/* ============================================
   BASE RESET & VARIABLES
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg:           #F4F6F9;
    --surface:      #FFFFFF;
    --surface-2:    #F8FAFC;
    --border:       #E2E8F0;
    --border-light: #EEF2F7;
    --text-primary: #0F172A;
    --text-sec:     #64748B;
    --text-muted:   #94A3B8;

    --accent:       #E85D04;
    --accent-dark:  #C84B03;
    --accent-light: rgba(232, 93, 4, 0.08);

    --success:      #059669;
    --error:        #DC2626;
    --error-bg:     #FEF2F2;

    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    16px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);

    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 0.2s ease;
}

/* ============================================
   BODY & PAGE
   ============================================ */
body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 0 0 5rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   PAGE HEADER (outside the box)
   ============================================ */
.page-header {
    max-width: 820px;
    margin: 4rem auto 2.5rem;
    padding: 0 1.25rem;
    text-align: center;
}

.page-header h1 {
    font-size: clamp(26px, 4vw, 38px);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
    line-height: 1.2;
}

.page-header p {
    font-size: 16px;
    color: var(--text-sec);
    max-width: 560px;
    margin: 0 auto 1rem;
}

.page-header small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 5px 14px;
    border-radius: 99px;
}

.page-header small::before {
    content: "ℹ";
    font-size: 11px;
    opacity: 0.7;
}

/* ============================================
   CALCULATOR WRAPPER
   ============================================ */
.calculator-wrapper {
    max-width: 1080px;
    margin: 0 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

@media (min-width: 1120px) {
    .calculator-wrapper {
        margin: 0 auto;
    }
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.calc-main {
    padding: 2rem 2.5rem 2.5rem;
}

/* ============================================
   CONTROLS: MODE & UNIT TOGGLES
   ============================================ */
.controls-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2.25rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.toggle-group {
    display: flex;
    flex-wrap: wrap;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
    width: 100%;
}

.toggle-btn {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-sec);
    cursor: pointer;
    transition: all var(--transition);
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.toggle-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(0,0,0,0.04);
}

.toggle-btn.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-xs);
}

/* ============================================
   FORM & RESULTS GRID
   ============================================ */
.form-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    align-items: start;
}

/* ============================================
   FORM SECTION
   ============================================ */
.calc-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.form-group-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.form-field {
    flex: 1 1 calc(50% - 0.5rem);
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.form-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-field input,
.form-field select {
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-field input::placeholder {
    color: var(--text-muted);
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-field input.invalid,
.form-field select.invalid {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.08);
    background: var(--error-bg);
}

.error-message {
    color: var(--error);
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
    font-weight: 500;
}

/* ============================================
   MULTI-SECTION
   ============================================ */
.multi-section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.multi-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.multi-section-header h4 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.btn-remove-section {
    background: none;
    border: none;
    color: var(--error);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background var(--transition);
    font-family: var(--font);
}

.btn-remove-section:hover {
    background: var(--error-bg);
}

.add-section-btn {
    width: 100%;
    margin-bottom: 1.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.75rem;
}

.btn-primary,
.btn-secondary {
    height: 48px;
    padding: 0 1.5rem;
    font-size: 14.5px;
    font-weight: 600;
    font-family: var(--font);
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    flex: 2;
}

.btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232,93,4,0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-sec);
    border: 1.5px solid var(--border);
    flex: 1;
}

.btn-secondary:hover {
    background: var(--surface-2);
    border-color: #CBD5E1;
    color: var(--text-primary);
}

/* ============================================
   RESULTS SECTION
   ============================================ */
.calc-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1.5rem;
}

/* Primary Result Card */
.primary-result {
    background: linear-gradient(135deg, var(--accent) 0%, #c84b03 100%);
    color: #fff;
    padding: 1.75rem 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.primary-result::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}

.primary-result::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}

.primary-result .res-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
    margin-bottom: 0.6rem;
    position: relative;
    z-index: 1;
    display: block;
}

.primary-result .val {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
}

.primary-result .val span {
    font-size: 18px;
    font-weight: 600;
    opacity: 0.85;
    margin-left: 4px;
}

/* Secondary Result Cards */
.secondary-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.result-card {
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.1rem 1rem;
    text-align: center;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.result-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

.result-card .res-title {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 0.45rem;
    display: block;
}

.result-card .res-val {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.result-card .res-val span {
    font-size: 12px;
    color: var(--text-sec);
    font-weight: 500;
}

/* Results Notes */
.results-notes {
    padding: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.7;
}

/* ============================================
   HIDDEN UTILITY
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeSlideIn 0.3s ease-out forwards;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .calc-main {
        padding: 1.75rem 2rem 2rem;
    }

    .form-results-grid {
        gap: 2rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 1.5rem 1rem 4rem;
    }

    .calc-main {
        padding: 1.5rem;
    }

    .form-results-grid {
        grid-template-columns: 1fr;
    }

    .calc-results {
        position: static;
    }

    .form-field {
        flex: 1 1 100%;
    }

    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }

    .toggle-group {
        width: 100%;
        justify-content: stretch;
    }

    .toggle-btn {
        flex: 1;
        text-align: center;
    }

    .primary-result .val {
        font-size: 34px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        flex: unset;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .secondary-results-grid {
        grid-template-columns: 1fr;
    }

    .page-header h1 {
        font-size: 24px;
    }

}

/* ============================================
   LONG FORM CONTENT (SEO Content below Calculator)
   ============================================ */
.page-content {
    max-width: 820px;
    margin: 4rem auto;
    padding: 0 1.25rem;
    color: var(--text-primary);
    line-height: 1.8;
}

.page-content h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 3rem;
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 0.5rem;
}

.page-content h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.page-content p {
    font-size: 16px;
    color: var(--text-sec);
    margin-bottom: 1.5rem;
}

.page-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   INTERACTIVE ELEMENTS
   ============================================ */

/* Quick Estimate Widget */
.interactive-widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; margin: 2rem 0; }
.widget-header { font-weight: 700; font-size: 15px; color: var(--text-primary); display: flex; align-items: center; gap: 8px; margin-bottom: 1.25rem; }
.quick-stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.quick-stat { text-align: center; padding: 1rem 0.5rem; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.qs-num { display: block; font-size: 24px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.qs-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.widget-hint { font-size: 12px !important; color: var(--text-muted) !important; text-align: center; margin: 1rem 0 0 !important; }

/* Interactive Steps */
.interactive-steps { display: flex; align-items: center; gap: 0; margin: 2rem 0; overflow-x: auto; padding: 0.5rem 0; }
.step-card { display: flex; align-items: center; gap: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.85rem 1.1rem; flex-shrink: 0; transition: all var(--transition); }
.step-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.step-body { display: flex; flex-direction: column; }
.step-body strong { font-size: 13px; color: var(--text-primary); }
.step-body span { font-size: 11px; color: var(--text-muted); }
.step-connector { width: 24px; height: 2px; background: var(--border); flex-shrink: 0; }

/* Mode Comparison */
.compare-table { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 2rem 0; }
.compare-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.compare-head { padding: 0.85rem 1rem; font-weight: 700; font-size: 14px; text-align: center; }
.simple-head { background: var(--surface-2); color: var(--text-sec); }
.advanced-head { background: var(--accent); color: #fff; }
.compare-list { list-style: none; padding: 1rem; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.compare-list li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-primary); }
.compare-muted { opacity: 0.5; }

/* Calculation Flow */
.calc-flow-diagram { display: flex; align-items: center; justify-content: center; gap: 0; margin: 2rem 0; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow-x: auto; }
.flow-node { text-align: center; padding: 1rem; min-width: 90px; }
.flow-icon { font-size: 28px; margin-bottom: 4px; }
.flow-label { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.flow-formula { font-size: 12px; color: var(--text-muted); font-family: monospace; background: var(--surface-2); padding: 2px 8px; border-radius: 4px; margin-top: 4px; display: inline-block; }
.flow-arrow { font-size: 20px; color: var(--accent); font-weight: 700; padding: 0 6px; }

/* Shape Formula Cards */
.formula-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 2rem 0; }
.formula-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem; text-align: center; transition: all var(--transition); }
.formula-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.shape-icon { font-size: 32px; color: var(--accent); margin-bottom: 0.5rem; }
.formula-card h4 { font-size: 14px; margin: 0 0 0.5rem; color: var(--text-primary); }
.formula-card code { font-size: 15px; font-weight: 700; color: var(--accent); background: var(--accent-light); padding: 4px 12px; border-radius: 6px; }

/* Thickness Guide */
.thickness-guide-visual { margin: 2rem 0; display: flex; flex-direction: column; gap: 0.75rem; }
.tg-row { display: flex; align-items: center; gap: 1rem; padding: 0.6rem 0; }
.tg-bar-wrap { flex: 1; height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border-light); }
.tg-bar { height: 100%; background: linear-gradient(90deg, var(--accent), #F59E0B); border-radius: 99px; transition: width 1s ease; }
.tg-info { min-width: 180px; display: flex; justify-content: space-between; align-items: center; }
.tg-info strong { font-size: 13px; color: var(--text-primary); }
.tg-info span { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-light); padding: 2px 10px; border-radius: 99px; }

/* Impact Factor Cards */
.impact-factors { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.75rem; margin: 2rem 0; }
.impact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem 0.75rem; text-align: center; transition: all var(--transition); display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.impact-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.impact-icon { font-size: 24px; }
.impact-card strong { font-size: 12px; color: var(--text-primary); }
.impact-level { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.05em; }
.impact-level.high { background: #FEE2E2; color: #DC2626; }
.impact-level.medium { background: #FEF3C7; color: #D97706; }
.impact-level.low { background: #DCFCE7; color: #16A34A; }

/* Mix Type Grid */
.mix-type-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.75rem; margin: 2rem 0; }
.mix-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; transition: all var(--transition); }
.mix-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.mix-badge { font-size: 9px; font-weight: 800; padding: 3px 10px; border-radius: 99px; letter-spacing: 0.08em; color: #fff; }
.mix-badge.hot { background: #EF4444; }
.mix-badge.warm { background: #F59E0B; }
.mix-badge.cold { background: #3B82F6; }
.mix-badge.porous { background: #06B6D4; }
.mix-badge.rap { background: #059669; }
.mix-card strong { font-size: 12px; color: var(--text-primary); }
.mix-density { font-size: 13px; font-weight: 700; color: var(--accent); }
.mix-use { font-size: 10px; color: var(--text-muted); }

/* Cost Breakdown */
.cost-breakdown-widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; margin: 2rem 0; }
.cost-bar-stack { display: flex; height: 28px; border-radius: 99px; overflow: hidden; gap: 2px; margin-bottom: 1rem; }
.cost-seg { background: var(--accent); position: relative; transition: flex 0.5s; cursor: pointer; }
.cost-seg.labor { background: #3B82F6; }
.cost-seg.equip { background: #8B5CF6; }
.cost-seg.other { background: #94A3B8; }
.cost-seg:hover { filter: brightness(1.15); }
.cost-seg::after { content: attr(data-label); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 9px; font-weight: 700; color: #fff; white-space: nowrap; opacity: 0; transition: opacity 0.2s; }
.cost-seg:hover::after { opacity: 1; }
.cost-legend { display: flex; align-items: center; gap: 1rem; font-size: 12px; color: var(--text-sec); flex-wrap: wrap; }
.cl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 4px; }
.cl-dot.labor { background: #3B82F6; }
.cl-dot.equip { background: #8B5CF6; }
.cl-dot.other { background: #94A3B8; }

/* FAQ Accordion */
.faq-accordion { margin: 1.5rem 0; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 0.5rem; overflow: hidden; transition: border-color var(--transition); }
.faq-item.open { border-color: var(--accent); }
.faq-q { display: flex; align-items: center; border: none; width: 100%; text-align: left; font-family: inherit; justify-content: space-between; padding: 1rem 1.25rem; cursor: pointer; font-weight: 600; font-size: 15px; color: var(--text-primary); background: var(--surface); transition: background var(--transition); gap: 1rem; }
.faq-q:hover { background: var(--surface-2); }
.faq-q .faq-chevron { width: 18px; height: 18px; transition: transform 0.3s; flex-shrink: 0; color: var(--text-muted); }
.faq-item.open .faq-chevron { transform: rotate(180deg); color: var(--accent); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height 0.35s ease, padding 0.35s ease; }
.faq-item.open .faq-a { max-height: 500px; }
.faq-a-inner { padding: 0 1.25rem 1rem; font-size: 14px; color: var(--text-sec); line-height: 1.7; }

/* Responsive Interactive */
@media (max-width: 768px) {
    .quick-stat-row { grid-template-columns: repeat(2, 1fr); }
    .interactive-steps { flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
    .step-connector { display: none; }
    .compare-table { grid-template-columns: 1fr; }
    .calc-flow-diagram { flex-wrap: wrap; }
    .formula-cards { grid-template-columns: 1fr; }
    .impact-factors { grid-template-columns: repeat(3, 1fr); }
    .mix-type-grid { grid-template-columns: repeat(2, 1fr); }
    .tg-info { min-width: 140px; }
}

/* ============================================
   SCROLL TO TOP BUTTON
   ============================================ */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--accent);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(232, 93, 4, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background: var(--accent-dark);
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(232, 93, 4, 0.6);
}

@media (max-width: 768px) {
.scroll-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 42px;
        height: 42px;
    }
}

/* ============================================
   GLOBAL NAVIGATION & FOOTER (LIGHT THEME)
   ============================================ */
.site-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.logo-accent {
    color: var(--accent);
    font-weight: 800;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-sec);
    font-size: 14.5px;
    font-weight: 600;
    transition: color var(--transition);
}

.nav-links a:hover {
    color: var(--accent);
}

.mobile-menu-toggle {
    display: none !important;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    z-index: 101;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    min-width: 44px;
    min-height: 44px;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        height: 100vh;
        background: var(--surface);
        flex-direction: column;
        padding: 80px 2rem 2rem;
        transition: 0.3s ease-in-out;
        box-shadow: -4px 0 15px rgba(0,0,0,0.1);
        z-index: 100;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        display: block;
        padding: 15px 0;
        font-size: 18px;
        border-bottom: 1px solid var(--border-light);
    }
}

/* ============================================
   SITE FOOTER (LIGHT THEME)
   ============================================ */
.site-footer {
    background: var(--surface);
    color: var(--text-sec);
    padding: 4rem 0 1.5rem;
    font-family: var(--font);
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: grid;
    grid-template-columns: 1.8fr 1fr 1.4fr 1.3fr 1.3fr;
    gap: 2.5rem;
    margin-bottom: 3rem;
}

.footer-col .footer-title {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
    display: block;
}

.footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.footer-col ul li {
    font-size: 14px;
}

.footer-col ul a {
    text-decoration: none;
    color: var(--text-sec);
    transition: color var(--transition);
}

.footer-col ul a:hover {
    color: var(--accent);
}

/* Brand Column */
.brand-col .site-logo {
    margin-bottom: 1rem;
    display: block;
}

.brand-col p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    max-width: 280px;
    color: var(--text-muted);
}

.social-links {
    display: flex;
    gap: 0.75rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: #FFFFFF;
    text-decoration: none;
    transition: all var(--transition);
    border: none;
}

.social-tw { background-color: #1DA1F2; }
.social-fb { background-color: #3b5998; }
.social-in { background-color: #0077b5; }
.social-pi { background-color: #CB2027; }

.social-links a:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1);
}

/* Contact Column */
.contact-col ul li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-sec);
}

.contact-col ul li svg {
    color: var(--text-muted);
}

/* Language Column */
.lang-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.lang-grid a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sec);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: all var(--transition);
}

.lang-grid a:hover {
    border-color: #CBD5E1;
    color: var(--text-primary);
    background: var(--surface-2);
}

.lang-grid a.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* Footer Bottom */
.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
    text-align: center;
    border-top: 1px solid var(--border-light);
    padding-top: 1.5rem;
}

.footer-bottom p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Responsive Footer & Header */
@media (max-width: 992px) {
    .footer-container {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .footer-container {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   BLOG LAYOUT + SIDEBAR
   ============================================ */
.blog-layout {
    max-width: 1180px;
    margin: 2.5rem auto 0;
    padding: 0 1.25rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 2.5rem;
    align-items: start;
}

.blog-main {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.blog-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sidebar-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-xs);
}

.sidebar-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    background: var(--surface-2);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.sidebar-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--surface);
}

.sidebar-search svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-search input {
    border: none;
    background: transparent;
    height: 42px;
    flex: 1;
    width: 100%;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text-primary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.sidebar-posts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-posts li {
    border-bottom: 1px solid var(--border-light);
}

.sidebar-posts li:last-child {
    border-bottom: none;
}

.sidebar-posts a {
    display: block;
    padding: 0.7rem 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-sec);
    text-decoration: none;
    line-height: 1.45;
    transition: color var(--transition);
}

.sidebar-posts a:hover {
    color: var(--accent);
}

.sidebar-noresults {
    display: none;
    font-size: 13px;
    color: var(--text-muted);
    padding-top: 0.75rem;
}

.sidebar-cta-card {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border: none;
}

.sidebar-cta-btn {
    width: 100%;
    background: #fff;
    color: var(--accent);
    height: auto;
    min-height: 48px;
    padding: 0.85rem 1rem;
    line-height: 1.3;
    white-space: normal;
    text-align: center;
}

.sidebar-cta-btn:hover {
    background: #fff;
    color: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@media (max-width: 900px) {
    .blog-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
    }

    .blog-sidebar {
        position: static;
    }
}

/* ============================================
   v8 ADDITIONS: tables, figures, chips, tool grid,
   trust box, share/print, quick answer
   ============================================ */
.quick-answer { background: var(--accent-light); border-left: 4px solid var(--accent); border-radius: var(--radius-md); padding: 1.25rem 1.5rem; margin: 2rem 0; }
.quick-answer p { margin-bottom: 0.5rem; color: var(--text-primary); }
.quick-answer p:last-child { margin-bottom: 0; }
.quick-answer code { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 6px; font-size: 14px; }

.table-wrap { overflow-x: auto; margin: 1.5rem 0 2rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.data-table caption { caption-side: top; text-align: left; padding: 0.85rem 1rem; font-weight: 600; color: var(--text-primary); border-bottom: 1px solid var(--border); }
.data-table th, .data-table td { padding: 0.65rem 1rem; text-align: left; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.data-table th.num, .data-table td.num { white-space: nowrap; }
.data-table thead th { background: var(--surface-2); color: var(--text-primary); font-weight: 600; font-size: 14px; }
.data-table tbody td { color: var(--text-sec); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-note { font-size: 13px !important; color: var(--text-muted) !important; margin-top: -1.25rem; }

.diagram { margin: 2rem 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem; }
.diagram svg { display: block; width: 100%; height: auto; }
.diagram figcaption { font-size: 14px; color: var(--text-sec); margin-top: 0.75rem; text-align: center; }

.preset-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.chip { font: inherit; font-size: 13px; padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-sec); cursor: pointer; transition: var(--transition); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 0.35rem; }

.result-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.result-actions .btn-secondary { flex: 1 1 auto; font-size: 14px; padding: 0.6rem 0.9rem; }
.result-breakdown { margin-top: 1rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0.9rem 1rem; font-size: 14px; color: var(--text-sec); line-height: 1.6; }
.result-breakdown strong { color: var(--text-primary); }
.result-breakdown:empty { display: none; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin: 1.5rem 0 2rem; }
.tool-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.1rem 1.2rem; text-decoration: none; transition: var(--transition); }
.tool-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.tool-card strong { display: block; color: var(--text-primary); font-size: 16px; margin-bottom: 0.25rem; }
.tool-card span { display: block; color: var(--text-sec); font-size: 14px; line-height: 1.5; }

.trust-box { display: flex; gap: 1rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.1rem 1.25rem; margin: 2rem 0; }
.trust-box svg { flex-shrink: 0; color: var(--success); margin-top: 3px; }
.trust-box p { margin: 0 !important; font-size: 14px !important; line-height: 1.6; }

.breadcrumbs { max-width: 820px; margin: 1.5rem auto 0; padding: 0 1.25rem; font-size: 13px; color: var(--text-muted); }
.breadcrumbs a { color: var(--text-sec); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs span[aria-hidden] { margin: 0 0.4rem; }
.breadcrumbs + .page-header { margin-top: 2rem; }

.page-content ul.content-list, .page-content ol.content-list { padding-left: 1.25rem; margin: 0 0 1.5rem; color: var(--text-sec); }
.page-content ul.content-list li, .page-content ol.content-list li { margin-bottom: 0.5rem; }
.page-content a { color: var(--accent-dark); }

@media print {
    .site-navbar, .site-footer, .scroll-to-top, .page-content, .controls-section, .action-buttons, .result-actions, .breadcrumbs, .preset-chips { display: none !important; }
    body { background: #fff; padding: 0; }
    .page-header { margin: 1rem auto; }
}

/* Footer site search */
.footer-search { display: flex; margin: 1rem 0 1.25rem; max-width: 320px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.footer-search input { flex: 1; min-width: 0; border: none; padding: 0.55rem 0.75rem; font: inherit; font-size: 14px; background: transparent; color: var(--text-primary); }
.footer-search input:focus { outline: none; }
.footer-search:focus-within { border-color: var(--accent); }
.footer-search button { border: none; background: var(--accent); color: #fff; padding: 0 0.8rem; cursor: pointer; display: flex; align-items: center; }
a.scroll-to-top { text-decoration: none; }
.search-results { list-style: none; padding: 0; margin: 1.5rem 0; }
.search-results li { padding: 1rem 0; border-bottom: 1px solid var(--border-light); }
.search-results a { font-weight: 600; font-size: 17px; color: var(--accent-dark); text-decoration: none; }
.search-results p { margin: 0.25rem 0 0 !important; font-size: 15px !important; }
.search-page-form { display: flex; gap: 0.5rem; margin: 1rem 0; }
.search-page-form input { flex: 1; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; }

/* Generated blog posts */
.article-lede { font-size: 18px !important; color: var(--text-primary) !important; }
.table-of-contents { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-md); padding: 1.1rem 1.4rem; margin: 0 0 2rem; }
.table-of-contents strong { display: block; margin-bottom: 0.5rem; }
.table-of-contents ol { margin: 0; padding-left: 1.2rem; }
.table-of-contents li { margin: 0.3rem 0; }
.table-of-contents a { color: var(--accent-dark); text-decoration: none; font-weight: 500; }
.article-cta { margin-top: 3rem; padding: 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); text-align: center; }
.article-cta h2 { border: none !important; margin-top: 0 !important; }
.article-cta .btn-primary { display: inline-block; text-decoration: none; padding: 0.8rem 1.8rem; margin-top: 0.5rem; }
.blog-card-title a { color: inherit; text-decoration: none; }
.blog-sidebar .sidebar-title { font-size: 16px; }

/* v9 UX: get the calculator above the fold, tighter mobile form */
.page-header { margin: 2.75rem auto 1.75rem; }
@media (max-width: 768px) {
    .page-header { margin: 1.25rem auto 1rem; }
    .page-header h1 { margin-bottom: 0.35rem; }
    .page-header p { font-size: 15px; margin-bottom: 0.5rem; line-height: 1.5; }
    .page-header small { font-size: 11.5px; padding: 3px 10px; }
    .breadcrumbs { margin-top: 0.75rem; }
    .breadcrumbs + .page-header { margin-top: 0.75rem; }
    .calc-main { padding: 1rem; }
    .controls-section { gap: 0.5rem; margin-bottom: 1.1rem; padding-bottom: 0.9rem; }
    .toggle-btn { padding-top: 0.55rem; padding-bottom: 0.55rem; font-size: 14px; }
    .form-group-row { gap: 0.75rem; }
    .form-group-row .form-field { flex: 1 1 120px; min-width: 0; }
    .form-field label { font-size: 11.5px; }
}

/* Collapsible "On this page" contents */
.page-toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin: 1.5rem 0 2rem; }
.page-toc summary { cursor: pointer; padding: 0.85rem 1.1rem; font-weight: 600; color: var(--text-primary); list-style: none; display: flex; justify-content: space-between; align-items: center; }
.page-toc summary::-webkit-details-marker { display: none; }
.page-toc summary::after { content: "+"; font-size: 20px; color: var(--accent); line-height: 1; }
.page-toc[open] summary::after { content: "−"; }
.page-toc ol { margin: 0; padding: 0 1.1rem 1rem 2.4rem; columns: 2; column-gap: 2rem; }
.page-toc li { margin: 0.3rem 0; break-inside: avoid; font-size: 15px; }
.page-toc a { color: var(--accent-dark); text-decoration: none; }
.page-toc a:hover { text-decoration: underline; }
@media (max-width: 600px) { .page-toc ol { columns: 1; } }
html { scroll-behavior: smooth; }
.page-content h2[id], .page-content h3[id] { scroll-margin-top: 1rem; }

/* Long <select> options must not stretch the form column on phones */
.form-results-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form-field select, .form-field input { width: 100%; max-width: 100%; min-width: 0; }
@media (max-width: 768px) { .form-results-grid { grid-template-columns: minmax(0, 1fr); } }
