:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #162033;
    --muted: #6a7280;
    --line: #dce2ea;
    --accent: #146c5c;
    --accent-dark: #0e5145;
    --warn: #fff6da;
    --warn-line: #ead28a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

body.sheet-open {
    overflow: hidden;
}

.app {
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 20px 16px 32px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 8px;
}

.lang-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 64px;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.lang-toggle img {
    width: 22px;
    height: 16px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 2px;
}

.lang-toggle:hover {
    border-color: var(--accent);
    background: #eef8f5;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 26px;
    line-height: 1.15;
}

.refresh,
button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

.refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    white-space: nowrap;
}

.refresh:hover,
button:hover {
    background: var(--accent-dark);
}

.notice,
.converter,
.result,
.rates {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.notice {
    margin-bottom: 14px;
    padding: 14px;
    background: var(--warn);
    border-color: var(--warn-line);
}

.notice p {
    margin-top: 6px;
    color: #6b5413;
}

.converter {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.currency-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
    align-items: end;
    gap: 10px;
}

.swap-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-height: 48px;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--accent);
    font-size: 24px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.swap-button:hover {
    border-color: var(--accent);
    background: #eef8f5;
}

label {
    display: grid;
    gap: 7px;
}

label span,
.result span,
.section-title span {
    color: var(--muted);
    font-size: 13px;
}

input,
select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 16px;
    padding: 0 12px;
}

.amount-field {
    position: relative;
}

.amount-field input {
    padding-right: 48px;
}

.clear-amount {
    position: absolute;
    top: 50%;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-height: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: #eef2f6;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    transform: translateY(-50%);
}

.clear-amount:hover {
    background: #dde5ee;
    color: var(--text);
}

.select-with-flag {
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.currency-picker {
    position: relative;
    display: grid;
    grid-template-columns: 66px minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 58px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    text-align: left;
    padding-right: 38px;
}

.currency-picker::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: translateY(-65%) rotate(45deg);
}

.currency-picker:hover {
    border-color: var(--accent);
    background: #fff;
}

.currency-picker img,
.currency-option img {
    width: 36px;
    height: 26px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 3px;
}

.currency-picker img,
.currency-picker .flag-empty {
    margin-left: 16px;
}

.currency-picker span,
.currency-option span {
    display: grid;
    min-width: 0;
}

.currency-picker strong,
.currency-option strong {
    font-size: 15px;
    line-height: 1.2;
}

.currency-picker small,
.currency-option small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-with-flag img {
    width: 28px;
    height: 20px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 3px;
}

.rate-name img {
    width: 36px;
    height: 26px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 3px;
}

.select-with-flag img,
.select-with-flag .flag-empty {
    margin-left: 12px;
}

.select-with-flag select {
    min-height: 46px;
    border: 0;
    border-radius: 0;
}

.flag-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #eef2f6;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.flag-empty.small {
    width: 36px;
    height: 26px;
}

select {
    appearance: auto;
}

button {
    width: 100%;
    font-size: 16px;
}

.result {
    margin-top: 14px;
    padding: 18px 16px;
}

.result strong {
    display: block;
    margin-top: 6px;
    font-size: 30px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.result p {
    margin-top: 6px;
    color: var(--muted);
}

.rates {
    margin-top: 14px;
    overflow: hidden;
}

.section-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.section-title h2 {
    font-size: 17px;
}

.rate-list {
    display: grid;
}

.rate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.rate-row:last-child {
    border-bottom: 0;
}

.rate-row span {
    color: var(--muted);
}

.rate-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(22, 32, 51, 0.45);
}

.bottom-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 21;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    width: min(720px, 100%);
    height: 82vh;
    max-height: 82vh;
    margin: 0 auto;
    padding: 8px 16px 16px;
    border-radius: 18px 18px 0 0;
    background: var(--panel);
    box-shadow: 0 -18px 45px rgba(22, 32, 51, 0.22);
    transform: translateY(105%);
    transition: transform 180ms ease;
}

.bottom-sheet.is-open {
    transform: translateY(0);
}

.sheet-handle {
    justify-self: center;
    width: 44px;
    height: 5px;
    margin: 2px 0 12px;
    border-radius: 999px;
    background: #ccd5df;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.sheet-head h2 {
    font-size: 18px;
}

.sheet-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-height: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: #eef2f6;
    color: var(--muted);
    font-size: 22px;
}

.sheet-close:hover {
    background: #dde5ee;
    color: var(--text);
}

.currency-search {
    margin-bottom: 12px;
}

.currency-list {
    display: grid;
    align-content: start;
    gap: 4px;
    overflow-y: auto;
    padding-right: 2px;
}

.currency-option {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 56px;
    padding: 8px 10px 8px 0;
    border: 0;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    text-align: left;
}

.currency-option:hover {
    background: #f1f7f5;
}

.currency-option img,
.currency-option .flag-empty {
    margin-left: 10px;
}

.currency-picker > img,
.currency-picker > .flag-empty {
    width: 42px;
    height: 30px;
}

.privacy-page {
    display: grid;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px 16px;
}

.privacy-updated,
.privacy-intro,
.privacy-section p {
    color: var(--muted);
    line-height: 1.6;
}

.privacy-intro {
    color: var(--text);
}

.privacy-section {
    display: grid;
    gap: 6px;
}

.privacy-section h2 {
    font-size: 17px;
}

@media (max-width: 560px) {
    .app {
        padding-top: 16px;
    }

    h1 {
        font-size: 22px;
    }

    .grid,
    .section-title {
        grid-template-columns: 1fr;
    }

    .currency-grid {
        position: relative;
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
    }

    .currency-grid label:last-child {
        margin-top: 32px;
    }

    .swap-button {
        position: absolute;
        top: 84px;
        right: 52px;
        z-index: 2;
        width: 40px;
        height: 40px;
        min-height: 40px;
        margin: 0;
        box-shadow: 0 6px 18px rgba(22, 32, 51, 0.12);
        transform: rotate(90deg);
    }

    .section-title {
        display: grid;
    }
}
