:root {
    --primary-color: #2A4365;
    --secondary-color: #4299E1;
    --accent-color: #ED8936;
    --text-dark: #2D3748;
    --text-light: #F7FAFC;
    --background-light: #EBF8FF;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --max-width: 1000px;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    background-color: #f8f9fa;
    color: var(--text-dark);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
}

.header {
    background-color: var(--primary-color);
    padding: 1rem 0;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: var(--text-light);
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.logo:hover {
    opacity: 0.9;
}

.nav-list {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-link {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    padding: 0.5rem 0;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent-color);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.hamburger-line {
    display: block;
    width: 25px;
    height: 2px;
    background-color: var(--text-light);
    margin: 5px 0;
    transition: all 0.3s ease;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .hamburger {
        display: block;
    }

    .nav-list {
        position: fixed;
        top: 0;
        right: -100%;
        height: 100vh;
        width: 70%;
        max-width: 300px;
        background-color: var(--primary-color);
        flex-direction: column;
        padding: 6rem 2rem;
        transition: right 0.3s ease;
        z-index: 1000;
    }

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

    .overlay.active {
        display: block;
    }

    .hamburger.active .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .hamburger.active .hamburger-line:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
}

.footer {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: 2rem 0;
    margin-top: auto;
}

.footer-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-right {
    display: flex;
    gap: 1.5rem;
}

.footer a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

.to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--accent-color);
    color: var(--text-light);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.to-top.show {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .footer-container {
        flex-direction: column;
        text-align: center;
    }

    .footer-right {
        flex-direction: column;
        gap: 0.5rem;
    }

    .to-top {
        bottom: 1rem;
        right: 1rem;
    }
}

main {
    max-width: var(--max-width);
    margin: 0 auto;
}

.title {
    text-align: center;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.description {
    text-align: center;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.calculator-container {
    max-width: 600px;
    margin: 2rem auto;
}

.calculator-form {
    flex: 1;
    min-width: 300px;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.results-container {
    flex: 1;
    min-width: 300px;
    background-color: white;
    margin-top: 2rem;
}


#distance {
    background-color: #ddd;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.unit-toggle {
    max-width: 300px;
    display: flex;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-top: 5px;
    margin-bottom: 5px;

}

.unit-toggle label {
    flex: 1;
    text-align: center;
    margin-bottom: 0;
    padding: 0.25rem 1rem;
    cursor: pointer;
    font-weight: normal;
    transition: background-color 0.3s;
}

.unit-toggle input {
    display: none;
}

.unit-toggle input:checked+label {
    background-color: var(--primary-color);
    color: white;
}

.btn {
    display: inline-block;
    background-color: #4285F4;
    color: white;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.3s;
    width: 100%;
    margin-top: 10px;
}

.btn:hover {
    background-color: #2980b9;
}

.result-box {
    background-color: #f1f8fe;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
}

.result-box h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.result-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--dark-color);
}

.result-unit {
    font-size: 14px;
    color: #666;
}

.result-detail {
    margin-top: 5px;
    font-size: 14px;
}

.tips-container {
    background-color: #f0fbf6;
    border-left: 4px solid var(--secondary-color);
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

.tips-container h3 {
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.chart-container {
    margin-top: 30px;
}

.chart-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
}

.chart-tab {
    padding: 10px 15px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    color: #666;
}

.chart-tab.active {
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
}

canvas {
    width: 100%;
    max-height: 300px;
}

.comparison-container {
    margin-top: 30px;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

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

.comparison-table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.tooltip {
    position: relative;
    display: inline-block;
    margin-left: 5px;
    cursor: help;
}

.tooltip-icon {
    background-color: #ddd;
    color: #666;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    font-weight: normal;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

@media (max-width: 768px) {
    .calculator-container {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .calculator-container {
        flex-direction: column;
        gap: 15px;
    }

    .form-control {
        font-size: 16px;
        padding: 12px;
    }

    .btn {
        padding: 15px;
        margin-top: 20px;
    }

    .result-value {
        font-size: 28px;
    }

    .chart-container {
        margin-top: 20px;
    }

    .chart-tabs {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .chart-tab {
        padding: 12px;
        font-size: 14px;
    }

    .comparison-table {
        font-size: 14px;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 8px;
    }

    /* Improve tooltip behavior on mobile */
    .tooltip-text {
        width: 160px;
        margin-left: -80px;
        font-size: 11px;
    }
}

/* Additional fixes for very small screens */
@media (max-width: 360px) {
    .container {
        padding: 5px;
    }
}

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

.results-text {
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

.tool-info h2 {
    margin-top: 1rem;
}

.tool-info p {
    font-size: 1rem;
    margin: 0.5rem 0;
}

.tool-info ul {
    list-style-type: disc;
    padding-left: 1.5rem;
}

.tool-info ul li,
.tool-info ol li {
    margin: 0.5rem 0;
}

.tool-info canvas {
    width: 100%;
    max-width: 600px;
    height: 400px;
    margin: 0 1rem;
    display: block;
}

@media (max-width: 768px) {
    .tool-info canvas {
        max-width: 100%;
        height: 300px;
        overflow: wrap;
    }
}

.table-container {
    max-width: 100%;
    margin: 1rem auto;
    overflow-x: auto;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #ccc;
}

.table-container th,
.table-container td {
    padding: 0.5rem;
    text-align: center;
    border: 1px solid #ccc;
}

.table-container th {
    background-color: var(--primary-color);
    color: var(--text-light);
}


.code-block {
    background: var(--dark-color);
    color: white;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    margin: 1rem 0;
}

.calculation-method {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    margin: 1.5rem 0;
}

.method-card {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.formula-box {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-family: monospace;
}

.conversion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.conversion-item {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.unit-pair {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .calculation-method {
        grid-template-columns: 1fr;
    }

    .conversion-grid {
        grid-template-columns: 1fr;
    }
}

details {
    padding: 0.5rem;
}

details summary {
    cursor: pointer;
    font-weight: bold;
}

#results {
    display: none;
    /* Hide results by default */
}

#results.show {
    display: block;
    /* Show results when the 'show' class is added */
}

.image {
    margin: 2rem 0;
}

.image img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
}

.image figcaption {
    font-size: 14px;
    color: #555;
    margin-top: 8px;
    line-height: 1.4;
}