/* ========================================
   TON Wallet — "Crystal" theme
   One bold element: the faceted balance card (echoes the diamond logo).
   Everything else stays quiet: frost surfaces, hairlines, one accent.
   ======================================== */

:root {
    color-scheme: light dark;

    /* Brand and accent. The Gram logo blue is decoration only: as text or behind white
       text it fails contrast, so buttons, rings and links use deeper shades. */
    --brand: #30A1F5;
    --ton: #0072C0;        /* filled buttons (white text 5:1), borders, focus rings */
    --ton-strong: #005E9F;
    --ton-soft: rgba(0, 114, 192, 0.1);
    --link: #006FBB;       /* accent-coloured text */
    --focus: #0072C0;

    /* Surfaces (light: frost) */
    --bg: #F3F7FB;         /* app background */
    --surface: #FFFFFF;    /* lists, inputs, sheets */
    --surface-2: #EAF1F7;  /* pressed rows, chips */
    --surface-raised: #FFFFFF; /* the selected option of a switch, lifted above its --surface-2 track */
    --line: #D9E3EC;

    /* Text */
    --ink: #0E2233;
    --ink-2: #51697E;
    --ink-3: #607589;      /* placeholders, seed numbers, secondary icons: 4.7:1 on white */

    /* Status */
    --positive: #0B7F52;
    --positive-soft: #DDF3E8;
    --positive-ink: #0A7048; /* text on --positive-soft */
    --negative: #C9363B;
    --negative-soft: #FBE6E6;
    --danger-ink: #A4262C; /* text on --negative-soft */
    --warn-ink: #7E4B00;
    --warn-soft: #FFF0D2;

    --shadow-float: 0 12px 32px -12px rgba(14, 34, 51, 0.28);
    --overlay: rgba(6, 20, 33, 0.45);

    /* Type */
    --font-body: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Unbounded', var(--font-body);
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;

    /* Radius: larger means higher in the hierarchy */
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;

    --gutter: 10px;

    /* Brilliant-cut facets (top view), lit from the upper right like the logo's crystal:
       octagonal table, 8 star, 8 kite and 16 upper-girdle facets. Wallet and token cards. */
    --facets: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid slice'%3E%3Cpath d='M95.7 52.5L86.5 61.7L73.5 61.7L64.3 52.5L64.3 39.5L73.5 30.3L86.5 30.3L95.7 39.5Z' fill='%238FDBFF' fill-opacity='0.16' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M95.7 39.5L112.0 46.0L95.7 52.5Z' fill='%23ffffff' fill-opacity='0.101' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M112.0 46.0L95.7 52.5L102.6 68.6L137.3 69.7Z' fill='%23ffffff' fill-opacity='0.099' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M112.0 46.0L137.3 22.3L142.0 46.0Z' fill='%23ffffff' fill-opacity='0.168' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M112.0 46.0L142.0 46.0L137.3 69.7Z' fill='%23ffffff' fill-opacity='0.069' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M95.7 52.5L102.6 68.6L86.5 61.7Z' fill='%23ffffff' fill-opacity='0.0' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M102.6 68.6L86.5 61.7L80.0 78.0L103.7 103.3Z' fill='%23031E54' fill-opacity='0.138' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M102.6 68.6L137.3 69.7L123.8 89.8Z' fill='%23ffffff' fill-opacity='0.032' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M102.6 68.6L123.8 89.8L103.7 103.3Z' fill='%23031E54' fill-opacity='0.025' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M86.5 61.7L80.0 78.0L73.5 61.7Z' fill='%23031E54' fill-opacity='0.14' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M80.0 78.0L73.5 61.7L57.4 68.6L56.3 103.3Z' fill='%23031E54' fill-opacity='0.333' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M80.0 78.0L103.7 103.3L80.0 108.0Z' fill='%23031E54' fill-opacity='0.17' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M80.0 78.0L80.0 108.0L56.3 103.3Z' fill='%23031E54' fill-opacity='0.131' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M73.5 61.7L57.4 68.6L64.3 52.5Z' fill='%23031E54' fill-opacity='0.198' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M57.4 68.6L64.3 52.5L48.0 46.0L22.7 69.7Z' fill='%23031E54' fill-opacity='0.333' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M57.4 68.6L56.3 103.3L36.2 89.8Z' fill='%23031E54' fill-opacity='0.285' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M57.4 68.6L36.2 89.8L22.7 69.7Z' fill='%23031E54' fill-opacity='0.16' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M64.3 52.5L48.0 46.0L64.3 39.5Z' fill='%23031E54' fill-opacity='0.14' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M48.0 46.0L64.3 39.5L57.4 23.4L22.7 22.3Z' fill='%23031E54' fill-opacity='0.138' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M48.0 46.0L22.7 69.7L18.0 46.0Z' fill='%23031E54' fill-opacity='0.233' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M48.0 46.0L18.0 46.0L22.7 22.3Z' fill='%23031E54' fill-opacity='0.095' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M64.3 39.5L57.4 23.4L73.5 30.3Z' fill='%23ffffff' fill-opacity='0.0' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M57.4 23.4L73.5 30.3L80.0 14.0L56.3 -11.3Z' fill='%23ffffff' fill-opacity='0.099' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M57.4 23.4L22.7 22.3L36.2 2.2Z' fill='%23031E54' fill-opacity='0.045' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M57.4 23.4L36.2 2.2L56.3 -11.3Z' fill='%23ffffff' fill-opacity='0.018' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M73.5 30.3L80.0 14.0L86.5 30.3Z' fill='%23ffffff' fill-opacity='0.101' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M80.0 14.0L86.5 30.3L102.6 23.4L103.7 -11.3Z' fill='%23ffffff' fill-opacity='0.24' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M80.0 14.0L56.3 -11.3L80.0 -16.0Z' fill='%23ffffff' fill-opacity='0.123' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M80.0 14.0L80.0 -16.0L103.7 -11.3Z' fill='%23ffffff' fill-opacity='0.095' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M86.5 30.3L102.6 23.4L95.7 39.5Z' fill='%23ffffff' fill-opacity='0.143' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M102.6 23.4L95.7 39.5L112.0 46.0L137.3 22.3Z' fill='%23ffffff' fill-opacity='0.24' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M102.6 23.4L103.7 -11.3L123.8 2.2Z' fill='%23ffffff' fill-opacity='0.205' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M102.6 23.4L123.8 2.2L137.3 22.3Z' fill='%23ffffff' fill-opacity='0.116' stroke='%23fff' stroke-opacity='0.11' stroke-width='1' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
    --header-height: 56px;
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0B1A29;       /* deep water, not black */
        --surface: #11253A;
        --surface-2: #183049;
        /* Lighter than the track (--surface is darker here, and would look pressed in);
           --ink on it 8.9:1 */
        --surface-raised: #24435F;
        --line: #213A52;

        --ink: #E6F0F8;
        --ink-2: #93A9BD;
        --ink-3: #7D96AC;

        --positive: #3DD68C;
        --positive-soft: rgba(61, 214, 140, 0.13);
        --positive-ink: #3DD68C;
        --negative: #FF7A7D;
        --negative-soft: rgba(255, 122, 125, 0.13);
        --danger-ink: #FF9A9C;
        --warn-ink: #FFC061;
        --warn-soft: rgba(255, 192, 97, 0.12);
        --ton-soft: rgba(77, 179, 247, 0.16);
        --link: #4DB3F7;
        --focus: #4DB3F7;

        --shadow-float: 0 16px 40px -12px rgba(0, 0, 0, 0.6);
        --overlay: rgba(2, 8, 14, 0.6);
    }
}

/* ========================================
   Base
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

/* The app uses the whole screen at every width: one column on phones,
   two dashboard columns from 720px, a wallet sidebar from 960px, three columns from 1600px */
#app {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
}

/* ========================================
   Header & wallet selector
   ======================================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    padding: 0 var(--gutter);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 100%;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 50%;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn:hover {
    background: var(--surface-2);
}

.icon-btn:active {
    transform: scale(0.94);
}

.update-label {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.header-brand {
    display: none;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.header-brand img {
    width: 28px;
    height: 28px;
}

.icon-btn.is-spinning svg {
    animation: spin 0.9s linear infinite;
}

.wallet-selector {
    padding: 12px var(--gutter) 0;
    background: var(--bg);
}

/* A switcher with one wallet has nothing to switch to */
.wallet-selector.is-single {
    display: none;
}

.wallet-switch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wallet-switch:focus-within {
    border-color: var(--ton);
    box-shadow: 0 0 0 3px var(--ton-soft);
}

.wallet-switch-text {
    display: flex;
    flex: 1;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.wallet-switch-name {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.wallet-switch-address {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink-2);
}

.wallet-switch-chevron,
.send-from-chevron {
    flex-shrink: 0;
    color: var(--ink-2);
}

/* The native picker lies invisibly over the custom face and opens the OS list */
.wallet-switch-select,
.send-from-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    font-size: 16px;
    opacity: 0;
    appearance: none;
    cursor: pointer;
}

/* ========================================
   Layout
   ======================================== */
/* The window scrolls; only the wallet layout from 1200px scrolls this column instead (a scroll
   container here would also be the one sticky elements stick in, and it never scrolls) */
.main-content {
    flex: 1;
    padding: 12px var(--gutter) 24px;
}

.screen {
    position: relative;
    animation: screenIn 0.18s ease-out;
}

@keyframes screenIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 20px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    color: #FFFFFF;
    background: var(--ton);
}

.btn-primary:hover:not(:disabled) {
    background: var(--ton-strong);
}

.btn-secondary {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-2);
}

.btn-outline {
    color: var(--link);
    background: transparent;
    border-color: var(--ton);
}

.btn-outline:hover:not(:disabled) {
    background: var(--ton-soft);
}

.btn-large {
    width: 100%;
    min-height: 54px;
    font-size: 16px;
    border-radius: 16px;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 340px;
}

/* ========================================
   Screen titles: the back arrow shares the title's row
   ======================================== */
.screen-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.screen-head h2 {
    min-width: 0;
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 50%;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.back-btn:hover {
    background: var(--surface-2);
}

.back-btn:active {
    transform: scale(0.94);
}

.screen-description {
    max-width: 36em;
    margin: -6px 0 20px;
    font-size: 15px;
    color: var(--ink-2);
}

/* ========================================
   Welcome
   ======================================== */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 140px);
    padding: 24px 8px;
    text-align: center;
}

.logo-container {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    filter: drop-shadow(0 14px 22px rgba(0, 120, 210, 0.3));
}

.logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
}

.welcome-subtitle {
    max-width: 290px;
    margin-bottom: 32px;
    font-size: 15px;
    color: var(--ink-2);
}

/* ========================================
   Seed phrase
   ======================================== */
/* As many columns as the longest word allows (3 on most phones, 2 on narrow ones) */
.seed-words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 6px;
    margin-bottom: 16px;
}

.seed-word {
    display: flex;
    align-items: baseline;
    gap: 5px;
    min-width: 0;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}

.seed-word-num {
    min-width: 18px;
    font-size: 11px;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

/* Never cut: a word written down as "mushro…" can't restore the wallet */
.seed-word-text {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-copy-seed {
    width: 100%;
    margin-bottom: 16px;
}

.warning-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    padding: 14px;
    color: var(--warn-ink);
    background: var(--warn-soft);
    border-radius: var(--r-md);
}

.warning-box svg {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

.warning-box span {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

/* ========================================
   Inputs
   ======================================== */
.input-group,
.form-group {
    position: relative;
    margin-bottom: 16px;
}

.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
}

.input,
.seed-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px; /* 16px prevents iOS zoom on focus */
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.seed-input {
    min-height: 132px;
    margin-bottom: 20px;
    line-height: 1.5;
    resize: none;
}

.input:focus,
.seed-input:focus {
    outline: none;
    border-color: var(--ton);
    box-shadow: 0 0 0 3px var(--ton-soft);
}

.input::placeholder,
.seed-input::placeholder {
    color: var(--ink-3);
}

/* ========================================
   Loading
   ======================================== */
#loadingScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
}

.loader {
    width: 44px;
    height: 44px;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    font-size: 15px;
    color: var(--ink-2);
}

/* ========================================
   Balance card — the faceted crystal
   ======================================== */
.wallet-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: 18px 16px 16px;
    color: #FFFFFF;
    border-radius: var(--r-xl);
    /* Brilliant-cut facets (top view), lit from the upper right like the logo's crystal.
       Generated: octagonal table, 8 star, 8 kite and 16 upper-girdle facets. */
    background:
        var(--facets) center / cover no-repeat,
        linear-gradient(145deg, #0870BA 0%, #0865B2 50%, #0A4796 100%);
    text-shadow: 0 1px 1px rgba(2, 28, 72, 0.22);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 18px 36px -18px rgba(6, 84, 168, 0.7);
}

/* A single light sweep when the wallet opens */
.wallet-card::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.26) 48%, rgba(255, 255, 255, 0.06) 54%, transparent 62%);
    transform: translateX(-110%);
    pointer-events: none;
}

.wallet-card.is-shining::after {
    animation: crystalSheen 1.5s 0.1s var(--ease-out) forwards;
}

@keyframes crystalSheen {
    to { transform: translateX(110%); }
}

/* Skeleton while the balance loads */
.wallet-card.is-loading #balanceTon,
.wallet-card.is-loading #balanceUsd,
.wallet-card.is-loading #balanceRub {
    color: transparent;
    text-shadow: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    animation: skeletonPulse 1.2s ease-in-out infinite;
}

.wallet-card.is-loading #balanceTon {
    min-width: 4.2em;
}

.wallet-card.is-loading #balanceUsd,
.wallet-card.is-loading #balanceRub {
    min-width: 6em;
}

@keyframes skeletonPulse {
    50% { opacity: 0.45; }
}

.wallet-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.wallet-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.wallet-name {
    overflow: hidden;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.edit-name-btn,
.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.16);
    border: none;
    border-radius: 50%;
    transition: background-color 0.15s ease;
}

.edit-name-btn:hover,
.copy-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Small icon buttons keep their size but get a finger-sized hit area (44px and up) from an
   invisible ring around them: copying the address is the core receive action */
.edit-name-btn,
.copy-btn,
.copy-btn-small,
.modal-close {
    position: relative;
}

.edit-name-btn::after,
.copy-btn::after,
.copy-btn-small::after,
.modal-close::after {
    content: '';
    position: absolute;
    inset: -8px;
}

.wallet-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(3, 30, 84, 0.42);
    border-radius: 999px;
}

.wallet-state:empty {
    display: none;
}

.wallet-state::before {
    content: '';
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
}

.wallet-state.active {
    color: #A6F4CB;
}

.wallet-state.inactive {
    color: #FFDC94;
}

.balance-section {
    margin-top: 26px;
}

.wallet-card,
.token-card,
.confirm-summary {
    container-type: inline-size;
}

.balance-ton {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    font-family: var(--font-display);
    font-size: clamp(26px, 10.5cqi, 40px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.balance-unit {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0.92;
}

.balance-fiat {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 8px;
    font-size: 15px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.balance-fiat .separator {
    display: none;
}

.wallet-address-container {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    margin-top: 18px;
    padding: 4px 4px 4px 12px;
    background: rgba(3, 30, 84, 0.24);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
}

.wallet-address {
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0.95;
}

.wallet-actions {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-wallet-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 12px;
    font-size: 15px;
    font-weight: 600;
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--r-md);
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn-wallet-action:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.26);
}

.btn-wallet-action:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-wallet-action:focus-visible,
.wallet-card button:focus-visible {
    outline-color: #FFFFFF;
}

.btn-wallet-action,
.wallet-address-container {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.btn-wallet-action:disabled {
    opacity: 0.45;
}

/* ========================================
   Dashboard column: tokens, then history
   ======================================== */
.dashboard-main {
    min-width: 0;
}

/* Hidden sections leave no gap */
.dashboard-home {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 24px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 2px 12px;
}

.section-title {
    margin: 0 2px 12px;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.section-head .section-title {
    margin: 0;
}

.section-meta {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

/* ========================================
   Transaction history
   ======================================== */
/* Lists size their rows by their own width (a narrow column on tablets and laptops) */
.transactions-list,
.tokens-list,
.asset-list {
    container-type: inline-size;
}

@container (max-width: 400px) {
    .tx-amount {
        max-width: 44cqi;
    }

    .tx-value {
        font-size: 14px;
    }
}


.tx-feed {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

.tx-group + .tx-group {
    border-top: 1px solid var(--line);
}

.tx-group-date {
    padding: 12px 12px 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
}

.transaction-item {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    width: 100%;
    padding: 12px;
    text-align: left;
    background: transparent;
    border: none;
    transition: background-color 0.15s ease;
}

/* Hairline between rows, inset past the icon */
.transaction-item + .transaction-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 64px;
    right: 0;
    height: 1px;
    background: var(--line);
}

.transaction-item:hover,
.transaction-item:active {
    background: var(--surface-2);
}

.transaction-item:focus-visible {
    outline-offset: -2px;
    border-radius: var(--r-lg);
}

.tx-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.tx-icon.incoming {
    color: var(--positive);
    background: var(--positive-soft);
}

.tx-icon.outgoing {
    color: var(--ink-2);
    background: var(--surface-2);
}

.tx-icon.swap {
    color: var(--link);
    background: var(--ton-soft);
}

.tx-icon.failed {
    color: var(--negative);
    background: var(--negative-soft);
}

/* Token image on the operation icon */
.tx-token-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 20px;
    height: 20px;
    object-fit: cover;
    background: var(--surface);
    border: 2px solid var(--surface);
    border-radius: 50%;
}

/* Folded spam, when shown: a grey icon and amount mark them, the text stays readable */
.transaction-item.is-spam .tx-icon {
    filter: grayscale(1);
    opacity: 0.6;
}

.transaction-item.is-spam .tx-value {
    color: var(--ink-2);
}

.tx-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tx-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
    font-size: 15px;
    font-weight: 600;
}

.tx-status {
    padding: 1px 8px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.5;
    border-radius: 999px;
}

.tx-status.is-failed {
    color: var(--danger-ink);
    background: var(--negative-soft);
}

.tx-status.is-pending {
    color: var(--warn-ink);
    background: var(--warn-soft);
}

.tx-status.is-spam {
    color: var(--ink-2);
    background: var(--surface-2);
}

/* Names, symbols and comments come from other people: right-to-left text in them
   must not reorder what surrounds it */
.tx-address,
.tx-comment,
.tx-value,
.tx-value-secondary {
    unicode-bidi: isolate;
}

/* "from Name · UQAb…cdEf": the short address stays whole (its first and last characters tell a
   look-alike apart). When both don't fit, the address moves to its own line instead of
   squeezing "from" to "f…" (320px rows with long amounts); a long name alone is cut. */
.tx-address {
    display: flex;
    flex-wrap: wrap;
    column-gap: 0.25em;
    min-width: 0;
    overflow: hidden;
    font-size: 13px;
    color: var(--ink-2);
    white-space: nowrap;
}

.tx-party-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    unicode-bidi: isolate;
}

.tx-party-address {
    flex-shrink: 0;
}

.tx-comment {
    align-self: flex-start;
    max-width: 100%;
    margin-top: 6px;
    padding: 5px 10px;
    overflow: hidden;
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
    background: var(--surface-2);
    border-radius: 4px 12px 12px 12px;
}

/* A label in place of a comment with a link from a stranger */
.tx-comment.is-masked {
    font-style: italic;
    color: var(--ink-2);
}

/* Long token symbols ("USD₮-GRAM LP") are cut at the end so the title keeps its room */
.tx-amount {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
    max-width: 12rem;
}

.tx-value {
    display: flex;
    column-gap: 0.25em;
    max-width: 100%;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Only the symbol is cut: the number stays whole */
.tx-value-number {
    flex-shrink: 0;
}

.tx-value-symbol {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-value.incoming {
    color: var(--positive);
}

.tx-value.outgoing {
    color: var(--ink);
}

.tx-value.failed {
    color: var(--ink-3);
    text-decoration: line-through;
}

.tx-value-secondary {
    display: flex;
    column-gap: 0.25em;
    max-width: 100%;
    overflow: hidden;
    font-size: 13px;
    color: var(--ink-2);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.tx-time {
    font-size: 13px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.empty-state {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 28px 20px;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--r-lg);
}

.empty-state-title {
    font-size: 15px;
    font-weight: 600;
}

.empty-state-hint {
    font-size: 14px;
    color: var(--ink-2);
}

.empty-state .history-more {
    align-self: center;
    margin-top: 10px;
}

/* "Load more", "Show spam" */
.history-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.history-more {
    min-height: 40px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--link);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: background-color 0.15s ease;
}

.history-more:hover:not(:disabled) {
    background: var(--surface-2);
}

.history-more:disabled {
    opacity: 0.6;
    cursor: default;
}

.history-note {
    width: 100%;
    margin-top: 12px;
    font-size: 13px;
    text-align: center;
    color: var(--ink-2);
}

.history-footer .history-note {
    margin-top: 0;
}

.tx-feed.is-skeleton .transaction-item {
    cursor: default;
}

.tx-feed.is-skeleton .transaction-item:hover {
    background: transparent;
}

.skeleton,
.skeleton-line {
    background: var(--surface-2);
    animation: skeletonPulse 1.2s ease-in-out infinite;
}

.skeleton-line {
    display: block;
    width: 55%;
    height: 12px;
    margin: 4px 0;
    border-radius: 6px;
}

.skeleton-line.is-wide {
    width: 80%;
}

.skeleton-line.is-short {
    width: 64px;
}

/* ========================================
   Send
   ======================================== */
.send-form {
    display: flex;
    flex-direction: column;
}

.send-form .form-group {
    margin-bottom: 10px;
}

.send-from {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.send-from:focus-within {
    border-color: var(--ton);
    box-shadow: 0 0 0 3px var(--ton-soft);
}

.send-from.is-single {
    cursor: default;
}

.send-from.is-single .send-from-chevron {
    display: none;
}

.send-from-label {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--ink-2);
}

.send-from-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.send-from-name {
    overflow: hidden;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.send-from-balance {
    flex-shrink: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

/* Text field with an inline action */
.input-wrap {
    position: relative;
}

.input-wrap.has-action .input {
    padding-right: 116px;
}

.input-mono {
    font-family: var(--font-mono);
}

.input-action {
    position: absolute;
    top: 50%;
    right: 8px;
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--link);
    background: var(--ton-soft);
    border: none;
    border-radius: var(--r-sm);
    transform: translateY(-50%);
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Taller hit area than the 34px pill, without overlapping the button beside it */
.input-action::after {
    content: '';
    position: absolute;
    inset: -5px 0;
}

/* Hover only where a pointer hovers: a phone keeps :hover on the last tapped element, and
   "Max" would stay filled like a switched-on mode. A tap gets a short press state instead. */
@media (hover: hover) {
    .input-action:hover {
        color: #FFFFFF;
        background: var(--ton);
    }
}

.input-action:active {
    color: #FFFFFF;
    background: var(--ton);
}

/* A valid address gets a check mark where the paste button was */
.input-wrap.is-valid .input {
    padding-right: 46px;
}

.input-wrap.is-valid::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 14px;
    width: 20px;
    height: 20px;
    background: var(--positive);
    transform: translateY(-50%);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
    pointer-events: none;
}

.input-wrap.is-invalid .input,
.input.is-invalid {
    border-color: var(--negative);
}

.input-wrap.is-invalid .input:focus,
.input.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--negative-soft);
}

.amount-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.amount-field:focus-within {
    border-color: var(--ton);
    box-shadow: 0 0 0 3px var(--ton-soft);
}

.amount-field.is-invalid {
    border-color: var(--negative);
}

.amount-field.is-invalid:focus-within {
    box-shadow: 0 0 0 3px var(--negative-soft);
}

.amount-input,
.amount-measure {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.amount-input {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0;
    font-size: 28px;
    color: var(--ink);
    background: transparent;
    border: none;
    outline: none;
}

/* The invisible copy of the amount that fitAmountFont measures; the zero-size box keeps a
   long copy from widening the page */
.amount-measure {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    white-space: pre;
}

.amount-input::placeholder {
    color: var(--ink-3);
}

.amount-field .input-action {
    position: relative; /* holds the hit area */
    top: auto;
    right: auto;
    transform: none;
}

/* On phones the amount gets the whole first row; the asset and "Max" sit under it */
.amount-group {
    container: amount / inline-size;
}

@container amount (max-width: 480px) {
    .amount-field {
        flex-wrap: wrap;
        row-gap: 2px;
        padding: 6px 8px 8px 16px;
    }

    .amount-input {
        flex-basis: 100%;
        height: 52px;
        font-size: 32px;
    }

    .amount-field .asset-chip {
        margin-right: auto;
        margin-left: -8px;
    }
}

/* Hints keep their height so the form doesn't jump while typing */
.field-hint {
    min-height: 19px;
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink-2);
    white-space: pre-wrap;
    font-variant-numeric: tabular-nums;
}

.field-hint.is-error {
    color: var(--negative);
}

.field-hint.is-warning {
    color: var(--warn-ink);
}

/* Recent recipients */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    padding: 7px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) {
    .chip:hover {
        background: var(--surface-2);
        border-color: var(--ink-3);
    }
}

/* What is being sent: a chip inside the amount field that opens the asset picker */
.asset-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    max-width: 45%;
    height: 38px;
    padding: 0 8px 0 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: border-color 0.15s ease;
}

.asset-chip:hover:not(:disabled) {
    border-color: var(--ink-3);
}

.asset-chip.is-static {
    padding-right: 12px;
    cursor: default;
}

.asset-chip.is-static .asset-chip-chevron {
    display: none;
}

.asset-chip-icon {
    display: flex;
    flex-shrink: 0;
}

.asset-chip-icon .token-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
}

.asset-chip-symbol {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    unicode-bidi: isolate;
}

.asset-chip-chevron {
    flex-shrink: 0;
    color: var(--ink-2);
}

#sendFeeNotice {
    margin: 10px 0 4px;
}

#sendConfirmBtn {
    margin-top: 10px;
}

/* Confirmation sheet */
.confirm-summary {
    margin: 4px 0 18px;
    text-align: center;
}

.confirm-amount {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    column-gap: 8px;
    font-family: var(--font-display);
    font-size: clamp(22px, 9cqi, 32px);
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.confirm-amount.is-long {
    font-size: clamp(18px, 7cqi, 26px);
}

.confirm-amount.is-very-long {
    font-size: clamp(15px, 5.6cqi, 20px);
}

.confirm-unit {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ink-2);
    unicode-bidi: isolate;
}

.confirm-fiat {
    margin-top: 6px;
    font-size: 15px;
    color: var(--ink-2);
    white-space: pre-wrap;
}

.confirm-note {
    margin: 14px 2px 18px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink-2);
}

.confirm-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.confirm-icon .token-icon {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

/* The address in groups of four, first and last groups emphasized */
.confirm-address {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.65;
    word-spacing: 0.12em;
    color: var(--ink-2);
}

.confirm-address strong {
    font-weight: 700;
    color: var(--ink);
}

.confirm-check {
    display: block;
    margin-top: 4px;
    font-family: var(--font-body);
    font-size: 12.5px;
    word-spacing: normal;
    color: var(--ink-2);
}

.confirm-check.is-new {
    font-weight: 600;
    color: var(--warn-ink);
}

#confirmSendModal .tx-detail-rows {
    background: var(--bg);
}

/* Asset picker */
.asset-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.asset-list .token-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    border-radius: var(--r-md);
}

.asset-list .token-row + .token-row::before {
    display: none;
}

.asset-list .token-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.asset-list .token-row.is-selected {
    background: var(--ton-soft);
    box-shadow: inset 0 0 0 1px var(--ton);
}


/* ========================================
   Transaction result
   ======================================== */
#txResultScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 24px 4px;
    text-align: center;
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    margin-bottom: 20px;
    border-radius: 50%;
}

.result-icon svg {
    width: 40px;
    height: 40px;
}

.result-icon.success {
    color: var(--positive);
    background: var(--positive-soft);
}

.result-icon.error {
    color: var(--negative);
    background: var(--negative-soft);
}

.result-title {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}

.result-message {
    max-width: 340px;
    margin-bottom: 16px;
    font-size: 15px;
    color: var(--ink-2);
}

.result-message:empty {
    display: none;
}

.result-icon.unknown {
    color: var(--warn-ink);
    background: var(--warn-soft);
}

.result-summary {
    margin-bottom: 20px;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    unicode-bidi: isolate;
    overflow-wrap: anywhere;
}

.result-summary:empty {
    display: none;
}

/* Technical reason of a failure, for support */
.result-detail {
    width: 100%;
    max-width: 360px;
    margin-bottom: 20px;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    text-align: left;
    color: var(--ink-2);
    background: var(--surface-2);
    border-radius: var(--r-sm);
    overflow-wrap: anywhere;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 360px;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 16px;
    padding: 12px 16px;
    font-size: 12px;
    text-align: center;
    color: var(--ink-2);
    border-top: 1px solid var(--line);
}

.lang-switch {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.lang-option {
    position: relative; /* holds the hit area */
    min-width: 40px;
    min-height: 28px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--ink-2);
    background: transparent;
    border: none;
    border-radius: 999px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.lang-option:hover {
    color: var(--ink);
}

/* 44px tall to the finger; sideways the two options only meet */
.lang-option::after {
    content: '';
    position: absolute;
    inset: -8px 0;
}

.lang-option[aria-pressed="true"] {
    color: var(--ink);
    background: var(--surface-raised);
    box-shadow: 0 1px 2px rgba(14, 34, 51, 0.14);
}

.footer a {
    color: var(--link);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ========================================
   Menu
   ======================================== */
/* Fixed, not absolute: below 1200px the window scrolls while the sticky header keeps the menu
   button on screen, so a menu placed in the document would open above the viewport.
   A short (landscape) viewport scrolls the menu itself. */
.dropdown-menu {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    right: var(--gutter);
    z-index: 200;
    max-height: calc(100vh - var(--header-height) - 16px);
    max-height: calc(100dvh - var(--header-height) - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    min-width: 252px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-float);
    animation: menuIn 0.16s var(--ease-out);
    transform-origin: top right;
}

@keyframes menuIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    color: var(--ink);
    background: transparent;
    border: none;
    border-radius: 12px;
    transition: background-color 0.15s ease;
}

.dropdown-item svg {
    flex-shrink: 0;
    color: var(--ink-2);
}

.dropdown-item:hover,
.dropdown-item:active {
    background: var(--surface-2);
}

.dropdown-item.danger,
.dropdown-item.danger svg {
    color: var(--negative);
}

.dropdown-divider {
    height: 1px;
    margin: 6px 8px;
    background: var(--line);
}

/* ========================================
   Overlay, modals and bottom sheets
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: var(--overlay);
    animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: none; /* taps outside the content reach the overlay */
}

.modal-content {
    width: 100%;
    max-width: 380px;
    /* dvh: the visible height. Phone vh counts the hidden browser bars too, and a sheet that
       tall would push its title and close button above the screen. vh stays as a fallback. */
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow-float);
    animation: popIn 0.2s var(--ease-out);
    pointer-events: auto;
}

.modal-small {
    max-width: 340px;
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

/* On phones, receive and transaction details slide up from the bottom */
@media (max-width: 480px) {
    .modal-sheet {
        align-items: flex-end;
        padding: 0;
    }

    .modal-sheet .modal-content {
        max-width: none;
        max-height: 88vh;
        max-height: 88dvh;
        padding-bottom: env(safe-area-inset-bottom);
        border-radius: 24px 24px 0 0;
        animation: sheetUp 0.28s var(--ease-out);
    }
}

@keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 8px;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    color: var(--ink-2);
    background: var(--surface-2);
    border: none;
    border-radius: 50%;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-close:hover {
    color: var(--ink);
    background: var(--line);
}

.modal-body {
    padding: 12px 20px 20px;
}

.modal-body .input {
    margin-bottom: 16px;
}

/* Receive */
.receive-qr {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 208px;
    height: 208px;
    margin: 4px auto 16px;
    padding: 16px;
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}

.receive-qr img,
.receive-qr canvas {
    max-width: 100%;
    max-height: 100%;
}

.receive-hint {
    margin-bottom: 14px;
    font-size: 14px;
    text-align: center;
    color: var(--ink-2);
}

.receive-address-box {
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: var(--r-md);
    word-break: break-all;
}

.receive-address {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.55;
}

/* Transaction details */
.tx-detail-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.tx-detail-type {
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
}

.tx-detail-type.incoming {
    color: var(--positive-ink);
    background: var(--positive-soft);
}

.tx-detail-type.outgoing {
    color: var(--ink-2);
    background: var(--surface-2);
}

.tx-detail-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.tx-detail-value.incoming {
    color: var(--positive);
}

.tx-detail-value.outgoing {
    color: var(--ink);
}

.tx-detail-type.swap {
    color: var(--link);
    background: var(--ton-soft);
}

.tx-detail-value.swap {
    color: var(--positive);
}

.tx-detail-value,
.tx-detail-second {
    max-width: 100%;
    overflow-wrap: anywhere;
    unicode-bidi: isolate;
}

.tx-detail-second {
    margin-top: -4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.tx-detail-rows {
    display: flex;
    flex-direction: column;
    padding: 4px 14px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}

.tx-detail-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 0;
}

.tx-detail-row + .tx-detail-row {
    border-top: 1px solid var(--line);
}

.tx-detail-label {
    font-size: 13px;
    color: var(--ink-2);
}

.tx-detail-text {
    font-size: 15px;
    overflow-wrap: anywhere;
    unicode-bidi: isolate;
}

.tx-detail-text.is-warning {
    color: var(--warn-ink);
}

.tx-detail-text.is-negative {
    color: var(--negative);
}

.tx-detail-value-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tx-detail-address,
.tx-detail-hash {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.5;
    word-break: break-all;
}

.copy-btn-small {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    color: var(--ink-2);
    background: var(--surface-2);
    border: none;
    border-radius: var(--r-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.copy-btn-small:hover {
    color: var(--ink);
    background: var(--line);
}

.tx-viewer-link {
    margin-top: 16px;
}

#txDetailWarning,
#confirmWarning {
    margin-bottom: 14px;
}

/* Several warnings, one per line */
#confirmWarning {
    white-space: pre-line;
}

.receive-share {
    margin-top: 10px;
}

.nowrap {
    white-space: nowrap;
}

/* ========================================
   Tokens (list rows are shared with the asset picker)
   ======================================== */
.token-row {
    position: relative;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    text-align: left;
    background: transparent;
    border: none;
    transition: background-color 0.15s ease;
}

.token-row + .token-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 64px;
    right: 0;
    height: 1px;
    background: var(--line);
}

.token-row:hover {
    background: var(--surface-2);
}

.token-row:focus-visible {
    outline-offset: -2px;
    border-radius: var(--r-lg);
}

.token-row.is-skeleton {
    cursor: default;
}

.token-row.is-skeleton:hover {
    background: transparent;
}

.token-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface-2);
    border-radius: 50%;
}

.token-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* No image or a broken one: the first letter on a neutral disc, never a brand look */
.token-icon.is-letter {
    border: 1px solid var(--line);
}

.token-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.token-symbol,
.token-sub {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    unicode-bidi: isolate;
}

.token-symbol {
    font-size: 15px;
    font-weight: 600;
}

.token-sub {
    font-size: 13px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.token-sub.is-warning {
    color: var(--warn-ink);
}

.token-change {
    margin-left: 4px;
    font-weight: 600;
}

.token-change.is-up {
    color: var(--positive);
}

.token-change.is-down {
    color: var(--negative);
}

.token-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
    text-align: right;
}

.token-amount {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.token-fiat {
    font-size: 13px;
    color: var(--ink-2);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.token-chevron {
    font-size: 24px;
    line-height: 1;
    color: var(--ink-3);
}

.token-more {
    display: block;
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: var(--link);
    background: transparent;
    border: none;
    border-top: 1px solid var(--line);
    transition: background-color 0.15s ease;
}

.token-more:hover {
    background: var(--surface-2);
}

/* Inside, like the rows: the list's overflow:hidden would clip an outer ring */
.token-more:focus-visible {
    outline-offset: -2px;
    border-radius: var(--r-lg);
}

.token-hidden-row {
    border-top: 1px solid var(--line);
}

.token-hidden-row::before {
    display: none;
}

/* ========================================
   Token screen and hidden tokens (inside the dashboard)
   ======================================== */
.token-view {
    min-width: 0;
}

/* The token's card: the wallet card's crystal in the token's own tone */
.token-card {
    --card-tone: linear-gradient(145deg, #0870BA 0%, #0865B2 50%, #0A4796 100%);
    --card-glow: rgba(6, 84, 168, 0.7);
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: 16px;
    color: #FFFFFF;
    border-radius: var(--r-xl);
    background:
        var(--facets) center / cover no-repeat,
        var(--card-tone);
    text-shadow: 0 1px 1px rgba(2, 20, 40, 0.24);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 18px 36px -18px var(--card-glow);
}

.token-card.tone-usdt {
    --card-tone: linear-gradient(145deg, #0E7A61 0%, #0B6B57 50%, #085A4F 100%);
    --card-glow: rgba(8, 104, 86, 0.7);
}

.token-card.tone-1 {
    --card-tone: linear-gradient(145deg, #6A4FD6 0%, #5237B3 50%, #3A2385 100%);
    --card-glow: rgba(70, 44, 160, 0.7);
}

.token-card.tone-2 {
    --card-tone: linear-gradient(145deg, #A0560F 0%, #874A0E 50%, #6B3A0A 100%);
    --card-glow: rgba(130, 70, 14, 0.65);
}

.token-card.tone-3 {
    --card-tone: linear-gradient(145deg, #C23A6B 0%, #9C2754 50%, #711A3D 100%);
    --card-glow: rgba(150, 34, 80, 0.65);
}

.token-card.tone-4 {
    --card-tone: linear-gradient(145deg, #3F57C2 0%, #2E43A0 50%, #1F2F78 100%);
    --card-glow: rgba(40, 60, 160, 0.7);
}

.token-card.tone-5 {
    --card-tone: linear-gradient(145deg, #257A3C 0%, #1F6C35 50%, #17552A 100%);
    --card-glow: rgba(30, 110, 55, 0.65);
}

/* Unverified and suspicious: no colour, so a fake never looks like the real token */
.token-card.is-plain {
    --card-tone: linear-gradient(145deg, #5C6B79 0%, #475562 50%, #333F4A 100%);
    --card-glow: rgba(40, 52, 64, 0.55);
}

.token-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* The size of Back on every other screen (40px) */
.token-card .back-btn {
    margin-right: 2px;
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.22);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.token-card .back-btn:hover {
    background: rgba(255, 255, 255, 0.28);
}

.token-card .token-icon {
    width: 44px;
    height: 44px;
    font-size: 17px;
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.16);
    border: 2px solid rgba(255, 255, 255, 0.34);
    text-shadow: none;
}

.token-card-names {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.token-card-name {
    overflow: hidden;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    text-overflow: ellipsis;
    unicode-bidi: isolate;
}

.token-card-symbol {
    overflow: hidden;
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0.92;
    unicode-bidi: isolate;
}

.token-card-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #FFDC94;
    background: rgba(3, 20, 40, 0.3);
    border-radius: 999px;
}

.token-card-balance {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    margin-top: 22px;
    font-family: var(--font-display);
    font-size: clamp(24px, 9.5cqi, 36px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.token-card-balance .balance-unit {
    unicode-bidi: isolate;
}

.balance-ton.is-long {
    font-size: clamp(22px, 8.2cqi, 32px);
}

.balance-ton.is-very-long {
    font-size: clamp(18px, 6.6cqi, 26px);
}

.token-card-balance.is-long {
    font-size: clamp(20px, 7.6cqi, 30px);
}

.token-card-balance.is-very-long {
    font-size: clamp(17px, 6.2cqi, 24px);
}

/* A number is never split across lines; only the unit may wrap */
.balance-ton > span:first-child,
.token-card-balance > span:first-child,
.confirm-amount > span:first-child {
    white-space: nowrap;
}

.token-card-fiat {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 8px;
    font-size: 15px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.token-card-price {
    margin-top: 6px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    opacity: 0.92;
}

.token-card .wallet-actions {
    margin-top: 18px;
}

.token-card button:focus-visible {
    outline-color: #FFFFFF;
}

.token-summary > .notice {
    margin: 12px 0 0;
}

.token-view .field-hint {
    min-height: 0;
    margin-top: 12px;
}

.token-view .section-title {
    margin-top: 28px;
}

.token-view .tx-detail-rows {
    background: var(--surface);
}

.token-visibility {
    margin-top: 14px;
    font-size: 14px;
}

.text-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--link);
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

/* A button that reads as a link */
.link-button {
    padding: 0;
    font-weight: 600;
    color: var(--link);
    background: none;
    border: none;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

/* Callouts: warnings about tokens, fees and recipients */
.notice {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin-bottom: 14px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--surface-2);
    border-radius: var(--r-md);
}

.notice.is-warning {
    color: var(--warn-ink);
    background: var(--warn-soft);
}

.notice.is-danger {
    color: var(--danger-ink);
    background: var(--negative-soft);
}

.notice .link-button {
    color: inherit;
}

/* ========================================
   Toast
   ======================================== */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 300;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: var(--bg);
    background: var(--ink);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-float);
    opacity: 0;
    transform: translate(-50%, 16px);
    transition: opacity 0.2s ease, transform 0.2s var(--ease-out);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ========================================
   Staking (Tonstakers): the card shows the yield, the panel the form
   ======================================== */
.token-card.staking-card {
    --card-tone: linear-gradient(145deg, #0B7C8F 0%, #086C83 50%, #0A4F73 100%);
    --card-glow: rgba(8, 96, 128, 0.7);
}

.staking-apy {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 10px;
    margin-top: 22px;
}

.staking-apy-value {
    font-family: var(--font-display);
    font-size: clamp(30px, 12cqi, 44px);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Full white: it sits on the card's lit facets, where 92% white measured 4.42:1 (white 4.9:1) */
.staking-apy-label {
    font-size: 15px;
    font-weight: 500;
}

.staking-position {
    display: grid;
    gap: 2px;
    margin-top: 18px;
    padding: 12px 14px;
    background: rgba(3, 30, 60, 0.26);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--r-md);
}

.staking-position-label {
    font-size: 13px;
    opacity: 0.92;
}

.staking-position-value {
    font-size: 17px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.staking-position-sub {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: pre-wrap;
    opacity: 0.92;
}

.staking-position-sub:empty {
    display: none;
}

.staking-pending {
    margin: 10px 0 0;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: #FFE3A8;
    background: rgba(3, 20, 40, 0.3);
    border-radius: var(--r-sm);
}

.staking-explain {
    margin: 12px 2px 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink-2);
}

.staking-panel {
    min-width: 0;
    margin-top: 20px;
}

/* Two tabs in one track: the current one is lifted */
.segmented {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    background: var(--surface-2);
    border-radius: var(--r-md);
}

.segmented-item {
    min-height: 40px;
    padding: 0 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-2);
    background: transparent;
    border: none;
    border-radius: 10px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.segmented-item:hover {
    color: var(--ink);
}

.segmented-item[aria-selected="true"] {
    color: var(--ink);
    background: var(--surface-raised);
    box-shadow: 0 1px 2px rgba(14, 34, 51, 0.12), 0 0 0 1px var(--line);
}

/* Dark theme: the --line ring and the shadow vanish on the dark track; a light hairline
   outlines the selected option instead */
@media (prefers-color-scheme: dark) {
    .segmented-item[aria-selected="true"],
    .lang-option[aria-pressed="true"] {
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    }
}

/* Like .amount-field.is-invalid of the send form: a red border, and a red halo while focused */
.staking-form .amount-field:has(.amount-input[aria-invalid="true"]) {
    border-color: var(--negative);
}

.staking-form .amount-field:has(.amount-input[aria-invalid="true"]):focus-within {
    box-shadow: 0 0 0 3px var(--negative-soft);
}

/* When the GRAM comes back: two choices as cards */
.staking-modes {
    min-width: 0;
    margin: 4px 0 14px;
    padding: 0;
    border: none;
}

.staking-modes legend {
    padding: 0;
}

.staking-mode {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.staking-mode + .staking-mode {
    margin-top: 8px;
}

.staking-mode:hover {
    border-color: var(--ink-3);
}

.staking-mode:has(input:checked) {
    border-color: var(--ton);
    box-shadow: inset 0 0 0 1px var(--ton);
}

.staking-mode input {
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--ton);
}

.staking-mode-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.staking-mode-title {
    font-size: 15px;
    font-weight: 600;
}

.staking-mode-hint {
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink-2);
}

.staking-details {
    margin-bottom: 14px;
    background: var(--surface);
}

.staking-details:empty {
    display: none;
}

.staking-risk {
    margin: 0 2px 16px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-2);
}

/* Padding, not margin: the text stays where it was, the tap area grows to about 44px */
.staking-provider-link {
    align-self: center;
    margin-top: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--link);
    text-decoration: none;
}

.staking-provider-link:hover {
    text-decoration: underline;
}

/* Three actions in a narrow card: the icon goes above the label */
@container (max-width: 460px) {
    .wallet-actions:has(> :nth-child(3)) > .btn-wallet-action {
        flex-direction: column;
        gap: 4px;
        min-height: 62px;
        padding: 8px 4px;
        font-size: 13px;
        line-height: 1.2;
    }
}

/* ========================================
   Wallet sidebar (wide screens)
   ======================================== */
.wallet-nav,
.receive-panel {
    display: none;
}

.wallet-nav-title {
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}

.wallet-nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wallet-nav-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wallet-nav-item:hover {
    background: var(--surface-2);
}

.wallet-nav-item[aria-current] {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: inset 3px 0 0 var(--ton);
}

.wallet-nav-name {
    max-width: 100%;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.wallet-nav-address {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-2);
}

.wallet-nav-actions {
    display: grid;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
}

.wallet-nav-actions .btn {
    justify-content: flex-start;
    min-height: 44px;
    padding: 0 14px;
    font-size: 14px;
}

@media (min-width: 720px) {
    :root {
        --gutter: 24px;
    }

    .main-content {
        padding-top: 20px;
    }

    #dashboardScreen {
        display: grid;
        grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
        align-items: start;
        gap: 24px;
    }

    .dashboard-side {
        display: flex;
        flex-direction: column;
        gap: 16px;
        min-width: 0;
        container-type: inline-size;
    }


    .dashboard-home {
        margin-top: 0;
    }

    .section-head,
    .dashboard-home > .transactions-section > .section-title {
        margin-top: 4px;
    }

    /* Forms and onboarding: one readable column */
    .screen:not(#dashboardScreen) {
        max-width: 560px;
        margin-inline: auto;
    }

    /* Receive panel: scan the address from a phone without opening a dialog */
    .receive-panel {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 16px;
        padding: 16px;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--r-lg);
    }

    .receive-panel-qr {
        width: 136px;
        height: 136px;
        padding: 8px;
        background: #FFFFFF;
        border: 1px solid var(--line);
        border-radius: 12px;
    }

    .receive-panel-qr img,
    .receive-panel-qr canvas {
        display: block;
        width: 100%;
        height: 100%;
    }

    .receive-panel-title {
        font-size: 15px;
        font-weight: 600;
    }

    .receive-panel-address {
        margin: 6px 0 12px;
        font-family: var(--font-mono);
        font-size: 12.5px;
        line-height: 1.5;
        color: var(--ink-2);
        word-break: break-all;
    }

    .receive-panel .btn {
        min-height: 40px;
        padding: 0 14px;
        font-size: 14px;
    }

    /* A narrow side column (tablets): a smaller QR leaves room for the address and the button */
    @container (max-width: 360px) {
        .receive-panel {
            gap: 12px;
            padding: 12px;
        }

        .receive-panel-qr {
            width: 104px;
            height: 104px;
            padding: 6px;
        }
    }

    /* Narrower still: the QR above the address */
    @container (max-width: 300px) {
        .receive-panel {
            grid-template-columns: minmax(0, 1fr);
            justify-items: center;
            text-align: center;
        }
    }
}

@media (min-width: 960px) {
    .header {
        height: 64px;
        padding: 0 24px;
    }

    .header-brand {
        display: flex;
        margin-right: auto;
    }

    .update-label {
        flex: none;
        order: 1;
    }

    #refreshBtn {
        order: 2;
    }

    #menuBtn {
        order: 3;
    }

    .dropdown-menu {
        top: 72px;
        right: 24px;
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
    }

    .main-content {
        padding: 28px 32px 40px;
    }

    /* Dashboard: the card stays in view while the history scrolls */
    #dashboardScreen {
        grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
        gap: 28px;
    }

    /* Below the sticky 64px header and the column's 28px top padding, where it starts */
    .dashboard-side {
        position: sticky;
        top: 92px;
    }
}

/* The wallet sidebar from 1200px: below that it would squeeze the dashboard */
@media (min-width: 1200px) {
    #app.has-wallet-chrome {
        display: grid;
        grid-template-columns: 280px minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "header header"
            "nav main"
            "footer footer";
        height: 100vh;
    }

    #app.has-wallet-chrome .header {
        grid-area: header;
    }

    #app.has-wallet-chrome .main-content {
        grid-area: main;
        overflow-y: auto;
    }

    /* Sticky inside the scrolling column, at its top */
    #app.has-wallet-chrome .dashboard-side,
    #app.has-wallet-chrome .staking-summary {
        top: 0;
    }

    #app.has-wallet-chrome .footer {
        grid-area: footer;
    }

    /* The sidebar replaces the compact switcher */
    .wallet-selector {
        display: none !important;
    }

    .wallet-nav {
        grid-area: nav;
        display: flex;
        flex-direction: column;
        gap: 12px;
        min-height: 0;
        padding: 20px 16px;
        overflow-y: auto;
        border-right: 1px solid var(--line);
    }
}

/* Wide monitors: tokens and history side by side */
@media (min-width: 1600px) {
    .main-content {
        padding-inline: 40px;
    }

    #dashboardScreen {
        grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
        gap: 32px;
    }

    .dashboard-home {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
        align-items: start;
        gap: 32px;
    }

    /* A wallet without tokens: the history takes the whole column */
    .dashboard-home:has(> .tokens-section.hidden) {
        grid-template-columns: minmax(0, 1fr);
    }

    .token-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
        align-items: start;
        gap: 32px;
    }

    .token-history > .section-title {
        margin-top: 4px;
    }
}

/* Phones: an open token screen or hidden list takes the whole screen */
@media (max-width: 719px) {
    #dashboardScreen.is-subview .dashboard-side {
        display: none;
    }
}

/* Staking on wide screens: the card stays beside the form */
@media (min-width: 960px) {
    #stakingScreen.screen {
        max-width: 940px;
    }

    .staking-layout {
        display: grid;
        grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
        align-items: start;
        gap: 28px;
    }

    .staking-summary {
        position: sticky;
        top: 92px; /* like .dashboard-side */
    }

    .staking-panel {
        margin-top: 0;
    }
}

/* ========================================
   Small phones
   ======================================== */
@media (max-width: 360px) {
    :root {
        --gutter: 8px;
    }

    /* The operation title keeps room next to a long amount */
    .tx-amount {
        max-width: 44vw;
    }

    .tx-value {
        font-size: 14px;
    }

    .amount-input {
        font-size: 28px;
    }

    .token-row {
        gap: 10px;
        padding-inline: 12px;
    }

    /* Two actions side by side (token cards). Three actions stack the icon over the label in
       their container rule, which wins; this is their fallback in browsers without :has() */
    .btn-wallet-action {
        gap: 6px;
        padding: 0 8px;
        font-size: 14px;
    }
}

/* iOS safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* Scrollbar */
.main-content::-webkit-scrollbar {
    width: 4px;
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 2px;
}

/* ========================================
   Reduced motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .wallet-card::after {
        display: none;
    }

    .loader {
        animation-duration: 1.6s !important;
        animation-iteration-count: infinite !important;
    }
}

/* Print */
@media print {
    .header,
    .footer,
    .dropdown-menu,
    .modal-overlay,
    .toast,
    .btn {
        display: none !important;
    }
}
