* {
    box-sizing: border-box;
}

:root {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #172033;
    background: #f3f5f8;
    font-synthesis: none;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 32rem),
        #f3f5f8;
}

.app {
    width: min(100% - 32px, 560px);
    margin: 0 auto;
    padding: 48px 0 24px;
}

.card {
    background: #ffffff;
    border: 1px solid #e3e7ee;
    border-radius: 20px;
    box-shadow: 0 16px 45px rgba(24, 39, 75, 0.08);
    padding: 32px;
}


.top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid #d6dce5;
    border-radius: 999px;
    background: #ffffff;
    color: #4b5563;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.theme-toggle:hover {
    background: #f7f9fc;
}

body.dark-mode .theme-toggle {
    border-color: #4b5563;
    background: #1f2937;
    color: #d1d5db;
}

body.dark-mode .theme-toggle:hover {
    background: #374151;
}

.header {
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: #2563eb;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 2.7rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.intro {
    margin: 14px 0 0;
    color: #687386;
    line-height: 1.55;
}

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

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.92rem;
    font-weight: 700;
}

.input-with-unit {
    display: flex;
    align-items: center;
    min-height: 52px;
    border: 1px solid #cfd6e1;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-with-unit:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-with-unit input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 13px 14px;
    color: #172033;
    background: transparent;
    font: inherit;
    font-size: 1rem;
}

.input-with-unit > span {
    flex: 0 0 auto;
    padding: 0 14px;
    color: #687386;
    font-size: 0.9rem;
}

.input-with-unit > span:first-child {
    padding-right: 0;
    color: #172033;
    font-weight: 600;
}

.help-text {
    margin: 7px 0 0;
    color: #7a8494;
    font-size: 0.8rem;
}

.calculate-button {
    width: 100%;
    margin-top: 4px;
    padding: 14px 18px;
    border: 0;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease;
}

.calculate-button:hover {
    background: #1d4ed8;
}

.calculate-button:active {
    transform: translateY(1px);
}

.results {
    margin-top: 24px;
    padding: 22px;
    border-radius: 16px;
    background: #f7f9fc;
    border: 1px solid #e5eaf1;
}

.results-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e1e6ee;
}

.results-heading span {
    color: #687386;
    font-size: 0.9rem;
}

.results-heading strong {
    color: #172033;
    font-size: 2rem;
    line-height: 1;
    letter-spacing: -0.04em;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding-top: 18px;
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-item span {
    color: #687386;
    font-size: 0.8rem;
}

.result-item strong {
    font-size: 1.05rem;
}

.error-message {
    min-height: 20px;
    margin: 9px 0 0;
    color: #c62828;
    font-size: 0.85rem;
}

.clear-button {
    display: block;
    margin: 20px auto 0;
    padding: 6px 10px;
    border: 0;
    background: transparent;
    color: #687386;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.clear-button:hover {
    color: #172033;
    text-decoration: underline;
}

footer {
    padding: 16px 8px 0;
    text-align: center;
    color: #8992a1;
    font-size: 0.75rem;
}

footer p {
    margin: 0;
}

[hidden] {
    display: none !important;
}

@media (max-width: 480px) {
    .app {
        width: min(100% - 20px, 560px);
        padding-top: 20px;
    }

    .card {
        padding: 24px 20px;
        border-radius: 16px;
    }

    .results-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .results-heading strong {
        font-size: 2.2rem;
    }
}


/* Dark mode
   Add class="dark-mode" to the <body> element to enable it.
   The JavaScript can also toggle this class dynamically.
*/
body.dark-mode {
    color: #edf2f7;
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 32rem),
        #111827;
}

body.dark-mode .card {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.28);
}

body.dark-mode .intro,
body.dark-mode .help-text,
body.dark-mode footer,
body.dark-mode .clear-button {
    color: #9ca3af;
}

body.dark-mode .input-with-unit {
    background: #111827;
    border-color: #4b5563;
}

body.dark-mode .input-with-unit input {
    color: #f3f4f6;
}

body.dark-mode .input-with-unit > span {
    color: #9ca3af;
}

body.dark-mode .input-with-unit > span:first-child {
    color: #f3f4f6;
}

body.dark-mode .results {
    background: #111827;
    border-color: #374151;
}

body.dark-mode .results-heading {
    border-bottom-color: #374151;
}

body.dark-mode .results-heading span,
body.dark-mode .result-item span {
    color: #9ca3af;
}

body.dark-mode .results-heading strong,
body.dark-mode .result-item strong {
    color: #f3f4f6;
}

body.dark-mode .clear-button:hover {
    color: #f3f4f6;
}
