:root {
    --primary-color: #d32f2f;
    --bg-color: #f4f4f4;
    --card-bg: #ffffff;
    --text-color: #333;
    --header-bg: #2c3e50;
    --header-text: #ecf0f1;
}

[data-theme="dark"] {
    --primary-color: #e53935;
    --bg-color: #121218;
    --card-bg: #1c1c28;
    --text-color: #d4d4dc;
    --header-bg: #151520;
    --header-text: #ecf0f1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Nav */
header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 1500;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}

#dm-indicator {
    background-color: #f39c12;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
    animation: pulse-dm 2s infinite;
}

@keyframes pulse-dm {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 15px;
}

nav button {
    background: none;
    border: none;
    color: #bdc3c7;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px 10px;
    transition: color 0.3s, border-bottom 0.3s;
    border-bottom: 2px solid transparent;
}

nav button:hover, nav button.active {
    color: white;
    border-bottom: 2px solid var(--primary-color);
}

nav button.menu-highlight {
    color: white;
    border-bottom: 2px solid #f39c12;
    animation: menu-pulse 0.4s ease-in-out 3;
}

@keyframes menu-pulse {
    0% { background: transparent; }
    50% { background: rgba(243, 156, 18, 0.3); }
    100% { background: transparent; }
}

/* Scroll to Top Button */
#scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: transform 0.2s, background-color 0.2s;
}

#scroll-top:hover {
    transform: scale(1.1);
    background-color: #b71c1c;
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    font-size: calc(1rem * var(--content-scale, 1));
}

/* Welcome Page */
.welcome-page {
    max-width: 900px;
    margin: 0 auto;
}

.welcome-hero {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

.welcome-hero h1 {
    font-size: 2.5rem;
    color: var(--header-bg);
    margin: 0 0 0.5rem;
}

.welcome-subtitle {
    font-size: 1.2rem;
    color: #777;
    margin: 0;
}

.welcome-content {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.welcome-content > p {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #555;
    text-align: center;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 2rem 0;
}

.welcome-card {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: 8px;
    background: var(--bg-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.welcome-card-clickable {
    cursor: pointer;
}

.welcome-card-clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}

.welcome-card-clickable:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.welcome-card i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

.welcome-card h3 {
    margin: 0 0 0.5rem;
    color: var(--header-bg);
}

.welcome-card p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.welcome-cta {
    text-align: center;
    font-style: italic;
    color: #999 !important;
    margin-bottom: 0 !important;
}

/* Cards Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 300px; 
    overflow: hidden;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.card::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--card-bg));
    pointer-events: none;
}

/* HEADER DE CARTE AVEC IMAGE A DROITE */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
    padding-bottom: 5px;
}

.card h2 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.25rem;
    flex: 1;
    padding-right: 10px;
}

.card-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* IMAGE DANS LE MODAL - FLOAT RIGHT */
.modal-image {
    float: right;
    margin-left: 20px;
    margin-bottom: 15px;
    max-width: 250px;
}

.modal-image img {
    width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: zoom-in;
}

.modal-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    clear: both;
}

.modal-gallery-img {
    width: calc(50% - 5px);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: zoom-in;
    object-fit: cover;
    max-height: 250px;
    transition: transform 0.2s;
}

.modal-gallery-img:hover {
    transform: scale(1.02);
}

/* Nettoyage du float pour que le footer du modal reste en dessous */
.modal-body::after {
    content: "";
    display: table;
    clear: both;
}

/* Metadata Pills (shared between list & cards) */
.meta-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    background: #f0f0f0;
    color: #555;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.meta-align { background: #ede9fe; color: #5b21b6; }
.meta-race { background: #dbeafe; color: #1e40af; }
.meta-status { background: #f3f4f6; color: #374151; }
.meta-alive { background: #dcfce7; color: #166534; }
.meta-dead { background: #fee2e2; color: #991b1b; }
.meta-lieu { background: #fef3c7; color: #92400e; }
.meta-role { background: #f3f4f6; color: #555; font-style: italic; }
.meta-region { background: #e0f2fe; color: #075985; }
.meta-leader { background: #fce7f3; color: #9d174d; }
.meta-type { background: #f0f0f0; color: #555; }
.meta-pop { background: #ecfdf5; color: #065f46; }
.meta-date { background: #fff7ed; color: #9a3412; }
.meta-journal { background: #f0f9ff; color: #0c4a6e; font-style: italic; }
.meta-session { background: #dcfce7; color: #166534; }
.meta-xp { background: #fef3c7; color: #92400e; font-weight: bold; }
.meta-cat { background: #ede9fe; color: #5b21b6; }
.meta-rarity { background: #fef3c7; color: #92400e; }
.meta-value { background: #ecfdf5; color: #065f46; }
.meta-replace { background: #fff7ed; color: #9a3412; }
.meta-attune { background: #fce7f3; color: #9d174d; }
.meta-owner { background: #ccfbf1; color: #0f766e; }
.meta-location { background: #e0e7ff; color: #3730a3; }
.meta-weight { background: #f3f4f6; color: #4b5563; }
.meta-hidden { background: #fee2e2; color: #991b1b; font-weight: bold; }

/* Item Tags */
.item-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.68rem;
    background: #e5e7eb;
    color: #6b7280;
    white-space: nowrap;
}

.item-tag-more {
    background: transparent;
    color: #9ca3af;
    font-style: italic;
}

/* Card metadata & tags */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 8px;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background: #e0e0e0;
    margin-top: auto;
}

/* Utilities */
.loading { color: #888; font-style: italic; }
.error { color: red; font-weight: bold; }

/* Toolbar */
.toolbar {
    position: sticky;
    top: 75px; /* Offset because of sticky header */
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.toolbar input, .toolbar select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
}

.toolbar input:focus, .toolbar select:focus {
    border-color: var(--primary-color);
}

.toolbar .search-box {
    flex: 1;
    min-width: 200px;
}

.toolbar .sort-filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toolbar label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
}

/* XP Total Badge */
.xp-total-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid #fbbf24;
}

.xp-total-badge i {
    color: #f59e0b;
}

/* View Toggle (Cards / List) */
.view-toggle {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.view-toggle-btn {
    background: white;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: #888;
    font-size: 1rem;
    transition: background 0.2s, color 0.2s;
}

.view-toggle-btn:not(:last-child) {
    border-right: 1px solid #ddd;
}

.view-toggle-btn.active {
    background: var(--header-bg);
    color: white;
}

.view-toggle-btn:hover:not(.active) {
    background: #f0f0f0;
    color: #555;
}

/* List View */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 12px 18px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.list-item:hover {
    transform: translateX(4px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.14);
}

.list-item-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.list-item-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.list-item-info {
    flex-shrink: 0;
    min-width: 160px;
}

.list-item-title {
    font-weight: bold;
    font-size: 1rem;
    color: var(--primary-color);
}

.list-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.list-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
    max-width: 220px;
}

.list-item-desc {
    flex: 1;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 100px;
}

/* Barometer Physics */
#barometer-container {
    margin-top: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.barometer {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: 1px solid #eee;
    width: 100%;
    max-width: 850px;
    box-sizing: border-box;
}

.physics-world {
    position: relative;
    width: 100%;
    max-width: 800px;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0f0f1a 60%, #0a0a12 100%);
    border-radius: 16px;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.6), 0 4px 20px rgba(0,0,0,0.3);
    border: 2px solid #2a2a3e;
    overflow: hidden;
    margin-bottom: 20px;
}

.physics-canvas {
    width: 100%;
    height: auto;
}

.baro-interface {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
}

.baro-section {
    text-align: center;
    width: 150px;
}

.baro-section h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: #555;
}

.baro-section.positive .count {
    color: #27ae60;
    font-size: 3rem;
    font-weight: bold;
}

.baro-section.negative .count {
    color: #c0392b;
    font-size: 3rem;
    font-weight: bold;
}

.baro-mid-btns {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.btn-use-point {
    background: #2c3e50 !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.btn-use-point.use-pos { background: #1b5e20 !important; }
.btn-use-point.use-neg { background: #7b1fa2 !important; }
.btn-use-point.red-btn { background: #c0392b !important; }

.btn-use-point:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.baro-controls {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 5px;
}

.baro-controls button {
    background: #f1f3f5;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
}

/* Notifications / Toasts */
#notification-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 300px;
    animation: toastIn 0.3s ease-out;
    border-left: 5px solid #888;
}

.notification.error {
    border-left-color: #c0392b;
}

.notification.success {
    border-left-color: #27ae60;
}

.notification.info {
    border-left-color: #2980b9;
}

@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

/* MODAL STYLES */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease-out;
    font-size: calc(1rem * var(--content-scale, 1));
}

.modal-content h2 {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 2.5rem;
    line-height: 2rem;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    user-select: none;
    z-index: 10;
}

.close-modal:hover {
    color: var(--primary-color);
}

/* Crossref Modal (stacked above main modal) */
.crossref-overlay {
    z-index: 3500;
}

/* Internal links in rendered content */
.description a[href*="category="],
.full-content a[href*="category="] {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.description a[href*="category="]:hover,
.full-content a[href*="category="]:hover {
    color: #b71c1c;
    border-bottom-style: solid;
}

/* DM Modal Components */
.modal-sm {
    max-width: 400px;
}

.dm-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.dm-btn-primary {
    width: 100%;
    padding: 8px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.dm-btn-secondary {
    padding: 8px 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    background: white;
}

.dm-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.dm-confirm-actions .dm-btn-primary {
    width: auto;
}

/* LIGHTBOX STYLES */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 4000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
}

.lightbox-overlay img {
    max-width: 95%;
    max-height: 95vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border: 2px solid #333;
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    user-select: none;
}

.close-lightbox:hover {
    color: var(--primary-color);
}

@keyframes slideIn {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
        padding: 1rem;
    }

    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    main {
        padding: 1rem;
    }

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

    .toolbar {
        top: auto;
        position: relative;
        flex-direction: column;
    }

    .toolbar .sort-filter-group {
        flex-wrap: wrap;
    }

    .list-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    .list-item-info {
        min-width: auto;
    }

    .list-item-tags {
        max-width: 100%;
        width: 100%;
    }

    .list-item-desc {
        width: 100%;
        white-space: normal;
    }

    .baro-interface {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .baro-mid-btns {
        flex-direction: column;
        align-items: center;
    }

    .baro-section {
        width: auto;
    }

    .baro-section .count {
        font-size: 2rem;
    }

    .modal-content {
        max-width: 95vw;
        padding: 1rem;
    }

    .modal-image {
        float: none;
        margin: 0 auto 15px;
        max-width: 100%;
    }

    .welcome-hero h1 {
        font-size: 1.75rem;
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }
}

/* ================================
   JSON EDITOR (DM only)
   ================================ */

.editor-page {
    max-width: 1200px;
    margin: 0 auto;
}

/* Toolbar */
.editor-toolbar {
    position: sticky;
    top: 75px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.editor-toolbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

#editor-file-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 220px;
    outline: none;
}

#editor-file-select:focus {
    border-color: var(--primary-color);
}

.editor-mode-toggle {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.editor-mode-btn {
    background: white;
    border: none;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.editor-mode-btn:not(:last-child) {
    border-right: 1px solid #ddd;
}

.editor-mode-btn.active {
    background: var(--header-bg);
    color: white;
}

.editor-mode-btn:hover:not(.active) {
    background: #f0f0f0;
}

.editor-save-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.editor-save-btn:hover:not(:disabled) {
    background: #219a52;
    transform: translateY(-1px);
}

.editor-save-btn:disabled {
    background: #aaa;
    cursor: not-allowed;
}

/* Content area */
.editor-content {
    min-height: 500px;
}

.editor-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #999;
    gap: 15px;
}

.editor-placeholder i {
    font-size: 3rem;
    opacity: 0.4;
}

.editor-placeholder p {
    font-size: 1.1rem;
    margin: 0;
}

.editor-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 20px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
}

.editor-message i {
    font-size: 1.2rem;
}

/* Raw Editor */
.raw-editor-wrap {
    position: relative;
}

#raw-editor-textarea {
    width: 100%;
    min-height: 600px;
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    padding: 20px;
    border: 1px solid #313244;
    border-radius: 8px;
    resize: vertical;
    tab-size: 2;
    box-sizing: border-box;
    outline: none;
}

#raw-editor-textarea:focus {
    border-color: #89b4fa;
    box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.2);
}

.raw-editor-status {
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
    font-size: 0.85rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.raw-editor-status.valid {
    background: #d4edda;
    color: #155724;
}

.raw-editor-status.invalid {
    background: #f8d7da;
    color: #721c24;
}

/* Structured Editor Layout */
.editor-layout {
    display: flex;
    gap: 20px;
    min-height: 500px;
}

/* Sidebar */
.editor-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--header-bg);
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.editor-add-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.editor-add-btn:hover {
    background: rgba(255,255,255,0.35);
}

.editor-sidebar-list {
    flex: 1;
    overflow-y: auto;
    max-height: 600px;
}

.editor-sidebar-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-sidebar-item:hover {
    background: #f5f5f5;
}

.editor-sidebar-item.active {
    background: #e8f4f8;
    border-left: 3px solid var(--primary-color);
    font-weight: bold;
    color: var(--primary-color);
}

/* Form area */
.editor-form, .editor-flat-form {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 20px;
    overflow-y: auto;
    max-height: 700px;
}

.editor-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.editor-form-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.editor-delete-btn {
    background: #fff5f5;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.editor-delete-btn:hover {
    background: #e74c3c;
    color: white;
}

/* Field styling */
.editor-field {
    margin-bottom: 16px;
}

.editor-field-label {
    display: block;
    font-weight: bold;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 4px;
    text-transform: capitalize;
}

.editor-field-hint {
    display: block;
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 4px;
    font-style: italic;
}

.editor-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    box-sizing: border-box;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.editor-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.1);
}

.editor-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

.editor-json-field {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    min-height: 100px;
}

.field-invalid {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.15) !important;
}

.editor-combo {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.editor-combo-input {
    border-left: 3px solid var(--primary-color) !important;
}

/* Nested sub-fields */
.editor-subfields {
    border-left: 3px solid #e0e0e0;
    padding-left: 16px;
    margin-top: 8px;
}

/* Metadata details */
.editor-metadata {
    margin-top: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.editor-metadata summary {
    padding: 12px 16px;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.editor-metadata summary:hover {
    background: #e9ecef;
}

.editor-metadata > .editor-field {
    padding: 0 16px;
}

.editor-metadata > .editor-field:first-of-type {
    padding-top: 16px;
}

/* #btn-editor in nav */
#btn-editor {
    color: #f39c12 !important;
}

#btn-editor.active {
    color: white !important;
    border-bottom-color: #f39c12 !important;
}

/* Responsive */
@media (max-width: 768px) {
    .editor-toolbar {
        flex-direction: column;
        top: auto;
        position: relative;
    }

    .editor-toolbar-left {
        flex-direction: column;
        width: 100%;
    }

    #editor-file-select {
        width: 100%;
        min-width: auto;
    }

    .editor-mode-toggle {
        width: 100%;
    }

    .editor-mode-btn {
        flex: 1;
        justify-content: center;
    }

    .editor-save-btn {
        width: 100%;
        justify-content: center;
    }

    .editor-layout {
        flex-direction: column;
    }

    .editor-sidebar {
        width: 100%;
    }

    .editor-sidebar-list {
        max-height: 200px;
    }

    .editor-form, .editor-flat-form {
        max-height: none;
    }
}

/* ================================
   TIMELINE HISTORIQUE
   ================================ */

.timeline-container {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 0;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, transparent, #8B7355 2%, #8B7355 98%, transparent);
    transform: translateX(-50%);
    z-index: 0;
}

/* Era Banners */
.timeline-era {
    position: relative;
    z-index: 2;
    margin: 30px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.timeline-era.timeline-visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-era-content {
    background: linear-gradient(135deg, #2c1810 0%, #4a3018 50%, #2c1810 100%);
    border: 2px solid #c9a84c;
    border-radius: 12px;
    padding: 24px 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.timeline-era-content::before,
.timeline-era-content::after {
    content: '\2756';
    position: absolute;
    color: rgba(201, 168, 76, 0.2);
    font-size: 2.5rem;
}

.timeline-era-content::before {
    top: 5px;
    left: 10px;
}

.timeline-era-content::after {
    bottom: 5px;
    right: 10px;
}

.timeline-era-content:hover {
    transform: scale(1.01);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.timeline-era-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #c9a84c;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(201, 168, 76, 0.15);
}

.timeline-era-icon i {
    color: #f5deb3;
    font-size: 1.3rem;
}

.timeline-era-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.3rem;
    font-weight: bold;
    color: #f5deb3;
    flex: 1;
}

.timeline-era-dates {
    font-style: italic;
    color: #c9a84c;
    font-size: 0.95rem;
    white-space: nowrap;
}

.timeline-era-arrow {
    color: #c9a84c;
    transition: transform 0.2s;
}

.timeline-era-content:hover .timeline-era-arrow {
    transform: translateX(4px);
}

/* Date Markers */
.timeline-date-marker {
    position: relative;
    z-index: 2;
    text-align: center;
    margin: 20px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.timeline-date-marker.timeline-visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-date-label {
    display: inline-block;
    background: var(--header-bg);
    color: white;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* Timeline Events */
.timeline-event {
    position: relative;
    z-index: 1;
    margin: 20px 0;
    display: flex;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.timeline-left {
    padding-right: calc(50% + 30px);
    justify-content: flex-end;
    transform: translateX(-30px);
}

.timeline-right {
    padding-left: calc(50% + 30px);
    justify-content: flex-start;
    transform: translateX(30px);
}

.timeline-event.timeline-visible {
    opacity: 1;
    transform: translateX(0);
}

.timeline-event-content {
    background: #fdf6e3;
    border: 1px solid #d4a843;
    border-radius: 10px;
    padding: 18px 20px;
    max-width: 420px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Connector line from card to dot */
.timeline-event-content::before {
    content: '';
    position: absolute;
    top: 24px;
    width: 24px;
    height: 2px;
    background: #c9a84c;
}

.timeline-left .timeline-event-content::before {
    right: -24px;
}

.timeline-right .timeline-event-content::before {
    left: -24px;
}

.timeline-event-content:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Event Dot on Timeline */
.timeline-event-dot {
    position: absolute;
    left: 50%;
    top: 22px;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.2);
    z-index: 3;
}

.dot-range {
    border-radius: 7px;
    height: 24px;
    width: 14px;
}

/* Event Badges */
.timeline-event-badges {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.event-type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.3px;
}

.type-article {
    background: #dbeafe;
    color: #1e40af;
}

.type-session {
    background: #dcfce7;
    color: #166534;
}

.type-historique {
    background: #ffedd5;
    color: #9a3412;
}

.type-lore {
    background: #ede9fe;
    color: #5b21b6;
}

.type-autre {
    background: #f3f4f6;
    color: #374151;
}

.xp-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    background: #fef3c7;
    color: #92400e;
}

.xp-badge i {
    font-size: 0.65rem;
}

/* Event Content */
.timeline-event-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    color: var(--header-bg);
    line-height: 1.3;
}

.timeline-event-date {
    font-size: 0.82rem;
    color: #8B7355;
    margin-bottom: 10px;
}

.timeline-event-date i {
    margin-right: 4px;
}

.timeline-event-thumb {
    max-width: 100%;
    max-height: 120px;
    border-radius: 6px;
    margin-bottom: 10px;
    object-fit: cover;
}

.timeline-left .timeline-event-thumb {
    float: right;
    max-width: 40%;
    margin-left: 12px;
}

.timeline-right .timeline-event-thumb {
    float: left;
    max-width: 40%;
    margin-right: 12px;
}

.timeline-event-excerpt {
    margin: 0 0 8px;
    font-size: 0.88rem;
    color: #555;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.timeline-event-source {
    font-size: 0.78rem;
    color: #999;
    font-style: italic;
    clear: both;
}

.timeline-event-source i {
    margin-right: 4px;
}

/* Responsive Timeline */
@media (max-width: 768px) {
    .timeline-line {
        left: 20px;
    }

    .timeline-left,
    .timeline-right {
        padding-left: 50px;
        padding-right: 10px;
        justify-content: flex-start;
    }

    .timeline-left {
        transform: translateX(-30px);
    }

    .timeline-right {
        transform: translateX(-30px);
    }

    .timeline-event-content {
        max-width: 100%;
    }

    .timeline-event-content::before {
        left: -24px !important;
        right: auto !important;
    }

    .timeline-event-dot {
        left: 20px;
    }

    .timeline-era-content {
        padding: 16px 20px;
        gap: 12px;
    }

    .timeline-era-icon {
        width: 40px;
        height: 40px;
    }

    .timeline-era-icon i {
        font-size: 1rem;
    }

    .timeline-era-title {
        font-size: 1.1rem;
    }

    .timeline-era-dates {
        font-size: 0.8rem;
    }

    .timeline-left .timeline-event-thumb,
    .timeline-right .timeline-event-thumb {
        float: none;
        max-width: 100%;
        margin: 0 0 10px;
    }
}

/* ================================
   DM NOTES & VISIBILITY
   ================================ */

/* Notes DM dans la modale */
.dm-note {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 20px;
    clear: both;
}

.dm-note-label {
    display: inline-block;
    background: #f39c12;
    color: white;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.dm-note-label i {
    margin-right: 4px;
}

.dm-note-content {
    color: #856404;
    font-size: 0.95rem;
    line-height: 1.6;
}

.dm-note-content p {
    margin: 0 0 8px;
}

/* ================================
   TRÉSOR: CHARGES & TYPES DE DÉGÂTS
   ================================ */

.tresor-charges,
.tresor-damage-types {
    background: var(--card-bg);
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 20px;
    clear: both;
}

.tresor-section-title {
    font-weight: bold;
    font-size: 0.95rem;
    color: var(--header-bg);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tresor-section-title i {
    color: var(--primary-color);
}

/* Charges bar */
.charges-bar {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.charge-pip {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #27ae60;
    border: 2px solid #1a9850;
    transition: background 0.3s, border-color 0.3s, transform 0.2s;
    box-shadow: inset 0 -2px 3px rgba(0,0,0,0.15);
}

.charge-pip.used {
    background: #3a3a3a;
    border-color: #555;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

/* Charges controls */
.charges-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.charges-count {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-color);
    min-width: 50px;
    text-align: center;
}

.charges-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, transform 0.1s;
    color: #555;
}

.charges-btn:hover {
    transform: translateY(-1px);
}

.charges-btn-use:hover { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.charges-btn-restore:hover { background: #dcfce7; color: #166534; border-color: #86efac; }
.charges-btn-reset:hover { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* Damage types grid */
.damage-types-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.damage-type-chip {
    background: var(--bg-color);
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-color);
}

.damage-type-chip:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.damage-type-chip i {
    font-size: 0.7rem;
    color: #999;
}

.damage-type-chip.dt-used {
    background: #dcfce7;
    border-color: #27ae60;
    color: #166534;
    text-decoration: line-through;
}

.damage-type-chip.dt-used i {
    color: #27ae60;
}

/* Damage types footer */
.damage-types-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.dt-counter {
    font-size: 0.85rem;
    color: #888;
    font-style: italic;
}

/* Métadonnées trésors dans la modale */
.modal-tresor-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

/* Items invisibles dans l'éditeur sidebar */
.editor-sidebar-item.item-hidden {
    opacity: 0.5;
    font-style: italic;
}

.editor-sidebar-item.item-hidden .item-hidden-icon {
    color: #999;
    font-size: 0.75rem;
    margin-right: 2px;
}

.editor-sidebar-item.item-hidden.active {
    opacity: 0.7;
}

/* Badge "invisible" sur les cartes (DM) */
.item-hidden-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(153, 27, 27, 0.1);
    color: #991b1b;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Carte invisible (DM voit grisé) */
.card-hidden-dm {
    opacity: 0.6;
    border: 1px dashed #ccc;
}

.card-hidden-dm:hover {
    opacity: 0.85;
}

/* Item liste invisible (DM voit grisé) */
.list-item-hidden-dm {
    opacity: 0.6;
    border-left: 3px solid #991b1b;
}

/* ================================
   HEADER LEFT (logo + theme toggle)
   ================================ */

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ================================
   THEME TOGGLE BUTTON
   ================================ */

.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--header-text);
    cursor: pointer;
    font-size: 1rem;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.1);
    transform: scale(1.05);
}

/* Size Controls */
.size-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 2px;
}

.size-btn {
    background: none;
    border: none;
    color: var(--header-text);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 4px 7px;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}

.size-btn:hover {
    background: rgba(255,255,255,0.15);
}

.size-label {
    color: var(--header-text);
    font-size: 0.75rem;
    min-width: 32px;
    text-align: center;
    opacity: 0.8;
}

/* ================================
   DM MULTI-DEVICE MANAGEMENT
   ================================ */

.modal-md {
    max-width: 600px;
}

/* Options modal */
.dm-options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.dm-option-btn {
    width: 100%;
    padding: 14px 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: var(--bg-color);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s, transform 0.1s;
    color: var(--text-color);
}

.dm-option-btn:hover {
    background: #e8f4f8;
    transform: translateX(4px);
}

.dm-option-btn-danger:hover {
    background: #fee2e2;
    color: #991b1b;
}

.dm-option-btn i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    color: var(--primary-color);
}

/* Device management */
.dm-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.dm-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.dm-section-title {
    font-weight: bold;
    font-size: 0.95rem;
    color: var(--header-bg);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dm-section-title i {
    color: var(--primary-color);
}

.dm-device-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dm-device-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg-color);
    border-left: 4px solid #27ae60;
    transition: box-shadow 0.2s;
}

.dm-device-row:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.dm-device-row.device-inactive {
    border-left-color: #e74c3c;
    opacity: 0.7;
}

.dm-device-row.device-current {
    border-left-color: #f39c12;
    background: #fff8e1;
}

.dm-device-info {
    flex: 1;
    min-width: 0;
}

.dm-device-name {
    font-weight: bold;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dm-device-badge {
    font-size: 0.7rem;
    background: #f39c12;
    color: white;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: normal;
}

.dm-device-meta {
    font-size: 0.78rem;
    color: #888;
    margin-top: 2px;
}

.dm-device-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.dm-btn-sm {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.78rem;
    transition: background 0.2s;
    color: #555;
}

.dm-btn-sm:hover {
    background: #e0e0e0;
}

.dm-btn-sm.dm-btn-danger:hover {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.dm-btn-sm.dm-btn-toggle:hover {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

/* Registration toggle */
.dm-registration-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-color);
    border-radius: 8px;
}

.dm-registration-status {
    font-weight: bold;
    font-size: 0.9rem;
}

.dm-registration-status.status-open {
    color: #27ae60;
}

.dm-registration-status.status-locked {
    color: #e74c3c;
}

/* Change key form */
.dm-change-key-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dm-change-key-form .dm-input {
    margin-bottom: 0;
}

.dm-change-key-form .dm-btn-primary {
    width: auto;
    align-self: flex-start;
}

/* ================================
   DARK THEME OVERRIDES
   ================================ */

/* Footer */
[data-theme="dark"] footer {
    background: #151520;
    color: #666;
}

/* Toolbar */
[data-theme="dark"] .toolbar {
    background: rgba(28, 28, 40, 0.95);
    border-color: #2a2a3a;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

[data-theme="dark"] .toolbar input,
[data-theme="dark"] .toolbar select {
    background: #252535;
    color: #d4d4dc;
    border-color: #3a3a4a;
}

[data-theme="dark"] .toolbar label {
    color: #aaa;
}

/* Cards */
[data-theme="dark"] .card {
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

[data-theme="dark"] .card-header {
    border-bottom-color: #2a2a3a;
}

/* Meta pills */
[data-theme="dark"] .meta-pill { background: #2a2a3a; color: #bbb; }
[data-theme="dark"] .meta-align { background: #2d2350; color: #a78bfa; }
[data-theme="dark"] .meta-race { background: #1e3050; color: #60a5fa; }
[data-theme="dark"] .meta-status { background: #252535; color: #9ca3af; }
[data-theme="dark"] .meta-alive { background: #14352a; color: #4ade80; }
[data-theme="dark"] .meta-dead { background: #3b1515; color: #f87171; }
[data-theme="dark"] .meta-lieu { background: #3b2e10; color: #fbbf24; }
[data-theme="dark"] .meta-role { background: #252535; color: #aaa; }
[data-theme="dark"] .meta-region { background: #0c3045; color: #38bdf8; }
[data-theme="dark"] .meta-leader { background: #3d1535; color: #f472b6; }
[data-theme="dark"] .meta-type { background: #2a2a3a; color: #bbb; }
[data-theme="dark"] .meta-pop { background: #0a3025; color: #34d399; }
[data-theme="dark"] .meta-date { background: #3b2510; color: #fb923c; }
[data-theme="dark"] .meta-journal { background: #0c2840; color: #38bdf8; }
[data-theme="dark"] .meta-session { background: #14352a; color: #4ade80; }
[data-theme="dark"] .meta-xp { background: #3b2e10; color: #fbbf24; }
[data-theme="dark"] .meta-cat { background: #2d2350; color: #a78bfa; }
[data-theme="dark"] .meta-rarity { background: #3b2e10; color: #fbbf24; }
[data-theme="dark"] .meta-value { background: #0a3025; color: #34d399; }
[data-theme="dark"] .meta-replace { background: #3b2510; color: #fb923c; }
[data-theme="dark"] .meta-attune { background: #3d1535; color: #f472b6; }
[data-theme="dark"] .meta-owner { background: #0a3030; color: #2dd4bf; }
[data-theme="dark"] .meta-location { background: #1e2050; color: #818cf8; }
[data-theme="dark"] .meta-weight { background: #252535; color: #9ca3af; }
[data-theme="dark"] .meta-hidden { background: #3b1515; color: #f87171; }

/* Item tags */
[data-theme="dark"] .item-tag { background: #2a2a3a; color: #9ca3af; }
[data-theme="dark"] .item-tag-more { background: transparent; color: #666; }

/* View toggle */
/* XP Total Badge */
[data-theme="dark"] .xp-total-badge { background: #3b2e10; color: #fbbf24; border-color: #5a4a10; }
[data-theme="dark"] .xp-total-badge i { color: #fbbf24; }

[data-theme="dark"] .view-toggle { border-color: #3a3a4a; }
[data-theme="dark"] .view-toggle-btn { background: #1c1c28; color: #888; }
[data-theme="dark"] .view-toggle-btn.active { background: var(--primary-color); color: white; }
[data-theme="dark"] .view-toggle-btn:not(:last-child) { border-right-color: #3a3a4a; }
[data-theme="dark"] .view-toggle-btn:hover:not(.active) { background: #252535; color: #bbb; }

/* List view */
[data-theme="dark"] .list-item { box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
[data-theme="dark"] .list-item-desc { color: #888; }

/* Modal */
[data-theme="dark"] .modal-content {
    background: #1c1c28;
    box-shadow: 0 10px 25px rgba(0,0,0,0.7);
}

[data-theme="dark"] .modal-content h2 { border-bottom-color: #2a2a3a; }
[data-theme="dark"] .close-modal { color: #666; }
[data-theme="dark"] .close-modal:hover { color: var(--primary-color); }
[data-theme="dark"] .modal-tresor-meta { border-bottom-color: #2a2a3a; }

/* Welcome page */
[data-theme="dark"] .welcome-hero h1 { color: #d4d4dc; }
[data-theme="dark"] .welcome-subtitle { color: #888; }
[data-theme="dark"] .welcome-content { box-shadow: 0 2px 10px rgba(0,0,0,0.4); }
[data-theme="dark"] .welcome-content > p { color: #aaa; }
[data-theme="dark"] .welcome-card { background: var(--bg-color); }
[data-theme="dark"] .welcome-card h3 { color: #d4d4dc; }
[data-theme="dark"] .welcome-card p { color: #888; }
[data-theme="dark"] .welcome-card-clickable:hover { box-shadow: 0 4px 15px rgba(0,0,0,0.4); }
[data-theme="dark"] .welcome-cta { color: #666 !important; }

/* Barometer */
[data-theme="dark"] .barometer { background: #1c1c28; border-color: #2a2a3a; }
[data-theme="dark"] .baro-section h3 { color: #aaa; }
[data-theme="dark"] .baro-controls button { background: #252535; border-color: #3a3a4a; color: #d4d4dc; }

/* Scroll to top */
[data-theme="dark"] #scroll-top { box-shadow: 0 4px 10px rgba(0,0,0,0.5); }

/* DM modals */
[data-theme="dark"] .dm-input { background: #252535; color: #d4d4dc; border-color: #3a3a4a; }
[data-theme="dark"] .dm-btn-secondary { background: #252535; color: #d4d4dc; border-color: #3a3a4a; }
[data-theme="dark"] .dm-option-btn { background: #252535; border-color: #3a3a4a; color: #d4d4dc; }
[data-theme="dark"] .dm-option-btn:hover { background: #1a2a3a; }
[data-theme="dark"] .dm-option-btn-danger:hover { background: #3b1515; color: #f87171; }
[data-theme="dark"] .dm-device-row { background: #252535; border-left-color: #2ecc71; }
[data-theme="dark"] .dm-device-row.device-inactive { border-left-color: #e74c3c; }
[data-theme="dark"] .dm-device-row.device-current { border-left-color: #f39c12; background: #2a2510; }
[data-theme="dark"] .dm-device-meta { color: #666; }
[data-theme="dark"] .dm-btn-sm { background: #1c1c28; border-color: #3a3a4a; color: #aaa; }
[data-theme="dark"] .dm-btn-sm:hover { background: #252535; }
[data-theme="dark"] .dm-btn-sm.dm-btn-danger:hover { background: #3b1515; color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .dm-btn-sm.dm-btn-toggle:hover { background: #1e3050; color: #60a5fa; border-color: #1e40af; }
[data-theme="dark"] .dm-registration-toggle { background: #252535; }
[data-theme="dark"] .dm-section { border-bottom-color: #2a2a3a; }
[data-theme="dark"] .dm-section-title { color: #d4d4dc; }

/* Trésor charges & dégâts */
[data-theme="dark"] .tresor-charges,
[data-theme="dark"] .tresor-damage-types { border-color: #2a2a3a; }
[data-theme="dark"] .tresor-section-title { color: #d4d4dc; }
[data-theme="dark"] .charge-pip { background: #2ecc71; border-color: #1a9850; }
[data-theme="dark"] .charge-pip.used { background: #2a2a3a; border-color: #444; }
[data-theme="dark"] .charges-btn { background: #252535; border-color: #3a3a4a; color: #aaa; }
[data-theme="dark"] .charges-btn-use:hover { background: #3b1515; color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .charges-btn-restore:hover { background: #14352a; color: #4ade80; border-color: #166534; }
[data-theme="dark"] .charges-btn-reset:hover { background: #1e3050; color: #60a5fa; border-color: #1e40af; }
[data-theme="dark"] .damage-type-chip { background: #252535; border-color: #3a3a4a; }
[data-theme="dark"] .damage-type-chip.dt-used { background: #14352a; border-color: #166534; color: #4ade80; }
[data-theme="dark"] .damage-type-chip.dt-used i { color: #4ade80; }

/* DM Notes */
[data-theme="dark"] .dm-note { background: #2a2510; border-color: #5a4a10; }
[data-theme="dark"] .dm-note-content { color: #d4a843; }

/* Editor */
[data-theme="dark"] .editor-toolbar { background: rgba(28, 28, 40, 0.95); border-color: #2a2a3a; box-shadow: 0 4px 15px rgba(0,0,0,0.4); }
[data-theme="dark"] #editor-file-select { background: #252535; color: #d4d4dc; border-color: #3a3a4a; }
[data-theme="dark"] .editor-mode-toggle { border-color: #3a3a4a; }
[data-theme="dark"] .editor-mode-btn { background: #1c1c28; color: #888; }
[data-theme="dark"] .editor-mode-btn:not(:last-child) { border-right-color: #3a3a4a; }
[data-theme="dark"] .editor-mode-btn:hover:not(.active) { background: #252535; }
[data-theme="dark"] .editor-sidebar { background: #1c1c28; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
[data-theme="dark"] .editor-sidebar-item { border-bottom-color: #2a2a3a; color: #d4d4dc; }
[data-theme="dark"] .editor-sidebar-item:hover { background: #252535; }
[data-theme="dark"] .editor-sidebar-item.active { background: #1a2a3a; }
[data-theme="dark"] .editor-form,
[data-theme="dark"] .editor-flat-form { background: #1c1c28; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
[data-theme="dark"] .editor-form-header { border-bottom-color: #2a2a3a; }
[data-theme="dark"] .editor-input { background: #252535; color: #d4d4dc; border-color: #3a3a4a; }
[data-theme="dark"] .editor-field-label { color: #aaa; }
[data-theme="dark"] .editor-field-hint { color: #666; }
[data-theme="dark"] .editor-subfields { border-left-color: #3a3a4a; }
[data-theme="dark"] .editor-metadata { border-color: #3a3a4a; }
[data-theme="dark"] .editor-metadata summary { background: #252535; color: #aaa; }
[data-theme="dark"] .editor-metadata summary:hover { background: #2a2a3a; }
[data-theme="dark"] .editor-placeholder { color: #666; }
[data-theme="dark"] .editor-message { background: #2a2510; border-color: #5a4a10; color: #d4a843; }

/* Timeline */
[data-theme="dark"] .timeline-event-content { background: #1c1c28; border-color: #3a3a4a; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
[data-theme="dark"] .timeline-event-content::before { background: #3a3a4a; }
[data-theme="dark"] .timeline-event-content:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
[data-theme="dark"] .timeline-event-title { color: #d4d4dc; }
[data-theme="dark"] .timeline-event-date { color: #888; }
[data-theme="dark"] .timeline-event-excerpt { color: #aaa; }
[data-theme="dark"] .timeline-event-dot { border-color: #1c1c28; }

/* Markdown content */
[data-theme="dark"] .description,
[data-theme="dark"] .full-content { color: #d4d4dc; }

[data-theme="dark"] .description code,
[data-theme="dark"] .full-content code {
    background: #252535;
    color: #e0e0e0;
}

[data-theme="dark"] .description blockquote,
[data-theme="dark"] .full-content blockquote {
    border-left-color: #3a3a4a;
    color: #aaa;
}

[data-theme="dark"] .description pre,
[data-theme="dark"] .full-content pre {
    background: #0f0f18;
}

[data-theme="dark"] .description table th,
[data-theme="dark"] .full-content table th {
    background: #252535;
    border-color: #3a3a4a;
}

[data-theme="dark"] .description table td,
[data-theme="dark"] .full-content table td {
    border-color: #2a2a3a;
}

/* Nav buttons (subtle text color fix) */
[data-theme="dark"] nav button { color: #888; }
[data-theme="dark"] nav button:hover,
[data-theme="dark"] nav button.active { color: #ecf0f1; }

/* Notifications (already dark-ish, just refine) */
[data-theme="dark"] .notification { background: #252535; }

/* Loading & error */
[data-theme="dark"] .loading { color: #888; }

/* Card hidden DM */
[data-theme="dark"] .card-hidden-dm { border-color: #3a3a4a; }
[data-theme="dark"] .list-item-hidden-dm { border-left-color: #f87171; }

/* ========================================
   CARTE LEAFLET (Lieux)
   ======================================== */
.map-view-container {
    width: 100%;
}

.map-carte-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.map-carte-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.map-carte-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.map-carte-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

#leaflet-map {
    height: 600px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    z-index: 1;
}

/* Poignée de redimensionnement */
.map-resize-handle {
    width: 100%;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    color: #aaa;
    background: var(--card-bg);
    border-radius: 0 0 8px 8px;
    border-top: 1px solid #eee;
    user-select: none;
    transition: background 0.2s, color 0.2s;
}

.map-resize-handle:hover {
    background: #f0f0f0;
    color: #666;
}

.map-resize-handle i {
    font-size: 0.75rem;
}

/* Marqueurs custom */
.map-marker-icon {
    background: none;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.map-marker-icon:hover {
    transform: scale(1.2);
}

.map-marker-icon i {
    font-size: 28px;
    line-height: 1;
}

/* Popup */
.map-popup {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-width: 140px;
}

.map-popup strong {
    color: var(--primary-color);
    font-size: 1rem;
}

.map-popup-type {
    font-size: 0.85rem;
    color: #888;
}

.map-popup-region {
    font-size: 0.8rem;
    color: #aaa;
    font-style: italic;
}

.map-popup-btn {
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.map-popup-btn:hover {
    background: #b71c1c;
}

/* Responsive carte */
@media (max-width: 768px) {
    #leaflet-map {
        height: 400px;
    }
}

/* Dark theme — Carte Leaflet */
[data-theme="dark"] .map-carte-btn {
    border-color: #3a3a4a;
    background: #1c1c28;
    color: #d4d4dc;
}

[data-theme="dark"] .map-carte-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

[data-theme="dark"] .map-carte-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

[data-theme="dark"] .map-resize-handle {
    background: #1c1c28;
    border-top-color: #3a3a4a;
    color: #555;
}

[data-theme="dark"] .map-resize-handle:hover {
    background: #252535;
    color: #888;
}

[data-theme="dark"] #leaflet-map {
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

[data-theme="dark"] .map-marker-icon {
    color: #e53935;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7));
}

[data-theme="dark"] .leaflet-popup-content-wrapper {
    background: #1c1c28;
    color: #d4d4dc;
}

[data-theme="dark"] .leaflet-popup-tip {
    background: #1c1c28;
}

[data-theme="dark"] .map-popup strong {
    color: var(--primary-color);
}

[data-theme="dark"] .map-popup-type {
    color: #999;
}

[data-theme="dark"] .leaflet-control-zoom a {
    background: #1c1c28;
    color: #d4d4dc;
    border-color: #3a3a4a;
}

[data-theme="dark"] .leaflet-control-zoom a:hover {
    background: #252535;
}

/* === Éditeur visuel de cartes (DM) === */

.cartes-editor {
    margin-bottom: 1rem;
}

.cartes-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    margin-bottom: 12px;
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.cartes-add-btn:hover {
    background: #1b5e20;
}

.cartes-entries {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cartes-entry {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    background: var(--card-bg);
}

.cartes-entry-header {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.cartes-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}

.cartes-field-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #666;
}

.cartes-carte-select,
.cartes-icon-select {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
}

.cartes-icon-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    color: var(--primary-color);
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.cartes-field:has(.cartes-icon-select) {
    position: relative;
}

.cartes-icon-select {
    padding-right: 36px;
}

.cartes-remove-btn {
    padding: 8px 12px;
    background: #c62828;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
    flex-shrink: 0;
    align-self: flex-end;
}

.cartes-remove-btn:hover {
    background: #b71c1c;
}

.cartes-coords {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cartes-coord-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #666;
    min-width: 12px;
}

.cartes-coord-input {
    width: 80px !important;
    padding: 4px 8px !important;
    text-align: center;
    font-size: 0.9rem;
}

.cartes-editor-map {
    height: 300px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #eee;
    overflow: hidden;
}

.cartes-no-carte {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-style: italic;
}

.cartes-click-hint {
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    margin-top: 6px;
    font-style: italic;
}

/* Dark theme overrides */
[data-theme="dark"] .cartes-entry {
    border-color: #3a3a4a;
}

[data-theme="dark"] .cartes-field-label {
    color: #999;
}

[data-theme="dark"] .cartes-carte-select,
[data-theme="dark"] .cartes-icon-select {
    border-color: #3a3a4a;
    background: #1c1c28;
    color: #d4d4dc;
}

[data-theme="dark"] .cartes-coord-label {
    color: #999;
}

[data-theme="dark"] .cartes-editor-map {
    border-color: #3a3a4a;
    background: #151520;
}

[data-theme="dark"] .cartes-no-carte {
    color: #666;
}

[data-theme="dark"] .cartes-click-hint {
    color: #666;
}
