:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --primary: #3155d4;
    --primary-dark: #243fa5;
    --border: #d9dee7;
    --text: #202633;
    --muted: #A6ABB5;
    --input-bg: #f8fafc;
    --swap: #0153f4;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        Arial,
        sans-serif;

    background: radial-gradient(circle at 50% 0%, #263653 0%, #172238 38%, #111827 75%);

    color: var(--text);

    display: flex;
    justify-content: center;
    align-items: flex-start;

    padding: 40px 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    margin: 0 0 10px;

    color: #34cc34;

    font-size: clamp(1.4rem, 3vw, 2.1rem);
    line-height: 1.15;
}

header h3 {
    margin: 0 0 10px;

    color: #E78889;

    font-size: clamp(1rem, 1.5vw, 1.3rem);
    line-height: 1.15;
}

header p {
    margin: 0;
    color: var(--muted);
    font-size: 1rem;
}

.converter-card {
    background: var(--card-bg);

    border-radius: 18px;

    padding: 30px;

    box-shadow: 0 12px 35px rgba(30, 50, 90, 0.12);
}

.category-label {
    display: block;

    font-weight: 600;

    margin-bottom: 8px;
}

#category {
    width: 100%;

    padding: 13px 15px;

    border: 1px solid var(--border);

    border-radius: 10px;

    background: white;

    font-size: 1rem;

    color: var(--text);

    cursor: pointer;

    margin-bottom: 28px;
}

.conversion-row {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(0, 1fr);

    gap: 15px;

    align-items: end;
}

#conversionRow1 {
    margin-bottom: 18px;
}

#conversionRow2 {
    margin-top: 2px;
}

.field {
    min-width: 0;
}

.field label {
    display: block;

    font-weight: 600;

    margin-bottom: 8px;
}

.field input,
.field select {
    width: 100%;

    height: 50px;

    padding: 0 14px;

    border: 1px solid var(--border);

    border-radius: 10px;

    background: var(--input-bg);

    color: var(--text);

    font-size: 1rem;

    outline: none;
}

.field input {
    font-size: 1.15rem;
}

.field input:focus,
.field select:focus,
#category:focus {
    border-color: var(--primary);

    box-shadow: 0 0 0 3px rgba(49, 85, 212, 0.12);
}

.swap-container {
    display: flex;

    justify-content: center;

    align-items: center;

    margin: 8px 0;
}

#swap {
    width: 45px;
    height: 45px;

    border: 1px solid var(--swap);
    border-radius: 50%;

    background: var(--swap);

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    position: relative;

}

/* Bulle */
.swap-tooltip {
    position: absolute;

    top: calc(100% + 8px);
    left: 50%;

    transform: translateX(-50%);

    padding: 5px 9px;

    background: #111827;
    color: white;

    font-size: 0.8rem;
    white-space: nowrap;

    border-radius: 5px;

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.15s ease,
        visibility 0.15s ease;

    pointer-events: none;

    z-index: 10;
}

/* Petite pointe */
.swap-tooltip::before {
    content: "";

    position: absolute;

    top: -5px;
    left: 50%;

    transform: translateX(-50%);

    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #111827;
}

/* Apparition au survol */
#swap:hover .swap-tooltip {
    opacity: 1;
    visibility: visible;
}

#swap img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.swap-hover {
    display: none;
}

#swap:hover {
    background: #fff;
    border: 1px solid #c00000;
}

#swap:hover .swap-normal {
    display: none;
}

#swap:hover .swap-hover {
    display: block;
}

.result-info {
    margin-top: 25px;

    padding: 15px;

    background: #C7FFCD;

    border-radius: 10px;

    color: #DC2626;

    text-align: center;

    font-size: 0.92rem;
}

.result-notice {
    opacity: 0;
    transition: opacity 0.5s ease;
    color: black;
}

.result-notice-red {
    opacity: 0;
    transition: opacity 0.5s ease;
    color: #DC2626;
    white-space: pre-line;
}

.result-notice-blue {
    opacity: 0;
    transition: opacity 0.5s ease;
    color: blue;
    white-space: pre-line;
}

.result-notice.visible, .result-notice-blue.visible, .result-notice-red.visible {
    opacity: 1;
}

.result-main {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.result-main.visible {
    opacity: 1;
}

.invalid {
    border-color: #dc2626 !important;

    background: #fff7f7 !important;
}

.mass-fractions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 20px;
    margin-top: 12px;
}

.mass-fractions div:nth-child(odd) {
    font-style: italic;
}

.mass-fractions div:nth-child(even) {
    text-align: right;
}

#author {
    text-align: center;
    font-size: 1rem;
    color: yellow;
    margin-top: 10px;
}

@media (max-width: 600px) {
    body {
        padding: 20px 12px;
    }

    .converter-card {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .conversion-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .swap-container {
        padding: 2px 0;
    }

     #swap img {
        transform: rotate(90deg);
    }

}
