:root {
    /* Palette */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #1e293b;

    /* Glass Card Palette (Light/Premium) */
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-text: #1e293b;
    --card-muted: #64748b;
    --card-border: rgba(226, 232, 240, 0.8);

    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    line-height: 1.5;
}

/* --- Background Animation --- */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite alternate ease-in-out;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -10%;
    left: -10%;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: #8b5cf6;
    bottom: 10%;
    right: 10%;
    animation-delay: -5s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: #ec4899;
    top: 40%;
    left: 60%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 100px) scale(1.1); }
}

/* --- Main Container --- */
.app-container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    z-index: 1;
}

.glass-card {
    background: var(--card-bg);
    color: var(--card-text);
    border: 1px solid var(--card-border);
    border-radius: 32px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(18px);
    animation: cardEnter 0.6s ease-out;
}

@keyframes cardEnter {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Header --- */
.card-header {
    text-align: center;
    margin-bottom: 32px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.eyebrow {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--card-muted);
    background: rgba(0,0,0,0.05);
    padding: 4px 10px;
    border-radius: 20px;
}

.live-indicator .dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.card-header h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--card-text);
}

.subtitle {
    font-size: 16px;
    color: var(--card-muted);
}

/* --- Form --- */
.converter-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--card-muted);
    margin-left: 4px;
}

.amount-wrapper input {
    width: 100%;
    padding: 16px 20px;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid var(--card-border);
    border-radius: 16px;
    background: white;
    color: var(--card-text);
    transition: var(--transition-smooth);
    outline: none;
}

.amount-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* --- Selectors --- */
.selectors-container {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.selector-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.selector-card label {
    font-size: 12px;
    font-weight: 700;
    color: var(--card-muted);
    margin-left: 4px;
}

.selector-card select {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid var(--card-border);
    border-radius: 16px;
    background: white;
    color: var(--card-text);
    cursor: pointer;
    transition: var(--transition-smooth);
    outline: none;
}

.selector-card select:hover {
    border-color: #cbd5e1;
}

.selector-card select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.swap-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--card-border);
    background: white;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: var(--transition-bounce);
    margin-bottom: 2px;
}

.swap-button:hover {
    border-color: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.swap-button:active {
    transform: scale(0.9);
}

.swap-button.rotating {
    transform: rotate(180deg) scale(1.1);
}

/* --- Primary Button --- */
.primary-btn {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn:focus-visible {
    outline: 3px solid var(--warning);
    outline-offset: 3px;
}

/* --- States Container --- */
.state-container {
    margin-top: 32px;
    min-height: 100px;
}

.state-content {
    text-align: center;
    padding: 24px;
    border-radius: 24px;
    animation: stateEnter 0.4s ease-out;
}

@keyframes stateEnter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.idle-message {
    color: var(--card-muted);
    font-style: italic;
}

/* --- Success State --- */
.success-card {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.success-icon {
    font-size: 32px;
    margin-bottom: 16px;
    display: block;
}

.result-main {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 8px;
}

.result-sub {
    font-size: 16px;
    opacity: 0.8;
    font-weight: 500;
}

/* --- Loading State --- */
.loading-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: var(--card-text);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-heading {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.loading-text {
    color: var(--card-muted);
    font-size: 14px;
}

/* --- Error State --- */
.error-card {
    background: #fef2f2;
    border: 1px solid #fee2e2;
    color: #991b1b;
}

.error-icon {
    font-size: 32px;
    margin-bottom: 16px;
    display: block;
}

.error-heading {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.error-text {
    font-size: 14px;
    margin-bottom: 20px;
    color: #b91c1c;
}

.retry-btn {
    padding: 10px 20px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.retry-btn:hover {
    background: #dc2626;
}

/* --- Empty State --- */
.empty-card {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    color: #92400e;
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 16px;
    display: block;
}

.empty-heading {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-text {
    font-size: 14px;
    margin-bottom: 8px;
}

.empty-subtext {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.8;
}

/* --- Footer --- */
.card-footer {
    margin-top: 40px;
    text-align: center;
    font-size: 12px;
    color: var(--card-muted);
}

.card-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.card-footer a:hover {
    text-decoration: underline;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .glass-card {
        padding: 24px;
    }

    .selectors-container {
        flex-direction: column;
        align-items: center;
    }

    .swap-button {
        margin: 8px 0;
        transform: rotate(90deg);
    }

    .swap-button.rotating {
        transform: rotate(270deg) scale(1.1);
    }

    .card-header h1 {
        font-size: 24px;
    }
}

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
    .orb, .glass-card, .swap-button, .primary-btn, .state-content {
        animation: none !important;
        transition: none !important;
    }
}

/* Handle overflow for very long numbers */
.result-main {
    overflow-wrap: anywhere;
    word-break: break-word;
}
.loading-spinner {
    width: 42px;
    height: 42px;

    margin: 0 auto 18px;

    border: 4px solid #e2e8f0;
    border-top-color: var(--primary);

    border-radius: 50%;

    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}