/* ============================================ */
/* FLOATING EDITOR MENU (MOBILE) */
/* ============================================ */

#floatingEditorToggle {
    display: none;
    position: fixed;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 44px;
    border-radius: 0;
    background: white;
    border: none;
    border-left: 1px solid #e0e0e0;
    border-top: 1px solid #e0e0e0;
    color: #333;
    font-size: 24px;
    cursor: pointer;
    box-shadow: -2px -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10002;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#floatingEditorToggle:active {
    transform: scale(0.95);
    background: #f5f5f5;
}

#floatingEditorMenu {
    display: none;
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    overflow: visible;
    padding: 0;
    flex-direction: column;
    border-radius: 12px;
    width: 90vw;
    max-width: 400px;
    height: auto;
    backdrop-filter: blur(10px);
}

#floatingEditorMenu.active {
    display: flex;
}

#floatingMenuHandle {
    display: flex;
    height: 14px;
    background: var(--accent-gold);
    border-radius: 12px 12px 0 0;
    cursor: grab;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    touch-action: none;
    /* Prevents scroll on drag handle; compensates for passive:true on touchmove */
}

#floatingMenuHandle::after {
    content: "";
    width: 30px;
    height: 3px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 2px;
}

#floatingMenuHandle:active {
    cursor: grabbing;
}

#floatingMenuContent {
    padding: 10px;
    background: transparent;
    display: flex;
    flex-wrap: wrap;
    /* Permet le retour à la ligne automatique */
    gap: 8px;
    align-items: center;
    justify-content: center;
    height: auto;
    /* Hauteur s'adapte au nombre de lignes */
}

/* Barre de sous-menu avancé intégrée à la grille */
#advancedMenuBar {
    padding: 10px;
    background: rgba(0, 0, 0, 0.03);
    display: none !important;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    height: auto;
    border-top: 1px solid var(--border-color);
    width: 100%;
    border-radius: 0 0 12px 12px;
}

#advancedMenuBar.active {
    display: flex !important;
}

.floating-toolbar-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.floating-btn-mini {
    min-width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    color: #333;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 400;
    position: relative;
    flex-shrink: 0;
}

.floating-btn-mini:active {
    background: #f0f0f0;
    border-radius: 6px;
}

.floating-select-mini {
    height: 36px;
    padding: 0 28px 0 10px;
    background: transparent;
    border: none;
    color: #333;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    flex-shrink: 0;
}

.floating-select-mini:active {
    background-color: #f0f0f0;
    border-radius: 6px;
}

.floating-divider {
    width: 1px;
    height: 24px;
    background: #e0e0e0;
    flex-shrink: 0;
}

/* Storage icon mobile - déjà géré dans la media query principale */
/* Link Editor Modal */
.link-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.link-editor-modal {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    min-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.link-editor-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.link-editor-field {
    margin-bottom: 1rem;
}

.link-editor-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.link-editor-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
}

.link-editor-colors {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.link-color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
}

.link-color-option:hover {
    transform: scale(1.1);
}

.link-color-option.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-primary);
}

.link-editor-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Relation Graph Styles */
.relation-graph {
    width: 100%;
    height: 100%;
    position: relative;
}

.relation-node {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 3px solid var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

.relation-node:hover {
    transform: scale(1.2);
    z-index: 100;
}

.relation-node-avatar {
    font-size: 2rem;
}

.relation-node-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px var(--shadow);
}

.relation-legend {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    box-shadow: 0 4px 12px var(--shadow);
}

.relation-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.relation-legend-line {
    width: 30px;
    height: 3px;
}

/* Timeline Viz Styles */
.timeline-viz-container {
    width: 100%;
    padding: 2rem;
    overflow-x: auto;
}

.timeline-viz {
    display: flex;
    position: relative;
    min-width: 100%;
    padding: 2rem 0;
}

.timeline-viz-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-gold);
    transform: translateY(-50%);
}

.timeline-viz-item {
    position: relative;
    flex: 0 0 200px;
    padding: 0 1rem;
}

.timeline-viz-marker {
    width: 20px;
    height: 20px;
    background: var(--accent-gold);
    border: 4px solid white;
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-viz-marker:hover {
    transform: scale(1.5);
    background: var(--accent-red);
}

.timeline-viz-content {
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 2rem;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.2s ease;
}

.timeline-viz-content:hover {
    border-color: var(--accent-gold);
    transform: translateY(-4px);
}

.timeline-viz-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.timeline-viz-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.timeline-viz-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Metro Timeline Styles moved to 08.visualizations.css */

/* Plot Graph Styles */
.plot-graph {
    width: 100%;
    height: 100%;
    padding: 2rem;
}

.plot-legend {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    box-shadow: 0 4px 12px var(--shadow);
}

/* Map Styles */
.world-map-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;
    background: #f0e6d2;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 20px, rgba(0, 0, 0, 0.03) 20px, rgba(0, 0, 0, 0.03) 21px),
        repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(0, 0, 0, 0.03) 20px, rgba(0, 0, 0, 0.03) 21px);
}

.world-map {
    min-width: 100%;
    min-height: 100%;
    position: relative;
    cursor: grab;
}

.world-map:active {
    cursor: grabbing;
}

.map-location {
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--accent-red);
    border: 3px solid white;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.2s ease;
}

.map-location:hover {
    transform: rotate(-45deg) scale(1.2);
    z-index: 100;
}

.map-location::after {
    content: attr(data-label);
    position: absolute;
    top: 45px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px var(--shadow);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.map-location:hover::after {
    opacity: 1;
}

.map-upload-zone {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.map-upload-zone:hover {
    border-color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.05);
}

.map-upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.map-uploaded-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Toolbar pour les visualisations */
.visualization-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.viz-tool-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Crimson Pro', serif;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.viz-tool-btn:hover {
    background: var(--accent-gold);
    color: var(--bg-secondary);
    border-color: var(--accent-gold);
}

.viz-tool-btn.active {
    background: var(--accent-gold);
    color: var(--bg-secondary);
    border-color: var(--accent-gold);
}

/* ========================================
           MOBILE BOTTOM NAVIGATION BAR
           ======================================== */

.mobile-bottom-nav {
    display: none;
    /* Shown only at <900px via media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 10000;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.6rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 4px 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: inherit;
}

.mobile-bottom-nav-item i {
    width: 22px;
    height: 22px;
}

.mobile-bottom-nav-item.active {
    color: var(--accent-gold);
}

.mobile-bottom-nav-item:active {
    color: var(--accent-gold);
    transform: scale(0.92);
}

/* ========================================
           MOBILE TOOLS BOTTOM SHEET
           ======================================== */

.mobile-tools-sheet {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10010;
}

.mobile-tools-sheet.active {
    display: block;
}

.mobile-tools-sheet-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    animation: mobileSheetFadeIn 0.2s ease;
}

.mobile-tools-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    animation: mobileSheetSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    max-height: 60vh;
    overflow-y: auto;
}

@keyframes mobileSheetSlideUp {
    to {
        transform: translateY(0);
    }
}

@keyframes mobileSheetFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.mobile-tools-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto 12px;
}

.mobile-tools-sheet-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
}

.mobile-tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.mobile-tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    min-height: 64px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.mobile-tool-item i {
    width: 24px;
    height: 24px;
}

.mobile-tool-item:active {
    background: var(--accent-gold);
    color: white;
    border-color: var(--accent-gold);
    transform: scale(0.95);
}

/* ========================================
           RESPONSIVE DESIGN - MOBILE & TABLET
           ======================================== */

/* Mobile Menu Handle (poignée latérale) */
/* Mobile Menu Handle (poignée latérale) - Style blanc épuré */
.mobile-menu-handle {
    display: none;
    position: fixed;
    top: 50%;
    left: 50px;
    transform: translateY(-50%);
    width: 24px;
    height: 100px;
    background: white;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    z-index: 10003;
    transition: all 0.3s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-left: none;
}

.mobile-menu-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 50px;
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0.1) 0%,
            rgba(0, 0, 0, 0.3) 50%,
            rgba(0, 0, 0, 0.1) 100%);
    border-radius: 1px;
}

.mobile-menu-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
}

.mobile-menu-handle:active {
    transform: translateY(-50%) translateX(6px);
    box-shadow: 1px 0 8px rgba(0, 0, 0, 0.1);
}

.mobile-menu-handle.hidden {
    opacity: 0;
    pointer-events: none;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Mobile Navigation Dropdown */
.mobile-nav-dropdown {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: rgba(var(--bg-secondary-rgb, 255, 255, 255), 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 2px solid var(--accent-gold);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10010;
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-nav-dropdown.active {
    max-height: 80vh;
    overflow-y: auto;
}

.mobile-nav-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.8;
}

.mobile-nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.85rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    width: 100%;
    text-align: left;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mobile-nav-item:active {
    background: var(--accent-gold);
    color: white;
    transform: scale(0.97);
    border-color: var(--accent-gold);
}

.mobile-nav-item.active {
    background: var(--accent-gold);
    color: white;
    font-weight: 600;
    border-color: var(--accent-gold);
    box-shadow: 0 2px 8px rgba(var(--accent-gold-rgb), 0.3);
}

.mobile-nav-item-icon {
    font-size: 1.1rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.mobile-lang-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.mobile-lang-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(var(--bg-primary-rgb), 0.5);
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.mobile-lang-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.mobile-lang-flags {
    display: flex;
    gap: 0.5rem;
}

.mobile-lang-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.mobile-lang-btn:active {
    background: var(--accent-gold);
    transform: scale(0.9);
    border-color: var(--accent-gold);
}

.mobile-nav-toggle-btn {
    display: none;
    /* Changed from flex to none by default */
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-gold);
    color: white;
    border: none;
    border-radius: 6px;
    width: 38px;
    /* Slightly larger for easier touch */
    height: 38px;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10011;
    align-items: center;
    justify-content: center;
}

.mobile-nav-toggle-btn:active {
    opacity: 0.7;
}

/* Collapsible Editor Toolbar on Mobile */
.toolbar-mobile-toggle {
    display: none;
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    margin-bottom: 0.5rem;
    text-align: center;
    font-weight: 600;
}

.toolbar-mobile-toggle:active {
    background: var(--accent-gold);
    color: white;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Critical: never capture events when invisible/inactive */
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
    /* Only capture events when truly active/visible */
}

/* Tablet styles (landscape phones and portrait tablets) */
@media (max-width: 1024px) {
    .app-header {
        padding: 0 1rem;
        gap: 1rem;
    }

    .app-logo {
        font-size: 1.1rem;
    }

    .header-nav {
        gap: 0.25rem;
    }

    .nav-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .header-actions {
        gap: 0.25rem;
    }

    .header-action-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .app-container {
        grid-template-columns: 240px 1fr;
    }

    .sidebar {
        width: 240px;
    }

    .modal-content {
        max-width: 90%;
        margin: 2rem auto;
    }

    /* Masquer le texte des boutons scene-tools sur tablette */
    .scene-tool-btn span:not(.scene-tool-badge) {
        display: none;
    }
}

/* Force mobile nav quand le header déborde */
body.force-mobile-nav .header-nav {
    display: none !important;
}

body.force-mobile-nav .mobile-nav-toggle-btn {
    display: flex !important;
}

body.force-mobile-nav .mobile-nav-dropdown {
    display: block !important;
}

body.force-mobile-nav #headerStatsContainer {
    display: none !important;
}

body.force-mobile-nav .header-actions {
    gap: 0.35rem;
}

body.force-mobile-nav #pomodoroHeaderBtn,
body.force-mobile-nav #headerProjectsBtn {
    display: none !important;
}

body.force-mobile-nav .split-mode-toggle {
    display: none !important;
}

/* Mobile styles (phones) */
/* ============================================ */
/* RESPONSIVE - MOBILE FIRST */
/* ============================================ */

/* MOBILE (< 900px) */
@media (max-width: 900px) {

    /* Layout Mobile - Same as tablet, sidebar always visible */
    .app-content {
        display: flex;
        flex-direction: row;
    }

    /* Sidebar versions en overlay sur mobile */
    .sidebar-versions {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 10000 !important;
        background: var(--bg-primary) !important;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .sidebar-versions:not(.hidden) {
        transform: translateX(0);
    }

    .sidebar-versions.hidden {
        display: block !important;
        transform: translateX(100%);
    }

    .sidebar-versions {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 20px));
    }

    .sidebar-versions-header {
        padding: 1rem;
        border-bottom: 2px solid var(--primary-color);
    }

    .sidebar-versions-toggle {
        font-size: 1.5rem;
        padding: 0.5rem;
    }

    /* Header Mobile - Apple iOS Premium Style */
    .app-header {
        height: 52px;
        padding: 0 0.5rem;
        gap: 0.25rem;
        background: rgba(255, 255, 255, 0.85);
        /* fallback */
        background: rgba(var(--bg-primary-rgb, 255, 255, 255), 0.85);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
        box-shadow: none;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-start;
    }

    .app-logo {
        order: 1;
        flex-shrink: 0;
        font-size: 1.1rem;
    }

    [data-theme="dark"] .app-header {
        background: rgba(28, 28, 30, 0.85);
        border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
    }

    .app-logo {
        font-size: 1.1rem;
    }

    .app-logo-icon {
        font-size: 1.3rem;
    }

    /* Cacher navigation desktop */
    .header-nav {
        display: none !important;
    }

    /* Mobile navigation - re-enabled for overlay mode */
    .mobile-nav-toggle-btn {
        display: none !important;
        /* Replaced by bottom nav bar */
    }

    /* Accordéon en mode mobile : style grille pour remplacer le menu mobile */
    .sidebar-accordion-content.mobile-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 10px;
    }

    .sidebar-accordion-content.mobile-grid .accordion-group {
        grid-column: span 3;
        margin-top: 12px;
    }

    .sidebar-accordion-content.mobile-grid .accordion-group:first-child {
        margin-top: 0;
    }

    .sidebar-accordion-content.mobile-grid .accordion-group-title {
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        color: var(--text-muted);
        margin-bottom: 8px;
        padding-left: 4px;
        font-weight: 700;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 4px;
    }

    .sidebar-accordion-content.mobile-grid .accordion-group-items {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .sidebar-accordion-content.mobile-grid .accordion-nav-item {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 10px 4px;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        gap: 4px;
        height: auto;
        min-height: 64px;
        position: relative;
    }

    .sidebar-accordion-content.mobile-grid .accordion-nav-item i {
        width: 20px;
        height: 20px;
        margin: 0;
        color: var(--primary-color);
    }

    .sidebar-accordion-content.mobile-grid .accordion-nav-item span {
        font-size: 0.7rem;
        padding: 0;
        line-height: 1.1;
        font-weight: 500;
    }

    .sidebar-accordion-content.mobile-grid .accordion-nav-item.active {
        background: rgba(var(--primary-color-rgb), 0.1);
        border-color: var(--primary-color);
    }

    /* Masquer les actions secondaires sur mobile grid */
    .sidebar-accordion-content.mobile-grid .accordion-item-actions {
        display: none !important;
    }

    .sidebar-accordion-content.mobile-grid .accordion-nav-item {
        padding-right: 4px !important;
        /* Reset padding-right du style inline */
    }

    .mobile-menu-handle {
        display: none !important;
        /* Replaced by bottom nav bar */
    }

    .sidebar-overlay {
        display: block;
        /* Re-enabled for sidebar overlay mode */
    }

    /* Hide floating editor toggle - replaced by bottom nav "Format" button */
    #floatingEditorToggle {
        display: none !important;
    }

    /* Sidebar column - overlay mode (hidden by default, slides from left) */
    .sidebar-column,
    .activity-bar {
        position: fixed !important;
        top: 56px !important;
        left: -100% !important;
        width: 85vw !important;
        max-width: 360px !important;
        height: calc(100vh - 56px) !important;
        z-index: 10002 !important;
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        background: var(--bg-secondary) !important;
        overflow-y: auto !important;
        min-width: unset !important;
        box-shadow: none !important;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        display: flex !important;
    }

    .sidebar-column.mobile-visible,
    .activity-bar.mobile-visible {
        left: 0 !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15) !important;
    }

    /* Hide tools-sidebar on mobile - replaced by bottom nav tools sheet */
    .tools-sidebar {
        display: none !important;
    }

    /* Show bottom navigation bar on mobile */
    .mobile-bottom-nav {
        display: flex !important;
    }

    /* Adjust editor padding for bottom nav */
    .editor-container {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Storage badge above bottom nav */
    .storage-badge {
        bottom: calc(56px + 15px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Cacher stats sur mobile pour gagner de la place (optionnel, mais recommandé) */
    #headerStatsContainer {
        display: none !important;
    }

    .header-search {
        order: 2;
    }

    /* Header actions mobile - compacts et alignés */
    .header-actions {
        order: 3;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        margin-left: auto;
        margin-right: 0 !important;
        flex-shrink: 0;
    }

    .header-action-btn {
        width: 32px;
        height: 32px;
        padding: 0;
        font-size: 1rem;
        flex-shrink: 0;
        border: none !important;
        background: transparent !important;
        border-radius: 50% !important;
        color: var(--text-primary) !important;
        transition: background-color 0.2s ease, opacity 0.2s cubic-bezier(0.2, 0, 0, 1);
    }

    .header-action-btn:active {
        background: rgba(120, 120, 128, 0.16) !important;
        transform: scale(0.96);
    }

    .mobile-nav-toggle-btn {
        order: 4;
        border: none !important;
        background: transparent !important;
        border-radius: 50% !important;
        color: var(--text-primary) !important;
        width: 32px !important;
        height: 32px !important;
        box-shadow: none !important;
        position: static !important;
        transform: none !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        flex-shrink: 0;
        margin-left: 0.25rem;
    }

    .mobile-nav-toggle-btn:active {
        background: rgba(120, 120, 128, 0.16) !important;
        transform: scale(0.96) !important;
    }

    /* Split toggle plus compact sur mobile */
    .split-mode-toggle {
        display: none !important;
    }

    /* Logo plus compact */
    .app-logo {
        font-size: 0.95rem;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-logo-icon {
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    /* Sidebar Mobile - DÉSACTIVÉ - Géré par .sidebar-column dans css/sidebar.css */
    /* Le positionnement mobile est maintenant géré au niveau du conteneur .sidebar-column */
    /* pour éviter les conflits de positionnement fixed entre parent et enfant */
    /*
    .sidebar {
        position: fixed;
        top: 56px;
        left: -100%;
        width: 100vw;
        max-width: 320px;
        height: calc(100vh - 56px);
        z-index: 10002;
        transition: left 0.3s ease;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
        background: var(--bg-secondary);
        overflow-y: auto;
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 20px));
    }

    .sidebar.mobile-open {
        left: 50px;
    }
    */

    /* Padding pour les listes de la sidebar sur mobile */
    .chapters-list,
    .database-list {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    }

    .sidebar-actions {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 20px));
    }

    /* Secondary Panels (Annotations, Todos, Plot, etc.) on Mobile */
    .annotations-panel,
    .sidebar-plot,
    .arc-scene-panel,
    .links-panel-sidebar,
    .word-rep-sidebar {
        position: fixed !important;
        top: 56px !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 10005 !important;
        background: var(--bg-primary) !important;
        box-shadow: none;
        border-left: none;
        display: flex;
        flex-direction: column;
    }

    .annotations-panel.hidden,
    .sidebar-plot.hidden,
    .arc-scene-panel.hidden,
    .links-panel-sidebar.hidden,
    .word-rep-sidebar.hidden {
        display: none !important;
    }

    /* Sidebar Structure - Touch-friendly overlay mode */
    .status-filters {
        padding: 0.4rem 0.75rem;
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    .status-filter-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
        gap: 0.25rem;
        min-height: 36px;
    }

    .status-filter-btn span:not(.status-filter-dot):not(.status-filter-count) {
        display: none;
        /* Cacher le texte, garder seulement le point et le count */
    }

    .status-filter-dot {
        width: 8px;
        height: 8px;
    }

    .status-filter-count {
        font-size: 0.7rem;
        padding: 0 0.25rem;
    }

    .scene-tools {
        display: none !important;
    }

    .scene-tool-btn i {
        width: 16px !important;
        height: 16px !important;
    }

    .tree-collapse-toolbar {
        padding: 0.35rem 0.75rem;
        gap: 0.25rem;
    }

    .tree-collapse-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
        gap: 0.2rem;
        min-height: 36px;
    }

    /* Treeview - Touch-friendly in sidebar overlay (min 44px tap targets) */
    .act-group {
        margin-bottom: 0.25rem;
    }

    .act-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        gap: 0.5rem;
        min-height: 44px;
    }

    .act-icon {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .act-title {
        font-size: 0.9rem;
    }

    .act-chapters {
        padding-left: 0.5rem;
    }

    .chapter-group {
        margin-bottom: 0.1rem;
    }

    .chapter-header {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.5rem;
        min-height: 40px;
    }

    .chapter-icon {
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .chapter-title {
        font-size: 0.85rem;
    }

    .scenes-list {
        padding-left: 0.75rem;
    }

    .scene-item {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.4rem;
        min-height: 44px;
    }

    .auto-number {
        font-size: 0.7rem;
        min-width: 24px;
        margin-right: 0.25rem;
    }

    .word-count-badge {
        font-size: 0.65rem;
        padding: 0.1rem 0.3rem;
    }

    .status-badge {
        width: 8px;
        height: 8px;
    }

    .drag-handle {
        padding: 0 0.25rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .drag-handle i {
        width: 16px !important;
        height: 16px !important;
    }

    .delete-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.75rem !important;
        padding: 0 !important;
    }

    .edit-hint {
        display: none;
    }

    .chapter-count {
        font-size: 0.7rem;
    }

    /* Barre de progression mobile */
    .sidebar-progress-info {
        padding: 0.35rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Search bar mobile */
    .search-container {
        padding: 0.3rem 0.5rem;
        margin-bottom: 0.5rem;
    }

    .search-container input {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Stats overview compact */
    .stats-overview {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .stats-overview .stat-group {
        gap: 0.25rem;
    }

    .stats-overview .stat-badge {
        padding: 0.15rem 0.4rem;
        font-size: 0.7rem;
    }

    /* Toolbar collapse buttons compact */
    .tree-collapse-toolbar {
        padding: 0.25rem 0.5rem;
        margin-bottom: 0.25rem;
    }

    .tree-collapse-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        gap: 0.25rem;
    }

    /* Sidebar actions mobile - touch-friendly */
    .sidebar-actions .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-height: 44px;
    }

    /* Editor full width */
    .editor-container {
        width: 100%;
    }

    /* Toolbar Desktop - masqué et remplacé par bouton toggle */
    .toolbar-mobile-toggle {
        display: block;
        width: 100%;
        padding: 12px;
        background: white;
        border: none;
        border-bottom: 1px solid var(--border-color);
        color: var(--text-primary);
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        text-align: center;
        transition: all 0.2s ease;
    }

    .toolbar-mobile-toggle:active {
        background: var(--bg-secondary);
    }

    .toolbar-mobile-toggle .toggle-icon {
        display: inline-block;
        transition: transform 0.3s ease;
        margin-left: 0.5rem;
    }

    .toolbar-mobile-toggle.expanded .toggle-icon {
        transform: rotate(180deg);
    }

    /* Toolbar collapsible */
    .editor-toolbar {
        max-height: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.3s ease;
        padding: 0 !important;
        border-bottom: none !important;
    }

    .editor-toolbar.expanded {
        max-height: 500px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 12px !important;
        border-bottom: 1px solid var(--border-color) !important;
        flex-wrap: wrap !important;
    }

    /* Menu flottant mobile visible */
    #floatingEditorToggle {
        display: flex;
    }

    /* Editor content */
    .editor-content {
        padding: 1.5rem;
    }

    .editor-textarea {
        font-size: 1rem;
        line-height: 1.7;
    }

    /* Editor header mobile */
    .editor-header {
        padding: 1rem 1rem 0.75rem;
    }

    .editor-breadcrumb {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .editor-title {
        font-size: 1.4rem;
    }

    .editor-meta {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
        font-size: 0.75rem;
    }

    /* Bouton Focus plus compact */
    .editor-header .btn-small,
    .editor-header .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    /* Links panel toggle - comme toolbar */
    .links-panel-toggle {
        display: none;
        /* Hidden, now using sidebar */
        width: 100%;
        padding: 12px;
        background: white;
        border: none;
        border-bottom: 1px solid var(--border-color);
        color: var(--text-primary);
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        text-align: center;
        transition: all 0.2s ease;
    }

    .links-panel-toggle:active {
        background: var(--bg-secondary);
    }

    /* Links panel collapsible - DEPRECATED for sidebar behavior */
    /*
    #linksPanel {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        padding: 0 1rem;
        border-bottom: none;
    }
    */

    /*
    #linksPanel.expanded {
        max-height: 500px;
        overflow-y: auto;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    */

    .links-panel-sticky>div {
        flex-direction: column;
        gap: 0.75rem !important;
    }

    .quick-links {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .link-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* Links panel toggle - comme toolbar */
    .btn {
        padding: 0.7rem 1rem;
        font-size: 15px;
        touch-action: manipulation;
    }

    /* Formulaires */
    .form-input,
    .form-textarea {
        font-size: 16px;
        /* Évite le zoom sur iOS */
    }

    /* Storage badge */
    .storage-badge {
        bottom: 60px;
        right: 15px;
        font-size: 11px;
        min-width: 80px;
        min-height: 40px;
        padding: 8px 12px;
    }
}

/* TABLETTE (901px - 1024px) */
@media (min-width: 901px) and (max-width: 1024px) {
    .app-content {
        display: flex;
        flex-direction: row;
    }

    /* Hide mobile-only elements on tablet */
    .mobile-bottom-nav,
    .mobile-tools-sheet {
        display: none !important;
    }

    .sidebar {
        position: static !important;
        left: auto !important;
        width: auto !important;
        min-width: 250px !important;
        max-width: none !important;
        height: auto !important;
        z-index: auto !important;
        transition: none !important;
        display: flex !important;
        flex-shrink: 0;
    }

    .mobile-menu-handle,
    .sidebar-overlay,
    .mobile-nav-toggle-btn,
    .mobile-nav-dropdown {
        display: none !important;
    }

    .editor-content {
        padding: 2rem;
    }

    .app-header {
        padding: 0 1.5rem;
    }

    .editor-toolbar {
        padding: 8px 12px;
        flex-wrap: wrap;
    }
}

/* DESKTOP (> 1024px) */
@media (min-width: 1025px) {

    .mobile-nav-toggle-btn,
    .mobile-nav-dropdown,
    .toolbar-mobile-toggle,
    .mobile-menu-handle,
    .sidebar-overlay,
    .mobile-bottom-nav,
    .mobile-tools-sheet {
        display: none !important;
    }

    /* Afficher navigation desktop */
    .header-nav {
        display: flex !important;
    }

    /* Toolbar toujours visible */
    .editor-toolbar {
        /*display: flex !important;*/
        max-height: none !important;
        flex-wrap: wrap !important;
    }

    /* SIDEBAR DESKTOP - LIBÉRATION DES CONTRAINTES */
    .sidebar {
        position: static;
        left: auto;
        width: auto;
        /* Laisser le style inline (le resize JS) piloter la largeur */
        min-width: 250px;
        max-width: none;
        height: auto;
        z-index: auto;
        transition: none;
        display: flex;
    }

    /* Grid layout desktop */
    .app-container {
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "header header"
            "sidebar main";
    }
}

/* GRAND ÉCRAN (> 1440px) */
@media (min-width: 1441px) {
    .editor-content {
        max-width: 850px;
    }
}

/* Styles additionnels pour mobile (900px) - storage badge */
@media (max-width: 900px) {
    .storage-badge {
        bottom: calc(56px + 15px + env(safe-area-inset-bottom, 0px));
        right: 15px;
        padding: 10px 15px;
        font-size: 12px;
        min-width: 100px;
        min-height: 44px;
        z-index: 10001;
    }

    /* Scene metadata */
    .scene-metadata {
        flex-direction: column;
        gap: 0.75rem;
    }

    .metadata-item {
        width: 100%;
    }

    /* Character and element links */
    .scene-links {
        flex-direction: column;
    }

    .link-group {
        width: 100%;
    }

    /* Content editor */
    #sceneContent {
        font-size: 1rem;
        line-height: 1.6;
        padding: 1rem;
    }

    /* Sidebar actions */
    .sidebar-actions {
        flex-direction: row;
        gap: 0.25rem;
        padding: 0.5rem;
    }

    .sidebar-actions .btn {
        width: 33.333%;
        flex: 1;
        font-size: 0.8rem;
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }

    /* Projects Landing */
    .projects-landing-container {
        padding: 1rem !important;
    }

    .projects-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .projects-title {
        font-size: 1.5rem;
        justify-content: center;
    }

    .projects-actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .projects-actions .btn {
        flex: 1 1 auto;
        min-width: 140px;
    }

    /* Projects Table to Cards on Mobile - PREMIUM REDESIGN */
    .projects-table-wrapper {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0.5rem 0;
    }

    .projects-table,
    .projects-table thead,
    .projects-table tbody,
    .projects-table th,
    .projects-table td,
    .projects-table tr {
        display: block !important;
    }

    .projects-table thead {
        display: none !important;
    }

    .projects-table tr {
        background: var(--bg-secondary) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 20px !important;
        padding: 1.5rem !important;
        margin-bottom: 2rem !important;
        position: relative;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border-bottom: 4px solid transparent !important;
    }

    .projects-table tr.active {
        border-color: var(--accent-gold) !important;
        border-bottom-color: var(--accent-gold) !important;
        background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary)) !important;
        box-shadow: 0 15px 35px rgba(212, 175, 55, 0.15) !important;
        transform: translateY(-4px);
    }

    .projects-table td {
        padding: 0 !important;
        border: none !important;
        text-align: left !important;
    }

    /* Card Layout Sections */
    .projects-table td:nth-child(1) {
        /* Title section */
        margin-bottom: 1.25rem;
    }

    .table-title {
        font-size: 1.35rem !important;
        font-weight: 800 !important;
        color: var(--text-primary) !important;
        gap: 14px !important;
        letter-spacing: -0.02em;
    }

    .table-title i {
        color: var(--accent-gold) !important;
        width: 24px !important;
        height: 24px !important;
        filter: drop-shadow(0 2px 4px rgba(212, 175, 55, 0.2));
    }

    .projects-table td:nth-child(2) {
        /* Stats section */
        display: block !important;
        background: rgba(var(--accent-gold-rgb), 0.05);
        padding: 1rem !important;
        border-radius: 14px;
        margin-bottom: 1.25rem;
        border: 1px solid rgba(var(--accent-gold-rgb), 0.1);
    }

    .table-stats-row {
        justify-content: space-around !important;
        gap: 20px !important;
    }

    .projects-table td:nth-child(3) {
        /* Word count / Progress */
        margin-bottom: 1.25rem;
        padding: 0 0.5rem !important;
    }

    .projects-table td:nth-child(3)>div {
        align-items: stretch !important;
        gap: 8px !important;
    }

    /* Progress bar transformation */
    .projects-table td:nth-child(3) [style*="width: 80px"] {
        width: 100% !important;
        height: 12px !important;
        border-radius: 6px !important;
        background: rgba(var(--accent-gold-rgb), 0.1) !important;
        border: 1px solid rgba(var(--accent-gold-rgb), 0.2) !important;
    }

    .projects-table td:nth-child(3) [style*="font-weight: 600"] {
        font-size: 1.1rem !important;
        color: var(--accent-gold) !important;
        text-align: right;
    }

    .projects-table td:nth-child(4) {
        /* Date updated */
        display: flex !important;
        align-items: center;
        gap: 8px;
        font-size: 0.85rem !important;
        color: var(--text-muted);
        margin-bottom: 1.25rem;
        padding: 0 0.5rem !important;
    }

    .projects-table td:nth-child(4)::before {
        content: "📅 Dernière modification :";
        font-weight: 600;
        color: var(--text-secondary);
    }

    .projects-table td:nth-child(5) {
        /* Active Dot */
        position: absolute;
        top: 1.6rem;
        right: 1.6rem;
    }

    .projects-table td:nth-child(6) {
        /* Actions row */
        margin-top: 1rem;
        padding-top: 1.5rem !important;
        border-top: 1px solid rgba(var(--border-color-rgb), 0.4) !important;
    }

    .table-actions {
        justify-content: center !important;
        gap: 2rem !important;
    }

    .table-actions .icon-btn {
        width: 52px !important;
        height: 52px !important;
        background: var(--bg-primary) !important;
        border-radius: 16px !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.06) !important;
        color: var(--text-secondary) !important;
    }

    .table-actions .icon-btn i {
        width: 22px !important;
        height: 22px !important;
    }

    .table-actions .icon-btn:active {
        background: var(--accent-gold) !important;
        color: white !important;
        transform: scale(0.92);
        box-shadow: none !important;
    }

    /* Forms */
    .form-input,
    .form-textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Buttons */
    .btn {
        padding: 0.65rem 1rem;
        font-size: 0.95rem;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .btn-small {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    /* Stats cards */
    .stats-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Character/World cards */
    .character-card,
    .world-card {
        padding: 1rem;
    }

    /* Act/Chapter structure */
    .act-header,
    .chapter-header {
        padding: 0.5rem 0.75rem;
        min-height: unset;
    }

    .act-title,
    .chapter-title {
        font-size: 0.9rem;
        line-height: 1.3;
    }

    .scene-item {
        padding: 0.45rem 0.75rem;
        font-size: 0.85rem;
        min-height: unset;
        line-height: 1.3;
    }

    /* Reduce spacing in act/chapter groups */
    .act-group {
        margin-bottom: 0.5rem;
    }

    .chapter-group {
        margin-bottom: 0.25rem;
    }

    /* Compact word count badges */
    .word-count-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }

    /* Compact status badges */
    .status-badge {
        width: 6px;
        height: 6px;
    }

    /* Compact chapter count */
    .chapter-count {
        font-size: 0.7rem;
        padding: 0.15rem 0.35rem;
    }

    /* Empty state */
    .empty-state {
        padding: 2rem 1rem;
    }

    .empty-state-icon {
        font-size: 3rem;
    }

    .empty-state-title {
        font-size: 1.3rem;
    }

    /* Timeline visualization */
    .timeline-item {
        padding: 1rem;
    }

    /* Cork board */
    .cork-card {
        min-width: 200px;
        font-size: 0.9rem;
    }

    /* Search */
    .search-input {
        font-size: 0.95rem;
        padding: 0.65rem 2.5rem 0.65rem 1rem;
    }

    /* Tabs */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        flex-shrink: 0;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* Small mobile phones */
@media (max-width: 480px) {
    .app-header {
        height: 52px;
        padding: 0 0.5rem;
    }

    .app-logo {
        font-size: 0.9rem;
    }

    .app-logo-icon {
        font-size: 1.1rem;
    }

    .nav-btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.95rem;
    }

    .header-action-btn {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    .sidebar {
        width: 90%;
        max-width: 280px;
        top: 52px;
        height: calc(100vh - 52px);
    }

    /* Sidebar column overlay ajustement petit mobile */
    .sidebar-column {
        top: 52px !important;
        height: calc(100vh - 52px) !important;
    }

    .app-container {
        grid-template-rows: 52px 1fr;
    }

    .scene-editor {
        padding: 0.75rem;
    }

    .scene-title {
        font-size: 1.3rem;
    }

    #sceneContent {
        font-size: 0.95rem;
        padding: 0.75rem;
    }

    .mobile-menu-toggle {
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
        bottom: 16px;
        right: 16px;
    }

    .btn {
        padding: 0.6rem 0.85rem;
        font-size: 0.9rem;
    }
}

/* Landscape orientation on phones */
@media (max-width: 900px) and (orientation: landscape) {
    .app-header {
        height: 48px;
    }

    .sidebar {
        top: 48px;
        height: calc(100vh - 48px);
    }

    /* Sidebar overlay ajustement paysage */
    .sidebar-column {
        top: 48px !important;
        height: calc(100vh - 48px) !important;
    }

    .app-container {
        grid-template-rows: 48px 1fr;
    }

    .modal-content {
        max-height: 85vh;
    }

    .mobile-menu-toggle {
        width: 48px;
        height: 48px;
        bottom: 12px;
        right: 12px;
    }

    /* Bottom nav plus compact en paysage */
    .mobile-bottom-nav {
        height: 44px;
    }

    .mobile-bottom-nav-item span {
        display: none;
        /* Icônes seules en paysage pour économiser l'espace vertical */
    }

    .mobile-bottom-nav-item i {
        width: 20px;
        height: 20px;
    }

    /* Ajuster padding editeur en paysage */
    .editor-container {
        padding-bottom: calc(44px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {

    /* iOS safe area insets */
    .app-header {
        padding-top: max(env(safe-area-inset-top), 0px);
    }

    .sidebar {
        padding-bottom: max(env(safe-area-inset-bottom), 0px);
    }

    .mobile-menu-toggle {
        bottom: max(env(safe-area-inset-bottom, 20px) + 20px, 20px);
        right: max(env(safe-area-inset-right, 20px) + 20px, 20px);
    }

    /* Prevent elastic scrolling on body */
    body {
        position: fixed;
        width: 100%;
    }

    /* Fix textarea font size to prevent zoom */
    input,
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Android Chrome specific */
@media screen and (-webkit-min-device-pixel-ratio: 0) {

    select,
    textarea,
    input {
        font-size: 16px;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .app-header {
        border-bottom-width: 1px;
    }
}

/* Dark mode support (if device prefers dark) */
@media (prefers-color-scheme: dark) {
    /* This is ready for future dark mode implementation */
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn,
    .nav-btn,
    .toolbar-btn,
    button {
        min-height: 33px;
        min-width: 33px;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-btn:hover,
    .toolbar-btn:hover {
        transform: none;
    }

    /* Add active state feedback */
    .btn:active,
    .nav-btn:active,
    .toolbar-btn:active {
        opacity: 0.7;
    }
}

/* LIVE TENSION METER - MOBILE BAR CONCEPT */
@media (max-width: 900px) {
    .tension-meter-container {
        position: fixed !important;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 10px !important;
        border-radius: 0 !important;
        border: none !important;
        background: rgba(0, 0, 0, 0.1) !important;
        box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1) !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 10001 !important;
        /* Just above bottom nav */
        cursor: default !important;
        overflow: hidden !important;
        transform: none !important;
    }

    .tension-meter-bar-bg {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        background: transparent !important;
    }

    .tension-meter-bar-fill {
        height: 100% !important;
        width: 0%;
        background: var(--accent-blue);
        transition: width 0.5s ease, background-color 0.5s ease !important;
    }

    /* Hide desktop circular elements on mobile by default */
    .tension-meter-svg,
    .tension-value-display {
        display: none !important;
    }

    .tension-tooltip {
        display: block !important;
        position: fixed !important;
        bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) translateY(10px) !important;
        width: 85% !important;
        max-width: 320px !important;
        padding: 1.2rem !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: auto !important;
        transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
        z-index: 10002 !important;
        background: var(--bg-primary) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 12px !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
    }

    .tension-tooltip.active {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateX(-50%) translateY(0) !important;
    }

    .tension-meter-container:hover {
        transform: none !important;
    }
}

/* DESKTOP HIDING OF BAR */
@media (min-width: 901px) {
    .tension-meter-bar-bg {
        display: none !important;
    }
}