:root {
    --bg-1: #020617;
    --bg-2: #0f172a;
    --surface: rgba(15, 23, 42, 0.75);
    --surface-strong: rgba(15, 23, 42, 0.95);
    --text-primary: #e2e8f0;
    --text-muted: #cbd5e1;
    --accent-a: #0ea5e9;
    --accent-b: #14b8a6;
    --accent-c: #f59e0b;
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
    --line: rgba(148, 163, 184, 0.24);
    --radius-lg: 22px;
    --radius-md: 14px;
    --shadow-soft: 0 18px 38px rgba(2, 6, 23, 0.38);
}

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

body {
    font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    background:
        radial-gradient(circle at 14% 16%, rgba(14, 165, 233, 0.28), transparent 37%),
        radial-gradient(circle at 86% 12%, rgba(20, 184, 166, 0.22), transparent 36%),
        radial-gradient(circle at 50% 84%, rgba(245, 158, 11, 0.16), transparent 35%),
        linear-gradient(130deg, var(--bg-1) 0%, var(--bg-2) 100%);
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 0.8rem;
    background: #e2e8f0;
    color: #0f172a;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    z-index: 2000;
    text-decoration: none;
    font-weight: 700;
}

.skip-link:focus-visible {
    top: 0.75rem;
}

.container {
    width: min(1220px, 100% - 2.4rem);
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2.5rem 0 1.2rem;
}

.header {
    margin-bottom: 2rem;
    padding: 2.2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(130deg, rgba(30, 41, 59, 0.82), rgba(2, 6, 23, 0.72));
    box-shadow: var(--shadow-soft);
    animation: rise-in 0.65s ease both;
}

.header h1 {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(1.65rem, 3vw, 2.75rem);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    letter-spacing: -0.03em;
    margin-bottom: 0.6rem;
}

.header h1 i {
    color: var(--accent-a);
    animation: pulse-icon 2.8s ease-in-out infinite;
}

.header p {
    color: var(--text-muted);
    max-width: 65ch;
    line-height: 1.4;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

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

.rate-card-primary {
    border-color: rgba(56, 189, 248, 0.55);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.82));
    box-shadow:
        0 22px 44px rgba(2, 6, 23, 0.45),
        inset 0 0 0 1px rgba(56, 189, 248, 0.2);
}

.rate-card-primary .card-header {
    background: linear-gradient(95deg, rgba(14, 165, 233, 0.25), rgba(20, 184, 166, 0.15));
}

.rate-card-primary .rate {
    font-size: clamp(2.05rem, 4.8vw, 2.9rem);
    color: #f8fafc;
}

.rate-context {
    display: block;
    margin-top: 0.45rem;
    color: #94d8ff;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

.card {
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    position: relative;
    transition: transform 0.28s ease, border-color 0.28s ease;
    animation: rise-in 0.5s ease both;
}

.card:hover {
    transform: translateY(-3px);
    border-color: rgba(14, 165, 233, 0.5);
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(120deg, transparent 20%, rgba(56, 189, 248, 0.07) 48%, transparent 72%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::after {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(2, 6, 23, 0.68), rgba(15, 23, 42, 0.88));
}

.card-header h3 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header i {
    color: var(--accent-a);
}

.card-body {
    padding: 1.25rem;
}

.rate-card .card-body {
    min-height: 176px;
}

.rate-card.is-loading .rate-content {
    display: none;
}

.rate-card:not(.is-loading) .rate-skeleton {
    display: none;
}

.rate-skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 0.15rem 0;
}

.skeleton {
    display: block;
    border-radius: 999px;
    background: linear-gradient(100deg, rgba(148, 163, 184, 0.2) 20%, rgba(226, 232, 240, 0.3) 50%, rgba(148, 163, 184, 0.2) 80%);
    background-size: 220% 100%;
    animation: skeleton-shimmer 1.15s ease infinite;
}

.skeleton-pill {
    width: 5.2rem;
    height: 0.85rem;
}

.skeleton-line {
    width: min(90%, 15.5rem);
    height: 2.15rem;
    border-radius: 0.85rem;
}

.skeleton-line.short {
    width: min(70%, 12rem);
    height: 0.8rem;
}

.rate-display {
    text-align: center;
}

.currency {
    color: var(--text-muted);
    font-size: 0.79rem;
    display: block;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.rate {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(1.7rem, 4.2vw, 2.45rem);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.rate-info {
    margin-top: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.85rem;
}

.rate-info-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.freshness-badge {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.freshness-badge.live {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
}

.freshness-badge.recent {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.45);
}

.freshness-badge.stale {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.4);
}

.status-indicator {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 999px;
    padding: 0.34rem 0.7rem;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.status-indicator.online {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
}

.status-indicator.loading {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.5);
}

.status-indicator.error {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.45);
}

.tab-navigation {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.65);
    display: flex;
    padding: 0.25rem;
    gap: 0.35rem;
    width: fit-content;
    margin: 0 auto;
}

.tab-button {
    border: none;
    border-radius: 999px;
    color: var(--text-muted);
    background: transparent;
    padding: 0.78rem 1.6rem;
    cursor: pointer;
    transition: all 0.22s ease;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.tab-button:hover {
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.8);
}

.tab-button.active {
    color: #022c22;
    background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
}

.tab-content {
    position: relative;
}

.tab-pane {
    display: none;
    animation: fade-in-up 0.36s ease both;
}

.tab-pane.active {
    display: block;
}

.chart-section,
.controls-section,
.calculator-section {
    margin-top: 1rem;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.chart-range-presets {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    flex-wrap: wrap;
}

.chart-preset {
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.85);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 0.45rem 0.72rem;
    min-width: 3.15rem;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-preset:hover {
    color: var(--text-primary);
    border-color: rgba(56, 189, 248, 0.6);
}

.chart-preset.active {
    color: #082f49;
    border-color: transparent;
    background: linear-gradient(90deg, #38bdf8, #2dd4bf);
}

.chart-controls select {
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text-primary);
    background: var(--surface-strong);
    padding: 0.58rem 0.72rem;
    min-width: 168px;
}

#rateChart {
    height: 385px !important;
    width: 100% !important;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    align-items: center;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 0.74rem 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.btn-primary {
    color: #082f49;
    background: linear-gradient(90deg, #38bdf8, #2dd4bf);
}

.btn-secondary {
    color: #fff;
    background: linear-gradient(90deg, #0284c7, #0f766e);
}

.calculator-card {
    max-width: 980px;
    margin: 0 auto;
}

.calculator-subtitle {
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-size: 0.9rem;
}

.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.currency-toggle {
    display: flex;
    justify-content: center;
    gap: 0.65rem;
}

.currency-btn {
    border: 1px solid rgba(56, 189, 248, 0.45);
    background: rgba(2, 6, 23, 0.58);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 0.65rem 1rem;
    min-width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.currency-btn.active,
.currency-btn:hover {
    background: rgba(14, 165, 233, 0.3);
    border-color: rgba(45, 212, 191, 0.75);
}

.amount-input {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.amount-input label {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.88rem;
}

.input-group {
    display: flex;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface-strong);
}

.currency-symbol,
.currency-code {
    padding: 0.8rem 0.9rem;
    background: rgba(15, 23, 42, 0.94);
    color: var(--text-muted);
    font-weight: 700;
}

#amount-input {
    flex: 1;
    border: none;
    outline: none;
    text-align: center;
    font-size: 1.15rem;
    color: var(--text-primary);
    background: transparent;
    font-family: "Space Grotesk", sans-serif;
}

.conversion-results {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}

.result-card {
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 1rem;
    text-align: center;
    background: linear-gradient(140deg, rgba(15, 23, 42, 0.9), rgba(2, 6, 23, 0.85));
}

.result-header {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}

.result-header h4 {
    font-size: 0.95rem;
}

.result-amount {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.32rem;
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 1.75rem;
    font-family: "Space Grotesk", sans-serif;
}

.result-rate {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.calculator-actions {
    display: flex;
    justify-content: center;
}

.footer {
    margin-top: 1.4rem;
    padding: 0.8rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.spinner {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    max-width: 300px;
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 0.8rem 1rem;
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-soft);
    z-index: 1000;
    animation: fade-in-up 0.28s ease both;
}

.notification.success {
    background: rgba(34, 197, 94, 0.92);
    border-color: rgba(187, 247, 208, 0.6);
}

.notification.error {
    background: rgba(239, 68, 68, 0.92);
    border-color: rgba(252, 165, 165, 0.65);
}

.notification.info {
    background: rgba(14, 165, 233, 0.92);
    border-color: rgba(186, 230, 253, 0.75);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 3px solid #facc15;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.25);
}

.tab-button:active,
.btn:active,
.currency-btn:active {
    transform: scale(0.98);
}

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

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(22px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-icon {
    0% {
        transform: translateY(0);
        filter: drop-shadow(0 0 0 rgba(56, 189, 248, 0));
    }
    50% {
        transform: translateY(-1px);
        filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.65));
    }
    100% {
        transform: translateY(0);
        filter: drop-shadow(0 0 0 rgba(56, 189, 248, 0));
    }
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1060px) {
    .cards-grid,
    .conversion-results {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rate-card-primary {
        grid-column: span 2;
    }
}

@media (max-width: 760px) {
    .container {
        width: min(1220px, 100% - 1rem);
        padding-top: 1.1rem;
    }

    .header {
        padding: 1.35rem;
    }

    .cards-grid,
    .controls-grid,
    .conversion-results {
        grid-template-columns: 1fr;
    }

    .rate-card-primary {
        grid-column: auto;
    }

    .tab-navigation {
        width: 100%;
        border-radius: 14px;
        flex-direction: column;
    }

    .tab-button {
        width: 100%;
        justify-content: center;
    }

    .chart-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .chart-range-presets {
        width: 100%;
        justify-content: space-between;
    }

    .chart-controls select,
    .chart-controls .btn {
        width: 100%;
    }

    #rateChart {
        height: 300px !important;
    }

    .currency-toggle {
        flex-direction: column;
    }

    .currency-btn {
        width: 100%;
    }
}
