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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #FFF8F0;
    color: #3D2914;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.container {
    width: 100%;
    max-width: 540px;
}

.title-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.title-row h1 {
    line-height: 1;
}

.title-row .fun-toggle {
    position: absolute;
    right: 0;
}

@media (max-width: 480px) {
    .title-row {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .title-row .fun-toggle {
        position: static;
    }
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #3D2914;
    margin: 0;
}

.type-row {
    margin-bottom: 1rem;
}

.fun-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.fun-toggle input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: #F0E6DC;
    border-radius: 24px;
    transition: background 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.fun-toggle input:checked + .toggle-slider {
    background: #E07A5F;
}

.fun-toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 1rem;
    font-weight: 500;
    color: #8B7355;
    transition: color 0.2s;
}

.fun-toggle input:checked ~ .toggle-label {
    color: #E07A5F;
}

.type-dropdown {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    border: 2px solid #E07A5F;
    border-radius: 12px;
    background: white;
    color: #3D2914;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23E07A5F' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    transition: box-shadow 0.2s;
}

.type-dropdown:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.2);
}

.converter-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(61, 41, 20, 0.1);
}

.row-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #8B7355;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.value-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

@media (max-width: 480px) {
    .value-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .value-row input[type="number"],
    .value-row .result {
        width: 100%;
    }
    
    .value-row .unit-select {
        width: 70%;
        min-width: unset;
    }
}

input[type="number"] {
    flex: 1.5;
    min-width: 0;
    padding: 0.875rem 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid #F0E6DC;
    border-radius: 12px;
    background: #FFFCF9;
    color: #3D2914;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"]:focus {
    outline: none;
    border-color: #E07A5F;
}

.unit-select {
    flex: 1;
    min-width: 100px;
    padding: 0.875rem 2rem 0.875rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 2px solid #F0E6DC;
    border-radius: 12px;
    background: #FFFCF9;
    color: #3D2914;
    cursor: pointer;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B5344' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

.unit-select:focus {
    outline: none;
    border-color: #E07A5F;
}

#swap-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 1rem auto;
    background: #E07A5F;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

#swap-btn:hover {
    background: #C96A52;
}

#swap-btn:active {
    transform: scale(0.95);
}

.result {
    flex: 1.5;
    min-width: 0;
    font-size: 1.5rem;
    font-weight: 600;
    padding: 0.875rem 1rem;
    background: #FFF4E6;
    border: 2px solid #E07A5F;
    border-radius: 12px;
    text-align: left;
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result.loading {
    opacity: 0.6;
}

.rate-info {
    text-align: center;
    font-size: 0.75rem;
    color: #8B7355;
    margin-top: 1rem;
}

.error {
    text-align: center;
    font-size: 0.875rem;
    color: #C0392B;
    margin-top: 0.5rem;
    display: none;
}

.error.show {
    display: block;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.3; }
}

.result.loading {
    animation: pulse 1s infinite;
}

/* Comparison Panel */
.comparison-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: #FFF4E6;
    border-radius: 12px;
    font-size: 0.875rem;
    color: #6B5344;
    text-align: center;
    display: none;
}

.comparison-panel.show {
    display: block;
}

.comparison-panel .comparison-text {
    line-height: 1.5;
}

.comparison-panel .comparison-icon {
    font-size: 1.25rem;
    margin-right: 0.25rem;
}
