:root {
    --bg: #0b0c10;
    --text: #e7eaf3;
    --muted: #9aa4b2;
    --panel: #12141b;
    --panel2: #0f1117;
    --stroke: #222635;
    --accent: #3b82f6;
    --ok: #10b981;
    --err: #ef4444;
}

html,
body {
    height: 100%;
    width: 100%;
}

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 20% -10%, #1a1f33 0%, #0b0c10 50%), #0b0c10;
    color: var(--text);
    font-family: Inter, system-ui, Segoe UI, Roboto, Arial, sans-serif
}

.container {

    margin: 0 auto;
    padding: 24px
}

.appbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px
}

.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(45deg, #6ee7b7, #3b82f6)
}

.wallet-actions {
    display: flex;
    gap: 8px;
    align-items: center
}

.btn {
    padding: 10px 14px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer
}

.btn.pill {
    border-radius: 999px
}

.btn-primary {
    background: var(--accent);
    color: #fff
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--stroke)
}

.btn[disabled] {
    opacity: .6;
    cursor: not-allowed
}

.swap-box {
    max-width: 560px;
    margin: 80px auto
}

.swap-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px
}

.tab {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--stroke);
    background: transparent;
    color: var(--muted);
    cursor: not-allowed
}

.tab.active {
    background: var(--panel);
    color: #fff;
    cursor: default
}

.swap-card {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel2) 100%);
    border: 1px solid var(--stroke);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .35)
}

.swap-row {
    background: #0f1117;
    border: 1px solid #1e2232;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px
}

.row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px
}

.muted {
    color: var(--muted);
    font-size: 13px
}

.net-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0b0d13;
    border: 1px solid #242a3b;
    padding: 6px 10px;
    border-radius: 999px
}

.net-chip .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #55c9a6
}

.chip-select {
    appearance: none;
    background: transparent;
    border: none;
    color: #e7eaf3;
    font-weight: 600;
    cursor: pointer;
    background-color: #0b0c10;
}

.row-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px
}

.token-chip {
    display: flex;
    align-items: center;
    gap: 10px
}

.token-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #1b2135;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #8bd6ff
}

.token-meta {
    display: flex;
    flex-direction: column;
    line-height: 1
}

.token-symbol {
    font-weight: 700
}

.token-network {
    font-size: 12px;
    color: var(--muted)
}

.amount-input {
    flex: 1;
    text-align: right;
    font-size: 28px;
    background: transparent;
    border: none;
    outline: none;
    color: #fff
}

.amount-input::placeholder {
    color: #3b415a
}

.row-foot {
    display: flex;
    justify-content: flex-end
}

.fiat {
    font-size: 12px
}

.swap-sep {
    display: flex;
    justify-content: center;
    margin: 8px 0
}

.switch-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--stroke);
    background: #0f1117;
    color: #aeb7d0;
    display: grid;
    place-items: center;
    cursor: pointer
}

.rate-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f1117;
    border: 1px dashed #2a3045;
    border-radius: 12px;
    padding: 10px 12px;
    margin: 12px 0
}

.rate {
    font-size: 12px;
    color: #b5bfd8
}

.small {
    font-size: 12px;
    color: var(--muted)
}

.status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 12px;
    background: #101116;
    border: 1px solid #242632
}

.status.ok {
    border-color: #1b3b2e;
    color: var(--ok)
}

.status.err {
    border-color: #3b1b1b;
    color: var(--err)
}

.btn.big {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 16px
}

/* --- 1inch-like topbar --- */
.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .logo .normal_logo {
    height: 65px;
    display: block
}

.nav {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-left: 6px;
    flex: 1
}

.nav-link,
.nav-btn {
    color: #b8c2d3;
    font-weight: 600;
    font-size: 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 10px;
}

.nav-link:hover,
.nav-btn:hover {
    background: #0d0f15;
    color: #e8edf7
}

.nav-item {
    position: relative
}

.caret {
    opacity: .7;
    margin-left: 6px;
    font-size: 12px
}

.has-dd .dd {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: #0f1117;
    border: 1px solid #242839;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: .15s ease;
}

.has-dd:hover .dd {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0)
}

.dd a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: #dbe4f4;
    text-decoration: none;
    font-size: 14px;
}

.dd a:hover {
    background: #141826
}

.actions {
    display: flex;
    align-items: center;
    gap: 12px
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--stroke);
    background: #0f1117;
    color: #aeb7d0;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.icon-btn:hover {
    background: #141826;
    color: #d8def0
}

/* keep your button styles */
.btn.pill {
    border-radius: 999px
}

.burger {
    display: none;
    margin-left: 6px;
    width: 40px;
    height: 36px;
    border: 1px solid var(--stroke);
    background: #0f1117;
    border-radius: 10px;
    cursor: pointer;
    padding: 8px;
}

.burger span {
    display: block;
    height: 2px;
    background: #c9d3e6;
    margin: 5px 0;
    border-radius: 2px
}

.mobile-menu {
    display: none;
    position: absolute;
    top: 64px;
    right: 20px;
    left: 20px;
    background: #0f1117;
    border: 1px solid #242839;
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
    z-index: 60;
}

.mobile-menu.open {
    display: block;
}

.m-item {
    display: block;
    padding: 12px 10px;
    color: #dbe4f4;
    text-decoration: none;
    border-radius: 10px;
}

.m-item:hover {
    background: #141826
}

/* контейнер контента */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px
}

/* карточка */
.swap-box {
    max-width: 560px;
    margin: 80px auto
}

.small_logo {
    display: none;
}

.token-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #1b2135;
    padding: 4px;
    object-fit: contain;
    box-shadow: 0 0 6px rgba(0, 0, 0, .3);
    cursor: pointer;
    user-select: none;
}

.token-chip {
    position: relative;
}

.token-popover {
    position: absolute;
    top: 44px;
    left: 0;
    width: 220px;
    background: #0f1117;
    border: 1px solid #242839;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
    z-index: 40;
}

.token-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
}

.token-item:hover {
    background: #141826;
}

.token-item-icon {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    object-fit: contain;
}

.token-item-name {
    font-weight: 700;
    color: #e7eaf3;
}

/* ================= ADAPTIVE PATCH ================= */

/* 0) Базовая «резина» */
:root {
    --fs-base: clamp(14px, 1.4vw, 16px);
    --fs-small: clamp(12px, 1.2vw, 13px);
    --fs-title: clamp(16px, 2vw, 18px);
    --radius: 14px;
}

body {
    font-size: var(--fs-base);
}

.muted,
.small {
    font-size: var(--fs-small);
}

.btn.big {
    font-size: clamp(14px, 1.6vw, 16px);
    padding: clamp(10px, 1.6vw, 14px) clamp(12px, 2vw, 16px);
}

.amount-input {
    font-size: clamp(20px, 3.2vw, 28px);
}

/* Чиним опечатку: высота 32px без «а» */
@media (max-width: 768px) {
    .token-logo {
        width: 32px;
        height: 32px;
    }
}

/* Контейнер тянется, с учётом safe-area */
.container {
    max-width: 1200px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

/* Токен-иконка: чуть меньше на мелких */
.token-icon {
    width: 36px;
    height: 36px;
}

@media (max-width: 768px) {
    .token-icon {
        width: 28px;
        height: 28px;
        padding: 3px;
    }
}

/* Поповер монет: не вываливается за край, скролл если длинный */
.token-chip {
    position: relative;
}

.token-popover {
    min-width: 200px;
    max-width: min(92vw, 320px);
    max-height: min(60vh, 420px);
    overflow: auto;
    overscroll-behavior: contain;
}

@media (max-width: 480px) {
    .token-popover {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Карточка и строки: компактно на мобиле */
.swap-box {
    max-width: 560px;
    margin: clamp(24px, 8vw, 80px) auto;
}

.swap-card {
    border-radius: clamp(12px, 2vw, 18px);
    padding: clamp(10px, 2vw, 14px);
}

.swap-row {
    padding: clamp(10px, 2vw, 12px);
    border-radius: clamp(10px, 2vw, 14px);
}

.row-body {
    gap: clamp(8px, 2vw, 12px);
}

/* На узких экранах складываем контент строки в колонку */
@media (max-width: 520px) {
    .row-body {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .amount-input {
        text-align: left;
        font-size: clamp(18px, 6vw, 22px);
        padding: 6px 0 2px;
    }

    .token-chip {
        justify-content: space-between;
    }
}

/* Бар с курсом и комиссией — в столбик на мобиле */
@media (max-width: 520px) {
    .rate-bar {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }
}

/* Шапка: ужимаем логотип и лишние кнопки */
.topbar {
    height: clamp(56px, 7vw, 64px);
    padding-inline: 0;
}

.topbar .logo .normal_logo {
    height: clamp(44px, 5.5vw, 65px);
}

.actions {
    gap: clamp(8px, 1.4vw, 12px);
}

@media (max-width: 992px) {
    .nav {
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .nav {
        display: none;
    }

    .icon-btn {
        display: none;
    }

    #connect-btn {
        padding: 8px 12px;
        font-size: clamp(12px, 1.8vw, 13px);
    }
}

/* Селекты-чипы: меньше внутренний отступ и маска шрифта */
.net-chip {
    padding: clamp(5px, 0.9vw, 6px) clamp(8px, 1.4vw, 10px);
}

.chip-select {
    font-size: clamp(13px, 1.6vw, 16px);
}

/* Кнопка «перевернуть» */
.switch-btn {
    width: 34px;
    height: 34px;
}

@media (max-width: 520px) {
    .swap-sep {
        margin: 6px 0;
    }

    .switch-btn {
        width: 32px;
        height: 32px;
    }
}

/* Статус-плашка: компактнее и перенос строки */
.status {
    font-size: clamp(12px, 1.6vw, 14px);
    word-break: break-word;
}

/* Уменьшаем тени на ретина-мобиле */
@media (max-width: 480px) {
    .swap-card {
        box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
    }
}

/* Не трясём интерфейс тем, кому плохо от анимаций */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}