:root {
    --bg-dark: #000000;
    --glass-bg: rgba(25, 25, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --accent: #0A84FF;
    --accent-hover: #0070E0;
    --danger: #FF453A;
    --success: #32D74B;
    --text-main: #FFFFFF;
    --text-muted: #EBEBF599;
    --spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --smooth: cubic-bezier(0.25, 1, 0.5, 1);
}

body {
    margin: 0; 
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark); 
    color: var(--text-main);
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center;
    min-height: 100vh; 
    /* Support for mobile safe areas (notches/swipe bars) */
    min-height: calc(100vh - env(safe-area-inset-bottom));
    overflow-x: hidden; /* Allow Y scroll if screen is very small */
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
    position: relative;
}

/* Background Animations */
.bg-orb { 
    position: absolute; 
    border-radius: 50%; 
    filter: blur(80px); 
    z-index: -1; 
    opacity: 0.4; 
    animation: float 20s infinite ease-in-out alternate; 
}
.orb-1 { width: 60vw; height: 60vw; max-width: 400px; max-height: 400px; background: var(--accent); top: -10%; left: -10%; }
.orb-2 { width: 70vw; height: 70vw; max-width: 500px; max-height: 500px; background: var(--danger); bottom: -10%; right: -10%; animation-delay: -5s;}
.orb-3 { width: 50vw; height: 50vw; max-width: 300px; max-height: 300px; background: #BF5AF2; top: 30%; left: 50%; animation-delay: -10s;}

@keyframes float { 
    0% { transform: translate(0, 0) scale(1); } 
    100% { transform: translate(30px, 50px) scale(1.1); } 
}

/* Main Container */
.glass-panel {
    background: var(--glass-bg); 
    backdrop-filter: blur(25px); 
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border); 
    border-radius: 32px; 
    padding: 25px;
    width: 100%; 
    max-width: 420px; 
    margin-bottom: 60px; /* Space for footer */
    box-shadow: 0 30px 60px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.2);
    box-sizing: border-box; 
    position: relative; 
    z-index: 10;
    /* Smooth height transitions */
    min-height: 400px; 
}

/* Dynamic Island */
.dynamic-island {
    background: #000; 
    color: #fff; 
    border-radius: 20px; 
    padding: 8px 20px;
    font-size: 0.85rem; 
    font-weight: 600; 
    text-align: center; 
    margin: -10px auto 20px auto;
    width: max-content; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); 
    transition: all 0.4s var(--spring);
}
.dynamic-island.active { background: var(--accent); color: #fff;}
.dynamic-island.error { background: var(--danger); }
.dynamic-island.success { background: var(--success); color: #000;}

.app-title { 
    text-align: center; 
    font-size: 1.8rem; 
    font-weight: 700; 
    margin: 0 0 25px 0; 
    letter-spacing: -0.5px; 
}

/* View Routing */
/* Removed absolute positioning to allow natural container scaling */
.view-section { 
    transition: opacity 0.4s var(--smooth), transform 0.4s var(--smooth); 
    width: 100%;
}
.active-view { 
    opacity: 1; 
    transform: translateX(0); 
    display: block;
}
.hidden-view { 
    opacity: 0; 
    transform: translateX(20px); 
    display: none; 
}

/* UI Elements */
.card { 
    background: rgba(0,0,0,0.4); 
    border-radius: 20px; 
    padding: 25px 20px; 
    text-align: center; 
    margin-bottom: 20px; 
    border: 1px solid rgba(255,255,255,0.05); 
}
.subtitle { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 1.5px; margin: 0 0 10px 0; }
.pin-display { font-size: clamp(2.5rem, 10vw, 3.5rem); font-weight: 800; letter-spacing: 10px; margin: 0; color: #fff; font-family: monospace;}

.timer-wrapper { height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; margin: 20px 0 10px 0; }
.timer-bar { height: 100%; background: var(--accent); width: 0%; transition: width 1s linear, background-color 0.3s;}
.timer-text { font-size: 0.85rem; color: var(--text-muted); margin: 0;}

input[type="text"] {
    width: 100%; 
    background: rgba(0,0,0,0.5); 
    border: 1px solid rgba(255,255,255,0.1); 
    color: white;
    padding: 18px; 
    border-radius: 16px; 
    font-size: clamp(1.2rem, 6vw, 1.5rem); 
    text-align: center; 
    letter-spacing: 8px;
    box-sizing: border-box; 
    outline: none; 
    transition: 0.3s; 
    font-family: monospace; 
    font-weight: bold;
}
input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.2); }
input[type="text"]::placeholder { color: rgba(255,255,255,0.2); letter-spacing: normal; font-family: -apple-system, sans-serif; font-size: 1.2rem; font-weight: normal;}

/* Buttons */
.btn {
    width: 100%; padding: 16px; border: none; border-radius: 16px; font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: transform 0.1s, background 0.2s, opacity 0.2s; user-select: none; -webkit-tap-highlight-color: transparent;
    display: flex; justify-content: center; align-items: center; gap: 10px;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: rgba(255,255,255,0.1); color: white; }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.15); }
.btn-danger { background: rgba(255, 69, 58, 0.1); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 69, 58, 0.2); }
.btn-large { padding: 20px; font-size: 1.1rem; border-radius: 20px; }
.button-group { display: flex; flex-direction: column; gap: 12px; }

/* Transfer UI */
.connection-badge { text-align: center; font-size: 0.85rem; font-weight: 600; color: var(--success); margin-bottom: 20px; display: flex; align-items: center; justify-content: center; gap: 8px;}
.dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; display: inline-block;}
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(50, 215, 75, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(50, 215, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(50, 215, 75, 0); } }

.upload-zone {
    border: 2px dashed rgba(255,255,255,0.15); border-radius: 20px; padding: 30px 20px;
    text-align: center; position: relative; transition: all 0.3s; background: rgba(0,0,0,0.3); cursor: pointer;
}
.upload-zone:hover, .upload-zone.active { border-color: var(--accent); background: rgba(10, 132, 255, 0.1); }
.file-input { position: absolute; width: 100%; height: 100%; top: 0; left: 0; opacity: 0; cursor: pointer; z-index: 10; }
.upload-icon { color: var(--accent); margin-bottom: 10px; transition: transform 0.3s var(--spring);}
.upload-zone:hover .upload-icon { transform: translateY(-3px); }
.upload-text { margin: 0; color: var(--text-muted); font-size: 0.9rem; word-break: break-all; font-weight: 500;}

/* Progress Area */
.progress-container { margin-top: 20px; background: rgba(0,0,0,0.4); padding: 15px; border-radius: 16px;}
.progress-label { font-size: 0.8rem; font-weight: 600; margin-bottom: 8px; color: #fff;}
.progress-track { width: 100%; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden;}
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 4px; transition: width 0.1s linear;}
.progress-stats { text-align: right; font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; font-variant-numeric: tabular-nums;}

/* Transfer History */
.history-container { margin-top: 25px; }
.history-list { display: flex; flex-direction: column; gap: 10px; max-height: 200px; overflow-y: auto; padding-right: 5px;}
.history-empty { text-align: center; color: var(--text-muted); font-size: 0.85rem; padding: 20px 0; font-style: italic;}
.history-item { 
    display: flex; align-items: center; justify-content: space-between; 
    background: rgba(255,255,255,0.05); padding: 12px 15px; border-radius: 12px;
    font-size: 0.85rem; border: 1px solid rgba(255,255,255,0.02);
}
.hi-details { display: flex; flex-direction: column; max-width: 65%;}
.hi-name { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.hi-size { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px;}
.hi-status { font-weight: 600; font-size: 0.75rem; padding: 4px 8px; border-radius: 6px; flex-shrink: 0;}
.hi-status.sent { background: rgba(10, 132, 255, 0.15); color: var(--accent); }
.hi-status.received { background: rgba(50, 215, 75, 0.15); color: var(--success); }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

/* Custom Footer */
.app-footer {
    position: absolute;
    bottom: max(20px, env(safe-area-inset-bottom));
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.6;
    letter-spacing: 0.5px;
    z-index: 5;
    pointer-events: none;
}
.app-footer .brand {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    letter-spacing: 1px;
}

/* --- MEDIA QUERIES FOR RESPONSIVENESS --- */

/* For very small phones (e.g., iPhone SE) */
@media (max-width: 375px) {
    .glass-panel {
        padding: 20px;
    }
    .pin-display {
        letter-spacing: 5px; /* Prevent PIN from overflowing */
    }
    .btn-large {
        padding: 16px;
        font-size: 1rem;
    }
}

/* For Tablets and Desktop */
@media (min-width: 768px) {
    .glass-panel {
        max-width: 480px; /* Slightly wider on desktop for better breathing room */
        padding: 40px;
    }
    .upload-zone {
        padding: 50px 20px; /* Larger hit area for drag and drop */
    }
    .app-title {
        font-size: 2.2rem;
    }
    .subtitle {
        font-size: 0.85rem;
    }
}
