@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

/* ============================================================
   THÈMES AUTOMNE DORÉ (sombre, défaut) & AUTOMNE CLAIR — v3
   Modernisé : palettes affinées, grain subtil, profondeur à
   double ombre, texte en dégradé, transitions de thème douces.
   ============================================================ */

:root {
    color-scheme: dark;

    --bg-main: #211b14;
    --bg-darker: #17120d;
    --panel-bg: #2d251c;
    --panel-bg-light: #3b3024;

    --card-bg: rgba(48, 39, 29, 0.82);
    --card-bg-hover: rgba(65, 52, 38, 0.94);

    --text-primary: #faf7ef;
    --text-main: #faf7ef;
    --text-secondary: #ded2c1;
    --text-muted: #b5a38d;
    --text-dim: #91806b;

    /* Accents chauds — ambre profond, miel lumineux */
    --primary: #e7850b;
    --primary-light: #ffc94d;
    --primary-dark: #9a4a06;
    --primary-rgb: 231, 133, 11;
    --gradient-primary: linear-gradient(135deg, #ffd166 0%, #f59e0b 40%, #c2410c 100%);
    --gradient-text: linear-gradient(120deg, #ffe8b0, #fbbf24 45%, #ea8a1e);
    --gradient-sheen: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.10) 50%, transparent 65%);

    --accent: #f2610c;
    --accent-rgb: 242, 97, 12;
    --accent-meteo: #fbbf24;

    --purple: #b57bee;
    --purple-rgb: 181, 123, 238;

    --danger: #e5484d;
    --danger-light: #ff7a7f;

    --border-color: rgba(250, 247, 239, 0.09);
    --border: rgba(250, 247, 239, 0.09);
    --border-lift: rgba(231, 133, 11, 0.48);
    --shadow-color: rgba(0, 0, 0, 0.42);
    --glow: 0 0 0 1px rgba(231, 133, 11, 0.14), 0 8px 24px rgba(217, 119, 6, 0.14);
    --board-inset: rgba(0, 0, 0, 0.42);

    /* Ombre à double couche : ambiance + key light */
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 12px 30px -8px rgba(0, 0, 0, 0.38);
    --card-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.18), 0 20px 42px -10px rgba(0, 0, 0, 0.42);
    --item-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);

    --page-gradient:
        radial-gradient(circle 720px at 50% -12%, rgba(255, 190, 80, 0.15), transparent 70%),
        radial-gradient(circle 560px at 95% 105%, rgba(194, 65, 12, 0.07), transparent 70%),
        linear-gradient(180deg, #211b14 0%, #1b150f 100%);

    --radius-card: 20px;
    --radius-item: 12px;
    --keyboard-bg: #292117;

    --chart-accent: #fbbf24;
    --chart-accent-rgb: 251, 191, 36;
    --chart-text: #cfc2b0;
    --chart-grid: rgba(250, 247, 239, 0.06);
    --rules-bg: rgba(250, 247, 239, 0.05);

    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --on-primary: #1c1005;
    --surface-solid: var(--panel-bg);

    /* Mouvement & focus */
    --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --focus-ring: 0 0 0 3px rgba(var(--primary-rgb), 0.35);
}

/* ============================================================
   THÈME CLAIR — AUTOMNE CLAIR (Sable / Cuivre / Miel)
   ============================================================ */

[data-theme="light"] {
    color-scheme: light;

    --bg-main: #fbf7ef;
    --bg-darker: #f1eadd;
    --panel-bg: #ffffff;
    --panel-bg-light: #faf5ec;

    --card-bg: rgba(255, 255, 255, 0.85);
    --card-bg-hover: #ffffff;

    --text-primary: #292017;
    --text-main: #292017;
    --text-secondary: #5c4f41;
    --text-muted: #8b7c6c;
    --text-dim: #b6a897;

    --primary: #b45309;
    --primary-light: #d97706;
    --primary-dark: #92400e;
    --primary-rgb: 180, 83, 9;
    --gradient-primary: linear-gradient(135deg, #f59e0b 0%, #d97706 45%, #92400e 100%);
    --gradient-text: linear-gradient(120deg, #b45309, #d97706 50%, #92400e);
    --gradient-sheen: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);

    --accent: #c2410c;
    --accent-rgb: 194, 65, 12;
    --accent-meteo: #d97706;

    --purple: #7e22ce;
    --purple-rgb: 126, 34, 206;

    --danger: #d5383d;
    --danger-light: #ef4444;

    --border-color: rgba(41, 32, 23, 0.10);
    --border: rgba(41, 32, 23, 0.10);
    --border-lift: rgba(180, 83, 9, 0.45);
    --shadow-color: rgba(41, 32, 23, 0.10);
    --glow: 0 0 0 1px rgba(180, 83, 9, 0.10), 0 8px 24px rgba(180, 83, 9, 0.12);
    --board-inset: rgba(41, 32, 23, 0.06);

    --card-shadow: 0 1px 2px rgba(41, 32, 23, 0.06), 0 12px 32px -8px rgba(41, 32, 23, 0.18);
    --card-shadow-hover: 0 2px 6px rgba(41, 32, 23, 0.07), 0 20px 44px -10px rgba(41, 32, 23, 0.22);
    --item-shadow: 0 1px 2px rgba(41, 32, 23, 0.08);

    --page-gradient:
        radial-gradient(circle 720px at 50% -12%, rgba(217, 119, 6, 0.08), transparent 70%),
        radial-gradient(circle 560px at 95% 105%, rgba(180, 83, 9, 0.05), transparent 70%),
        linear-gradient(180deg, #fbf7ef, #f6efe3);
    --keyboard-bg: #ece4d6;

    --chart-accent: #b45309;
    --chart-accent-rgb: 180, 83, 9;
    --chart-text: #5c4f41;
    --chart-grid: rgba(41, 32, 23, 0.08);
    --rules-bg: rgba(180, 83, 9, 0.05);

    --focus-ring: 0 0 0 3px rgba(var(--primary-rgb), 0.25);
}

/* ============================================================
   BASE GLOBALE & ANTI-DÉBORDEMENT MOBILE
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100vw;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main, 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

body {
    background-image: var(--page-gradient, none);
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Grain photographique très subtil — donne de la matière au fond */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 16px;
    position: relative;
    z-index: 1;
}

/* Transition douce lors du changement de thème */
header, .bento section, .game, .weather, .nas-item,
.theme-btn, .tool-btn, #toast, .modal-box {
    transition: background-color .35s var(--ease-out), color .35s var(--ease-out),
                border-color .35s var(--ease-out), box-shadow .35s var(--ease-out);
}

/* Fondu doux lors du changement de thème (classe posée par common.js v2) */
html.theme-fade, html.theme-fade body,
html.theme-fade header, html.theme-fade .bento section,
html.theme-fade .game, html.theme-fade .weather, html.theme-fade .nas-item {
    transition: background-color .4s ease, background .4s ease,
                color .4s ease, border-color .4s ease, box-shadow .4s ease;
}

/* Sélection & scrollbar teintées */
::selection {
    background: rgba(var(--primary-rgb), 0.35);
    color: var(--text-primary);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb), 0.25);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(var(--primary-rgb), 0.5); background-clip: content-box; }
* { scrollbar-width: thin; scrollbar-color: rgba(var(--primary-rgb), 0.35) transparent; }

/* Accessibilité clavier */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-item);
}

/* ============================================================
   EN-TÊTE
   ============================================================ */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border: var(--border-width, 1px) solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 16px 20px;
    -webkit-backdrop-filter: blur(var(--card-blur, 14px));
    backdrop-filter: blur(var(--card-blur, 14px));
    box-shadow: var(--card-shadow);
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

/* Arc lumineux discret au sommet de l'en-tête */
header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: var(--header-line, var(--gradient-primary));
    opacity: var(--header-line-opacity, 0.55);
    pointer-events: none;
}

.hero-left .hero-greeting {
    font-family: var(--font-display, inherit);
    font-size: clamp(1.4rem, 4vw, 1.9rem);
    font-weight: 800;
    margin: 0 0 2px 0;
    letter-spacing: -0.01em;
    color: var(--greeting-color, transparent);
    /* Texte en dégradé ambré (thèmes plats : couleur pleine) */
    background: var(--greeting-bg, var(--gradient-text));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: var(--greeting-fill, transparent);
}

.hero-left .hero-sub {
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
    color: var(--text-secondary);
    margin: 0;
}

.hero-right .hero-clock {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.hero-right #clock {
    font-family: var(--font-clock, inherit);
    font-size: clamp(1.4rem, 4vw, 1.9rem);
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.hero-right .seconds {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.hero-right .date {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* ============================================================
   GRILLE BENTO
   ============================================================ */

.bento {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    flex: 1;
    width: 100%;
}

.bento section {
    background: var(--card-bg);
    border: var(--border-width, 1px) solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 16px;
    -webkit-backdrop-filter: blur(var(--card-blur, 14px));
    backdrop-filter: blur(var(--card-blur, 14px));
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    position: relative;
    /* Survol : la carte se soulève et son halo s'allume */
    transition: transform .3s var(--ease-out), box-shadow .35s var(--ease-out),
                border-color .35s var(--ease-out), background-color .35s var(--ease-out),
                opacity .35s var(--ease-out);
    animation: card-in .5s var(--ease-out) both;
}

.bento section:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover, var(--card-shadow));
    border-color: var(--border-lift, var(--border-color));
}

/* Reflet qui traverse la carte au survol */
.bento section::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--gradient-sheen);
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: none;
}
.bento section:hover::before {
    opacity: 1;
    animation: sheen 0.9s var(--ease-out);
}
@keyframes sheen {
    from { transform: translateX(-100%); }
    to   { transform: translateX(100%); }
}

.bento section:nth-child(1) { animation-delay: 0.04s; }
.bento section:nth-child(2) { animation-delay: 0.10s; }
.bento section:nth-child(3) { animation-delay: 0.16s; }
.bento section:nth-child(4) { animation-delay: 0.22s; }
.bento section:nth-child(5) { animation-delay: 0.28s; }
.bento section:nth-child(6) { animation-delay: 0.34s; }

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(var(--primary-rgb), 0.14);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    border: 1px solid rgba(var(--primary-rgb), 0.14);
}

.card-title-text {
    font-family: var(--font-display, inherit);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   JEUX / MÉTÉO / NAS
   ============================================================ */

.games {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.game {
    background: var(--panel-bg);
    border: var(--item-border-width, 1px) solid var(--border-color);
    border-radius: var(--radius-item);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--item-shadow);
    position: relative;
    overflow: hidden;
    min-width: 0;
    transition: transform .25s var(--ease-pop), background-color .2s ease,
                border-color .2s ease, box-shadow .25s ease;
}

.game:hover {
    background: var(--card-bg-hover);
    border-color: var(--border-lift, var(--primary));
    transform: translateY(-2px);
    box-shadow: var(--glow);
}

.game:active { transform: translateY(0) scale(0.98); }

/* Halo qui suit l'entrée de la souris (grâce à --mx/--my posés en JS) */
.game::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(140px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--primary-rgb), 0.12), transparent 70%);
    transition: opacity .25s ease;
}
.game:hover::after { opacity: 1; }

.game-icon {
    font-size: 1.1rem;
    color: var(--primary);
    flex-shrink: 0;
    transition: transform .25s var(--ease-pop);
}
.game:hover .game-icon { transform: scale(1.15) rotate(-4deg); }

.game-label {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.weather-grid, .nas-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.weather, .nas-item {
    background: var(--panel-bg);
    border: var(--item-border-width, 1px) solid var(--border-color);
    border-radius: var(--radius-item);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--item-shadow);
    transition: transform .25s var(--ease-pop), background-color .2s ease,
                border-color .2s ease, box-shadow .25s ease;
}

.weather:hover, .nas-item:hover {
    background: var(--card-bg-hover);
    border-color: var(--border-lift, var(--primary));
    transform: translateY(-1px);
    box-shadow: var(--glow);
}

.weather-flag { font-size: 1.2rem; flex-shrink: 0; }
.weather-info { flex: 1; min-width: 0; }
.weather-city { font-weight: 700; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weather-desc { font-size: 0.7rem; color: var(--text-muted); }
.weather-temp { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 1rem; color: var(--primary); flex-shrink: 0; }

.nas-icon { color: var(--primary); font-size: 1rem; flex-shrink: 0; }
.nas-label { flex: 1; font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nas-arrow { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; transition: transform .2s ease; }
.nas-item:hover .nas-arrow { transform: translateX(3px); }

.footer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 8px 0;
}

/* ============================================================
   ÉLÉMENTS PARTAGÉS & COMMANDES
   ============================================================ */

.theme-toggle-btn, .theme-btn {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--item-shadow);
    transition: all .25s var(--ease-pop);
    flex-shrink: 0;
}

.theme-toggle-btn:hover, .theme-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px) rotate(-8deg);
}

.theme-toggle-btn:active, .theme-btn:active { transform: scale(0.9); }

#bottom-controls {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-main);
    z-index: 100;
}

#toolbar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 10px;
    padding-bottom: calc(8px + var(--safe-bottom));
    background: var(--panel-bg);
    border-top: 1px solid var(--border-color);
    gap: 6px;
}

.tool-btn {
    background: var(--panel-bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: var(--radius-item);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s var(--ease-pop);
    flex: 1;
    min-width: 0;
}

.tool-btn i { font-size: 0.95rem; color: var(--primary); transition: transform .25s var(--ease-pop); }
.tool-btn:hover { background: var(--card-bg-hover); color: var(--text-primary); border-color: var(--primary); }
.tool-btn:hover i { transform: translateY(-2px) scale(1.2); }
.tool-btn:active i { transform: scale(0.9); }
.tool-btn.purple i { color: var(--purple); }
.tool-btn.accent i { color: var(--accent); }
.tool-btn.danger i { color: var(--danger); }
.tool-btn.blue i { color: var(--accent-meteo); }

.btn-modal {
    background: var(--gradient-primary, linear-gradient(135deg, var(--primary), var(--primary-dark)));
    color: var(--on-primary, #fff);
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-item);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    width: 100%;
    box-shadow: var(--item-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: filter .2s ease, transform .2s var(--ease-pop), box-shadow .2s ease;
}
.btn-modal:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-modal:active { transform: translateY(1px) scale(0.99); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.show { display: flex; }

.modal-box {
    background: var(--panel-bg);
    border: var(--border-width, 1px) solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 20px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    animation: modal-pop .32s var(--ease-pop) both;
}

@keyframes modal-pop {
    from { opacity: 0; transform: translateY(16px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-box h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.6rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.modal-box p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.theme-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-item);
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
}

.length-selector { display: flex; gap: 4px; }

.len-btn {
    flex: 1;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px;
    border-radius: var(--radius-item);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all .2s var(--ease-pop);
}
.len-btn.active {
    background: var(--primary);
    color: var(--on-primary, #fff);
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: var(--glow);
}

#toast {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface-solid, var(--panel-bg));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: all .3s var(--ease-pop);
    z-index: 10000;
    max-width: 90vw;
    text-align: center;
}
#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Accessibilité : texte sur bouton principal (thème clair) */
[data-theme="light"] { --on-primary: #ffffff; }

/* ============================================================
   CONTRASTE DES BANDEAUX — thème sombre uniquement
   Les zones de contenu ressortent davantage du fond, sans
   modifier la palette du thème clair.
   ============================================================ */
:root {
    --panel-bg: #403326;
    --panel-bg-light: #514131;
    --card-bg: rgba(57, 46, 34, 0.97);
    --card-bg-hover: rgba(75, 59, 42, 0.98);
    --border-color: rgba(255, 226, 177, 0.15);
    --border: rgba(255, 226, 177, 0.15);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 8px 22px -8px rgba(0, 0, 0, 0.30);
}

/* Cartes principales : bandeau légèrement plus clair que le fond */
.bento section,
header {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

/* Sous-bandeaux et blocs internes */
.game,
.weather,
.nas-item,
.tool-btn,
.keyboard,
#keyboard,
.key {
    border-color: rgba(255, 226, 177, 0.12);
}

/* Le thème clair garde ses couleurs d'origine */
[data-theme="light"] {
    --panel-bg: #ffffff;
    --panel-bg-light: #faf5ec;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-bg-hover: #ffffff;
    --border-color: rgba(41, 32, 23, 0.10);
    --border: rgba(41, 32, 23, 0.10);
}

/* ============================================================
   AJUSTEMENT FIN — BANDEAUX PLUS CLAIRS ET MIEUX SÉPARÉS
   Appliqué uniquement au thème sombre ; le thème clair reste intact.
   ============================================================ */
:root:not([data-theme="light"]) {
    --panel-bg: #382d21;
    --panel-bg-light: #493a29;
    --card-bg: rgba(57, 46, 33, 0.97);
    --card-bg-hover: rgba(72, 57, 39, 0.99);
    --border-color: rgba(255, 220, 160, 0.18);
    --border: rgba(255, 220, 160, 0.18);
    --border-lift: rgba(255, 190, 80, 0.52);
    --item-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
}

:root:not([data-theme="light"]) .bento section,
:root:not([data-theme="light"]) header {
    background-color: #392e22;
    border-color: rgba(255, 220, 160, 0.20);
}

:root:not([data-theme="light"]) .weather,
:root:not([data-theme="light"]) .nas-item,
:root:not([data-theme="light"]) .game,
:root:not([data-theme="light"]) .theme-select,
:root:not([data-theme="light"]) .len-btn {
    background-color: #30261b;
    border-color: rgba(255, 220, 160, 0.16);
}

:root:not([data-theme="light"]) .bento section:hover,
:root:not([data-theme="light"]) .weather:hover,
:root:not([data-theme="light"]) .nas-item:hover,
:root:not([data-theme="light"]) .game:hover {
    background-color: #453624;
    border-color: rgba(255, 190, 80, 0.48);
}

/* ============================================================
   RELIEF RENFORCÉ DU THÈME SOMBRE
   Plus de profondeur, sans modifier le thème clair.
   ============================================================ */
:root:not([data-theme="light"]) {
    --card-shadow: 0 1px 0 rgba(255, 226, 180, 0.10) inset,
                   0 2px 5px rgba(0, 0, 0, 0.22),
                   0 12px 28px -7px rgba(0, 0, 0, 0.48),
                   0 0 0 1px rgba(255, 220, 160, 0.045);
    --card-shadow-hover: 0 1px 0 rgba(255, 232, 195, 0.15) inset,
                         0 4px 8px rgba(0, 0, 0, 0.24),
                         0 18px 36px -8px rgba(0, 0, 0, 0.52),
                         0 0 0 1px rgba(255, 190, 80, 0.20);
    --item-shadow: 0 1px 0 rgba(255, 225, 180, 0.09) inset,
                   0 2px 5px rgba(0, 0, 0, 0.30),
                   0 0 0 1px rgba(255, 220, 160, 0.035);
    --glow: 0 1px 0 rgba(255, 232, 195, 0.13) inset,
            0 0 0 1px rgba(255, 190, 80, 0.18),
            0 8px 24px rgba(217, 119, 6, 0.20);
}

:root:not([data-theme="light"]) .bento section,
:root:not([data-theme="light"]) header {
    background-image: linear-gradient(145deg, rgba(255, 231, 190, 0.055), transparent 48%);
    box-shadow: var(--card-shadow);
}

:root:not([data-theme="light"]) .weather,
:root:not([data-theme="light"]) .nas-item,
:root:not([data-theme="light"]) .game,
:root:not([data-theme="light"]) .theme-select,
:root:not([data-theme="light"]) .len-btn {
    background-image: linear-gradient(145deg, rgba(255, 231, 190, 0.045), transparent 65%);
    box-shadow: var(--item-shadow);
}

:root:not([data-theme="light"]) .bento section:hover,
:root:not([data-theme="light"]) header:hover {
    box-shadow: var(--card-shadow-hover);
}

:root:not([data-theme="light"]) .weather:hover,
:root:not([data-theme="light"]) .nas-item:hover,
:root:not([data-theme="light"]) .game:hover {
    box-shadow: var(--glow), 0 5px 12px rgba(0, 0, 0, 0.24);
}

/* ============================================================
   CONTRASTE PLUS FRANC — THÈME SOMBRE
   Bandeaux plus clairs, blocs internes distincts et contours lisibles.
   Le thème clair n'est pas modifié.
   ============================================================ */
:root:not([data-theme="light"]) {
    --panel-bg: #3b2f23;
    --panel-bg-light: #51402d;
    --card-bg: #493a29;
    --card-bg-hover: #5b472f;
    --border-color: rgba(255, 226, 180, 0.26);
    --border: rgba(255, 226, 180, 0.26);
    --border-lift: rgba(255, 196, 92, 0.68);
    --card-shadow: 0 1px 0 rgba(255, 231, 194, 0.16) inset,
                   0 0 0 1px rgba(255, 220, 160, 0.09),
                   0 5px 12px rgba(0, 0, 0, 0.28),
                   0 15px 30px -10px rgba(0, 0, 0, 0.48);
    --card-shadow-hover: 0 1px 0 rgba(255, 235, 205, 0.22) inset,
                         0 0 0 1px rgba(255, 196, 92, 0.32),
                         0 8px 18px rgba(0, 0, 0, 0.30),
                         0 20px 38px -12px rgba(0, 0, 0, 0.52);
    --item-shadow: 0 1px 0 rgba(255, 226, 180, 0.12) inset,
                   0 0 0 1px rgba(255, 226, 180, 0.08),
                   0 3px 8px rgba(0, 0, 0, 0.30);
}

:root:not([data-theme="light"]) .bento section,
:root:not([data-theme="light"]) header {
    background-color: #493a29;
    background-image: linear-gradient(135deg, rgba(255, 231, 190, 0.10), rgba(255, 231, 190, 0.015) 58%, transparent 80%);
    border: 1px solid rgba(255, 226, 180, 0.29);
    box-shadow: var(--card-shadow);
}

:root:not([data-theme="light"]) .game,
:root:not([data-theme="light"]) .weather,
:root:not([data-theme="light"]) .nas-item,
:root:not([data-theme="light"]) .theme-select,
:root:not([data-theme="light"]) .len-btn {
    background-color: #34291e;
    background-image: linear-gradient(135deg, rgba(255, 231, 190, 0.065), transparent 70%);
    border: 1px solid rgba(255, 226, 180, 0.22);
    box-shadow: var(--item-shadow);
}

:root:not([data-theme="light"]) .bento section:hover,
:root:not([data-theme="light"]) header:hover {
    background-color: #55432e;
    border-color: rgba(255, 196, 92, 0.55);
    box-shadow: var(--card-shadow-hover);
}

:root:not([data-theme="light"]) .game:hover,
:root:not([data-theme="light"]) .weather:hover,
:root:not([data-theme="light"]) .nas-item:hover,
:root:not([data-theme="light"]) .theme-select:focus,
:root:not([data-theme="light"]) .len-btn.active {
    background-color: #493722;
    border-color: rgba(255, 196, 92, 0.58);
}

:root:not([data-theme="light"]) .card-title-icon {
    background-color: rgba(255, 190, 80, 0.20);
    border-color: rgba(255, 210, 130, 0.28);
}

/* ============================================================
   PARAGRAPHES PLUS MARRON CLAIR — THÈME SOMBRE UNIQUEMENT
   Fond miel/noisette pour faire ressortir les zones de texte.
   Le thème clair reste inchangé.
   ============================================================ */
:root:not([data-theme="light"]) .bento section p,
:root:not([data-theme="light"]) .modal-box p {
    background: #5a4630;
    color: #fff4df;
    border: 1px solid rgba(255, 220, 160, 0.24);
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: inset 0 1px 0 rgba(255, 239, 210, 0.10),
                0 2px 6px rgba(0, 0, 0, 0.16);
}

:root:not([data-theme="light"]) .bento section p + p {
    margin-top: 8px;
}

/* ============================================================
   CONTRASTE PAR LE FOND — AUTOMNE DORÉ
   Fond général plus profond et plus neutre pour détacher les panneaux.
   Les surfaces sont éclaircies par paliers. Automne clair inchangé.
   ============================================================ */
:root:not([data-theme="light"]) {
    --bg-main: #120e09;
    --bg-darker: #090705;
    --panel-bg: #382819;
    --panel-bg-light: #4b3521;
    --card-bg: #493321;
    --card-bg-hover: #5b4229;
    --border-color: rgba(255, 224, 178, 0.32);
    --border: rgba(255, 224, 178, 0.32);
    --border-lift: rgba(255, 194, 94, 0.78);
}

:root:not([data-theme="light"]) body {
    background-color: #120e09;
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(112, 72, 31, 0.16), transparent 62%);
}

:root:not([data-theme="light"]) .bento section,
:root:not([data-theme="light"]) header {
    background-color: #493321;
    background-image: linear-gradient(145deg, rgba(255, 231, 190, 0.10), rgba(255, 231, 190, 0.015) 60%, transparent 85%);
    border-color: rgba(255, 220, 165, 0.34);
    box-shadow: 0 1px 0 rgba(255, 235, 205, 0.13) inset,
                0 0 0 1px rgba(255, 220, 160, 0.06),
                0 8px 20px rgba(0, 0, 0, 0.42),
                0 18px 34px -12px rgba(0, 0, 0, 0.55);
}

:root:not([data-theme="light"]) .game,
:root:not([data-theme="light"]) .weather,
:root:not([data-theme="light"]) .nas-item,
:root:not([data-theme="light"]) #toolbar,
:root:not([data-theme="light"]) .theme-toggle-btn,
:root:not([data-theme="light"]) .theme-btn,
:root:not([data-theme="light"]) .tool-btn,
:root:not([data-theme="light"]) .theme-select,
:root:not([data-theme="light"]) .len-btn,
:root:not([data-theme="light"]) .modal-box {
    background-color: #5a4129;
    background-image: linear-gradient(145deg, rgba(255, 235, 205, 0.09), transparent 70%);
    border-color: rgba(255, 222, 175, 0.30);
}

:root:not([data-theme="light"]) .bento section p,
:root:not([data-theme="light"]) .modal-box p {
    background: #735638;
    color: #fff6e8;
    border-color: rgba(255, 229, 185, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 245, 222, 0.15),
                0 2px 7px rgba(0, 0, 0, 0.22);
}

:root:not([data-theme="light"]) .bento section:hover,
:root:not([data-theme="light"]) header:hover {
    background-color: #563d26;
    border-color: rgba(255, 196, 92, 0.66);
}

/* ============================================================
   RETOUR DU DORÉ — AUTOMNE DORÉ (thème sombre uniquement)
   Accents or miel, titres soulignés et contrôles dorés.
   Le thème clair reste inchangé.
   ============================================================ */
:root:not([data-theme="light"]) {
    --primary: #f2bd55;
    --primary-light: #ffe2a0;
    --primary-dark: #b77a22;
    --primary-rgb: 242, 189, 85;
    --accent: #e8a83e;
    --accent-rgb: 232, 168, 62;
    --border-lift: rgba(255, 207, 105, 0.9);
}

:root:not([data-theme="light"]) .card-title,
:root:not([data-theme="light"]) .card-title-text,
:root:not([data-theme="light"]) .modal-box h2 {
    color: #ffdc91;
}

:root:not([data-theme="light"]) .card-title-icon {
    color: #ffe4a6;
    background: linear-gradient(145deg, rgba(242, 189, 85, 0.30), rgba(183, 122, 34, 0.16));
    border-color: rgba(255, 211, 120, 0.58);
}

:root:not([data-theme="light"]) .bento section,
:root:not([data-theme="light"]) header {
    border-top-color: rgba(255, 211, 120, 0.52);
}

:root:not([data-theme="light"]) .game,
:root:not([data-theme="light"]) .weather,
:root:not([data-theme="light"]) .nas-item,
:root:not([data-theme="light"]) #toolbar,
:root:not([data-theme="light"]) .theme-toggle-btn,
:root:not([data-theme="light"]) .theme-btn,
:root:not([data-theme="light"]) .tool-btn,
:root:not([data-theme="light"]) .theme-select,
:root:not([data-theme="light"]) .len-btn,
:root:not([data-theme="light"]) .modal-box {
    border-color: rgba(255, 211, 120, 0.34);
}

:root:not([data-theme="light"]) .tool-btn:hover,
:root:not([data-theme="light"]) .theme-btn:hover,
:root:not([data-theme="light"]) .theme-toggle-btn:hover,
:root:not([data-theme="light"]) .len-btn:hover,
:root:not([data-theme="light"]) .len-btn.active {
    border-color: #ffd477;
    box-shadow: 0 0 0 1px rgba(255, 212, 119, 0.25), 0 0 14px rgba(242, 189, 85, 0.13);
}

:root:not([data-theme="light"]) .bento section p,
:root:not([data-theme="light"]) .modal-box p {
    background: #735638;
    border-color: rgba(255, 211, 120, 0.30);
}
