/* ============================================
   THE VAULT - Personal Archive App
   CSS Design System & Styles
   ============================================ */

/* --- CSS Variables (Theme Tokens) --- */
:root {
    /* Colors - Dark Theme */
    --color-bg-primary: #0f172a;
    --color-bg-secondary: #1e293b;
    --color-bg-tertiary: #334155;

    --color-text-primary: #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;

    --color-accent: #f59e0b;
    --color-accent-hover: #fbbf24;
    --color-accent-muted: rgba(245, 158, 11, 0.2);

    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;

    --color-purple: #a855f7;
    --color-pink: #ec4899;
    --color-orange: #f97316;

    /* Glassmorphism */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-blur: 10px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.3);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;

    /* Z-Index Scale */
    --z-base: 1;
    --z-overlay: 30;
    --z-modal: 40;
    --z-nav: 50;
    --z-toast: 60;
}

/* Light Theme Variables */
[data-theme="light"] {
    --color-bg-primary: #f8fafc;
    --color-bg-secondary: #e2e8f0;
    --color-bg-tertiary: #cbd5e1;

    --color-text-primary: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #94a3b8;

    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.05);
}

/* --- Base Styles --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

.font-mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Scrollbar Styles --- */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Custom scrollbar for content areas */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

/* --- Glass Panel --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
}

/* --- Input Styles --- */
.input-dark {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    transition: border-color var(--transition-fast);
}

.input-dark:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-muted);
}

.input-dark::placeholder {
    color: var(--color-text-muted);
}

/* --- Button Styles --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--color-accent);
    color: var(--color-bg-primary);
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-secondary {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-bg-tertiary);
}

.btn-secondary:hover {
    background: var(--color-bg-tertiary);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
}

.btn-danger {
    background: var(--color-error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* --- Animations & Keyframes --- */
@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 5px var(--color-accent);
    }

    50% {
        box-shadow: 0 0 20px var(--color-accent);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slide-in-bottom {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Animation Utility Classes */
.animate-fade-in {
    animation: fade-in var(--transition-normal) ease forwards;
}

.animate-slide-up {
    animation: slide-up var(--transition-slow) ease forwards;
}

.animate-slide-in-right {
    animation: slide-in-right var(--transition-slow) ease forwards;
}

.animate-slide-in-bottom {
    animation: slide-in-bottom var(--transition-slow) ease forwards;
}

.animate-bounce {
    animation: bounce 1s ease infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.ai-active {
    animation: pulse-glow 2s infinite;
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(90deg,
            var(--color-bg-secondary) 25%,
            var(--color-bg-tertiary) 50%,
            var(--color-bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* --- Toast Notification --- */
.toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: var(--z-toast);
    animation: slide-up var(--transition-normal) ease forwards;
}

.toast-success {
    background: var(--color-success);
    color: white;
}

.toast-error {
    background: var(--color-error);
    color: white;
}

.toast-info {
    background: var(--color-info);
    color: white;
}

/* --- Card Styles --- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--color-accent-muted);
    transform: translateY(-2px);
}

.card-accent {
    border-left: 4px solid var(--color-accent);
}

/* --- Badge Styles --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm);
    background: var(--color-bg-tertiary);
    color: var(--color-accent);
}

.badge-purple {
    background: rgba(168, 85, 247, 0.2);
    color: var(--color-purple);
}

.badge-pink {
    background: rgba(236, 72, 153, 0.2);
    color: var(--color-pink);
}

.badge-orange {
    background: rgba(249, 115, 22, 0.2);
    color: var(--color-orange);
}

/* --- Pill Styles (for category picker) --- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: var(--color-bg-tertiary);
    border: 2px solid transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.pill:hover {
    border-color: var(--color-accent-muted);
    background: var(--color-bg-secondary);
}

.pill.selected {
    border-width: 2px;
    font-weight: 600;
}

/* No Scrollbar Utility */
.no-scrollbar {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* --- FAB (Floating Action Button) --- */
.fab {
    position: fixed;
    bottom: 5rem;
    right: 1.25rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-full);
    background: var(--color-accent);
    color: var(--color-bg-primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transition: all var(--transition-fast);
    z-index: var(--z-overlay);
}

.fab:hover {
    background: var(--color-accent-hover);
    transform: scale(1.1);
}

.fab:active {
    transform: scale(0.9);
}

/* --- Navigation Bar --- */
.nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4rem;
    background: var(--color-bg-primary);
    border-top: 1px solid var(--color-bg-secondary);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: var(--z-nav);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.nav-item:hover {
    color: var(--color-text-secondary);
}

.nav-item.active {
    color: var(--color-accent);
}

.nav-item i {
    font-size: 1.25rem;
    margin-bottom: var(--space-xs);
}

.nav-item span {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* --- Header Styles --- */
.header {
    position: sticky;
    top: 0;
    z-index: var(--z-overlay);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--color-bg-secondary);
    padding: var(--space-md);
}

/* --- Modal/Editor Overlay --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-bg-primary);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    animation: slide-in-bottom var(--transition-normal) ease forwards;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    opacity: 0.5;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

/* --- Voice Recording --- */
.voice-recorder {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
}

.voice-btn {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.voice-btn.recording {
    background: var(--color-error);
    animation: pulse-glow 1s infinite;
}

.voice-waveform {
    flex: 1;
    height: 2rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* --- Swipe Action --- */
.swipe-container {
    position: relative;
    overflow: hidden;
}

.swipe-action {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    background: var(--color-error);
    color: white;
}

/* --- Onboarding Styles --- */
.onboarding {
    position: fixed;
    inset: 0;
    background: var(--color-bg-primary);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.onboarding-slide {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    text-align: center;
}

.onboarding-indicator {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
}

.onboarding-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: var(--radius-full);
    background: var(--color-bg-tertiary);
    transition: all var(--transition-fast);
}

.onboarding-dot.active {
    width: 1.5rem;
    background: var(--color-accent);
}

/* --- Auth Screen --- */
.auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    background: linear-gradient(180deg,
            var(--color-bg-primary) 0%,
            var(--color-bg-secondary) 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
}

.auth-logo {
    width: 4rem;
    height: 4rem;
    margin-bottom: var(--space-lg);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-accent);
    margin-bottom: var(--space-xs);
}

.auth-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xl);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.auth-input {
    width: 100%;
    padding: var(--space-md);
    background: var(--color-bg-primary);
    border: 1px solid var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1rem;
}

.auth-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.auth-btn {
    width: 100%;
    padding: var(--space-md);
    background: var(--color-accent);
    color: var(--color-bg-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-btn:hover {
    background: var(--color-accent-hover);
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-error {
    padding: var(--space-sm) var(--space-md);
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--color-error);
    border-radius: var(--radius-md);
    color: var(--color-error);
    font-size: 0.875rem;
    text-align: center;
}

/* --- Category/Tag Pills --- */
.pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pill:hover {
    border-color: var(--color-accent);
    color: var(--color-text-primary);
}

.pill.selected {
    background: var(--color-accent-muted);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.pill-remove {
    width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-bg-primary);
    color: var(--color-text-muted);
    font-size: 0.625rem;
}

/* --- Theme Toggle --- */
.theme-toggle {
    position: relative;
    width: 3rem;
    height: 1.5rem;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.theme-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.25rem;
    height: 1.25rem;
    background: var(--color-accent);
    border-radius: var(--radius-full);
    transition: transform var(--transition-fast);
}

.theme-toggle.dark::after {
    transform: translateX(1.5rem);
}

/* --- Responsive Adjustments --- */
@media (min-width: 640px) {
    .container {
        max-width: 640px;
        margin: 0 auto;
    }
}

@media (min-width: 768px) {
    .nav-bar {
        height: 5rem;
    }

    .nav-item i {
        font-size: 1.5rem;
    }

    .nav-item span {
        font-size: 0.75rem;
    }
}

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   MOBILE PWA OPTIMIZATIONS
   ============================================ */

/* --- iOS Safe Areas --- */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* Apply safe area padding to body for notched devices */
body {
    padding-top: var(--safe-area-top);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
}

/* Navigation bar with safe area */
.nav-bar {
    padding-bottom: var(--safe-area-bottom);
    height: calc(4rem + var(--safe-area-bottom));
}

/* Header with safe area for notch */
.header {
    padding-top: calc(var(--space-md) + var(--safe-area-top));
}

/* Modal overlay with safe areas */
.modal-overlay {
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
}

/* FAB positioning with safe area */
.fab {
    bottom: calc(5rem + var(--safe-area-bottom));
    right: calc(1.25rem + var(--safe-area-right));
}

/* Toast with safe area */
.toast {
    bottom: calc(5rem + var(--safe-area-bottom));
}

/* --- Touch Optimizations --- */
/* Larger touch targets for mobile */
.nav-item {
    min-height: 48px;
    min-width: 48px;
}

.btn,
.fab,
.pill,
.badge {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Better touch feedback */
.touchable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

.touchable:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* Card touch feedback */
.card {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* --- Swipe to Delete --- */
.swipeable-card {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.swipeable-card-content {
    position: relative;
    z-index: 2;
    background: var(--glass-bg);
    transition: transform 0.2s ease;
}

.swipeable-card.swiping .swipeable-card-content {
    transition: none;
}

.swipe-delete-action {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80px;
    background: var(--color-error);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    z-index: 1;
}

/* --- Pull to Refresh --- */
.pull-to-refresh {
    position: fixed;
    top: var(--safe-area-top);
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
    z-index: 100;
}

.pull-to-refresh.pulling {
    transform: translateX(-50%) translateY(20px);
}

.pull-to-refresh.refreshing {
    transform: translateX(-50%) translateY(60px);
}

.pull-to-refresh i {
    color: var(--color-accent);
    font-size: 1rem;
}

.pull-to-refresh.refreshing i {
    animation: spin 1s linear infinite;
}

/* --- PWA Install Banner --- */
.install-banner {
    position: fixed;
    bottom: calc(5rem + var(--safe-area-bottom));
    left: var(--space-md);
    right: var(--space-md);
    background: linear-gradient(135deg, var(--color-bg-secondary), var(--color-bg-tertiary));
    border: 1px solid var(--color-accent-muted);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(245, 158, 11, 0.2);
    z-index: var(--z-toast);
    animation: slide-up var(--transition-slow) ease forwards;
}

.install-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.install-banner-content {
    flex: 1;
    min-width: 0;
}

.install-banner-title {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
}

.install-banner-text {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.install-banner-btn {
    background: var(--color-accent);
    color: var(--color-bg-primary);
    border: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.install-banner-btn:active {
    transform: scale(0.95);
}

.install-banner-close {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
}

/* --- Offline Indicator --- */
.offline-banner {
    position: fixed;
    top: var(--safe-area-top);
    left: 0;
    right: 0;
    background: var(--color-warning);
    color: var(--color-bg-primary);
    text-align: center;
    padding: var(--space-xs) var(--space-md);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1000;
    animation: slide-in-bottom var(--transition-normal) ease forwards;
}

body.offline::before {
    content: '📴 Mod Luar Talian';
    position: fixed;
    top: var(--safe-area-top);
    left: 0;
    right: 0;
    background: var(--color-error);
    color: white;
    text-align: center;
    padding: var(--space-xs) var(--space-md);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1000;
}

/* --- Mobile-First Scrolling --- */
.scroll-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-behavior: smooth;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* --- Haptic Feedback Visual Cues --- */
@keyframes haptic-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1);
    }
}

.haptic-feedback {
    animation: haptic-pulse 0.15s ease;
}

/* --- Rubber Band Scroll Effect --- */
.bounce-scroll {
    overscroll-behavior-y: auto;
}

/* --- Mobile Keyboard Handling --- */
.keyboard-open .nav-bar {
    display: none;
}

.keyboard-open .fab {
    display: none;
}

.keyboard-open .modal-overlay {
    padding-bottom: 0;
}

/* --- Mobile Text Sizes --- */
@media (max-width: 360px) {
    :root {
        font-size: 14px;
    }

    .nav-item span {
        font-size: 0.5rem;
    }
}

/* --- Landscape Mobile --- */
@media (max-height: 500px) and (orientation: landscape) {
    .nav-bar {
        height: 3rem;
        padding-bottom: var(--safe-area-bottom);
    }

    .nav-item i {
        font-size: 1rem;
        margin-bottom: 0;
    }

    .nav-item span {
        display: none;
    }

    .fab {
        bottom: calc(3.5rem + var(--safe-area-bottom));
        width: 3rem;
        height: 3rem;
        font-size: 1rem;
    }

    .header {
        padding: var(--space-sm);
    }

    .onboarding-slide {
        flex-direction: row;
        gap: var(--space-lg);
    }

    .onboarding-slide>div:first-child {
        font-size: 3rem;
    }
}

/* --- iOS Specific Styles --- */
@supports (-webkit-touch-callout: none) {

    /* iOS Safari specific fixes */
    input,
    textarea {
        font-size: 16px;
        /* Prevents zoom on focus */
    }

    /* Fix iOS momentum scrolling */
    .scroll-container {
        -webkit-overflow-scrolling: touch;
    }

    /* iOS status bar area */
    .header {
        background: linear-gradient(to bottom,
                var(--color-bg-primary) 0%,
                var(--color-bg-primary) var(--safe-area-top),
                rgba(15, 23, 42, 0.9) var(--safe-area-top));
    }
}

/* --- Android Specific Styles --- */
@media (display-mode: standalone) {

    /* PWA installed mode */
    body {
        /* Ensure full screen experience */
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }

    html {
        height: -webkit-fill-available;
    }
}

/* --- High Contrast Mode for Accessibility --- */
@media (prefers-contrast: high) {
    :root {
        --glass-bg: var(--color-bg-secondary);
        --glass-border: var(--color-text-secondary);
    }

    .card {
        border-width: 2px;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* --- Dark Mode System Preference --- */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --color-bg-primary: #f8fafc;
        --color-bg-secondary: #e2e8f0;
        --color-bg-tertiary: #cbd5e1;
        --color-text-primary: #0f172a;
        --color-text-secondary: #475569;
        --color-text-muted: #94a3b8;
        --glass-bg: rgba(255, 255, 255, 0.7);
        --glass-border: rgba(0, 0, 0, 0.05);
    }
}

/* --- Loading Skeleton for Mobile --- */
.skeleton-card {
    background: var(--glass-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
}

.skeleton-line {
    height: 1rem;
    background: linear-gradient(90deg,
            var(--color-bg-tertiary) 25%,
            var(--color-bg-secondary) 50%,
            var(--color-bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

/* --- Splash Screen Styles --- */
.splash-screen {
    position: fixed;
    inset: 0;
    background: var(--color-bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fade-out 0.5s ease 1.5s forwards;
}

.splash-logo {
    width: 80px;
    height: 80px;
    animation: bounce 1s ease infinite;
}

.splash-text {
    margin-top: var(--space-md);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-accent);
    letter-spacing: -0.02em;
}

@keyframes fade-out {
    to {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

/* --- Bottom Sheet Styles --- */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-md);
    padding-bottom: calc(var(--space-md) + var(--safe-area-bottom));
    transform: translateY(100%);
    transition: transform var(--transition-slow) ease;
    z-index: var(--z-modal);
    max-height: 70vh;
    overflow-y: auto;
}

.bottom-sheet.open {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-md);
}

/* --- Action Sheet --- */
.action-sheet {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.action-sheet-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.action-sheet-item:active {
    background: var(--color-bg-tertiary);
}

.action-sheet-item i {
    width: 24px;
    text-align: center;
    color: var(--color-accent);
}

.action-sheet-item.destructive {
    color: var(--color-error);
}

.action-sheet-item.destructive i {
    color: var(--color-error);
}

/* --- Quick Actions (Long Press Menu) --- */
.quick-actions {
    position: fixed;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    z-index: var(--z-modal);
    animation: scale-in 0.15s ease forwards;
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Floating Label Input (Mobile-friendly) --- */
.floating-label-group {
    position: relative;
    margin-bottom: var(--space-md);
}

.floating-label-input {
    width: 100%;
    padding: var(--space-lg) var(--space-md) var(--space-sm);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.floating-label {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 1rem;
    pointer-events: none;
    transition: all var(--transition-fast);
}

.floating-label-input:focus+.floating-label,
.floating-label-input:not(:placeholder-shown)+.floating-label {
    top: var(--space-sm);
    transform: translateY(0);
    font-size: 0.75rem;
    color: var(--color-accent);
}

.floating-label-input:focus {
    border-color: var(--color-accent);
    outline: none;
}