/* ===========================
   DESIGN TOKENS
   =========================== */
:root {
    /* Palette signature */
    --color-signature:   #FF2D8B;
    --color-bg-page:     #FFF0F5;
    --color-bg-card:     #FFFFFF;
    --color-text:        #1A1A1A;
    --color-text-muted:  #6B6B6B;

    /* Aliases legacy (utilisés par zones admin, scratch, animations) */
    --surface: #FFFFFF;
    --text: #1A1A1A;
    --text-muted: #6B6B6B;
    --border: #E8E8E8;

    --accent-coral: #FF2D8B;
    --accent-coral-dark: #D4006E;
    --accent-teal: #4ECDC4;
    --accent-teal-dark: #36A89F;
    --accent-yellow: #FFD93D;
    --accent-purple: #A78BFA;
    --accent-purple-dark: #8B5CF6;

    --radius: 14px;
    --radius-pill: 999px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.1);

    --font-base: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ===========================
   GLOBAL
   =========================== */
* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg-page);
    background-image: radial-gradient(circle, rgba(255, 45, 139, 0.12) 1px, transparent 1px);
    background-size: 22px 22px;
    color: var(--color-text);
    font-family: var(--font-base);
}

a {
    color: var(--color-signature);
}

h1, h2, h3 {
    margin-top: 0;
    font-weight: 800;
}

/* ===========================
   HEADER & NAVIGATION
   =========================== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75em;
    padding: 1.25em 1.5em;
}

/* ===========================
   SIDEBAR NAVIGATION
   =========================== */

/* Hamburger button */
.hamburger-btn {
    background: var(--color-bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--color-text);
    transition: background 0.15s ease;
}

.hamburger-btn:hover {
    background: #f5f5f5;
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 40;
}

.sidebar-overlay.active {
    display: block;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--color-bg-card);
    border-right: 0.5px solid var(--border);
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
}

.sidebar.open {
    transform: translateX(0);
}

/* Sidebar header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 0.5px solid var(--border);
}

.sidebar-logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.sidebar-close:hover {
    color: var(--color-text);
}

/* Nav links */
.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-link:hover {
    background: #f5f5f5;
    color: var(--color-text);
}

.sidebar-link--active {
    background: rgba(255, 45, 139, 0.08);
    color: var(--color-signature);
}

.sidebar-link--active:hover {
    background: rgba(255, 45, 139, 0.12);
}

.sidebar-link i {
    font-size: 15px;
    width: 18px;
    text-align: center;
}

/* Bouton logout stylé comme un sidebar-link */
.sidebar-link--button {
    width: 100%;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}

/* Footer */
.sidebar-footer {
    padding: 0.75rem 0.5rem;
    border-top: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link--muted {
    color: var(--color-text-muted);
    opacity: 0.6;
}

/* ===========================
   FOOTER
   =========================== */
.site-footer {
    text-align: center;
    padding: 1.5em 1em;
    color: var(--text-muted);
    font-size: 0.85em;
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: underline;
}

.site-footer a:hover {
    color: var(--accent-purple-dark);
}

/* ===========================
   MAIN CONTENT
   =========================== */
main {
    flex: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5em 2em;
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.75em 1.6em;
    font-size: 1em;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    box-shadow: var(--shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-primary {
    background: var(--color-signature);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-coral-dark);
}

.btn-secondary {
    background: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #f5f5f5;
    border-color: #c8c8c8;
}

.btn-sm {
    padding: 0.5em 1.1em;
    font-size: 0.9em;
}

/* ===========================
   CARDS & BADGES
   =========================== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2em;
    margin: 1.5em auto;
}

.badge {
    display: inline-block;
    background: var(--accent-yellow);
    color: var(--text);
    border-radius: var(--radius-pill);
    padding: 0.3em 1em;
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ===========================
   GENERIC PAGE CENTERING
   =========================== */
.page-center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 1em;
}

.login-card,
.about-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
}

.about-card h1 {
    font-size: 1.3em;
}

.about-punchline {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--accent-purple-dark);
}

.about-cta {
    margin-top: 1.5em;
    color: var(--text-muted);
    font-size: 0.95em;
}

/* ===========================
   HOME — REVEAL CARD
   =========================== */
.display-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1em;
    min-height: 70vh;
    padding: 1em;
}

.reveal-card {
    position: relative;
    text-align: center;
    max-width: 900px;
    width: 100%;
    min-height: 300px;
    border: 1.5px solid rgba(255, 45, 139, 0.25);
    border-top: 3px solid var(--color-signature);
    box-shadow: 0 4px 24px rgba(255, 45, 139, 0.10);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1em;
}

.reveal-card--scratch-unrevealed .reactions,
.reveal-card--scratch-unrevealed #share-bar {
    opacity: 0.25;
    pointer-events: none;
    filter: blur(1px);
    transition: opacity 0.4s ease, filter 0.4s ease;
}

.reactions,
#share-bar {
    transition: opacity 0.4s ease, filter 0.4s ease;
}

.daily-date {
    font-size: 0.8em;
    color: var(--color-text-muted);
    margin: 0;
}

.daily-date.hidden {
    display: none;
}

.card-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4em;
}


.card-title {
    font-size: 1.4em;
    font-weight: 700;
    margin: 0;
    color: var(--color-text);
}

.card-icon {
    display: none;
}

.flip-face--back .card-icon,
.scratch-content .card-icon {
    display: block;
    font-size: 2em;
    line-height: 1;
}

.item {
    font-family: var(--font-mono);
    font-size: 1.8em;
    line-height: 1.5;
    margin: 0;
    min-height: 3.5em;
}

.caret {
    display: inline-block;
    width: 0.1em;
    height: 1em;
    background-color: var(--accent-coral);
    vertical-align: text-bottom;
    animation: blink-caret 1s step-end infinite;
}

@keyframes blink-caret {
    from, to { background-color: transparent; }
    50% { background-color: var(--accent-coral); }
}

/* ===========================
   SLOT MACHINE REVEAL
   =========================== */
.reveal-card.spinning {
    animation: slot-glow 0.3s ease-in-out infinite;
}

@keyframes slot-glow {
    0%, 100% { box-shadow: var(--shadow); }
    50% { box-shadow: 0 0 0 4px var(--accent-yellow), var(--shadow-hover); }
}

.slot-spin {
    animation: slot-spin 0.12s ease-in;
}

@keyframes slot-spin {
    0% { transform: translateY(-10px); opacity: 0; filter: blur(2px); }
    60% { transform: translateY(0); opacity: 1; filter: blur(0); }
    100% { transform: translateY(0); opacity: 1; filter: blur(0); }
}

.slot-land {
    animation: slot-land 0.4s ease-out;
}

@keyframes slot-land {
    0% { transform: scale(0.94); }
    55% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ===========================
   FLIP REVEAL
   =========================== */
.reveal-card[data-display="flip"] {
    perspective: 1000px;
}

.flip-inner {
    position: relative;
    display: grid;
    grid-template-areas: "face";
    width: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.flip-inner.flipped {
    transform: rotateY(180deg);
}

.flip-face {
    grid-area: face;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1em;
    padding: 2.5em 1.5em;
    border-radius: var(--radius);
    backface-visibility: hidden;
}

.flip-face--front {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-coral));
    color: #FFFFFF;
}

.flip-face--back {
    transform: rotateY(180deg);
}

.flip-face-icon {
    font-size: 3em;
    line-height: 1;
}

.flip-face-text {
    margin: 0;
    font-weight: 700;
    font-size: 1.1em;
}

/* ===========================
   SCRATCH REVEAL
   =========================== */
.scratch-content {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1em;
    border: 2px solid transparent;
    border-radius: var(--radius);
    background: linear-gradient(var(--surface), var(--surface)) padding-box,
                linear-gradient(135deg, #a855f7, #ec4899) border-box;
    padding: 2em;
    box-sizing: border-box;
}

.scratch-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius);
    cursor: grab;
    touch-action: none;
    transition: opacity 0.4s ease;
}

.scratch-canvas:active {
    cursor: grabbing;
}

.scratch-canvas.scratch-cleared {
    opacity: 0;
    pointer-events: none;
}

/* ===========================
   RÉTENTION (favoris, streak, compteur)
   =========================== */
.share-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.share-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 45, 139, 0.2);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: 0.15s ease;
}

.share-btn:hover {
    background: var(--color-signature);
    color: white;
    border-color: var(--color-signature);
}

.share-toast {
    position: fixed;
    bottom: 2em;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-teal);
    color: #fff;
    padding: 0.7em 1.5em;
    border-radius: var(--radius-pill);
    font-weight: 700;
    z-index: 100;
    animation: toast-in 0.3s ease;
}

.share-toast.hidden {
    display: none;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.favorite-btn {
    position: absolute;
    top: 1em;
    right: 1em;
    z-index: 5;
    background: var(--surface);
    border: none;
    border-radius: 50%;
    width: 2.4em;
    height: 2.4em;
    font-size: 1.2em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease;
}

.favorite-btn:hover {
    transform: scale(1.1);
}

.reactions {
    display: flex;
    justify-content: center;
    gap: 0.4em;
}

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.25em 0.7em;
    font-size: 0.82em;
    font-family: inherit;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: border-color 0.15s ease, color 0.15s ease;
}

.reaction-btn:hover {
    border-color: var(--color-signature);
    color: var(--color-text);
}

.reaction-btn.reacted {
    border-color: var(--accent-purple);
    background: rgba(167, 139, 250, 0.1);
}

.reaction-btn.reaction-pulse {
    animation: reaction-pulse 0.35s ease;
}

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

.reaction-count {
    font-weight: 700;
    font-size: 0.85em;
    color: var(--text-muted);
}

.utility-corner {
    position: fixed;
    bottom: 1.2em;
    right: 1.2em;
    z-index: 50;
    display: flex;
    gap: 0.4em;
}

.utility-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 2.4em;
    height: 2.4em;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease;
}

.utility-btn:hover {
    transform: scale(1.1);
}

.theme-toggle-btn .theme-icon-dark {
    display: none;
}

body.theme-dark .theme-toggle-btn .theme-icon-light {
    display: none;
}

body.theme-dark .theme-toggle-btn .theme-icon-dark {
    display: inline;
}

.favorite-btn.favorite-pulse {
    animation: favorite-pulse 0.4s ease;
}

@keyframes favorite-pulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.retention-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6em;
}

.retention-bar.hidden {
    display: none;
}

.retention-pill {
    display: inline-block;
    padding: 0.4em 1.1em;
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 0.9em;
    font-weight: 700;
}

.retention-pill:empty {
    display: none;
}

/* ===========================
   FAVORIS
   =========================== */
.favorites-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2em;
    align-items: stretch;
}

.favorite-card {
    margin: 0;
    border-top: 3px solid var(--color-signature);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.favorite-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.favorite-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    flex: 1;
}

.favorite-text {
    font-family: var(--font-base);
    font-size: 1rem;
    line-height: 1.6;
    text-align: left;
    margin: 0.6em 0 0;
    color: var(--color-text);
}

.favorite-remove-btn {
    position: absolute;
    top: 0.6em;
    right: 0.6em;
    background: none;
    border: none;
    font-size: 1.1em;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    opacity: 0.4;
    padding: 0.1em 0.3em;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.favorite-remove-btn:hover {
    opacity: 1;
    color: var(--color-signature);
}

#favorites-empty.hidden {
    display: none;
}

/* ===========================
   LOGIN PANEL (easter egg "bro")
   =========================== */
#login-panel {
    position: fixed;
    top: 5em;
    right: 1.5em;
    width: 280px;
    z-index: 10;
    opacity: 0;
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

#login-panel.hidden {
    display: none;
}

#login-panel.active {
    display: block;
    opacity: 1;
    transform: scaleY(1);
}

#login-panel h2 {
    text-align: center;
    font-size: 1.2em;
}

/* ===========================
   FORMS
   =========================== */
#login-panel form,
.login-card form {
    display: flex;
    flex-direction: column;
    gap: 0.8em;
}

#login-panel label,
.login-card label,
.toggle-form label,
.form-row label {
    font-weight: 600;
    font-size: 0.9em;
}

input[type="text"],
input[type="password"] {
    padding: 0.7em 1em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1em;
    background: var(--bg-end);
    color: var(--text);
}

select {
    padding: 0.6em 2.4em 0.6em 1em;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.8em center;
    color: var(--text);
    font-family: inherit;
    font-size: 1em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* ===========================
   ADMIN LAYOUT
   =========================== */
body.admin-page .site-header,
body.admin-page .site-footer,
body.admin-page .utility-corner,
body.admin-page .sidebar,
body.admin-page .sidebar-overlay {
    display: none;
}

body.admin-page .card {
    box-shadow: 0 1px 4px rgba(45, 45, 58, 0.06);
    border-radius: 10px;
}

body.admin-page main {
    max-width: none;
    margin: 0;
    padding: 0;
}

body.admin-page .flash-container {
    margin: 0 0 0 220px;
    padding: 1.5em 2em 0;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--surface);
    border-right: 0.5px solid var(--border);
    padding: 1.5em 1em;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 50;
}

.admin-sidebar-title {
    font-weight: 800;
    font-size: 1.1em;
    margin-bottom: 1em;
    padding: 0 0.6em;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 1rem;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.admin-nav-icon {
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.admin-nav-link:hover {
    background: var(--bg-end);
    color: var(--text);
}

.admin-nav-link:hover .admin-nav-icon {
    opacity: 1;
}

.admin-nav-link--muted {
    opacity: 0.4;
    font-style: italic;
}

.admin-nav-link--muted:hover {
    opacity: 0.7;
}

.admin-nav-link.active {
    background: var(--bg-end);
    color: var(--text);
    font-weight: 500;
}

.admin-nav-link.active .admin-nav-icon {
    opacity: 1;
}

.admin-sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3em;
    padding-top: 1em;
    border-top: 0.5px solid var(--border);
}

.admin-logout-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
}

.admin-content {
    margin-left: 220px;
    padding: 2em;
    min-height: 100vh;
}

.welcome-text {
    font-family: var(--font-mono);
    font-size: 1.2em;
    color: var(--accent-purple-dark);
    min-height: 1.5em;
}

/* ===========================
   TOGGLE (type de homepage)
   =========================== */
.toggle-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1em;
}

.toggle-group {
    display: flex;
    gap: 0.5em;
}

.toggle-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-pill span {
    display: inline-block;
    padding: 0.6em 1.4em;
    border-radius: var(--radius-pill);
    background: var(--bg-end);
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.toggle-pill input:checked + span {
    background: var(--accent-purple);
    color: #fff;
}

/* ===========================
   CONFIG CARD (dashboard admin)
   =========================== */
.config-card h2 {
    margin-top: 0;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    flex-wrap: wrap;
    padding: 1em 0;
}

.config-row--bordered {
    border-top: 0.5px solid var(--border);
}

.config-label p {
    margin: 0;
    font-weight: 600;
}

.config-label small {
    color: var(--text-muted);
    font-size: 0.85em;
}

.btn-toggle-group {
    display: flex;
    gap: 6px;
}

.btn-toggle {
    padding: 5px 14px;
    font-size: 12px;
    font-family: inherit;
    border-radius: var(--radius);
    border: 0.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn-toggle:hover {
    border-color: var(--border-strong, #c8c8c8);
    color: var(--text);
}

.btn-toggle--active {
    border: 1.5px solid var(--accent-purple);
    background: rgba(167, 139, 250, 0.1);
    color: var(--accent-purple-dark);
    font-weight: 600;
}

.config-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.8em;
    margin-top: 1em;
}

.config-save-feedback {
    font-size: 0.85em;
    color: var(--accent-purple-dark);
}

.config-save-feedback.hidden {
    display: none;
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}

.switch-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: var(--radius-pill);
    transition: background 0.15s ease;
}

.switch-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

.switch-toggle input:checked + .switch-toggle-track {
    background: var(--accent-purple);
}

.switch-toggle input:checked + .switch-toggle-track .switch-toggle-thumb {
    transform: translateX(20px);
}

.ql-toolbar {
    border: 0.5px solid var(--border) !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    background: var(--surface) !important;
}

.ql-container {
    border: 0.5px solid var(--border) !important;
    border-top: none !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
    font-family: var(--font-base) !important;
    font-size: 13px !important;
    min-height: 120px;
}

.ql-editor {
    min-height: 120px;
    color: var(--text);
}

.legendary-editor-wrap {
    display: block;
    width: 100%;
    max-width: 480px;
}

#legendary-config-form input[type="text"][name="password"] {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    padding: 0.6em 1em;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1em;
}

.config-row .toggle-right {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 1.5em;
}

.metric-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.metric-label {
    margin: 0 0 4px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    margin: 0;
    font-size: 22px;
    font-weight: 500;
    color: var(--text);
}

/* ===========================
   IMPORT
   =========================== */
.import-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1em;
}

.file-name {
    padding: 0.5em 1em;
    background: var(--bg-end);
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.9em;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.csv-preview {
    margin-top: 1.5em;
    overflow-x: auto;
}

/* ===========================
   TABLES
   =========================== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.5em 0.6em;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--text-muted);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

tbody tr:hover {
    background: var(--bg-end);
}

tr.removed {
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: opacity 0.5s ease, height 0.5s ease;
}

.action-btn {
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    border-radius: var(--radius-pill);
    padding: 0.3em 0.5em;
    transition: background 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.edit-btn:hover {
    background: rgba(167, 139, 250, 0.15);
}

.delete-btn {
    font-family: inherit;
}

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

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 0.2em;
}

.text-cell {
    white-space: normal;
    word-break: break-word;
    min-width: 250px;
}

.th-checkbox {
    width: 3em;
}

.row-exists {
    background: rgba(255, 107, 107, 0.15) !important;
}

.row-new {
    background: rgba(78, 205, 196, 0.15) !important;
}

.csv-preview table th,
.csv-preview table td {
    border-bottom: 1px solid var(--border);
    padding: 0.5em 0.7em;
}

/* ===========================
   SORTABLE HEADERS
   =========================== */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:hover {
    color: var(--accent-purple-dark);
}

.sort-arrow {
    display: inline-block;
    margin-left: 0.3em;
    font-size: 0.75em;
    opacity: 0.3;
}

.sort-arrow::after {
    content: '▲▼';
    font-size: 0.7em;
    letter-spacing: -0.2em;
}

th.sort-asc .sort-arrow,
th.sort-desc .sort-arrow {
    opacity: 1;
    color: var(--accent-purple-dark);
}

th.sort-asc .sort-arrow::after {
    content: '▲';
}

th.sort-desc .sort-arrow::after {
    content: '▼';
}

/* ===========================
   LIST HEADER & BULK ACTIONS
   =========================== */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1em;
    margin-bottom: 0.5em;
}

.list-header h1 {
    margin-bottom: 0;
}

.btn-danger {
    background: var(--accent-coral);
    color: #fff;
}

.btn-danger:hover {
    background: var(--accent-coral-dark);
}

.bulk-delete-btn.hidden {
    display: none;
}

.th-checkbox {
    width: 3em;
    text-align: center;
}

.row-checkbox,
#select-all {
    width: 1.1em;
    height: 1.1em;
    cursor: pointer;
    accent-color: var(--accent-purple);
}

/* ===========================
   CONFIRMATION MODAL
   =========================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(45, 45, 58, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1em;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    max-width: 420px;
    width: 100%;
    text-align: center;
    animation: modal-pop 0.2s ease;
}

@keyframes modal-pop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-message {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 1.5em;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 0.8em;
}

/* ===========================
   EDIT FORM
   =========================== */
.edit-form {
    display: flex;
    flex-direction: column;
    gap: 1.2em;
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9em;
}

.form-group textarea {
    padding: 0.7em 1em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1em;
    background: var(--bg-end);
    color: var(--text);
    resize: vertical;
}

.form-group--inline {
    flex-direction: row;
    align-items: center;
    gap: 0.5em;
}

.form-group--inline label {
    display: flex;
    align-items: center;
    gap: 0.5em;
    cursor: pointer;
}

.publish-toggle {
    display: inline-block;
    padding: 0.3em 0.8em;
    border-radius: var(--radius-pill);
    border: none;
    font-size: 0.8em;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.publish-toggle.published {
    background: #D1FAE5;
    color: #065F46;
}

.publish-toggle.unpublished {
    background: #FFE0E0;
    color: #9B2226;
}

.publish-toggle:hover {
    opacity: 0.8;
}

.form-actions {
    display: flex;
    gap: 0.8em;
}

/* ===========================
   FLASH MESSAGES
   =========================== */
.flash-container {
    margin: 1.5em 0;
    display: flex;
    flex-direction: column;
    gap: 0.6em;
}

.flash-banner {
    padding: 1em 1.4em;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity 0.5s ease, height 0.5s ease, padding 0.5s ease, margin 0.5s ease;
}

.flash-success {
    background: #D1FAE5;
    color: #065F46;
    border-color: #6EE7B7;
}

.flash-error {
    background: #FFE0E0;
    color: #9B2226;
    border-color: #FF8A8A;
}

.flash-info {
    background: #E0F2FE;
    color: #075985;
    border-color: #7DD3FC;
}

.flash-banner.hidden {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    overflow: hidden;
}

/* ===========================
   ERROR PAGES
   =========================== */
body.error-page {
    align-items: center;
    justify-content: center;
}

.error-wrap {
    text-align: center;
    max-width: 480px;
}

.error-emoji {
    font-size: 3em;
    line-height: 1;
    margin-bottom: 0.2em;
}

.error-code {
    font-size: 4em;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--accent-coral);
    line-height: 1;
}

.error-title {
    margin: 0.4em 0;
}

.error-message {
    color: var(--text-muted);
    margin-bottom: 1.5em;
}

/* ===========================
   SUBMIT FORM
   =========================== */
.submit-card {
    max-width: 540px;
    width: 100%;
}

.submit-card h1 {
    white-space: nowrap;
}

.submit-intro {
    color: var(--text-muted);
    margin-bottom: 1.5em;
}

.submit-form {
    display: flex;
    flex-direction: column;
    gap: 1.2em;
}

.submit-form input::placeholder,
.submit-form textarea::placeholder {
    font-size: 0.85em;
    color: var(--text-muted);
    opacity: 0.7;
}

.submit-actions {
    display: flex;
    justify-content: center;
}

.category-create-form {
    display: flex;
    gap: 0.8em;
    align-items: center;
}

.category-create-form input[type="text"] {
    flex: 1;
}

.category-edit-form {
    display: flex;
    gap: 0.5em;
    align-items: center;
}

.category-name-input {
    padding: 0.4em 0.7em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1em;
    background: var(--bg-end);
    color: var(--text);
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 2em 0;
}

/* ===========================
   TOP 10
   =========================== */
.top10-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 1em 0;
}

.top10-container h1 {
    text-align: center;
    margin-bottom: 1em;
}

.top10-list {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.disquette-card {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    height: 160px;
    overflow: hidden;
    margin: 0;
    position: relative;
    border-top: 4px solid var(--accent-teal);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.disquette-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 45, 139, 0.12);
    cursor: pointer;
}

.disquette-card.card--disquette {
    border-top-color: var(--accent-coral);
}

.dc-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.dc-header {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-wrap: wrap;
}

.dc-rank {
    font-size: 1.4em;
    font-weight: 800;
    flex-shrink: 0;
    line-height: 1;
}

.dc-title {
    flex: 1;
    min-width: 0;
}

.icon-link {
    font-size: 1em;
    text-decoration: none;
    opacity: 0.45;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.icon-link:hover {
    opacity: 1;
}

.dc-text {
    font-family: var(--font-mono);
    font-size: 0.95em;
    line-height: 1.5;
    margin: 0;
    color: var(--color-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dc-reactions {
    display: flex;
    gap: 0.8em;
    font-size: 0.9em;
    color: var(--color-text-muted);
    font-weight: 600;
}

.dc-total {
    margin-left: auto;
    color: var(--accent-purple-dark);
}

.dc-date {
    font-size: 0.8em;
    color: var(--color-text-muted);
    margin: 0;
    font-family: var(--font-mono);
}

/* ===========================
   ARCHIVE
   =========================== */
.archive-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 1em 0;
}

.archive-container h1 {
    text-align: center;
    margin-bottom: 1em;
}

.archive-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 680px;
    margin: 0 auto;
}


.archive-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    margin-top: 2em;
    flex-wrap: wrap;
}

.pagination-pages {
    display: flex;
    gap: 0.4em;
}

.pagination-link {
    font-size: 0.9em;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.2em 0.5em;
    transition: color 0.15s ease;
}

.pagination-link:hover {
    color: var(--color-signature);
}

.pagination-active {
    color: var(--color-signature);
    font-weight: 700;
}

.pagination-disabled {
    opacity: 0.35;
    cursor: default;
}

/* ===========================
   THEMES
   =========================== */
body.theme-dark {
    --color-bg-page: #16161f;
    --color-bg-card: #1e1e2a;
    --color-text: #e8e8ec;
    --color-text-muted: #8a8a95;
    --border: #2e2e3a;

    /* Le signature reste identique en clair et en sombre — c'est la marque du site */
    --color-signature: #FF2D8B;

    --surface: #1e1e2a;
    --text: #e8e8ec;
    --text-muted: #8a8a95;

    --bg-start: #16161f;
    --bg-end: #1e1e2a;

    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 12px 28px rgba(0, 0, 0, 0.5);
}

body.theme-dark {
    background-image: radial-gradient(circle, rgba(255, 45, 139, 0.10) 1px, transparent 1px);
}

body.theme-dark a {
    color: var(--color-signature);
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 700px) {
    body.admin-page .site-header {
        display: flex;
    }

    body.admin-page .site-footer {
        display: block;
    }

    body.admin-page .flash-container {
        margin-left: 0;
        padding: 1em 1em 0;
    }

    .admin-sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        box-shadow: none;
        border-bottom: 1px solid var(--border);
        overflow-y: visible;
    }

    .admin-sidebar-title {
        margin-bottom: 0;
        margin-right: 0.5em;
    }

    .admin-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .admin-sidebar-footer {
        margin-top: 0;
        margin-left: auto;
        flex-direction: row;
        border-top: none;
        padding-top: 0;
    }

    .admin-content {
        margin-left: 0;
        padding: 1em;
    }

    .item {
        font-size: 1.1em;
    }

    #login-panel {
        right: 1em;
        left: 1em;
        width: auto;
    }

    .site-header {
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .disquette-card {
        height: auto;
        min-height: 140px;
    }
}

/* ===========================
   LEGENDAIRE (page secrète)
   =========================== */
.legendary-overlay {
    background: rgba(0, 0, 0, 0.75);
}

.legendary-modal {
    background: #111111;
    border: 0.5px solid #333333;
    border-radius: 16px;
    padding: 2rem;
    width: 380px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: modal-pop 0.2s ease;
}

.legendary-modal.shake {
    animation: legendary-shake 0.4s ease;
}

@keyframes legendary-shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

.legendary-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legendary-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1e1e1e;
    border: 0.5px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 14px;
}

.legendary-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #e0e0e0;
    letter-spacing: 0.02em;
}

.legendary-close {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.legendary-close:hover {
    color: #888;
}

.legendary-enigme {
    border-top: 0.5px solid #222;
    padding-top: 1.25rem;
    padding-bottom: 0.5rem;
}

.legendary-riddle {
    margin: 0;
    font-size: 13px;
    line-height: 1.75;
    color: #aaaaaa;
    font-style: normal;
    white-space: pre-line;
}

.legendary-riddle p {
    margin: 0;
}

.legendary-riddle p + p {
    margin-top: 0.75em;
}

.legendary-key {
    color: #e0e0e0;
    font-weight: 500;
}

.legendary-input {
    background: #1a1a1a;
    border: 0.5px solid #333;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #e0e0e0;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    outline: none;
}

.legendary-input:focus {
    border-color: #555;
}

.legendary-modal .legendary-input,
.legendary-modal input[type="text"],
.legendary-modal input[type="password"] {
    background: #1a1a1a !important;
    border: 0.5px solid #333 !important;
    color: #e0e0e0 !important;
    border-radius: 8px !important;
}

.legendary-modal .legendary-input::placeholder {
    color: #555 !important;
}

.legendary-input-wrap {
    padding: 0.25rem 0;
}

.legendary-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 0.5rem;
    border-top: 0.5px solid #222;
    margin-top: 8px;
}

.legendary-btn-cancel {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
    border: 0.5px solid #333;
    background: none;
    color: #888;
    cursor: pointer;
    font-family: inherit;
}

.legendary-btn-submit {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
    border: none;
    background: var(--color-signature);
    color: #fff;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
}

.legendary-btn-submit:hover {
    background: var(--accent-coral-dark);
}

.legendary-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.legendary-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
    text-align: center;
}

.legendary-success-title {
    font-size: 16px;
    font-weight: 500;
    color: #e0e0e0;
    margin: 0;
}

.legendary-success-sub {
    font-size: 13px;
    color: #888;
    margin: 0;
    line-height: 1.6;
}

.legendary-btn-enter {
    padding: 10px 28px;
    background: var(--color-signature);
    color: #fff;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.legendary-btn-enter:hover {
    background: var(--accent-coral-dark);
}

.legendary-error {
    color: var(--accent-coral-dark);
    font-size: 0.9em;
    margin-top: 0.8em;
}

.legendary-error.hidden {
    display: none;
}

body.legendary-page {
    background-color: #0d0a1a;
    background-image: radial-gradient(circle, rgba(124, 58, 237, 0.12) 1px, transparent 1px);
    background-size: 22px 22px;
    color: #e8d5ff;

    /* Le violet nuit prime toujours sur le dark mode global : la sidebar
       partagée doit rester blanche et sobre même si theme-dark est actif. */
    --color-bg-card: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #6b6b6b;
    --border: #e8e8e8;
    --color-signature: #FF2D8B;
}

.legendary-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    background: #160d2e;
    border: 0.5px solid #2a1f3d;
    color: #9d7fd4;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s ease, color 0.15s ease;
}

.legendary-back-link:hover {
    background: #1e1040;
    color: #c4a8ff;
}

body.legendary-page .hamburger-btn {
    background: #1a1a1a;
    border-color: #333;
    color: #e0e0e0;
}

body.legendary-page .hamburger-btn:hover {
    background: #2a2a2a;
}

body.legendary-page .reveal-card {
    background: #0d0a1a;
    border: 0.5px solid #2a1f3d;
    border-top: 3px solid #7c3aed;
    box-shadow: 0 4px 32px rgba(124, 58, 237, 0.2);
}

body.legendary-page .scratch-content {
    background: #160d2e;
    border-color: #2a1f3d;
}

body.legendary-page .card-title {
    color: #c4a8ff;
}

body.legendary-page .daily-date {
    color: #6b4fa0;
    font-size: 0.8em;
}

body.legendary-page .item {
    font-family: var(--font-base);
    font-size: 1.8rem;
    font-style: normal;
    color: #e8d5ff;
}

body.legendary-page .site-footer,
body.legendary-page .site-footer a {
    color: #3d2a6e;
}
