:root {
    --bg: #f5f7fa;
    --glass: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --accent: #2563eb;
    /* Royal Blue */
    --accent-glow: rgba(37, 99, 235, 0.3);
    --bubble-me: #2563eb;
    --bubble-them: #ffffff;
    --danger: #ef4444;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: var(--font-main);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.app-layer {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: var(--bg);
    overflow: hidden;
}

/* --- CALCULATOR LAYER (Clean iOS Style) --- */
.calc-safe-area {
    height: 100%;
    padding: 20px;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    max-width: 450px;
    margin: 0 auto;
}

.calc-display {
    font-size: clamp(60px, 15vw, 90px);
    color: #111;
    text-align: right;
    font-weight: 300;
    margin-bottom: 20px;
    padding-right: 10px;
}

.calc-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(10px, 4vw, 15px);
}

.calc-btn {
    aspect-ratio: 1;
    border-radius: 50%;
    border: none;
    font-size: clamp(24px, 8vw, 32px);
    color: #000;
    font-weight: 500;
    cursor: pointer;
    transition: filter 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.calc-btn:active {
    filter: brightness(0.9);
    transform: scale(0.95);
}

.btn-gray {
    background: #e5e7eb;
    color: #000;
}

.btn-dark {
    background: #ffffff;
    color: #000;
}

.btn-orange {
    background: var(--accent);
    color: white;
    font-size: clamp(30px, 9vw, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 5px;
}

.btn-zero {
    grid-column: span 2;
    aspect-ratio: auto;
    border-radius: 40px;
    padding-left: 30px;
    text-align: left;
}


/* --- BOOT LAYER (Clean Tech) --- */
#boot-sequence {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    color: #000;
    font-family: var(--font-mono);
}

.boot-bg {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #f0f9ff 0%, #fff 100%);
    z-index: -1;
}

.boot-content {
    width: 90%;
    max-width: 600px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.boot-logo {
    max-width: 80%;
    max-height: 30vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin-bottom: 30px;
    filter: drop-shadow(0 10px 20px rgba(37, 99, 235, 0.2));
    animation: float 3s ease-in-out infinite;
}

/* --- NFC OVERLAY (iOS Style) --- */
#nfc-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(2px);
}

.ios-nfc-sheet {
    background: rgba(255, 255, 255, 0.95);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease-out;
    color: #000;
}

.nfc-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

.nfc-icon-ios {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #007aff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 15px;
    animation: pulse 2s infinite;
}

.nfc-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.nfc-body {
    font-size: 15px;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.4;
}

.nfc-footer button {
    background: #e5e5ea;
    border: none;
    padding: 12px 40px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    color: #007aff;
    cursor: pointer;
}

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

    to {
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(0, 122, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 122, 255, 0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.glitch {
    font-size: clamp(18px, 5vw, 24px);
    font-weight: 700;
    color: #111;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.terminal-log-window {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 11px;
    height: 200px;
    width: 100%;
    overflow: hidden;
    color: #4b5563;
    border-left: 2px solid var(--accent);
    padding-left: 15px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    border-radius: 0 8px 8px 0;
    margin: 20px 0;
}

#geo-trace {
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 10px;
    height: 20px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.progress-bar {
    height: 6px;
    background: #e5e7eb;
    width: 100%;
    margin-top: 10px;
    border-radius: 3px;
    overflow: hidden;
}

#boot-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.2s;
}


/* --- MESSENGER LAYER (White Glass) --- */
#messenger-app {
    background: #f3f4f6;
    color: #1f2937;
    display: flex;
    flex-direction: column;
    background-image: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);
}

/* Auth View */
#view-auth {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
}

#auth-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* FaceID Animation */
#face-id-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.scan-frame {
    width: 200px;
    height: 200px;
    border: 2px solid rgba(37, 99, 235, 0.3);
    border-radius: 30px;
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 30px rgba(37, 99, 235, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.face-grid {
    font-size: 80px;
    color: rgba(37, 99, 235, 0.2);
    animation: pulse-face 2s infinite;
}

.scan-line {
    position: absolute;
    width: 100%;
    height: 4px;
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent);
    top: 0;
    left: 0;
    animation: scan-move 1.5s infinite linear;
}

#scan-status {
    margin-top: 20px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 1px;
}

@keyframes scan-move {
    0% {
        top: 0;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

@keyframes pulse-face {
    0% {
        transform: scale(0.95);
        opacity: 0.2;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.4;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.2;
    }
}

.auth-logo {
    max-width: 60%;
    max-height: 20vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin-bottom: 20px;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.1));
}

.lock-icon {
    font-size: 50px;
    color: var(--accent);
    margin-bottom: 10px;
}

.auth-text {
    font-size: 22px;
    letter-spacing: 2px;
    font-weight: 600;
    color: #111;
}

.auth-sub {
    font-family: var(--font-mono);
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 40px;
}

.decrypt-btn {
    background: var(--accent);
    border: none;
    color: white;
    padding: 16px 40px;
    font-size: 14px;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 10px 25px var(--accent-glow);
    transition: all 0.3s ease;
}

.decrypt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px var(--accent-glow);
}

/* Chat Interface */
#view-chats {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    height: 60px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 12px;
}

.header-left {
    display: flex;
    align-items: center;
}

.id-label {
    font-size: 10px;
    color: #9ca3af;
    display: block;
    font-family: var(--font-mono);
    font-weight: 600;
}

.scramble-text {
    font-family: var(--font-mono);
    font-weight: bold;
    color: #111;
    font-size: 14px;
}

#panic-btn {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #ef4444;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 6px;
    transition: 0.2s;
}

#panic-btn:hover {
    background: #ef4444;
    color: white;
}

.main-layout {
    flex: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

.panel {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: transparent;
    position: absolute;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* --- RESPONSIVE LAYOUT --- */
@media (min-width: 850px) {
    .contacts-panel {
        width: 350px;
        border-right: 1px solid rgba(0, 0, 0, 0.05);
        position: relative;
        background: rgba(255, 255, 255, 0.6);
    }

    .messages-panel {
        width: calc(100% - 350px);
        position: relative;
        transform: none !important;
        background: rgba(255, 255, 255, 0.4);
    }

    #back-btn {
        display: none;
    }
}

/* Mobile Transitions */
.contacts-panel {
    z-index: 1;
}

.messages-panel {
    z-index: 2;
    transform: translateX(100%);
    background: #f9fafb;
}

.messages-panel.active {
    transform: translateX(0);
}

/* Contacts List */
.search-box {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.5);
}

.search-box input {
    width: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 12px;
    color: #111;
    outline: none;
    font-family: var(--font-main);
    border-radius: 8px;
    transition: 0.3s;
    font-size: 14px;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.list-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.contact-item {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    display: flex;
    justify-content: space-between;
    cursor: pointer;
    transition: 0.2s;
    background: rgba(255, 255, 255, 0.01);
    overflow: hidden;
    /* Fix overflow */
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.8);
    border-left: 3px solid var(--accent);
}

.c-info {
    flex: 1;
    min-width: 0;
    margin-right: 10px;
}

/* New wrapper for text truncation */
.c-name {
    font-weight: 600;
    color: #111;
    display: block;
    margin-bottom: 6px;
    font-size: 15px;
}

.c-prev {
    color: #6b7280;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
}

.c-meta {
    font-size: 11px;
    color: #9ca3af;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.c-badge {
    background: #eff6ff;
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 700;
}

/* Payment Gate */
#payment-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.5s ease;
}

.crypto-card {
    background: #fff;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    width: 100%;
    margin-bottom: 20px;
}

.btc-amount {
    font-size: 28px;
    font-weight: 800;
    color: #111;
    margin: 10px 0;
}

.fiat-amount {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 20px;
}

.qr-placeholder {
    width: 180px;
    height: 180px;
    background: #f9fafb;
    margin: 0 auto 20px;
    border-radius: 10px;
    border: 2px dashed #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    color: #9ca3af;
    font-size: 12px;
}

.wallet-address {
    font-family: var(--font-mono);
    font-size: 11px;
    background: #f3f4f6;
    padding: 10px;
    border-radius: 8px;
    word-break: break-all;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.pay-status {
    margin-top: 15px;
    font-size: 13px;
    font-weight: 600;
    height: 20px;
}

.status-pending {
    color: #f59e0b;
}

.status-success {
    color: #10b981;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message View */
.msg-topbar {
    height: 60px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 15px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
}

#back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

.chat-meta {
    flex: 1;
    text-align: center;
}

#chat-title {
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 16px;
    color: #111;
}

.enc-method {
    display: block;
    font-size: 10px;
    color: #10b981;
    font-family: var(--font-mono);
    margin-top: 2px;
}

.feed-scroll {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.bubble {
    max-width: 85%;
    padding: 12px 18px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.me {
    align-self: flex-end;
    background: var(--bubble-me);
    color: #fff;
    border-radius: 18px 4px 18px 18px;
}

.them {
    align-self: flex-start;
    background: var(--bubble-them);
    color: #1f2937;
    border-radius: 4px 18px 18px 18px;
}

.ts {
    font-size: 10px;
    opacity: 0.7;
    display: block;
    margin-top: 6px;
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 500;
}

.input-bar {
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 15px;
    align-items: center;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
    backdrop-filter: blur(10px);
}

.input-bar input {
    flex: 1;
    background: #f3f4f6;
    border: 1px solid transparent;
    color: #111;
    padding: 14px;
    outline: none;
    border-radius: 25px;
    font-size: 15px;
    transition: 0.3s;
}

.input-bar input:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#btn-send {
    background: var(--accent);
    border: none;
    color: #fff;
    padding: 0 25px;
    height: 46px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: 0.2s;
    box-shadow: 0 4px 12px var(--accent-glow);
}

#btn-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--accent-glow);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* --- CRYPTO WALLET APP --- */
#wallet-app {
    background: #0f172a;
    color: white;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    position: relative;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    background: rgba(15, 23, 42, 0.9);
}

.sb-left,
.sb-right {
    display: flex;
    gap: 5px;
    align-items: center;
}

.wallet-header {
    padding: 20px 20px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0) 100%);
    text-align: center;
}

/* ... (Existing Wallet Styles) ... */

/* Bottom Nav */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    padding: 15px 0;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #64748b;
    font-size: 10px;
    gap: 5px;
    cursor: pointer;
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

.nav-item.active {
    color: #3b82f6;
}

.w-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 30px;
    font-weight: 600;
    letter-spacing: 1px;
}

.w-balance-label {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.w-balance-val {
    font-size: 36px;
    font-weight: 700;
    color: white;
    margin-bottom: 5px;
    letter-spacing: -1px;
}

.w-change {
    color: #10b981;
    font-size: 14px;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
}

.w-assets {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.asset-row {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(30, 41, 59, 0.4);
    margin-bottom: 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: 0.2s;
}

.asset-row:active {
    transform: scale(0.98);
    background: rgba(30, 41, 59, 0.6);
}

.asset-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    margin-right: 15px;
}

.asset-info {
    flex: 1;
}

.a-name {
    font-weight: 600;
    font-size: 16px;
}

.a-amount {
    font-size: 12px;
    color: #94a3b8;
}

.asset-val {
    font-weight: 600;
    font-size: 15px;
    text-align: right;
}

/* Transaction Modal */
.tx-modal {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    display: flex;
    align-items: flex-end;
    z-index: 100;
    animation: blurFadeIn 0.6s ease-out forwards;
}

.tx-card {
    background: #1e293b;
    width: 100%;
    padding: 30px 20px;
    border-radius: 30px 30px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    animation: cardSlideUp 0.4s ease-out 0.2s backwards;
}

.tx-header {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: 1px;
    font-weight: 700;
}

.tx-to {
    text-align: center;
    font-size: 16px;
    color: white;
    margin-bottom: 10px;
}

.tx-amount {
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin-bottom: 10px;
}

.tx-fee {
    text-align: center;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 30px;
}

.tx-actions button {
    width: 100%;
    background: #3b82f6;
    color: white;
    border: none;
    padding: 18px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.tx-actions button:active {
    transform: scale(0.98);
}

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

    to {
        transform: translateY(0);
    }
}

/* Gradual Blur Fade-In for Payment Modal */
@keyframes blurFadeIn {
    0% {
        background: rgba(0, 0, 0, 0);
        backdrop-filter: blur(0px);
    }
    100% {
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(5px);
    }
}

@keyframes cardSlideUp {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}