:root {
    --bg-0: #050a14;
    --bg-1: #0c1628;
    --bg-2: #12203a;
    --surface-0: rgba(14, 23, 39, 0.78);
    --surface-1: rgba(16, 29, 48, 0.9);
    --surface-2: rgba(10, 19, 33, 0.95);
    --text-0: #ecf4ff;
    --text-1: #c9d8eb;
    --text-2: #90a7c2;
    --line-0: rgba(142, 173, 204, 0.22);
    --line-1: rgba(130, 168, 205, 0.12);
    --accent: #42d5ff;
    --accent-2: #2ef0b6;
    --warn: #ffb347;
    --ok: #39d98a;
    --danger: #ff6d81;
    --shadow-0: 0 30px 80px rgba(0, 0, 0, 0.45);
    --shadow-1: 0 14px 42px rgba(4, 11, 24, 0.5);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
    position: relative;
    min-height: 100vh;
    padding: 34px 18px;
    color: var(--text-0);
    background:
        radial-gradient(1200px circle at 10% -10%, #1b345f 0%, transparent 60%),
        radial-gradient(800px circle at 90% 10%, #0f5f63 0%, transparent 52%),
        linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 100%);
    overflow-x: hidden;
}

.bg-glow {
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(70px);
    opacity: 0.45;
    z-index: 0;
}

.bg-glow-one {
    width: 340px;
    height: 340px;
    top: -90px;
    left: -80px;
    background: #2fc6ff;
}

.bg-glow-two {
    width: 380px;
    height: 380px;
    right: -120px;
    bottom: -120px;
    background: #27e7b5;
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(126, 171, 212, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(126, 171, 212, 0.08) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
    padding: 34px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--line-0);
    background: linear-gradient(165deg, rgba(22, 34, 54, 0.88), rgba(10, 18, 31, 0.93));
    box-shadow: var(--shadow-0);
    backdrop-filter: blur(8px);
}

header {
    margin-bottom: 32px;
    text-align: center;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line-1);
}

.mode-badge {
    display: inline-block;
    margin-bottom: 14px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(66, 213, 255, 0.13);
    border: 1px solid rgba(66, 213, 255, 0.35);
    color: #95e8ff;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    font-weight: 600;
}

header h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-0);
    font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
    font-size: clamp(2rem, 4vw, 3.2rem);
    font-weight: 700;
    margin-bottom: 10px;
}

header h1 i {
    color: var(--accent);
    text-shadow: 0 0 24px rgba(66, 213, 255, 0.45);
}

.subtitle {
    color: var(--text-2);
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

main {
    display: grid;
    grid-template-columns: minmax(0, 1.85fr) minmax(300px, 1fr);
    gap: 22px;
}

.converter-card,
.info-card,
.status-card {
    border: 1px solid var(--line-0);
    border-radius: var(--radius-lg);
    background: linear-gradient(150deg, var(--surface-1), var(--surface-2));
    box-shadow: var(--shadow-1);
    animation: card-rise 0.8s ease both;
}

.converter-card {
    padding: 28px;
}

.info-card,
.status-card {
    padding: 24px;
}

.info-card {
    animation-delay: 0.12s;
}

.status-card {
    animation-delay: 0.2s;
}

.amount-section,
.result-section {
    margin-bottom: 22px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--text-1);
    font-weight: 600;
}

.input-group,
.result-display {
    display: flex;
    gap: 12px;
    align-items: center;
}

input[type="number"],
select {
    width: 100%;
    border: 1px solid var(--line-0);
    border-radius: var(--radius-md);
    background: rgba(7, 15, 27, 0.9);
    color: var(--text-0);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

input[type="number"] {
    flex: 1;
    padding: 14px 16px;
    font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
    font-size: 1.35rem;
    font-weight: 600;
}

.currency-select {
    width: 220px;
}

select {
    padding: 14px 16px;
    font-size: 1rem;
    cursor: pointer;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(66, 213, 255, 0.18);
    transform: translateY(-1px);
}

input[type="number"]::placeholder {
    color: rgba(200, 220, 240, 0.45);
}

.swap-section {
    display: flex;
    justify-content: center;
    margin: 20px 0 18px;
}

.swap-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 1px solid rgba(66, 213, 255, 0.35);
    background: linear-gradient(145deg, rgba(66, 213, 255, 0.25), rgba(46, 240, 182, 0.18));
    color: #c5f3ff;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 30px rgba(22, 145, 175, 0.24);
    transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.25s ease;
    animation: swap-pulse 2.4s ease-in-out infinite;
}

.swap-btn:hover {
    transform: rotate(180deg) scale(1.04);
    border-color: rgba(66, 213, 255, 0.72);
    box-shadow: 0 16px 34px rgba(36, 173, 206, 0.35);
}

.result-display {
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line-0);
    background: rgba(5, 13, 24, 0.72);
}

.result-value {
    flex: 1;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f2f8ff;
    font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
    font-size: clamp(1.9rem, 3.5vw, 2.9rem);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.rate-info {
    margin-top: 12px;
    text-align: center;
    color: var(--text-2);
    font-size: 0.96rem;
}

.actions {
    margin-top: 28px;
    display: flex;
    gap: 14px;
}

.convert-btn,
.refresh-btn {
    flex: 1;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 1.08rem;
    font-weight: 700;
    color: #031b22;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

.convert-btn {
    background: linear-gradient(145deg, #31f0ba, #2bc4ff);
    box-shadow: 0 10px 28px rgba(53, 202, 224, 0.35);
}

.refresh-btn {
    background: linear-gradient(145deg, #ffd06b, #ff9d42);
    box-shadow: 0 10px 28px rgba(255, 170, 77, 0.3);
}

.convert-btn:hover,
.refresh-btn:hover {
    transform: translateY(-2px);
    filter: saturate(1.05) brightness(1.02);
}

.info-card h3,
.status-card h3 {
    margin-bottom: 16px;
    color: var(--text-0);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    font-weight: 700;
}

.info-card h3 i,
.status-card h3 i {
    color: #8fe8ff;
}

.info-card ul {
    list-style: none;
    margin-bottom: 18px;
}

.info-card li {
    display: flex;
    gap: 10px;
    padding: 9px 0;
    color: var(--text-1);
    border-bottom: 1px dashed var(--line-1);
}

.info-card li::before {
    content: "✓";
    color: var(--ok);
    font-weight: 700;
    margin-top: 1px;
}

.currency-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.currency-item {
    padding: 11px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-1);
    background: rgba(6, 15, 28, 0.68);
    text-align: center;
    transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.currency-item:hover {
    transform: translateY(-2px);
    border-color: rgba(66, 213, 255, 0.45);
    background: rgba(16, 33, 56, 0.78);
}

.currency-code {
    display: block;
    color: #d8e8fb;
    font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
    font-size: 1.18rem;
    font-weight: 700;
}

.currency-name {
    display: block;
    margin-top: 4px;
    color: var(--text-2);
    font-size: 0.92rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line-1);
}

.status-label {
    color: var(--text-1);
    font-weight: 600;
}

.status-value {
    color: var(--text-2);
    text-align: right;
    font-weight: 500;
}

#backend-status.connected {
    color: var(--ok);
    font-weight: 700;
}

#backend-status.disconnected {
    color: var(--danger);
    font-weight: 700;
}

footer {
    margin-top: 30px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--line-1);
    color: var(--text-2);
    font-size: 0.92rem;
}

.footer-note {
    margin-top: 5px;
    font-size: 0.84rem;
    color: rgba(144, 167, 194, 0.85);
}

@keyframes card-rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes swap-pulse {
    0%,
    100% {
        box-shadow: 0 12px 30px rgba(22, 145, 175, 0.24);
    }

    50% {
        box-shadow: 0 16px 34px rgba(36, 173, 206, 0.36);
    }
}

@media (max-width: 980px) {
    .container {
        padding: 24px;
    }

    main {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px 10px;
    }

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

    .converter-card,
    .info-card,
    .status-card {
        padding: 18px;
    }

    .input-group,
    .result-display,
    .actions {
        flex-direction: column;
    }

    .currency-select {
        width: 100%;
    }

    .result-value {
        min-height: 48px;
    }

    .currency-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    header h1 {
        gap: 8px;
    }

    .subtitle {
        font-size: 1rem;
    }

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

    .mode-badge {
        margin-bottom: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
