* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #b64b39;
    --light-gray: #f5f5f5;
    --border-gray: #ddd;
    --text-muted: #666;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
    font-family: Arial, sans-serif;
    background-color: #fff;
    color: #333;
    line-height: 1.6;
}

/* Header */
.header {
    background: #f8f9fa;
    padding: 0.5rem 0;
    margin-bottom: 0.2rem;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.35rem;
    font-weight: bold;
    color: var(--primary-red);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-red);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu-toggle:hover {
    color: var(--primary-red);
}

/* Breadcrumbs */
.breadcrumb {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0.15rem 1rem 0rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-red);
}

/* Main Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem 1rem 1rem;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

/* Main Content */
.main-content h1 {
    font-size: 1.45rem;
    margin: 0rem;
    color: #333;
}

.page-title {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.description, .page-desc {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    line-height: 1.5;
}

/* Calculator Tabs */
.calculator-tabs {
    display: flex;
    justify-content: flex-start;
    background: #e9ecef;
    border-bottom: 1px solid var(--border-gray);
    gap: 2px;
    border-radius: 6px 6px 0 0;
    margin: 0 auto;
}

.tab-button {
    padding: 0.7rem 1.3rem;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    min-width: auto;
    white-space: nowrap;
}

.tab-button:hover {
    background: #dee2e6;
    color: #333;
}

.tab-button.active {
    background: white;
    color: var(--primary-red);
    border-bottom-color: var(--primary-red);
    font-weight: 600;
}

/* Balanced Calculator Styling */
.calculator {
    background: white;
    border: 1px solid var(--border-gray);
    border-radius: 6px;
    margin-bottom: 1rem;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.calculator-body {
    padding: 2rem;
    max-width: 550px;
    margin: 0 auto;
}

/* Form Structure - Balanced */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.form-row-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-label-cell {
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

.form-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    margin: 0;
    white-space: nowrap;
}

.form-input-cell {
    width: 175px;
    flex-shrink: 0;
}

.form-control, .to-value-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 0.95rem;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
    background-color: white;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.form-control:focus, .to-value-input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1), 0 0 0 2px rgba(182, 75, 57, 0.2);
}

.to-value-input {
    cursor: default;
    background-color: #f8f9fa;
}

.form-select-cell {
    width: 175px;
    flex-shrink: 0;
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 14px 10px;
    padding-right: 32px;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1), 0 0 0 2px rgba(182, 75, 57, 0.2);
}

/* PAIR PAGES - Balanced Structure */
.pair-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pair-form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pair-label-cell {
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

.pair-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    margin: 0;
    white-space: nowrap;
}

.pair-input-cell {
    width: 210px;
    flex-shrink: 0;
}

.pair-input-field, .pair-to-value {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 0.95rem;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
    background-color: white;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.pair-input-field:focus, .pair-to-value:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1), 0 0 0 2px rgba(182, 75, 57, 0.2);
}

.pair-to-value {
    cursor: default;
    background-color: #f8f9fa;
}

.pair-unit-cell {
    flex: 1;
    min-width: 110px;
	font-weight:bold;
}

.pair-unit-label {
    color: #333;
    margin: 0;
}

/* Balanced Button Layout */
.form-buttons-row {
    margin: 18px 0 0 0;
    width: 100%;
}

.form-buttons-cell {
    width: 100%;
}

.conversion-buttons, .button-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: nowrap;
    margin-left: 72px; /* 60px label + 12px gap */
}

.btn-container {
    display: flex;
    gap: 0.6rem;
}

.btn {
    padding: 10px 18px;
    border: 1px solid #999;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.2);
    text-transform: none;
}

.btn-calculate, .btn-convert {
    background: var(--primary-red);
    color: white;
    border-color: #a03d2b;
}

.btn-calculate:hover, .btn-convert:hover {
    background: #a03d2b;
    border-color: #8b3323;
    box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
}

.btn-copy, .btn-secondary {
    background: #28a745;
    color: white;
    border-color: #1e7e34;
}

.btn-copy:hover, .btn-secondary:hover {
    background: #218838;
    border-color: #1e7e34;
    box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
}

/* Answer Section - COMPLETELY HIDDEN when empty */
.answer-section {
    margin-top: 1.2rem;
    text-align: center;
    padding: 0;
    background: transparent;
    border: none;
}

/* Critical: Hide answer section completely when empty */
.answer-section.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.answer-display {
    background: #f8f9fa;
    border: 1px solid #e3e6f0;
    border-radius: 6px;
    padding: 20px 18px;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 15px;
}

.answer-result {
    font-size: 1.05rem;
    color: #333;
    line-height: 1.4;
    margin: 0;
}

/* Precision Control - Aligned and Balanced */
.precision-container {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin-top: 12px;
    margin-left: 72px; /* 60px label + 12px gap - same as buttons */
}

.precision-label {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    margin: 0;
    min-width: fit-content;
}

.precision-select {
    padding: 7px 10px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    min-width: 90px;
    cursor: pointer;
    transition: border-color 0.3s ease;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
}

.precision-select:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1), 0 0 0 2px rgba(182, 75, 57, 0.2);
}

/* Content Section */
.content-section {
    margin-top: 1.8rem;
}

.content-section h2 {
    font-size: 1.15rem;
    color: var(--primary-red);
    margin-bottom: 0.6rem;
}

.content-section h3 {
    font-size: 1.05rem;
    color: #333;
    margin: 0.8rem 0 0.5rem 0;
}

.content-section p {
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.3rem;
}

.ad-placeholder {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px dashed #dee2e6;
    border-radius: 6px;
    height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    position: relative;
}

.ad-placeholder::before {
    content: "Advertisement";
    position: absolute;
    top: 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: bold;
}

.related-card {
    background: var(--light-gray);
    border: 1px solid var(--border-gray);
    border-radius: 4px;
}

.related-header {
    background: linear-gradient(135deg, var(--primary-red), #d55a45);
    color: white;
    padding: 0.45rem 0.9rem;
    font-weight: bold;
    font-size: 0.9rem;
}

.related-body {
    padding: 0.25rem 0.9rem;
}

.related-link {
    display: block;
    padding: 0.45rem 0;
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.85rem;
}

.related-link:last-child {
    border-bottom: none;
}

.related-link:hover {
    color: var(--primary-red);
}

/* Footer */
.footer {
    background: #f8f9fa;
    padding: 1.1rem 0;
    margin-top: 1.8rem;
    text-align: center;
}

.footer-links {
    margin-bottom: 0.6rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 0.45rem;
    font-size: 0.85rem;
}

.footer-links a:hover {
    color: var(--primary-red);
}

.footer-copy {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* List styling */
.list-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    list-style: disc outside;
    margin: 12px 0 12px 1.3em;
    padding: 0;
}

.list-grid li {
    line-height: 1.35;
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
}

.list-grid a {
    color: #1061b2;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.list-grid a:hover {
    color: var(--primary-red);
}

/* Popular Conversions List */
.popular-conversions-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 7px 14px;
    list-style: disc outside;
    margin: 12px 0 12px 1.3em;
    padding: 0;
}

.popular-conversions-list li {
    line-height: 1.35;
    margin: 0;
    padding: 2px 0;
    font-size: 0.9rem;
}

.popular-conversions-list a {
    color: #1061b2;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.popular-conversions-list a:hover {
    color: var(--primary-red);
    text-decoration: underline;
}

/* Categories List */
.categories-list {
    list-style: disc outside;
    margin: 12px 0 12px 1.3em;
    padding: 0;
}

.categories-list li {
    line-height: 1.55;
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 0.95rem;
}

.categories-list a {
    color: var(--primary-red);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.categories-list a:hover {
    color: #a03d2b;
    text-decoration: underline;
}

/* All Units List */
.allunits {
    list-style: disc outside;
    margin: 8px 0 12px 1.3em;
    padding: 0;
    font-size: 15px;
}

.allunits li {
    margin: 2px 0;
    padding: 2px 0;
}

.allunits li div {
    padding-left: 5px;
    font-size: 0.9rem;
}

.allunits li div a {
    color: #1061b2;
    text-decoration: underline;
}

.allunits li div a:hover {
    color: var(--primary-red);
}

/* Error styling */
.error {
    color: #dc2626;
    background: #fef2f2;
    padding: 10px 14px;
    border-radius: 4px;
    border: 1px solid #dc2626;
    margin: 10px 0;
    text-align: center;
    font-size: 0.9rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem 1rem 1rem;
    }

    .nav-links {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .tab-button {
        padding: 0.55rem 1rem;
        font-size: 0.85rem;
    }

    .calculator {
        max-width: 100%;
        margin: 0 auto;
    }

    .calculator-body {
        max-width: 480px;
        margin: 0 auto;
        padding: 1.5rem;
    }

    .calculator-tabs {
        max-width: 100%;
    }

    .form-row, .pair-form {
        max-width: 100%;
    }

    .form-row-inner, .pair-form-row {
        gap: 10px;
        flex-wrap: wrap;
    }

    .form-label-cell, .pair-label-cell {
        width: 50px;
    }

    .form-input-cell {
        flex: 1;
        min-width: 120px;
        width: auto;
    }

    .form-select-cell {
        flex: 1;
        min-width: 120px;
        width: auto;
    }

    .pair-input-cell {
        flex: 1;
        min-width: 140px;
        width: auto;
    }

    .pair-unit-cell {
        width: 75px;
        flex-shrink: 0;
    }

    .conversion-buttons, .button-container {
        margin-left: 60px; /* 50px label + 10px gap for mobile */
    }

    .btn-container {
        gap: 0.5rem;
    }

    .btn {
        padding: 9px 14px;
        font-size: 0.85rem;
        min-width: 75px;
    }

    .precision-container {
        margin-left: 60px; /* 50px label + 10px gap for mobile */
    }
}

@media (max-width: 480px) {
    .calculator-body {
        padding: 1.2rem;
    }

    .form-label-cell, .pair-label-cell {
        display: none;
    }

    .form-row-inner, .pair-form-row {
        gap: 8px;
    }

    .form-input-cell, .form-select-cell {
        flex: 1;
        min-width: 0;
    }

    .pair-input-cell {
        width: 60%;
        flex: none;
        min-width: 0;
    }
    
    .pair-unit-cell {
        flex: 1;
        min-width: 60px;
    }

    .conversion-buttons, .button-container {
        margin-left: 0;
    }

    .btn-container {
        flex-direction: row;
        gap: 0.5rem;
        width: auto;
    }

    .btn {
        width: auto;
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: 65px;
        flex: none;
    }

    .tab-button {
        padding: 0.45rem 0.7rem;
        font-size: 0.75rem;
    }

    .list-grid {
        grid-template-columns: 1fr;
    }

    .popular-conversions-list {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .precision-container {
        margin-left: 0;
        padding: 10px 0;
    }

    .precision-select {
        min-width: 70px;
    }
}