/**
 * Winklyy SPA - Shared Styles
 */

/* ==========================================
   CSS VARIABLES (Design Tokens)
   ========================================== */

:root {
    /* Background colors - Deep plum */
    --bg: #120C16;
    --bg2: #1A1222;
    --bg3: #22192C;
    --card: #271D33;
    --hover: #2F233E;

    /* Brand colors - Plum + Rose */
    --accent: #D66DA6;
    --accent2: #7E5BEF;
    --grad: linear-gradient(135deg, #D66DA6 0%, #B96AE0 48%, #7E5BEF 100%);
    --glow: rgba(214, 109, 166, 0.16);
    --glow-strong: rgba(126, 91, 239, 0.22);

    /* Text colors */
    --text: #F7F2FA;
    --text2: #C9BFD6;
    --muted: #9A8CA8;

    /* Semantic colors */
    --success: #3ECF8E;
    --warn: #F3B562;
    --danger: #F06A7C;
    --info: #7AA2FF;

    /* Border */
    --border: #382847;
    --border-light: #4A345E;

    /* Typography - Urbanist for a softer, luxe tone */
    --font: 'Urbanist', 'SF Pro Text', 'Segoe UI', sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Border radius - Tighter for professional look */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Shadows - Subtle with warm undertone */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 2px 12px rgba(212, 151, 156, 0.2);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Z-index layers */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-toast: 400;
    --z-tooltip: 500;
}

/* ==========================================
   RESET & BASE
   ========================================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100%;
    height: 100%;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    background-image:
        radial-gradient(1200px 600px at 12% -12%, rgba(214, 109, 166, 0.22), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(126, 91, 239, 0.18), transparent 55%),
        linear-gradient(180deg, rgba(18, 12, 22, 0.9) 0%, rgba(18, 12, 22, 1) 40%);
    overflow-x: hidden;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    min-height: 100%;
}

#app-view {
    min-height: 100%;
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent2);
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
    outline: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--grad);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--hover);
    border-color: var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text2);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg3);
    color: var(--text);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.25);
}

.btn-success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.btn-success:hover:not(:disabled) {
    background: rgba(52, 211, 153, 0.25);
}

.btn-sm {
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 1rem 1.75rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* ==========================================
   FORM INPUTS
   ========================================== */

.input {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg2);
}

.input::placeholder {
    color: var(--muted);
}

.input-error {
    border-color: var(--danger);
}

textarea.input {
    resize: none;
    min-height: 100px;
}

.input-group {
    margin-bottom: 1rem;
}

.input-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.input-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

.input-error-msg {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.35rem;
}

/* ==========================================
   CARDS
   ========================================== */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ==========================================
   LOADING STATES
   ========================================== */

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.view-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.view-loading .spinner {
    margin-bottom: 1rem;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg3) 25%, var(--hover) 50%, var(--bg3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */

.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
    pointer-events: auto;
}

.toast-success {
    border-color: rgba(52, 211, 153, 0.3);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error {
    border-color: rgba(248, 113, 113, 0.3);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-info {
    border-color: rgba(96, 165, 250, 0.3);
}

.toast-info .toast-icon {
    color: var(--info);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ==========================================
   MODAL
   ========================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg3);
    border: none;
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--hover);
    color: var(--text);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================
   BADGES & CHIPS
   ========================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warn);
}

.badge-danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
}

.badge-info {
    background: rgba(96, 165, 250, 0.15);
    color: var(--info);
}

.badge-accent {
    background: var(--glow);
    color: var(--accent);
}

/* ==========================================
   TOGGLE SWITCH
   ========================================== */

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 13px;
    transition: var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background: var(--muted);
    border-radius: 50%;
    transition: var(--transition-normal);
}

.toggle input:checked + .toggle-slider {
    background: var(--glow);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: var(--accent);
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */

.hidden { display: none !important; }
.invisible { visibility: hidden; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* ==========================================
   VIEW TRANSITIONS
   ========================================== */

.view-enter {
    animation: viewEnter 0.25s ease forwards;
}

.view-exit {
    animation: viewExit 0.2s ease forwards;
}

@keyframes viewEnter {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes viewExit {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* ==========================================
   MOBILE-FIRST OPTIMIZATIONS
   Mobile is the primary design target
   ========================================== */

/* Base mobile styles (default) */
:root {
    /* Touch-friendly minimum sizes */
    --touch-target-min: 44px;
    --touch-target-comfort: 48px;
}

/* Prevent text size adjustment on rotation */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Improve touch scrolling */
body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Ensure all interactive elements meet touch target minimums */
button,
.btn,
a,
input[type="button"],
input[type="submit"],
[role="button"] {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

/* Disable tap highlight on iOS (custom highlight instead) */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Active state for touch feedback */
button:active,
.btn:active,
a:active,
[role="button"]:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* Prevent double-tap zoom on buttons */
button, .btn {
    touch-action: manipulation;
}

/* Prevent pull-to-refresh on entire page (allow on specific elements) */
body {
    overscroll-behavior: none;
}

/* Allow pull-to-refresh on scrollable containers */
.scrollable,
.activity-list,
.actions-list,
.audit-list {
    overscroll-behavior: auto;
}

/* Improve form inputs on mobile */
input, textarea, select {
    font-size: 16px !important; /* Prevents zoom on iOS */
    -webkit-appearance: none;
    appearance: none;
    border-radius: var(--radius-md);
}

/* Remove iOS input shadows */
input:not([type="checkbox"]):not([type="radio"]),
textarea {
    -webkit-appearance: none;
    box-shadow: none !important;
}

/* Better focus states for mobile */
/* UX: Use :focus for inputs (need to show when clicked) */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

/* UX: Use :focus-visible for buttons (only show on keyboard nav) */
button:focus {
    outline: none;
}

button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

/* ==========================================
   SAFE AREAS (Notched phones - iPhone X+, Android)
   ========================================== */

@supports (padding: env(safe-area-inset-top)) {
    /* Top safe area for status bar */
    .safe-top {
        padding-top: env(safe-area-inset-top);
    }

    /* Bottom safe area for home indicator */
    .safe-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Left/right safe areas for landscape */
    .safe-sides {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    /* Fixed bottom elements need safe area */
    .step-footer,
    .nav-dots,
    .emergency-fab,
    .toast-container,
    .modal-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    /* Fixed top elements */
    .status-header,
    .ai-paused-banner {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   Mobile-first: base styles are mobile
   ========================================== */

/* Small mobile (iPhone SE, small Android) */
@media (max-width: 375px) {
    :root {
        --space-md: 0.85rem;
        --space-lg: 1rem;
        --space-xl: 1.25rem;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.1rem; }

    .btn {
        padding: 0.75rem 0.85rem;
        font-size: 0.9rem;
    }

    .btn-lg {
        padding: 0.85rem 1rem;
        font-size: 1rem;
    }

    .card {
        padding: var(--space-md);
    }
}

/* Standard mobile (most phones) */
@media (max-width: 480px) {
    :root {
        --space-lg: 1.25rem;
        --space-xl: 1.5rem;
    }

    .btn {
        padding: 0.85rem 1rem;
    }

    .btn-lg {
        padding: 1rem 1.25rem;
    }

    /* Full-width buttons on mobile */
    .btn-block-mobile {
        width: 100%;
    }

    /* Stack horizontal layouts */
    .flex-stack-mobile {
        flex-direction: column;
    }

    /* Modal as bottom sheet on mobile */
    .modal {
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        margin-top: auto;
        animation: slideUpModal 0.3s ease;
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    /* Toast at bottom on mobile */
    .toast-container {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        left: var(--space-md);
        right: var(--space-md);
        transform: none;
    }

    .toast {
        width: 100%;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .modal {
        max-width: 500px;
    }
}

/* Desktop */
@media (min-width: 769px) {
    :root {
        --space-lg: 1.5rem;
        --space-xl: 2rem;
    }

    /* Center content on large screens */
    .container-app {
        max-width: 480px;
        margin: 0 auto;
    }

    /* Hover states only on desktop */
    .btn-primary:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: var(--shadow-glow);
    }

    .btn-secondary:hover:not(:disabled) {
        background: var(--hover);
        border-color: var(--accent);
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .step-footer {
        position: relative;
        padding-bottom: var(--space-md);
    }

    .modal {
        max-height: 85vh;
    }
}

/* ==========================================
   DYNAMIC VIEWPORT HEIGHT (iOS Safari fix)
   ========================================== */

@supports (height: 100dvh) {
    .full-height {
        height: 100dvh;
    }

    .min-full-height {
        min-height: 100dvh;
    }

    @media (max-width: 480px) {
        .modal {
            max-height: 90dvh;
        }
    }
}

/* Fallback for browsers without dvh support */
@supports not (height: 100dvh) {
    .full-height {
        height: 100vh;
        height: -webkit-fill-available;
    }

    .min-full-height {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* ==========================================
   iOS-SPECIFIC FIXES
   ========================================== */

/* Fix for iOS rubber-banding */
@supports (-webkit-touch-callout: none) {
    body {
        /* Prevent body scroll when modal is open */
        position: relative;
    }

    .modal-open {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    /* Fix iOS input zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* Fix iOS button styling */
    button,
    input[type="button"],
    input[type="submit"] {
        -webkit-appearance: none;
        border-radius: var(--radius-md);
    }
}

/* ==========================================
   ANDROID-SPECIFIC FIXES
   ========================================== */

/* Better scrollbar on Android */
@media (pointer: coarse) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 2px;
    }
}

/* ==========================================
   PULL-TO-REFRESH STYLING
   ========================================== */

.ptr-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
    transition: transform 0.2s ease;
}

.ptr-indicator.visible {
    transform: translateX(-50%) translateY(0);
}

.ptr-indicator.refreshing .ptr-spinner {
    animation: spin 0.8s linear infinite;
}

.ptr-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
}

/* ==========================================
   OFFLINE INDICATOR
   ========================================== */

.offline-banner {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: var(--space-md);
    right: var(--space-md);
    background: var(--danger);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: var(--z-toast);
    transform: translateY(150%);
    transition: transform 0.3s ease;
}

.offline-banner.visible {
    transform: translateY(0);
}

/* ==========================================
   KEYBOARD HANDLING
   ========================================== */

/* When keyboard is open, adjust fixed elements */
@media (max-height: 450px) {
    .step-footer {
        position: relative;
        padding-bottom: var(--space-md);
    }

    .emergency-fab {
        display: none;
    }
}

/* ==========================================
   DESKTOP ENHANCEMENTS
   ========================================== */

@media (min-width: 769px) {
    /* Show desktop-only elements */
    .desktop-only {
        display: block;
    }

    .mobile-only {
        display: none;
    }

    /* Body background for desktop - shows behind centered app */
    body {
        background: linear-gradient(135deg, var(--bg) 0%, #1a1a1f 100%);
    }

    /* App container for desktop - phone mockup style */
    #app {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        min-height: 100vh;
        padding: 2rem;
    }

    #app-view {
        width: 100%;
        max-width: 420px;
        min-height: calc(100vh - 4rem);
        background: var(--bg);
        border-radius: 24px;
        border: 1px solid var(--border);
        box-shadow:
            0 25px 50px -12px rgba(0, 0, 0, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.05);
        overflow: hidden;
        position: relative;
    }

    /* Optional: Phone notch effect */
    #app-view::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 150px;
        height: 28px;
        background: var(--bg);
        border-radius: 0 0 20px 20px;
        z-index: 1000;
        border: 1px solid var(--border);
        border-top: none;
    }

    /* Adjust content for notch */
    .onboarding-container,
    .dashboard-app,
    .login-container,
    .profile-container {
        padding-top: 35px !important;
    }

    /* Desktop tooltip */
    [data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: var(--bg3);
        color: var(--text);
        padding: 0.5rem 0.75rem;
        border-radius: var(--radius-sm);
        font-size: 0.8rem;
        white-space: nowrap;
        z-index: var(--z-tooltip);
    }

    /* Fixed elements need to be absolute within container */
    .step-footer,
    .emergency-fab,
    .nav-dots,
    .toast-container {
        position: absolute;
    }

    .toast-container {
        left: 50%;
        transform: translateX(-50%);
        bottom: 20px;
        width: calc(100% - 2rem);
        max-width: 380px;
    }

    /* Buttons with hover effects */
    .btn:hover:not(:disabled) {
        transform: translateY(-2px);
    }

    .btn-primary:hover:not(:disabled) {
        box-shadow: var(--shadow-glow);
    }

    /* Cards with hover */
    .card:hover,
    .activity-item:hover,
    .decision-card:hover {
        border-color: rgba(232, 121, 249, 0.3);
    }

    /* Better scrollbar for desktop */
    ::-webkit-scrollbar {
        width: 6px;
    }

    ::-webkit-scrollbar-track {
        background: var(--bg2);
    }

    ::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: var(--accent);
    }
}

/* Large desktop - even more space */
@media (min-width: 1200px) {
    #app {
        padding: 3rem;
    }

    #app-view {
        max-width: 440px;
        min-height: calc(100vh - 6rem);
        max-height: 900px;
    }
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }

    /* Reset any desktop styles */
    #app-view::before {
        display: none;
    }
}

/* ============================================
   OFFLINE INDICATOR
   Shows banner when user is offline
   ============================================ */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--danger);
    color: white;
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-banner.visible {
    transform: translateY(0);
}

.offline-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Push content down when offline banner is visible */
body.is-offline .dashboard-container,
body.is-offline #app-view {
    padding-top: 3rem;
}

/* ============================================
   ACCESSIBILITY: Reduced Motion Support
   Disable animations for users who prefer reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Disable specific animations */
    .spinner,
    .loading-spinner,
    .typing-indicator span,
    .pulse,
    .shimmer {
        animation: none !important;
    }

    /* Disable card hover lifts */
    .card:hover,
    .activity-item:hover,
    .decision-card:hover {
        transform: none !important;
    }

    /* Disable button scale effects */
    button:active,
    .btn:active {
        transform: none !important;
    }

    /* Keep essential feedback but instant */
    .toast {
        transition: none !important;
    }

    .modal-overlay {
        transition: none !important;
    }

    .settings-panel {
        transition: none !important;
    }
}

/* ============================================
   SKELETON LOADING STATES
   Placeholder cards while content loads
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, 
        var(--bg2) 0%, 
        var(--bg3, #2a2030) 50%, 
        var(--bg2) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton card - matches activity/action cards */
.skeleton-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg2);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.skeleton-line {
    height: 1rem;
    border-radius: 4px;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long { width: 90%; }

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.skeleton-badge {
    width: 60px;
    height: 24px;
    border-radius: 12px;
}

/* Stats skeleton */
.skeleton-stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg2);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.skeleton-stat-value {
    height: 2rem;
    width: 50%;
    border-radius: 4px;
}

.skeleton-stat-label {
    height: 0.875rem;
    width: 70%;
    border-radius: 4px;
}
