/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE APP - Dedicated Mobile Experience
   Complete separation from desktop - this file only affects mobile
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Hide mobile container on desktop */
@media (min-width: 769px) {
    #mobile-app-container {
        display: none !important;
    }
}

/* Hide desktop content on mobile viewports (CSS-only fallback before JS runs) */
@media (max-width: 768px) {
    body:has(#mobile-app-container:not(.hidden)) > .container {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Hide ALL desktop content when mobile app is active
   This is the primary mechanism - triggered by JS adding mobile-app-active class
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Nuclear option: hide everything except mobile container */
body.mobile-app-active > *:not(#mobile-app-container):not(.mobile-toast):not(script):not(style):not(link) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Ensure mobile container takes over completely */
body.mobile-app-active {
    overflow: hidden !important;
    height: 100vh;
    height: 100dvh;
    margin: 0 !important;
    padding: 0 !important;
}

/* Force mobile container visible and on top */
body.mobile-app-active #mobile-app-container {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Mobile App Container - Base
   ═══════════════════════════════════════════════════════════════════════════════ */

#mobile-app-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: #09090b;
    z-index: 9999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#mobile-app-container.hidden {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Mobile Screens - Shared Layout
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #09090b;
    overflow: hidden;
}

.mobile-screen.hidden {
    display: none !important;
}

.mobile-screen-header {
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    background: #18181b;
    border-bottom: 1px solid #27272a;
}

.mobile-screen-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Complete screen needs flex to allow centered content */
#mobile-complete-screen .mobile-screen-content {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Ensure debrief container fills the available space */
#mobile-complete-screen .debrief-container {
    flex: 1;
    width: 100%;
}

.mobile-screen-footer {
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    background: #18181b;
    border-top: 1px solid #27272a;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Sign In Screen
   ═══════════════════════════════════════════════════════════════════════════════ */

#mobile-sign-in-screen .mobile-screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    gap: 2rem;
}

.mobile-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.mobile-logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.3);
}

/* SVG logo variant */
.mobile-logo-icon.mobile-logo-svg {
    width: 100px;
    height: 100px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.mobile-logo-icon.mobile-logo-svg svg {
    width: 100%;
    height: 100%;
}

.mobile-logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fafafa;
    letter-spacing: -0.02em;
}

.mobile-logo-tagline {
    font-size: 0.875rem;
    color: #71717a;
}

/* Sign In Form */
.mobile-sign-in-form {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    color: #fafafa;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.mobile-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.mobile-input::placeholder {
    color: #52525b;
}

.mobile-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 48px; /* Touch-friendly */
}

.mobile-btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
}

.mobile-btn-primary:active {
    background: #2563eb;
    transform: scale(0.98);
}

.mobile-btn-secondary {
    background: #27272a;
    color: #fafafa;
    border: 1px solid #3f3f46;
}

.mobile-btn-secondary:active {
    background: #3f3f46;
    transform: scale(0.98);
}

.mobile-btn-row {
    display: flex;
    gap: 0.5rem;
}

.mobile-btn-row .mobile-btn {
    flex: 1;
}

/* Auth links row (magic link + forgot password) */
.mobile-auth-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.mobile-text-link {
    background: none;
    border: none;
    color: #71717a;
    font-size: 0.8125rem;
    padding: 0.25rem 0;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-text-link:active,
.mobile-text-link:hover {
    color: #a1a1aa;
}

.mobile-text-link:disabled {
    opacity: 0.6;
}

.mobile-link-dot {
    color: #3f3f46;
    font-size: 0.75rem;
}

/* OAuth Buttons */
.mobile-oauth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #52525b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mobile-oauth-divider::before,
.mobile-oauth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #27272a;
}

.mobile-oauth-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.mobile-oauth-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mobile-oauth-btn.google {
    background: white;
    color: #1f2937;
    border: none;
}

.mobile-oauth-btn.github {
    background: #161b22;
    color: white;
    border: 1px solid #30363d;
}

.mobile-oauth-btn.discord {
    background: #5865F2;
    color: white;
    border: none;
}

.mobile-oauth-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* OAuth Loading Overlay - shown during redirect back from OAuth provider */
.mobile-oauth-loading-overlay {
    position: absolute;
    inset: 0;
    background: #09090b;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.mobile-oauth-loading-overlay.hidden {
    display: none;
}

.mobile-oauth-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.mobile-oauth-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #a855f7;
    border-radius: 50%;
    animation: mobile-oauth-spin 0.8s linear infinite;
}

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

.mobile-oauth-loading-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-weight: 500;
}

.mobile-error-msg {
    color: #f87171;
    font-size: 0.875rem;
    text-align: center;
    padding: 0.5rem;
}

.mobile-error-msg.hidden {
    display: none;
}

.mobile-forgot-link {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    text-align: center;
    padding: 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.mobile-forgot-link:hover,
.mobile-forgot-link:active {
    color: rgba(255, 255, 255, 0.7);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Mode Selector Screen
   ═══════════════════════════════════════════════════════════════════════════════ */

#mobile-mode-screen .mobile-screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fafafa;
}

.mobile-header-subtitle {
    font-size: 0.75rem;
    color: #71717a;
    margin-top: 0.125rem;
}

.mobile-user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem 0.375rem 0.375rem;
    background: #27272a;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.8125rem;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-user-pill:active {
    background: #3f3f46;
    transform: scale(0.97);
}

.mobile-user-chevron-icon {
    color: #71717a;
    margin-left: 0.125rem;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.mobile-user-pill:active .mobile-user-chevron-icon {
    transform: translateY(1px);
}

.mobile-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: white;
    font-weight: 600;
}

.mobile-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Mode Grid */
.mobile-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1rem;
}

.mobile-mode-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.25rem 0.75rem;
    background: #18181b;
    border: 2px solid #27272a;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 100px;
}

.mobile-mode-card:active {
    transform: scale(0.97);
}

.mobile-mode-card.selected {
    border-color: var(--mode-color, #3b82f6);
    background: color-mix(in srgb, var(--mode-color, #3b82f6) 10%, #18181b);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode-color, #3b82f6) 20%, transparent);
}

.mobile-mode-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    background: linear-gradient(135deg, var(--mode-gradient-from, #3b82f6), var(--mode-gradient-to, #2563eb));
}

.mobile-mode-icon svg {
    width: 28px;
    height: 28px;
}

.mobile-mode-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #fafafa;
}

.mobile-mode-count {
    font-size: 0.6875rem;
    color: #71717a;
}

.mobile-mode-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--mode-color, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}

.mobile-mode-card.selected .mobile-mode-check {
    opacity: 1;
    transform: scale(1);
}

.mobile-mode-check svg {
    width: 12px;
    height: 12px;
    color: white;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MODE CARD SCANNER - KanjiOS Boot Sequence
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Scanner container overlay */
.mobile-mode-scanner {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mobile-mode-card.scanning .mobile-mode-scanner {
    opacity: 1;
}

/* Horizontal scan line */
.mobile-mode-scanner-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    top: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--mode-color, #3b82f6) 30%, 
        var(--mode-color, #3b82f6) 70%, 
        transparent 100%
    );
    box-shadow: 
        0 0 8px var(--mode-color, #3b82f6),
        0 0 20px color-mix(in srgb, var(--mode-color, #3b82f6) 50%, transparent);
    opacity: 0;
}

.mobile-mode-card.scanning .mobile-mode-scanner-line {
    animation: mode-scan-sweep 0.4s ease-out forwards;
}

@keyframes mode-scan-sweep {
    0% {
        top: 0%;
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Scan glow effect */
.mobile-mode-scanner-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 100% 50% at 50% 50%,
        color-mix(in srgb, var(--mode-color, #3b82f6) 15%, transparent) 0%,
        transparent 70%
    );
    opacity: 0;
}

.mobile-mode-card.scanning .mobile-mode-scanner-glow {
    animation: mode-scan-glow 0.4s ease-out forwards;
}

@keyframes mode-scan-glow {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* Post-scan reveal glow */
.mobile-mode-card.scan-complete {
    animation: mode-reveal-glow 0.5s ease-out forwards;
}

@keyframes mode-reveal-glow {
    0% {
        box-shadow: 
            0 0 0 1px rgba(255, 255, 255, 0.06),
            0 0 20px color-mix(in srgb, var(--mode-color, #3b82f6) 30%, transparent);
    }
    50% {
        box-shadow: 
            0 0 0 2px var(--mode-color, #3b82f6),
            0 0 30px color-mix(in srgb, var(--mode-color, #3b82f6) 40%, transparent);
    }
    100% {
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
    }
}

/* Count text reveal animation */
.mobile-mode-card.scan-complete .mobile-mode-count {
    animation: count-reveal 0.3s ease-out forwards;
}

@keyframes count-reveal {
    0% {
        opacity: 0;
        transform: translateY(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Syncing state text style */
.mobile-mode-count {
    transition: opacity 0.2s, transform 0.2s;
}

/* Start Review Button */
#mobile-start-review-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    border-radius: 14px;
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

#mobile-start-review-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

#mobile-start-review-btn:not(:disabled):active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ADD NEXT SECTION - KanjiOS Power Core Button
   A living, breathing "deploy next item" interface
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-add-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

/* Subtle circuit-like background pattern */
.mobile-add-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(90deg, transparent 24%, rgba(34, 197, 94, 0.03) 25%, rgba(34, 197, 94, 0.03) 26%, transparent 27%),
        linear-gradient(transparent 24%, rgba(34, 197, 94, 0.03) 25%, rgba(34, 197, 94, 0.03) 26%, transparent 27%);
    background-size: 20px 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-add-section:not(.hidden)::before {
    opacity: 1;
}

.mobile-add-section.hidden {
    display: none;
}

.mobile-add-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    position: relative;
    z-index: 1;
}

.mobile-add-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fafafa;
}

.mobile-add-remaining {
    font-size: 0.6875rem;
    color: #71717a;
}

/* Power Core Button - the main add action */
.mobile-add-btn {
    --core-color: #22c55e;
    --core-glow: rgba(34, 197, 94, 0.4);
    
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border: none;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    isolation: isolate;
    z-index: 1;
}

/* Ambient glow - always subtly pulsing when enabled */
.mobile-add-btn::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: var(--core-color);
    border-radius: 14px;
    z-index: -2;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.3s ease;
}

.mobile-add-btn:not(:disabled)::before {
    opacity: 0.4;
    animation: core-pulse 2s ease-in-out infinite;
}

@keyframes core-pulse {
    0%, 100% { 
        opacity: 0.3;
        transform: scale(1);
    }
    50% { 
        opacity: 0.5;
        transform: scale(1.02);
    }
}

/* Energy ring - rotating border effect */
.mobile-add-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 1.5px;
    background: conic-gradient(
        from var(--core-angle, 0deg),
        transparent 0deg,
        var(--core-color) 60deg,
        transparent 120deg,
        transparent 240deg,
        var(--core-color) 300deg,
        transparent 360deg
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-add-btn:not(:disabled)::after {
    opacity: 1;
    animation: core-ring-spin 4s linear infinite;
}

@supports (background: conic-gradient(red, blue)) {
    @property --core-angle {
        syntax: '<angle>';
        initial-value: 0deg;
        inherits: false;
    }
}

@keyframes core-ring-spin {
    to { --core-angle: 360deg; }
}

/* Fallback for browsers without @property */
@supports not (background: paint(something)) {
    .mobile-add-btn:not(:disabled)::after {
        animation: core-ring-fallback 4s linear infinite;
    }
    
    @keyframes core-ring-fallback {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
}

/* Active/Press state - energy discharge */
.mobile-add-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.mobile-add-btn:active:not(:disabled)::before {
    opacity: 0.8;
    animation: core-discharge 0.15s ease-out;
}

@keyframes core-discharge {
    0% { 
        transform: scale(1);
        opacity: 0.8;
    }
    50% { 
        transform: scale(1.3);
        opacity: 1;
    }
    100% { 
        transform: scale(1);
        opacity: 0.6;
    }
}

/* Disabled state - powered down */
.mobile-add-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: linear-gradient(135deg, #3f3f46 0%, #27272a 100%);
}

.mobile-add-btn:disabled::before,
.mobile-add-btn:disabled::after {
    display: none;
}

/* Adding state - energy channeling */
.mobile-add-btn.adding {
    pointer-events: none;
}

.mobile-add-btn.adding::after {
    animation: core-ring-spin 0.8s linear infinite;
    opacity: 1;
    background: conic-gradient(
        from var(--core-angle, 0deg),
        var(--core-color) 0deg,
        transparent 90deg,
        var(--core-color) 180deg,
        transparent 270deg
    );
}

/* Success flash */
.mobile-add-btn.success {
    animation: core-success 0.4s ease-out;
}

@keyframes core-success {
    0% { 
        box-shadow: 0 0 0 0 var(--core-glow);
    }
    50% { 
        box-shadow: 0 0 20px 8px var(--core-glow);
    }
    100% { 
        box-shadow: 0 0 0 0 var(--core-glow);
    }
}

/* The icon - subtle float animation */
.mobile-add-icon {
    font-size: 1.125rem;
    font-weight: 700;
    display: inline-flex;
    transition: transform 0.2s ease;
}

.mobile-add-btn:not(:disabled) .mobile-add-icon {
    animation: icon-float 3s ease-in-out infinite;
}

@keyframes icon-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

.mobile-add-btn:active:not(:disabled) .mobile-add-icon {
    animation: none;
    transform: scale(1.1) rotate(90deg);
}

/* Mode-aware theming - inherits from parent's mode color */
.mobile-add-section[data-mode-color="purple"] .mobile-add-btn {
    --core-color: #a855f7;
    --core-glow: rgba(168, 85, 247, 0.4);
    background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
}

.mobile-add-section[data-mode-color="red"] .mobile-add-btn {
    --core-color: #ef4444;
    --core-glow: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.mobile-add-section[data-mode-color="blue"] .mobile-add-btn {
    --core-color: #3b82f6;
    --core-glow: rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.mobile-add-section[data-mode-color="yellow"] .mobile-add-btn {
    --core-color: #eab308;
    --core-glow: rgba(234, 179, 8, 0.4);
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
}

.mobile-add-section[data-mode-color="pink"] .mobile-add-btn {
    --core-color: #ec4899;
    --core-glow: rgba(236, 72, 153, 0.4);
    background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
}

.mobile-add-section[data-mode-color="teal"] .mobile-add-btn {
    --core-color: #14b8a6;
    --core-glow: rgba(20, 184, 166, 0.4);
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
}


/* ═══════════════════════════════════════════════════════════════════════════════
   Review Screen
   ═══════════════════════════════════════════════════════════════════════════════ */

#mobile-review-screen {
    background: #0a0a0b;
}

/* Review Header */
.mobile-review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    background: #18181b;
    border-bottom: 1px solid #27272a;
}

.mobile-review-exit {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    font-size: 0.8125rem;
    color: #a1a1aa;
    cursor: pointer;
}

.mobile-review-exit svg {
    width: 16px;
    height: 16px;
}

.mobile-review-progress-wrap {
    flex: 1;
    max-width: 200px;
    margin: 0 1rem;
}

.mobile-review-progress-text {
    font-size: 0.6875rem;
    color: #71717a;
    text-align: center;
    margin-bottom: 0.25rem;
}

.mobile-review-progress-bar {
    height: 6px;
    background: #27272a;
    border-radius: 3px;
    overflow: hidden;
}

.mobile-review-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #6366f1);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.mobile-review-mode-badge {
    padding: 0.375rem 0.75rem;
    background: var(--mode-gradient-from, #3b82f6);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* Review Content */
.mobile-review-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Critical for flex children to scroll properly */
}

/* Review Tabs */
.mobile-review-tabs {
    display: flex;
    background: #18181b;
    border-bottom: 1px solid #27272a;
    flex-shrink: 0;
}

.mobile-review-tab {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #71717a;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-review-tab.active {
    color: #fafafa;
    border-bottom-color: #3b82f6;
}

/* Review Panels */
.mobile-review-panel {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Base padding - increased dynamically via .has-continue-button when Continue is visible */
    padding-bottom: 100px;
    transition: padding-bottom 0.2s ease;
}

/* When Continue button is visible, add extra padding so 4th MC option isn't covered */
.mobile-review-panel.has-continue-button {
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}

.mobile-review-panel.hidden {
    display: none !important;
}

/* Main Review Panel */
.mobile-review-main {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    /* Removed min-height: 100% - was preventing scroll */
}

.mobile-review-prompt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
}

.mobile-hero-glyph {
    font-size: clamp(3rem, 15vw, 6rem);
    font-weight: 400;
    color: #fafafa;
    line-height: 1.1;
    margin-bottom: 0.75rem;
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic Pro", sans-serif;
}

.mobile-hero-hint {
    font-size: 0.9375rem;
    color: #71717a;
    max-width: 280px;
}

/* MC Options */
.mobile-mc-options {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0 0.5rem;
    margin-top: auto;
    /* Extra bottom padding to ensure 4th option isn't covered by Continue button */
    padding-bottom: 1rem;
}

.mobile-mc-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #18181b;
    border: 2px solid #27272a;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
    text-align: left;
}

.mobile-mc-option:active:not(.correct):not(.incorrect) {
    transform: scale(0.98);
    background: #27272a;
}

/* Selected state (before final commit) */
.mobile-mc-option.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.mobile-mc-badge {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #27272a;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #a1a1aa;
}

.mobile-mc-text {
    flex: 1;
    font-size: 1rem;
    color: #fafafa;
    line-height: 1.4;
}

/* MC States */
.mobile-mc-option.correct {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.mobile-mc-option.correct .mobile-mc-badge {
    background: #22c55e;
    color: white;
}

.mobile-mc-option.incorrect {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.mobile-mc-option.incorrect .mobile-mc-badge {
    background: #ef4444;
    color: white;
}

.mobile-mc-option.show-correct {
    border-color: #22c55e;
}

.mobile-mc-option.show-correct .mobile-mc-badge {
    background: #22c55e;
    color: white;
}

/* Grading Buttons */
.mobile-grade-buttons {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    background: #18181b;
    border-top: 1px solid #27272a;
    flex-shrink: 0;
}

.mobile-grade-buttons.hidden {
    display: none !important;
}

.mobile-grade-btn {
    flex: 1;
    padding: 0.875rem 0.5rem;
    border: none;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.mobile-grade-btn:active {
    transform: scale(0.97);
}

.mobile-grade-btn.again {
    background: #dc2626;
}

.mobile-grade-btn.hard {
    background: #f59e0b;
}

.mobile-grade-btn.good {
    background: #22c55e;
}

.mobile-grade-btn.easy {
    background: #3b82f6;
}

/* Associations Panel */
.mobile-assoc-panel {
    padding: 1rem;
}

.mobile-assoc-empty {
    text-align: center;
    color: #71717a;
    padding: 2rem 1rem;
    font-size: 0.875rem;
}

.mobile-assoc-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    margin-bottom: 0.5rem;
}

.mobile-assoc-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #27272a;
    border-radius: 8px;
    font-size: 1.25rem;
}

.mobile-assoc-content {
    flex: 1;
    min-width: 0;
}

.mobile-assoc-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fafafa;
    margin-bottom: 0.125rem;
}

.mobile-assoc-desc {
    font-size: 0.8125rem;
    color: #a1a1aa;
    line-height: 1.4;
}

/* AI Panel */
.mobile-ai-panel {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.mobile-ai-empty {
    text-align: center;
    color: #71717a;
    padding: 2rem 1rem;
    font-size: 0.875rem;
}

/* AI Explain Button in Explain Tab */
.mobile-ai-explain-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-ai-explain-btn:active:not(:disabled) {
    transform: scale(0.98);
    opacity: 0.9;
}

.mobile-ai-explain-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-ai-explain-btn.generating {
    animation: pulse-btn 1.5s ease-in-out infinite;
}

/* Scanner container for Explain tab */
.mobile-ai-scanner-wrap {
    position: relative;
    min-height: 150px;
    margin-top: 1rem;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    overflow: hidden;
}

/* Scanner overlay for Explain tab */
.mobile-ai-scanner-wrap .mobile-scanner-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Content inside scanner wrap scrolls */
.mobile-ai-scanner-wrap .mobile-ai-content {
    position: relative;
    z-index: 1;
    min-height: 100px;
}

.mobile-ai-content {
    font-size: 0.9375rem;
    color: #e4e4e7;
    line-height: 1.6;
}

.mobile-ai-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #fafafa;
    margin: 1rem 0 0.5rem;
}

.mobile-ai-content ul,
.mobile-ai-content ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.mobile-ai-content li {
    margin: 0.25rem 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SESSION COMPLETE - KanjiOS Mission Debrief
   Full-screen celebration & stats display with HUD aesthetic
   ═══════════════════════════════════════════════════════════════════════════════ */

.debrief-container {
    --debrief-accent: #22c55e;
    --debrief-accent-glow: rgba(34, 197, 94, 0.3);
    
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    width: 100%;
    padding: 2rem 1.5rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0));
    box-sizing: border-box;
    background: #0a0a0c;
    overflow: hidden;
    /* Fallback for iOS */
    color: #fafafa;
}

/* Grid background */
.debrief-grid-bg {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(34, 197, 94, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 197, 94, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 20%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 20%, transparent 70%);
    opacity: 0;
    animation: debrief-grid-in 1s ease-out 0.3s forwards;
}

@keyframes debrief-grid-in {
    to { opacity: 1; }
}

/* Corner reticles */
.debrief-reticle {
    position: absolute;
    width: 32px;
    height: 32px;
    pointer-events: none;
    opacity: 0;
    animation: debrief-reticle-in 0.5s ease-out forwards;
}

.debrief-reticle.tl { top: 20px; left: 20px; animation-delay: 0.1s; }
.debrief-reticle.tr { top: 20px; right: 20px; animation-delay: 0.2s; }
.debrief-reticle.bl { bottom: calc(20px + env(safe-area-inset-bottom, 0)); left: 20px; animation-delay: 0.3s; }
.debrief-reticle.br { bottom: calc(20px + env(safe-area-inset-bottom, 0)); right: 20px; animation-delay: 0.4s; }

@keyframes debrief-reticle-in {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 0.6; transform: scale(1); }
}

.debrief-reticle::before,
.debrief-reticle::after {
    content: '';
    position: absolute;
    background: var(--debrief-accent);
}

.debrief-reticle::before { width: 16px; height: 2px; }
.debrief-reticle::after { width: 2px; height: 16px; }

.debrief-reticle.tl::before, .debrief-reticle.tl::after { top: 0; left: 0; }
.debrief-reticle.tr::before { top: 0; right: 0; }
.debrief-reticle.tr::after { top: 0; right: 0; }
.debrief-reticle.bl::before { bottom: 0; left: 0; }
.debrief-reticle.bl::after { bottom: 0; left: 0; }
.debrief-reticle.br::before { bottom: 0; right: 0; }
.debrief-reticle.br::after { bottom: 0; right: 0; }

/* Scan line */
.debrief-scanline {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    top: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--debrief-accent) 30%, 
        var(--debrief-accent) 70%, 
        transparent 100%
    );
    box-shadow: 0 0 20px var(--debrief-accent-glow);
    opacity: 0;
    animation: debrief-scan 1.5s ease-out 0.2s forwards;
}

@keyframes debrief-scan {
    0% { top: 0%; opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { top: 100%; opacity: 0; }
}

/* Header */
.debrief-header {
    text-align: center;
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: debrief-fade-in 0.5s ease-out 0.5s forwards;
}

@keyframes debrief-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.debrief-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--debrief-accent);
    font-family: ui-monospace, 'SF Mono', Monaco, monospace;
    padding: 0.375rem 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.debrief-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--debrief-accent);
    box-shadow: 0 0 8px var(--debrief-accent);
    animation: debrief-pulse 1.5s ease-in-out infinite;
}

@keyframes debrief-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.debrief-mode {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Grade ring */
.debrief-grade-container {
    text-align: center;
    margin-bottom: 2rem;
    opacity: 0;
    animation: debrief-grade-in 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.7s forwards;
}

@keyframes debrief-grade-in {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.debrief-grade-ring {
    position: relative;
    width: 140px;
    height: 140px;
    min-width: 140px;
    min-height: 140px;
    max-width: 140px;
    max-height: 140px;
    margin: 0 auto 0.75rem;
    flex-shrink: 0;
}

.debrief-grade-ring svg {
    width: 140px;
    height: 140px;
    max-width: 140px;
    max-height: 140px;
    transform: rotate(-90deg);
    display: block;
}

.debrief-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 8;
}

.debrief-ring-progress {
    fill: none;
    stroke: var(--debrief-accent);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    filter: drop-shadow(0 0 8px var(--debrief-accent-glow));
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.debrief-grade {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--debrief-accent);
    text-shadow: 0 0 30px var(--debrief-accent-glow);
    font-family: ui-monospace, 'SF Mono', Monaco, monospace;
}

.debrief-grade-label {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Stats */
.debrief-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: debrief-stats-in 0.5s ease-out 1s forwards;
}

@keyframes debrief-stats-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.debrief-stat {
    text-align: center;
    flex: 1;
}

.debrief-stat-label {
    font-size: 0.5625rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.debrief-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fafafa;
    font-family: ui-monospace, 'SF Mono', Monaco, monospace;
    font-variant-numeric: tabular-nums;
}

.debrief-stat-divider {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
}

/* Message */
.debrief-message {
    font-size: 0.9375rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    margin-bottom: 2rem;
    font-style: italic;
    opacity: 0;
    animation: debrief-fade-in 0.5s ease-out 1.2s forwards;
}

/* Return button */
.debrief-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    animation: debrief-fade-in 0.5s ease-out 1.4s forwards;
}

.debrief-btn:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--debrief-accent);
}

.debrief-btn-icon {
    font-size: 0.875rem;
    opacity: 0.6;
}

/* Footer */
.debrief-footer {
    position: absolute;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.25);
    font-family: ui-monospace, 'SF Mono', Monaco, monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Grade color variations */
.debrief-container[data-grade="S"] {
    --debrief-accent: #fbbf24;
    --debrief-accent-glow: rgba(251, 191, 36, 0.3);
}

.debrief-container[data-grade="A"] {
    --debrief-accent: #22c55e;
    --debrief-accent-glow: rgba(34, 197, 94, 0.3);
}

.debrief-container[data-grade="B"] {
    --debrief-accent: #3b82f6;
    --debrief-accent-glow: rgba(59, 130, 246, 0.3);
}

.debrief-container[data-grade="C"] {
    --debrief-accent: #a855f7;
    --debrief-accent-glow: rgba(168, 85, 247, 0.3);
}

.debrief-container[data-grade="D"] {
    --debrief-accent: #f97316;
    --debrief-accent-glow: rgba(249, 115, 22, 0.3);
}

.debrief-container[data-grade="F"] {
    --debrief-accent: #ef4444;
    --debrief-accent-glow: rgba(239, 68, 68, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Loading States
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
}

.mobile-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #27272a;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: mobile-spin 0.8s linear infinite;
}

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

@keyframes mobileToastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes mobileToastOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-12px) scale(0.95);
    }
}

.mobile-loading-text {
    font-size: 0.875rem;
    color: #71717a;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Utilities
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-text-center {
    text-align: center;
}

.mobile-mt-1 {
    margin-top: 0.5rem;
}

.mobile-mt-2 {
    margin-top: 1rem;
}

.mobile-opacity-60 {
    opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Detail Sheet - Slide-up Modal
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-detail-sheet {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
}

.mobile-detail-sheet.hidden {
    display: none !important;
}

.mobile-detail-sheet:not(.hidden) {
    pointer-events: auto;
}

/* Backdrop */
.mobile-detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.mobile-detail-sheet:not(.hidden) .mobile-detail-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

/* Container - Slide up from bottom */
.mobile-detail-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: #09090b;
    border-radius: 24px 24px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.mobile-detail-sheet:not(.hidden) .mobile-detail-container {
    transform: translateY(0);
}

/* Header */
.mobile-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #27272a;
    flex-shrink: 0;
}

.mobile-detail-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: #3f3f46;
    border-radius: 2px;
}

.mobile-detail-back,
.mobile-detail-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #27272a;
    border: none;
    border-radius: 10px;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-detail-back:active,
.mobile-detail-close:active {
    background: #3f3f46;
    transform: scale(0.95);
}

.mobile-detail-back.hidden {
    visibility: hidden;
}

.mobile-detail-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fafafa;
}

/* Scrollable Content */
.mobile-detail-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Hero Section */
.mobile-detail-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1.5rem 1.5rem;
    text-align: center;
    background: linear-gradient(180deg, #18181b 0%, #09090b 100%);
}

.mobile-detail-glyph {
    font-size: clamp(4rem, 20vw, 6rem);
    font-weight: 400;
    color: #fafafa;
    line-height: 1;
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic Pro", sans-serif;
    margin-bottom: 0.5rem;
}

.mobile-detail-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #27272a;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #a1a1aa;
    text-transform: capitalize;
    margin-bottom: 1rem;
}

.mobile-detail-audio {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: #27272a;
    border: none;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #fafafa;
    cursor: pointer;
    transition: all 0.15s;
}

.mobile-detail-audio:active {
    background: #3f3f46;
    transform: scale(0.97);
}

.mobile-detail-audio.hidden {
    display: none;
}

/* Info Section */
.mobile-detail-info {
    padding: 1rem 1.25rem;
}

.mobile-detail-info-row {
    display: flex;
    padding: 0.75rem 0;
    border-bottom: 1px solid #1f1f23;
}

.mobile-detail-info-row:last-child {
    border-bottom: none;
}

.mobile-detail-info-label {
    flex-shrink: 0;
    width: 90px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mobile-detail-info-value {
    flex: 1;
    font-size: 0.9375rem;
    color: #e4e4e7;
    line-height: 1.5;
}

/* Section containers for JP Def and Explain */
.mobile-detail-section {
    margin: 0.5rem 1.25rem 1rem;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 16px;
    overflow: hidden;
}

.mobile-detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: #1f1f23;
    border-bottom: 1px solid #27272a;
}

.mobile-detail-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #a1a1aa;
}

.mobile-detail-ai-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-detail-ai-btn:active:not(:disabled) {
    transform: scale(0.95);
    opacity: 0.9;
}

.mobile-detail-ai-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-detail-ai-btn.generating {
    animation: pulse-btn 1.5s ease-in-out infinite;
}

@keyframes pulse-btn {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* JP Definition */
.mobile-detail-jpdef {
    position: relative;
    min-height: 60px;
    padding: 1rem;
}

.mobile-detail-jpdef-text {
    position: relative;
    font-size: 1rem;
    color: #e4e4e7;
    line-height: 1.6;
}

.mobile-detail-jpdef-text.empty {
    color: #52525b;
    font-style: italic;
}

/* JP Definition Typewriter (during generation) */
.mobile-jpdef-typewriter {
    font-size: 1rem;
    color: #e4e4e7;
    line-height: 1.6;
    min-height: 1.6em;
}

.mobile-jpdef-timer {
    position: absolute;
    bottom: 0;
    right: 0;
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.35);
    font-family: ui-monospace, 'SF Mono', Monaco, monospace;
    font-variant-numeric: tabular-nums;
}

/* Examples Section */
.mobile-detail-examples-section.hidden {
    display: none;
}

.mobile-detail-examples {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mobile-detail-example {
    background: #27272a;
    border-radius: 10px;
    padding: 0.875rem 1rem;
}

.mobile-detail-example-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.mobile-detail-example-jp {
    font-size: 1rem;
    color: #fafafa;
    line-height: 1.6;
    flex: 1;
}

.mobile-detail-example-play {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3b82f620;
    border: 1px solid #3b82f640;
    border-radius: 8px;
    color: #3b82f6;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-detail-example-play:active {
    transform: scale(0.92);
    background: #3b82f630;
}

.mobile-detail-example-play.tts-active {
    background: #3b82f6;
    color: white;
}

.mobile-detail-example-en {
    font-size: 0.8125rem;
    color: #a1a1aa;
    line-height: 1.5;
    margin-top: 0.375rem;
}

/* Reading Pills (tappable for TTS) */
.mobile-reading-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.mobile-reading-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    font-size: 0.9375rem;
    color: #e4e4e7;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-reading-pill:active {
    transform: scale(0.95);
    background: #3b82f620;
    border-color: #3b82f6;
}

.mobile-reading-pill.tts-active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Sound Toggle in Account Sheet */
.mobile-sound-item {
    position: relative;
}

.mobile-sound-switch {
    display: flex;
    align-items: center;
}

.mobile-sound-switch-track {
    width: 44px;
    height: 26px;
    background: #3f3f46;
    border-radius: 13px;
    position: relative;
    transition: background 0.2s ease;
}

.mobile-sound-item.sound-enabled .mobile-sound-switch-track {
    background: #22c55e;
}

.mobile-sound-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.mobile-sound-item.sound-enabled .mobile-sound-switch-thumb {
    transform: translateX(18px);
}

/* Detail Audio Button styling */
.mobile-detail-audio {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: #3b82f620;
    border: 1px solid #3b82f640;
    border-radius: 8px;
    color: #3b82f6;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-detail-audio:active {
    transform: scale(0.95);
    background: #3b82f630;
}

.mobile-detail-audio svg {
    flex-shrink: 0;
}

/* Make JP definition text tappable when it has content */
.mobile-detail-jpdef-text:not(.empty) {
    cursor: pointer;
    transition: background 0.15s ease;
    border-radius: 4px;
    margin: -0.25rem;
    padding: 0.25rem;
}

.mobile-detail-jpdef-text:not(.empty):active {
    background: #3b82f610;
}

.mobile-detail-empty {
    text-align: center;
    color: #52525b;
    font-size: 0.875rem;
    font-style: italic;
    padding: 0.5rem;
}

/* AI Explanation styles (kept for Explain tab markdown rendering) */
.mobile-ai-explanation {
    font-size: 0.9375rem;
    color: #e4e4e7;
    line-height: 1.7;
}

.mobile-ai-explanation h3,
.mobile-ai-explanation h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #fafafa;
    margin: 1.25rem 0 0.5rem;
}

.mobile-ai-explanation h3:first-child,
.mobile-ai-explanation h4:first-child {
    margin-top: 0;
}

.mobile-ai-explanation p {
    margin: 0.75rem 0;
}

.mobile-ai-explanation p:first-child {
    margin-top: 0;
}

.mobile-ai-explanation strong {
    color: #fafafa;
    font-weight: 600;
}

.mobile-ai-explanation em {
    color: #d4d4d8;
    font-style: italic;
}

.mobile-ai-explanation code {
    background: #27272a;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875em;
    color: #fbbf24;
}

.mobile-ai-explanation ul,
.mobile-ai-explanation ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.mobile-ai-explanation li {
    margin: 0.375rem 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Mobile Scanner Animation - The Beloved UI
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Container for scanner effect */
.mobile-scanner-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: inherit;
}

.mobile-scanner-container.active {
    opacity: 1;
}

/* Subtle grid background */
.mobile-scanner-grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.6;
}

/* Horizontal scan line */
.mobile-scanner-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(59, 130, 246, 0.4) 20%, 
        rgba(59, 130, 246, 0.8) 50%, 
        rgba(59, 130, 246, 0.4) 80%, 
        transparent 100%
    );
    box-shadow: 
        0 0 8px rgba(59, 130, 246, 0.4),
        0 0 20px rgba(59, 130, 246, 0.2);
    opacity: 0;
}

.mobile-scanner-container.active .mobile-scanner-line {
    opacity: 1;
    animation: mobile-scanner-sweep 2s ease-in-out infinite;
}

@keyframes mobile-scanner-sweep {
    0%, 100% { top: 10%; }
    50% { top: 90%; }
}

/* Corner reticles */
.mobile-scanner-reticle {
    position: absolute;
    width: 16px;
    height: 16px;
    opacity: 0;
}

.mobile-scanner-container.active .mobile-scanner-reticle {
    opacity: 0.5;
    animation: mobile-reticle-pulse 2s ease-in-out infinite;
}

@keyframes mobile-reticle-pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

.mobile-scanner-reticle::before,
.mobile-scanner-reticle::after {
    content: '';
    position: absolute;
    background: #3b82f6;
}

/* Top-left */
.mobile-scanner-reticle.tl {
    top: 8px;
    left: 8px;
}
.mobile-scanner-reticle.tl::before {
    width: 10px;
    height: 2px;
    top: 0;
    left: 0;
}
.mobile-scanner-reticle.tl::after {
    width: 2px;
    height: 10px;
    top: 0;
    left: 0;
}

/* Top-right */
.mobile-scanner-reticle.tr {
    top: 8px;
    right: 8px;
    animation-delay: 0.3s !important;
}
.mobile-scanner-reticle.tr::before {
    width: 10px;
    height: 2px;
    top: 0;
    right: 0;
}
.mobile-scanner-reticle.tr::after {
    width: 2px;
    height: 10px;
    top: 0;
    right: 0;
}

/* Bottom-left */
.mobile-scanner-reticle.bl {
    bottom: 8px;
    left: 8px;
    animation-delay: 0.6s !important;
}
.mobile-scanner-reticle.bl::before {
    width: 10px;
    height: 2px;
    bottom: 0;
    left: 0;
}
.mobile-scanner-reticle.bl::after {
    width: 2px;
    height: 10px;
    bottom: 0;
    left: 0;
}

/* Bottom-right */
.mobile-scanner-reticle.br {
    bottom: 8px;
    right: 8px;
    animation-delay: 0.9s !important;
}
.mobile-scanner-reticle.br::before {
    width: 10px;
    height: 2px;
    bottom: 0;
    right: 0;
}
.mobile-scanner-reticle.br::after {
    width: 2px;
    height: 10px;
    bottom: 0;
    right: 0;
}

/* Center glow */
.mobile-scanner-glow {
    position: absolute;
    inset: 20%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-scanner-container.active .mobile-scanner-glow {
    opacity: 1;
    animation: mobile-glow-pulse 2s ease-in-out infinite;
}

@keyframes mobile-glow-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Scanner Color States - Synced with Generation Progress
   ═══════════════════════════════════════════════════════════════════════════════ */

/* SLOW state (yellow) - after 3 seconds */
.mobile-scanner-container.active.scanner-slow .mobile-scanner-reticle::before,
.mobile-scanner-container.active.scanner-slow .mobile-scanner-reticle::after {
    background: #f59e0b;
}
.mobile-scanner-container.active.scanner-slow .mobile-scanner-line {
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(245, 158, 11, 0.4) 20%, 
        rgba(245, 158, 11, 0.8) 50%, 
        rgba(245, 158, 11, 0.4) 80%, 
        transparent 100%
    );
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4), 0 0 20px rgba(245, 158, 11, 0.2);
}
.mobile-scanner-container.active.scanner-slow .mobile-scanner-glow {
    background: radial-gradient(circle, rgba(245, 158, 11, 0.1) 0%, transparent 70%);
}
.mobile-scanner-container.active.scanner-slow .mobile-scanner-grid {
    background-image: 
        linear-gradient(rgba(245, 158, 11, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(245, 158, 11, 0.04) 1px, transparent 1px);
}

/* CRITICAL state (red) - after 8 seconds */
.mobile-scanner-container.active.scanner-critical .mobile-scanner-reticle::before,
.mobile-scanner-container.active.scanner-critical .mobile-scanner-reticle::after {
    background: #ef4444;
}
.mobile-scanner-container.active.scanner-critical .mobile-scanner-line {
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(239, 68, 68, 0.4) 20%, 
        rgba(239, 68, 68, 0.8) 50%, 
        rgba(239, 68, 68, 0.4) 80%, 
        transparent 100%
    );
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4), 0 0 20px rgba(239, 68, 68, 0.2);
}
.mobile-scanner-container.active.scanner-critical .mobile-scanner-glow {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.1) 0%, transparent 70%);
}
.mobile-scanner-container.active.scanner-critical .mobile-scanner-grid {
    background-image: 
        linear-gradient(rgba(239, 68, 68, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(239, 68, 68, 0.04) 1px, transparent 1px);
}

/* SUCCESS state (green) - generation complete */
.mobile-scanner-container.active.scanner-success .mobile-scanner-reticle::before,
.mobile-scanner-container.active.scanner-success .mobile-scanner-reticle::after {
    background: #22c55e;
}
.mobile-scanner-container.active.scanner-success .mobile-scanner-line {
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(34, 197, 94, 0.4) 20%, 
        rgba(34, 197, 94, 0.8) 50%, 
        rgba(34, 197, 94, 0.4) 80%, 
        transparent 100%
    );
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4), 0 0 20px rgba(34, 197, 94, 0.2);
}
.mobile-scanner-container.active.scanner-success .mobile-scanner-glow {
    background: radial-gradient(circle, rgba(34, 197, 94, 0.15) 0%, transparent 70%);
}
.mobile-scanner-container.active.scanner-success .mobile-scanner-grid {
    background-image: 
        linear-gradient(rgba(34, 197, 94, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 197, 94, 0.05) 1px, transparent 1px);
}

/* Smooth color transitions */
.mobile-scanner-reticle::before,
.mobile-scanner-reticle::after,
.mobile-scanner-line,
.mobile-scanner-glow,
.mobile-scanner-grid {
    transition: background 0.5s ease, box-shadow 0.5s ease, background-image 0.5s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Association Items - Tap Interaction
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-assoc-item {
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-assoc-item:active {
    background: #27272a;
    transform: scale(0.98);
}

/* Arrow indicator for tappable items */
.mobile-assoc-item::after {
    content: '›';
    flex-shrink: 0;
    font-size: 1.25rem;
    color: #52525b;
    margin-left: 0.5rem;
}

/* Hero glyph - tappable when in review */
.mobile-hero-glyph.tappable {
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-hero-glyph.tappable:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   iOS Install Prompt - "Add to Home Screen" tooltip
   ═══════════════════════════════════════════════════════════════════════════════ */

#ios-install-prompt {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 20px);
    left: 0;
    right: 0;
    z-index: 1000000;
    display: flex;
    justify-content: center;
    padding: 0 16px 20px;
    pointer-events: none;
}

.ios-install-prompt {
    position: relative;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    padding: 16px 40px 16px 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 4px 16px rgba(59, 130, 246, 0.15);
    max-width: 340px;
    width: 100%;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-install-prompt.visible {
    opacity: 1;
    transform: translateY(0);
}

.ios-install-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.ios-install-close:hover,
.ios-install-close:active {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.ios-install-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.ios-install-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.ios-install-text {
    flex: 1;
    min-width: 0;
}

.ios-install-text strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.ios-install-text p {
    font-size: 13px;
    color: #94a3b8;
    margin: 0;
    line-height: 1.5;
}

.ios-install-text p strong {
    display: inline;
    font-size: inherit;
    color: #60a5fa;
}

.ios-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 2px;
    color: #60a5fa;
}

.ios-install-arrow {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #0f172a;
}

/* Subtle pulse animation on the icon */
@keyframes ios-install-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    }
}

.ios-install-prompt.visible .ios-install-icon {
    animation: ios-install-pulse 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Account Sheet - Action Menu
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-account-sheet {
    position: fixed;
    inset: 0;
    z-index: 10001;
    pointer-events: none;
}

.mobile-account-sheet.hidden {
    display: none !important;
}

.mobile-account-sheet:not(.hidden) {
    pointer-events: auto;
}

.mobile-account-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.mobile-account-sheet:not(.hidden) .mobile-account-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.mobile-account-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #18181b;
    border-radius: 20px 20px 0 0;
    padding: 0.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.mobile-account-sheet:not(.hidden) .mobile-account-container {
    transform: translateY(0);
}

/* Drag handle indicator */
.mobile-sheet-handle {
    width: 36px;
    height: 4px;
    background: #3f3f46;
    border-radius: 2px;
    margin: 0.5rem auto 1rem;
}

/* User info header */
.mobile-account-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: #27272a;
    border-radius: 12px;
}

.mobile-account-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.125rem;
    flex-shrink: 0;
    overflow: hidden;
}

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

.mobile-account-info {
    flex: 1;
    min-width: 0;
}

.mobile-account-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fafafa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-account-email {
    font-size: 0.8125rem;
    color: #71717a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Account Stats (Streak) */
.mobile-account-stats {
    display: flex;
    gap: 0.75rem;
    padding: 0 0.5rem;
    margin-bottom: 0.75rem;
}

.mobile-account-stat {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: #27272a;
    border-radius: 12px;
    border: 1px solid #3f3f46;
}

.mobile-stat-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-stat-icon img {
    width: 24px;
    height: 24px;
}

.mobile-account-streak .mobile-stat-icon {
    filter: drop-shadow(0 0 8px rgba(249, 115, 22, 0.4));
}

/* Streak glow animation for active streaks */
.mobile-account-streak.active .mobile-stat-icon {
    animation: streakGlow 2s ease-in-out infinite;
}

@keyframes streakGlow {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(249, 115, 22, 0.4)); }
    50% { filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.6)); }
}

.mobile-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fafafa;
    line-height: 1;
}

.mobile-account-streak .mobile-stat-value {
    color: #FB923C;
}

.mobile-stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Sync Status */
.mobile-sync-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0 0.5rem 0.75rem;
    background: rgba(39, 39, 42, 0.6);
    border: 1px solid #3f3f46;
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}

.mobile-sync-status:active {
    background: rgba(63, 63, 70, 0.8);
    transform: scale(0.98);
}

.mobile-sync-indicator {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-sync-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.mobile-sync-indicator.syncing .mobile-sync-icon {
    animation: syncSpin 1s linear infinite;
}

@keyframes syncSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mobile-sync-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mobile-sync-state {
    font-size: 0.875rem;
    font-weight: 500;
    color: #e4e4e7;
}

.mobile-sync-detail {
    font-size: 0.75rem;
    color: #71717a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-sync-action {
    padding: 0.5rem 1rem;
    background: #3b82f6;
    border-radius: 8px;
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.15s;
}

.mobile-sync-action.syncing {
    opacity: 0.7;
    pointer-events: none;
}

.mobile-sync-btn-text {
    display: block;
}

/* Menu items */
.mobile-account-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.mobile-account-menu-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: #e4e4e7;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    text-align: left;
}

.mobile-account-menu-item:active {
    background: #27272a;
}

.mobile-account-menu-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #27272a;
    border-radius: 10px;
    color: #a1a1aa;
    flex-shrink: 0;
}

.mobile-account-menu-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.mobile-account-menu-label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #fafafa;
}

.mobile-account-menu-desc {
    font-size: 0.75rem;
    color: #71717a;
}

.mobile-account-menu-arrow {
    color: #52525b;
    flex-shrink: 0;
}

/* Export/Import compact row */
.mobile-account-data-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.mobile-data-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(63, 63, 70, 0.5);
    border: 1px solid rgba(82, 82, 91, 0.5);
    border-radius: 0.75rem;
    color: #a1a1aa;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mobile-data-btn:active {
    background: rgba(82, 82, 91, 0.6);
    transform: scale(0.98);
}

.mobile-data-btn svg {
    flex-shrink: 0;
}

/* Clear local data styling */
.mobile-account-cleardata .mobile-account-menu-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.mobile-account-cleardata .mobile-account-menu-label {
    color: #fbbf24;
}

/* Sign out styling */
.mobile-account-signout .mobile-account-menu-icon {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.mobile-account-signout .mobile-account-menu-label {
    color: #f87171;
}

/* Close/Cancel button */
.mobile-account-close {
    width: 100%;
    padding: 0.875rem;
    background: #27272a;
    border: none;
    border-radius: 12px;
    color: #a1a1aa;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.mobile-account-close:active {
    background: #3f3f46;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Backup Sheet - Nested Sheet for Backup Management
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-backup-sheet {
    position: fixed;
    inset: 0;
    z-index: 10002;
    pointer-events: none;
}

.mobile-backup-sheet.hidden {
    display: none !important;
}

.mobile-backup-sheet:not(.hidden) {
    pointer-events: auto;
}

.mobile-backup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
}

.mobile-backup-sheet:not(.hidden) .mobile-backup-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.mobile-backup-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 80vh;
    background: #09090b;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
}

.mobile-backup-sheet:not(.hidden) .mobile-backup-container {
    transform: translateY(0);
}

/* Header */
.mobile-backup-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #27272a;
    flex-shrink: 0;
}

.mobile-backup-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: #3f3f46;
    border-radius: 2px;
}

.mobile-backup-back {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #27272a;
    border: none;
    border-radius: 10px;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-backup-back:active {
    background: #3f3f46;
    transform: scale(0.95);
}

.mobile-backup-refresh {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-backup-refresh:active {
    background: #3f3f46;
    transform: scale(0.95);
}

.mobile-backup-refresh:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mobile-backup-refresh.spinning svg {
    animation: spin 0.8s linear infinite;
}

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

.mobile-backup-title {
    flex: 1;
    text-align: center;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #fafafa;
}

.mobile-backup-spacer {
    width: 36px;
}

/* Content */
.mobile-backup-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.mobile-backup-desc {
    font-size: 0.8125rem;
    color: #71717a;
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* Loading state */
.mobile-backup-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    color: #71717a;
    font-size: 0.875rem;
}

.mobile-backup-loading.hidden {
    display: none !important;
}

/* Backup list */
.mobile-backup-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-backup-list.hidden {
    display: none !important;
}

.mobile-backup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem;
    background: #18181b;
    border-radius: 12px;
    border: 1px solid #27272a;
}

.mobile-backup-item-info {
    flex: 1;
    min-width: 0;
}

.mobile-backup-item-date {
    font-size: 0.875rem;
    font-weight: 500;
    color: #e4e4e7;
    margin-bottom: 0.25rem;
}

.mobile-backup-item-meta {
    font-size: 0.75rem;
    color: #71717a;
}

.mobile-backup-item-restore {
    padding: 0.5rem 0.875rem;
    background: #3b82f6;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
    flex-shrink: 0;
}

.mobile-backup-item-restore:active {
    background: #2563eb;
    transform: scale(0.95);
}

.mobile-backup-item-restore:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Empty state */
.mobile-backup-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.5rem 1rem;
    color: #52525b;
    font-size: 0.875rem;
}

.mobile-backup-empty.hidden {
    display: none !important;
}

.mobile-backup-empty-icon {
    color: #3f3f46;
}

/* Actions */
.mobile-backup-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    border-top: 1px solid #27272a;
    flex-shrink: 0;
}

.mobile-backup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    border: none;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}

.mobile-backup-btn:active {
    transform: scale(0.98);
}

.mobile-backup-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mobile-backup-btn-primary {
    background: #22c55e;
    color: white;
}

.mobile-backup-btn-primary:active:not(:disabled) {
    background: #16a34a;
}

.mobile-backup-btn-secondary {
    background: #27272a;
    color: #e4e4e7;
}

.mobile-backup-btn-secondary:active:not(:disabled) {
    background: #3f3f46;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Confirmation Dialog
   ═══════════════════════════════════════════════════════════════════════════════ */

.mobile-confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 10003;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    pointer-events: none;
}

.mobile-confirm-dialog.hidden {
    display: none !important;
}

.mobile-confirm-dialog:not(.hidden) {
    pointer-events: auto;
}

.mobile-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
}

.mobile-confirm-dialog:not(.hidden) .mobile-confirm-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.mobile-confirm-container {
    position: relative;
    background: #18181b;
    border-radius: 20px;
    padding: 1.5rem;
    max-width: 320px;
    width: 100%;
    text-align: center;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.mobile-confirm-dialog:not(.hidden) .mobile-confirm-container {
    transform: scale(1);
    opacity: 1;
}

.mobile-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 50%;
    color: #f87171;
}

.mobile-confirm-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #fafafa;
    margin: 0 0 0.5rem;
}

.mobile-confirm-message {
    font-size: 0.875rem;
    color: #71717a;
    line-height: 1.5;
    margin: 0 0 1.5rem;
}

.mobile-confirm-buttons {
    display: flex;
    gap: 0.75rem;
}

.mobile-confirm-btn {
    flex: 1;
    padding: 0.875rem;
    border: none;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}

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

.mobile-confirm-btn-cancel {
    background: #27272a;
    color: #a1a1aa;
}

.mobile-confirm-btn-cancel:active {
    background: #3f3f46;
}

.mobile-confirm-btn-danger {
    background: #ef4444;
    color: white;
}

.mobile-confirm-btn-danger:active {
    background: #dc2626;
}

.mobile-confirm-btn-primary {
    background: #22c55e;
    color: white;
}

.mobile-confirm-btn-primary:active {
    background: #16a34a;
}

/* Upgrade to Pro Button */
.mobile-upgrade-btn {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%) !important;
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    position: relative;
    overflow: hidden;
}

.mobile-upgrade-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.1), transparent);
    animation: upgradeShimmer 3s infinite;
}

@keyframes upgradeShimmer {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

.mobile-upgrade-btn:active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25) 0%, rgba(99, 102, 241, 0.25) 100%) !important;
}

.mobile-upgrade-icon {
    background: linear-gradient(135deg, #a78bfa, #818cf8) !important;
    color: white !important;
}

.mobile-upgrade-btn .mobile-account-menu-label {
    color: #c4b5fd;
    font-weight: 600;
}

.mobile-upgrade-btn .mobile-account-menu-desc {
    color: #a78bfa;
}

.mobile-upgrade-btn .mobile-account-menu-arrow {
    color: #a78bfa;
}

.mobile-pro-only.hidden,
.mobile-upgrade-btn.hidden {
    display: none !important;
}

