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

:root {
    --bg: var(--tg-theme-bg-color, #0f0f1a);
    --surface: var(--tg-theme-secondary-bg-color, #1a1a2e);
    --text: var(--tg-theme-text-color, #e8e8f0);
    --text-secondary: #9a9ab0;
    --hint: var(--tg-theme-hint-color, #7a7a9a);
    --link: var(--tg-theme-link-color, #6c5ce7);
    --btn: var(--tg-theme-button-color, #6c5ce7);
    --btn-hover: #7c6df7;
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --card-bg: rgba(26, 26, 46, 0.8);
    --border: rgba(108, 92, 231, 0.15);
    --success: #00d897;
    --success-bg: rgba(0, 216, 151, 0.1);
    --error: #ff6b6b;
    --error-bg: rgba(255, 107, 107, 0.1);
    --warning: #ffd93d;
    --gradient-1: #6c5ce7;
    --gradient-2: #a29bfe;
    --gradient-3: #00d897;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
    position: relative;
    min-height: 100vh;
}

/* ── Pages ─────────────────────────────────────── */

.page {
    display: none;
}

.page.active {
    display: block;
}

/* ── Section tabs (below header) ──────────────── */

.section-tabs {
    display: flex;
    gap: 6px;
    padding: 0 4px;
    margin: -8px 0 16px;
}

.stab {
    flex: 1;
    height: 38px;
    border: none;
    border-radius: 19px;
    background: rgba(108,92,231,0.08);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.stab.active {
    background: linear-gradient(135deg, var(--gradient-1), #4834d4);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(108,92,231,0.3);
}

.stab:not(.active):hover {
    color: var(--text);
    background: rgba(108,92,231,0.15);
}

/* ── Header ───────────────────────────────────── */

#header {
    position: relative;
    margin: 0 -16px 20px;
    padding: 24px 20px 20px;
    overflow: hidden;
}

.header-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--gradient-1) 0%, #4834d4 50%, var(--gradient-3) 100%);
    opacity: 0.9;
}

.header-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(162,155,254,0.2) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(0,216,151,0.15) 0%, transparent 50%);
}

.header-content {
    position: relative;
    z-index: 1;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.avatar-wrapper {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,0.15);
}

.avatar.hidden {
    display: none;
}

.avatar-wrapper:has(.avatar.hidden) {
    width: 56px;
    height: 56px;
}

.avatar-wrapper:has(.avatar.hidden)::after {
    content: '👤';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    z-index: 1;
}

.avatar-ring {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    z-index: 2;
}

#user-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

#user-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#free-badge {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    font-weight: 500;
}

.header-actions {
    display: flex;
    flex-direction: row;
    gap: 6px;
    flex-shrink: 0;
}

.header-btn {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.header-btn:hover {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.35);
    transform: scale(1.05);
}

.header-btn:active {
    transform: scale(0.95);
}

/* ── Stats Row ────────────────────────────────── */

#stats-row {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.1);
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-icon {
    font-size: 18px;
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.stat-divider {
    width: 1px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    margin: 0 8px;
}

/* ── Cards ────────────────────────────────────── */

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    animation: cardIn 0.4s ease-out both;
}

.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.form-card .card-icon {
    background: linear-gradient(135deg, rgba(108,92,231,0.2), rgba(0,216,151,0.2));
}

.history-card .card-icon {
    background: linear-gradient(135deg, rgba(162,155,254,0.2), rgba(108,92,231,0.2));
}

.rules-card .card-icon {
    background: rgba(255,217,61,0.15);
}

.card-title-group {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.4;
}

/* ── Quota Card ───────────────────────────────── */

.quota-card {
    background: linear-gradient(135deg, rgba(108,92,231,0.12), rgba(0,216,151,0.08));
    border-color: rgba(108,92,231,0.2);
}

.quota-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.quota-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.quota-count {
    font-size: 14px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-2), var(--gradient-3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(108,92,231,0.15);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--gradient-2), var(--gradient-3));
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.quota-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.quota-footer strong {
    color: var(--text);
}

/* ── Form ─────────────────────────────────────── */

.field {
    margin-bottom: 18px;
    position: relative;
}

.field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.label-icon {
    font-size: 15px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    height: 50px;
    padding: 0 44px 0 16px;
    font-size: 15px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    letter-spacing: 0.5px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    outline: none;
    transition: all 0.25s ease;
}

.input-wrapper input:focus {
    border-color: var(--link);
    background: rgba(108,92,231,0.06);
    box-shadow: 0 0 0 4px rgba(108,92,231,0.1);
}

.input-wrapper input::placeholder {
    color: var(--hint);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0;
}

.input-wrapper input.valid {
    border-color: var(--success);
    background: rgba(0,216,151,0.05);
}

.input-wrapper input.invalid {
    border-color: var(--error);
    background: rgba(255,107,107,0.05);
}

.input-status {
    position: absolute;
    right: 14px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.input-status.show {
    opacity: 1;
}

.input-status.valid {
    color: var(--success);
}

.input-status.invalid {
    color: var(--error);
}

.field-hint {
    font-size: 12px;
    color: var(--hint);
    margin-top: 6px;
    padding-left: 2px;
}

/* ── Field Note (info banner) ─────────────────── */

.field-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: var(--radius-sm);
    background: rgba(108,92,231,0.08);
    border: 1px solid rgba(108,92,231,0.15);
}

.note-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.note-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* ── Field Warning ────────────────────────────── */

.field-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin: -6px 0 18px;
    border-radius: var(--radius-sm);
    background: rgba(255,107,107,0.06);
    border: 1px solid rgba(255,107,107,0.12);
}

.warning-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.warning-text {
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.warning-text strong {
    color: var(--error);
    font-weight: 700;
}

/* ── Address Dropdown ─────────────────────────── */

.input-with-dropdown input {
    padding-right: 52px !important;
    cursor: pointer;
}

.dropdown-toggle {
    position: absolute;
    right: 36px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--hint);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 2;
}

.dropdown-toggle:hover {
    color: var(--text);
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.25s ease;
}

.dropdown-arrow.open {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    overflow: hidden;
    animation: dropdownIn 0.2s ease-out;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-header {
    padding: 10px 14px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.dropdown-list {
    max-height: 200px;
    overflow-y: auto;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    gap: 8px;
}

.dropdown-item:hover {
    background: rgba(108,92,231,0.08);
}

.dropdown-item:active {
    background: rgba(108,92,231,0.15);
}

.dropdown-item-addr {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.dropdown-item-label {
    font-size: 11px;
    color: var(--hint);
    background: rgba(108,92,231,0.1);
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.dropdown-footer {
    border-top: 1px solid var(--border);
    padding: 10px 14px;
}

.dropdown-empty {
    font-size: 13px;
    color: var(--hint);
    display: block;
    text-align: center;
}

/* ── Light mode overrides ─────────────────────── */

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f0f0f8;
        --surface: #ffffff;
        --text: #1a1a2e;
        --text-secondary: #6a6a8a;
        --hint: #9999b0;
        --card-bg: rgba(255,255,255,0.85);
        --border: rgba(108,92,231,0.12);
        --shadow: 0 4px 20px rgba(108,92,231,0.08);
    }

    .header-bg {
        opacity: 1;
    }

    #stats-row {
        background: rgba(0,0,0,0.1);
    }

    .input-wrapper input {
        background: rgba(0,0,0,0.02);
        border-color: rgba(108,92,231,0.15);
    }

    .input-wrapper input:focus {
        background: #fff;
        box-shadow: 0 0 0 4px rgba(108,92,231,0.08);
    }

    .quota-card {
        background: linear-gradient(135deg, rgba(108,92,231,0.06), rgba(0,216,151,0.04));
    }

    #submit-btn:disabled {
        background: #d0d0e0;
    }

    .dropdown-menu {
        box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    }

    .field-note {
        background: rgba(108,92,231,0.05);
    }

    .field-warning {
        background: rgba(255,107,107,0.04);
    }
}

/* ── Submit Button ────────────────────────────── */

#submit-btn {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gradient-1), #4834d4);
    color: var(--btn-text);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-top: 4px;
}

#submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--gradient-2), var(--gradient-3));
    opacity: 0;
    transition: opacity 0.3s;
}

#submit-btn:not(:disabled):hover::before {
    opacity: 1;
}

#submit-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(108,92,231,0.35);
}

#submit-btn:not(:disabled):active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(108,92,231,0.25);
}

#submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--surface);
}

#submit-btn .btn-text,
#submit-btn .btn-loader {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#submit-btn .btn-loader.hidden {
    display: none;
}

#submit-btn.loading .btn-text {
    display: none;
}

#submit-btn.loading .btn-loader {
    display: flex;
}

.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── Progress ─────────────────────────────────── */

#progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(108,92,231,0.08);
    font-size: 14px;
    color: var(--hint);
}

#progress.hidden {
    display: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--link);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Result ───────────────────────────────────── */

#result {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    animation: resultIn 0.3s ease-out;
}

@keyframes resultIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#result.hidden {
    display: none;
}

#result.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(0,216,151,0.2);
}

#result.error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(255,107,107,0.2);
}

/* ── Generated Address ─────────────────────────── */

#generated-address {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: rgba(108,92,231,0.08);
    border: 1px solid rgba(108,92,231,0.2);
    animation: resultIn 0.3s ease-out;
}

#generated-address.hidden {
    display: none;
}

.gen-addr-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(108,92,231,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.gen-addr-body {
    flex: 1;
    min-width: 0;
}

.gen-addr-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 3px;
}

.gen-addr-value {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--gradient-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gen-addr-copy {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(108,92,231,0.15);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.gen-addr-copy:hover {
    background: rgba(108,92,231,0.25);
    color: var(--text);
}

/* ── History ──────────────────────────────────── */

#history-list {
    min-height: 60px;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 0;
    color: var(--hint);
}

.empty-icon {
    font-size: 32px;
    opacity: 0.5;
}

.history-empty span {
    font-size: 14px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    margin-bottom: 8px;
    transition: background 0.2s;
}

.history-item:hover {
    background: rgba(255,255,255,0.06);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-status {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.history-status.success {
    background: var(--success-bg);
}

.history-status.failed {
    background: var(--error-bg);
}

.history-status.pending {
    background: rgba(255,217,61,0.12);
}

.history-body {
    flex: 1;
    min-width: 0;
}

.history-address {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-address .copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: var(--hint);
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.2s;
    vertical-align: middle;
    margin-left: 4px;
}

.history-address .copy-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

.history-meta {
    font-size: 12px;
    color: var(--hint);
    margin-top: 2px;
}

.history-amount {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ── Rules ────────────────────────────────────── */

.rules-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rules-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.rule-bullet {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(108,92,231,0.12);
    color: var(--gradient-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.rules-list li strong {
    color: var(--text);
}

/* ── Footer ───────────────────────────────────── */

#footer {
    text-align: center;
    padding: 20px 0 8px;
    font-size: 12px;
    color: var(--hint);
}

.footer-dot {
    margin: 0 6px;
}

/* ── Toast ────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.info {
    background: rgba(108,92,231,0.9);
    color: #fff;
}

.toast.success {
    background: rgba(0,216,151,0.9);
    color: #fff;
}

.toast.error {
    background: rgba(255,107,107,0.9);
    color: #fff;
}

/* ── Profile hero ─────────────────────────────── */

.profile-hero {
    position: relative;
    margin: 0 -16px 20px;
    padding: 28px 20px 22px;
    overflow: hidden;
    text-align: center;
}

.profile-hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--gradient-1) 0%, #4834d4 50%, var(--gradient-3) 100%);
    opacity: 0.85;
}

.profile-hero-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(0,216,151,0.1) 0%, transparent 50%);
}

.profile-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.profile-avatar-box {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.25);
    overflow: hidden;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-img.hidden {
    display: none;
}

.profile-avatar-box:has(.profile-avatar-img.hidden)::after {
    content: '👤';
    font-size: 32px;
}

.profile-display-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.profile-display-username {
    font-size: 13px;
    color: rgba(255,255,255,0.65);
    margin-top: 2px;
}

.profile-stat-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.1);
    width: 100%;
    max-width: 360px;
}

.pstat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.pstat-val {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.pstat-lbl {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    font-weight: 500;
}

.pstat-div {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.12);
    margin: 0 6px;
}

/* ── Rental page ──────────────────────────────── */

.rental-hero {
    position: relative;
    margin: 0 -16px 20px;
    padding: 36px 20px 28px;
    overflow: hidden;
    text-align: center;
}

.rental-hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #ffd93d 100%);
    opacity: 0.8;
}

.rental-hero-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255,217,61,0.15) 0%, transparent 50%);
}

.rental-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rental-hero-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 8px;
}

.rental-hero-title {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.rental-hero-desc {
    font-size: 14px;
    color: rgba(255,255,255,0.75);
    margin-top: 4px;
}

.rental-placeholder {
    text-align: center;
    padding: 32px 20px;
}

.rental-placeholder-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.rental-placeholder-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.rental-placeholder-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.rental-feature-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    max-width: 280px;
    margin: 0 auto;
}

.rfeature {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.rfeature-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.card-icon-addr {
    background: linear-gradient(135deg, rgba(108,92,231,0.2), rgba(0,216,151,0.2)) !important;
}

.card-icon-rules {
    background: rgba(255,217,61,0.15) !important;
}

#profile-addr-list {
    margin-bottom: 14px;
    min-height: 40px;
}

.addr-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 0;
    color: var(--hint);
}

.addr-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    margin-bottom: 8px;
    transition: background 0.2s;
}

.addr-item:hover {
    background: rgba(255,255,255,0.06);
}

.addr-item:last-child {
    margin-bottom: 0;
}

.addr-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(108,92,231,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.addr-item-body {
    flex: 1;
    min-width: 0;
}

.addr-item-addr {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.addr-item-label {
    font-size: 12px;
    color: var(--hint);
    margin-top: 2px;
}

.addr-item-delete {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--hint);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.addr-item-delete:hover {
    background: var(--error-bg);
    color: var(--error);
}

.addr-add-btn {
    width: 100%;
    height: 46px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--hint);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.addr-add-btn:hover {
    border-color: var(--link);
    color: var(--link);
    background: rgba(108,92,231,0.05);
}

.card-icon-addr {
    background: linear-gradient(135deg, rgba(108,92,231,0.2), rgba(0,216,151,0.2)) !important;
}

/* ── Modal ───────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: slideUp 0.3s ease-out;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.3);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    color: var(--hint);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text);
}

.modal-body {
    margin-bottom: 16px;
}

.modal-confirm {
    width: 100%;
    height: 50px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--gradient-1), #4834d4);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-confirm:hover {
    box-shadow: 0 8px 24px rgba(108,92,231,0.35);
    transform: translateY(-1px);
}

.modal-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (prefers-color-scheme: light) {
    .modal-content {
        background: #fff;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.08);
    }
    .modal-close {
        background: rgba(0,0,0,0.04);
    }
    .modal-close:hover {
        background: rgba(0,0,0,0.08);
    }
}


