/* Bedefil — Thème clair */

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #2c3e50;
    line-height: 1.5;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}
a, img, button {
    -webkit-user-drag: none;
}

/* Header */
.header {
    background: #fff;
    padding: 1rem 2rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-row {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: nowrap;
}
.header-main {
    display: flex;
    align-items: center;
    gap: 2rem;
    width: 100%;
}
.header h1 {
    font-size: 1.5rem;
    color: #c0392b;
    font-weight: 700;
}
.header h1 a {
    color: inherit;
    text-decoration: none;
}
.header-icon {
    height: 40px;
    vertical-align: middle;
    margin-right: 2px;
    margin-top: -8px;
    margin-bottom: -8px;
}
.header nav a {
    color: #5a6c7d;
    text-decoration: none;
    margin-right: 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.nav-icon {
    width: 32px;
    height: 32px;
    fill: currentColor;
    flex-shrink: 0;
}
.breadcrumb-icon {
    width: 1.3em;
    height: 1.3em;
    fill: currentColor;
    vertical-align: -0.2em;
}
.tab-icon {
    width: 1.6em;
    height: 1.6em;
    fill: currentColor;
    vertical-align: -0.3em;
}
.header nav a:hover,
.header nav a.active {
    color: #c0392b;
}

.header:has(.subheader) {
    padding-bottom: 0;
    gap: 0;
}
.header:has(.subheader) .header-main {
    padding-bottom: 1rem;
}

/* Sub-header (retour + titre page) */
.subheader {
    width: 100%;
    padding: 0.6rem 0 0.7rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-top: 1px solid #e8eaed;
}
.subheader .back {
    color: #7f8c8d;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: color 0.15s;
}
.subheader .back:hover { color: #c0392b; }
.subheader-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.subheader-link {
    color: #7f8c8d;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.85rem;
    margin-left: 0.5rem;
    transition: color 0.15s;
}
.subheader-link:hover { color: #c0392b; }

/* Container */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Stat cards (accueil) */
/* Hero image */
.hero-img {
    text-align: center;
    margin-bottom: 1.5rem;
}
.hero-img img {
    max-width: 100%;
    max-height: 280px;
    object-fit: contain;
}

.stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    flex: 1;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf1;
}
.stat-card .number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #c0392b;
}
.stat-card .label {
    color: #7f8c8d;
    margin-top: 0.4rem;
    font-size: 0.9rem;
}

/* Search bar */
.search-form { margin-bottom: 2rem; }
.search-wrap { position: relative; }
.search-bar {
    width: 100%;
    padding: 0.8rem 2.5rem 0.8rem 1.2rem;
    border: 2px solid #dfe6e9;
    border-radius: 10px;
    background: #fff;
    color: #2c3e50;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    font-size: 1.4rem; color: #7f8c8d; padding: 0.4rem 0.5rem;
    line-height: 1; display: none;
}
.search-clear:hover { color: #2c3e50; }
.search-wrap .search-bar:not(:placeholder-shown) ~ .search-clear { display: block; }
.search-bar:focus {
    outline: none;
    border-color: #c0392b;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}
.search-bar::placeholder { color: #b2bec3; }

/* Page title */
.page-title {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.page-title h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2c3e50;
}
.page-title .count {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Comic card grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}
.card {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf1;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.card a {
    text-decoration: none;
    color: inherit;
    display: block;
    -webkit-touch-callout: none;
}
.card .cover {
    width: 100%;
    aspect-ratio: 2/3;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.card .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card .cover .no-cover {
    color: #b2bec3;
    font-size: 3rem;
}

/* Reading progress bar */
.reading-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.6);
    z-index: 2;
}
.reading-bar-fill {
    height: 100%;
    background: #c0392b;
}

/* Read overlay (completed) */
.read-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.45);
    z-index: 1;
    pointer-events: none;
}

.card .info {
    padding: 0.8rem;
    position: relative;
}
.card .info .title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #2c3e50;
    padding-right: 24px;
}
.card .info .series {
    color: #7f8c8d;
    font-size: 0.75rem;
    margin-top: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Card menu button (⋯) in info bar */
.card-menu-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: none;
    color: #7f8c8d;
    border: none;
    font-size: 1.1rem;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}
.card-menu-btn:hover, .card-menu-btn:active {
    background: rgba(0,0,0,0.06);
    color: #2c3e50;
}

/* Card menu overlay + dropdown */
.card-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 199;
}
.card-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    z-index: 200;
    white-space: nowrap;
    overflow: hidden;
    min-width: 200px;
}
.card-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
    cursor: pointer;
    color: #2c3e50;
}
.card-menu button:hover { background: #f5f5f5; }

/* Author list (compact) */
.author-list { display: flex; flex-direction: column; gap: 2px; }
.author-item {
    display: flex; align-items: center; gap: 0.8rem;
    padding: 0.7rem 1rem; background: #fff; border-radius: 8px;
    text-decoration: none; color: #2c3e50; transition: background 0.15s;
}
.author-item:hover { background: #f0f0f0; }
.author-icon { font-size: 1.2rem; flex-shrink: 0; }
.author-name { flex: 1; font-weight: 500; font-size: 0.95rem; }
.author-count { font-size: 0.8rem; color: #7f8c8d; white-space: nowrap; }

/* Author page series groups */
.author-series-group { margin-bottom: 2rem; }
.author-series-title {
    font-size: 1.1rem; font-weight: 600; color: #2c3e50;
    margin-bottom: 0.8rem; padding-bottom: 0.4rem;
    border-bottom: 2px solid #eef1f5;
}
.author-series-title a { color: #2c3e50; text-decoration: none; }
.author-series-title a:hover { color: #c0392b; }
.author-series-count { font-weight: 400; color: #7f8c8d; font-size: 0.9rem; }

.card-menu hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 0;
}
.card-menu-status {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: #7f8c8d;
}

/* Pagination */
.pagination {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 0.4rem;
}
.pagination a, .pagination span {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: #2c3e50;
    background: #fff;
    border: 1px solid #dfe6e9;
    font-size: 0.9rem;
    transition: background 0.15s, border-color 0.15s;
}
.pagination a:hover {
    background: #f0f2f5;
    border-color: #c0392b;
    color: #c0392b;
}
.pagination .current {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

/* Detail page */
.detail {
    display: flex;
    gap: 2rem;
}
.detail .cover {
    flex: 0 0 300px;
}
.detail .cover img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}
.detail .cover .no-cover {
    width: 300px;
    aspect-ratio: 2/3;
    background: #f0f2f5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    border: 1px solid #e8ecf1;
}
.detail .meta {
    flex: 1;
}
.detail .meta h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #2c3e50;
    font-weight: 600;
}
.btn-read, .btn-download {
    display: inline-block;
    background: #c0392b;
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
    transition: background 0.2s, transform 0.15s;
}
.btn-read:hover, .btn-download:hover {
    background: #a93226;
    transform: translateY(-1px);
}
.btn-download {
    margin-left: 0.5rem;
}
.detail .meta table {
    width: 100%;
    border-collapse: collapse;
}
.detail .meta table tr {
    border-bottom: 1px solid #eef1f5;
}
.detail .meta table th {
    text-align: left;
    padding: 0.7rem 1rem 0.7rem 0;
    color: #7f8c8d;
    width: 140px;
    vertical-align: top;
    font-weight: 500;
}
.detail .meta table td {
    padding: 0.7rem 0;
    color: #2c3e50;
}
.detail .meta table td.summary {
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 500px;
}
.badge {
    display: inline-block;
    background: #c0392b;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Empty state */
.empty {
    text-align: center;
    padding: 3rem;
    color: #7f8c8d;
}
.empty .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty .hint { font-size: 0.85rem; margin-top: 0.5rem; opacity: 0.7; }
.hidden { display: none !important; }

/* Browse infinite scroll */
.browse-sentinel {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}
.top-sentinel {
    padding: 1rem 0;
}
.browse-loading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #7f8c8d;
    font-size: 0.95rem;
}
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e8ecf1;
    border-top-color: #c0392b;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section index (iOS-style letter bar) */
.section-index {
    position: fixed;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
    padding: 4px 0;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}
.section-index-letter {
    font-size: 10px;
    font-weight: 600;
    color: #c0392b;
    line-height: 1;
    padding: 1.5px 6px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.1s;
}
.section-index-letter.dimmed {
    color: #b2bec3;
}
.section-index-letter.active {
    background: #c0392b;
    color: #fff;
}
.section-index-bubble {
    display: none;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0,0,0,0.55);
    width: 80px;
    height: 80px;
    border-radius: 20px;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 101;
}
.section-index-bubble.visible {
    display: flex;
}
/* When index is active, add left margin to avoid overlap */
.has-section-index .container {
    padding-left: 22px;
}

/* Results info */
.results-info {
    color: #7f8c8d;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Folder link in detail */
.folder-link {
    color: #5a6c7d;
    text-decoration: none;
    transition: color 0.15s;
}
.folder-link:hover { color: #c0392b; }

/* ===== Hamburger Menu ===== */
.hamburger-btn {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    transition: background 0.15s;
    flex-shrink: 0;
}
.hamburger-btn:hover { background: #f0f2f5; }
.hamburger-icon {
    width: 1.5rem;
    height: 1.5rem;
    fill: #5a6c7d;
    display: block;
}

/* Slide-out menu */
.app-menu { display: none; }
.app-menu.open { display: block; }
.app-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 200;
}
.app-menu-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: #fff;
    z-index: 201;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
@keyframes library-pulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.5); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.nav-pulse .nav-icon {
    animation: library-pulse 0.5s ease-out;
}
.menu-section {
    padding: 0.5rem 1.2rem;
    border-bottom: 1px solid #e8ecf1;
}
.menu-section:last-child { border-bottom: none; }
.menu-profile-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 1.5rem 1.2rem;
}
.menu-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #5a6c7d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
}
.menu-avatar.avatar-parent { background: #c0392b; }
.menu-avatar.avatar-child { background: #27ae60; }
.menu-profile-name {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
}
.menu-profile-type {
    font-size: 0.8rem;
    color: #7f8c8d;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.7rem 0.4rem;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #2c3e50;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.menu-item:hover { background: #f0f2f5; }
.menu-item-danger { color: #c0392b; }
.menu-item-muted { color: #95a5a6; font-size: 0.85rem; }
.menu-section-bottom { margin-top: auto; border-top: 1px solid #e8ecf1; border-bottom: none; }
.menu-icon {
    width: 1.3rem;
    height: 1.3rem;
    fill: currentColor;
    flex-shrink: 0;
}

/* ===== Login & Profile Selection ===== */
.login-page {
    background: linear-gradient(135deg, #f0f2f5 0%, #e8ecf1 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: fixed;
    width: 100%;
}
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-card h2 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    text-align: center;
}
.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    color: #5a6c7d;
    margin-bottom: 0.3rem;
    font-weight: 500;
}
.form-group input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 2px solid #e8ecf1;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.15s;
    background: #fafbfc;
}
.form-group input:focus {
    outline: none;
    border-color: #c0392b;
    background: #fff;
}
.form-error {
    background: #fdf2f2;
    color: #c0392b;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid #f5c6cb;
}
.form-hint {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-bottom: 1rem;
}
.btn-login {
    width: 100%;
    padding: 0.8rem;
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-login:hover { background: #a93226; }
.btn-login:disabled { background: #d5a6a1; cursor: not-allowed; }

/* Profile selection */
.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: none;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.profile-card:hover {
    border-color: #e8ecf1;
    background: #fafbfc;
}
.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #5a6c7d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}
.profile-avatar.avatar-parent { background: #c0392b; }
.profile-avatar.avatar-child { background: #27ae60; }
.profile-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
}
.profile-type {
    font-size: 0.75rem;
    color: #7f8c8d;
}

/* PIN dialog */
.pin-dialog {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e8ecf1;
    text-align: center;
}
.pin-dialog p {
    margin-bottom: 1rem;
    color: #5a6c7d;
    font-size: 0.9rem;
}
.pin-input {
    width: 160px;
    padding: 0.7rem;
    border: 2px solid #e8ecf1;
    border-radius: 8px;
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.3em;
    margin-bottom: 1rem;
    -webkit-text-security: disc;
    text-security: disc;
}
.pin-input:focus {
    outline: none;
    border-color: #c0392b;
}
.pin-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}
.pin-actions .btn-login { width: auto; padding: 0.6rem 1.5rem; }

/* Numpad */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 280px;
    margin: 1rem auto 0;
    touch-action: manipulation;
}
.numpad-key {
    padding: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid #e8ecf1;
    border-radius: 12px;
    background: #fff;
    color: #2c3e50;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.1s, border-color 0.1s;
    user-select: none;
    touch-action: manipulation;
}
.numpad-key:active { background: #e8ecf1; border-color: #c0392b; transform: scale(0.95); }
.numpad-flash { background: #d5e8d4 !important; border-color: #27ae60 !important; }
.numpad-cancel { color: #c0392b; font-size: 1.2rem; }
.numpad-delete { font-size: 1.2rem; margin: 0.5rem auto 0; width: 100%; max-width: 280px; }
.numpad-validate { color: #27ae60; font-size: 1.4rem; }
.pin-back-btn {
    background: none;
    border: none;
    color: #5a6c7d;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.3rem 0;
    margin-bottom: 0.5rem;
    display: inline-block;
}
.pin-back-btn:hover { color: #c0392b; }
.select-profile-logout {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #95a5a6;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
}
.select-profile-logout:hover { color: #c0392b; }
.pin-display {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
    min-height: 24px;
}
.pin-dots {
    display: flex;
    gap: 1rem;
}
.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #ccc;
    background: transparent;
}
.pin-dot.filled {
    background: #2c3e50;
    border-color: #2c3e50;
    animation: dotPop 0.15s ease-out;
}
@keyframes dotPop {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.btn-cancel {
    padding: 0.6rem 1.5rem;
    background: none;
    border: 2px solid #e8ecf1;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #5a6c7d;
    cursor: pointer;
    transition: border-color 0.15s;
}
.btn-cancel:hover { border-color: #c0392b; color: #c0392b; }

/* Profile management page */
.profiles-manage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.2rem;
    margin-bottom: 2rem;
}
.profile-manage-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.profile-add-card {
    border: 2px dashed #d0d7de;
    background: #fafbfc;
    cursor: pointer;
    justify-content: center;
    transition: border-color 0.15s;
}
.profile-add-card:hover { border-color: #c0392b; }
.profile-add-card .profile-avatar { background: #d0d7de; font-size: 2rem; }
.profile-manage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.5rem;
}
.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    border: 1px solid #e8ecf1;
    border-radius: 6px;
    background: #fff;
    color: #2c3e50;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-small:hover { border-color: #c0392b; color: #c0392b; }
.btn-small-danger { color: #c0392b; border-color: #f5c6cb; }
.btn-small-danger:hover { background: #fdf2f2; }
.btn-small-muted { color: #7f8c8d; }
.btn-small-ok { color: #27ae60; border-color: #a3d9b1; }
.btn-small-ok:hover { background: #eafaf1; }
.btn-small-warn { color: #e67e22; border-color: #f0c48a; }
.btn-small-warn:hover { background: #fef6ec; }
.profile-blocked { opacity: 0.55; }
.profile-blocked .profile-avatar { filter: grayscale(0.6); }
.profile-blocked-label { color: #c0392b; font-weight: 600; }
.profile-card.profile-blocked { cursor: not-allowed; }
.editor-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}
.editor-actions .btn-login { width: auto; padding: 0.6rem 1.5rem; }
.form-select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 2px solid #e8ecf1;
    border-radius: 8px;
    font-size: 1rem;
    background: #fafbfc;
}
.form-select:focus { outline: none; border-color: #c0392b; background: #fff; }

/* Color palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    padding: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #2c3e50; transform: scale(1.15); }

.page-title {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}
.compact-title {
    display: none;
}
@media (max-width: 1024px) {
    .compact-title { display: block; }
}

/* Library page */
.library-stats {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #7f8c8d;
}
.library-switcher-wrap {
    margin-left: auto;
    position: relative;
    flex-shrink: 0;
}
.library-switcher-btn {
    background: none;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
    color: #2c3e50;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.library-switcher-btn:hover { border-color: #c0392b; color: #c0392b; }
.lib-switcher-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #5a6c7d;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.lib-switcher-avatar.avatar-parent { background: #c0392b; }
.lib-switcher-avatar.avatar-child { background: #27ae60; }
.library-switcher-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border: 1px solid #e8ecf1;
    min-width: 200px;
    z-index: 150;
    overflow: hidden;
}
.library-switcher-dropdown.open { display: block; }
.lib-switch-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    color: #2c3e50;
    cursor: pointer;
    transition: background 0.15s;
}
.lib-switch-item:hover { background: #f0f2f5; }
.lib-switch-item.active { color: #c0392b; font-weight: 600; }
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #7f8c8d;
}
.empty-state p { margin-bottom: 0.5rem; }

/* Custom message box */
.msgbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}
.msgbox {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.msgbox p {
    font-size: 0.95rem;
    color: #2c3e50;
    margin-bottom: 1.2rem;
    line-height: 1.5;
}
.msgbox-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
}

/* Impersonation banner */
.impersonation-banner {
    background: #e67e22;
    color: #fff;
    padding: 0.4rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 300;
}
.impersonation-banner button {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.5);
    color: #fff;
    padding: 0.2rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}
.impersonation-banner button:hover { background: rgba(255,255,255,0.3); }

/* Admin */
.admin-tree { display: flex; flex-direction: column; gap: 1rem; }
.admin-account-node {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.admin-account-node.admin-inactive { opacity: 0.5; }
.admin-account-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.admin-account-info { font-size: 0.95rem; color: #2c3e50; }
.admin-email { color: #7f8c8d; font-size: 0.85rem; }
.admin-account-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.admin-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: #3498db;
    color: #fff;
    vertical-align: middle;
}
.admin-badge-inactive { background: #95a5a6; }
.admin-badge-blocked { background: #e67e22; }
.admin-profiles {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.admin-profile-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
}
.admin-profile-row:hover { background: #f8f9fa; }
.admin-profile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #5a6c7d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.admin-profile-avatar.avatar-parent { background: #c0392b; }
.admin-profile-avatar.avatar-child { background: #27ae60; }
.admin-profile-name { font-weight: 600; font-size: 0.9rem; color: #2c3e50; }
.admin-profile-type { font-size: 0.8rem; color: #7f8c8d; }
.admin-action-icon { width: 1rem; height: 1rem; fill: currentColor; vertical-align: middle; }
.form-input {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid #e8ecf1;
    border-radius: 8px;
    font-size: 0.9rem;
    box-sizing: border-box;
}
.form-input:focus { outline: none; border-color: #c0392b; }

/* Responsive */
/* Responsive — tablet: icons only in nav */
@media (max-width: 1024px) {
    .header { padding: 0.8rem 1rem; }
    .header-row { gap: 1rem; }
    .header h1 { font-size: 1.2rem; flex-shrink: 0; }
    .header nav { display: flex; gap: 0.2rem; flex-shrink: 0; }
    .header nav a { font-size: 0; gap: 0; margin-right: 0; padding: 0.4rem; }
    .header nav a .nav-icon { width: 32px; height: 32px; }
}

/* Responsive — mobile */
@media (max-width: 768px) {
    .header { padding: 0.6rem 0.8rem; }
    .header-row { gap: 0.5rem; }
    .header h1 { font-size: 1.1rem; }
    .header nav a { padding: 0.3rem; }
    .header nav a .nav-icon { width: 28px; height: 28px; }
    .subheader { padding: 0.5rem 0; }
    .stats { flex-direction: column; }
    .detail { flex-direction: column; }
    .detail .cover { flex: none; }
    .detail .cover, .detail .cover img, .detail .cover .no-cover { width: 100%; max-width: 300px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
}

/* ===== Cache / Hors-ligne page ===== */

/* Storage bar */
.storage-bar {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf1;
}
.storage-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #5a6c7d;
    margin-bottom: 0.5rem;
}
.storage-track {
    height: 8px;
    background: #eef1f5;
    border-radius: 4px;
    overflow: hidden;
}
.storage-fill {
    height: 100%;
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s;
}

/* Download notification */
.dl-notification {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf1;
}
.dl-notification.hidden { display: none; }
.dl-notification-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.dl-notification-text {
    font-size: 0.9rem;
    color: #2c3e50;
    font-weight: 500;
}
.dl-notification-count {
    font-size: 0.8rem;
    color: #7f8c8d;
}
.dl-notification-track {
    height: 4px;
    background: #eef1f5;
    border-radius: 2px;
    overflow: hidden;
}
.dl-notification-fill {
    height: 100%;
    background: #c0392b;
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s;
}

/* Error banner */
.cache-error-banner {
    background: #fdf2f2;
    border: 1px solid #e74c3c;
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    color: #c0392b;
    font-size: 0.9rem;
}
.cache-error-banner.hidden { display: none; }
.cache-error-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}
.cache-error-actions button {
    background: #c0392b;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}
.cache-error-actions button:hover { background: #a93226; }
.cache-error-actions button:last-child {
    background: transparent;
    color: #c0392b;
    font-size: 1.1rem;
    padding: 0.2rem 0.5rem;
}

/* Tabs */
.cache-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e8ecf1;
    padding: 0 2rem;
}
.header .cache-tabs {
    margin-bottom: 0;
    border-bottom: none;
    border-top: 1px solid #e8ecf1;
    width: 100%;
    padding: 0;
}
.header:has(.cache-tabs) {
    padding-bottom: 0;
    gap: 0;
}
.header:has(.cache-tabs) .header-main {
    padding-bottom: 1rem;
}
.header:has(.cache-tabs) + .container {
    margin-top: 1rem;
}
.cache-tab {
    background: none;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #7f8c8d;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}
.cache-tab:hover { color: #2c3e50; }
.cache-tab.active {
    color: #c0392b;
    border-bottom-color: #c0392b;
}

/* Cache panels */
.cache-panel.hidden { display: none; }

/* Generic hidden */
.hidden { display: none !important; }

/* Cache card */
.cache-card {
    position: relative;
    display: flex;
    flex-direction: column;
}
.cache-card .cover {
    position: relative;
}
.cache-card-cover {
    text-decoration: none;
    display: block;
}
.cache-card-body {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    position: relative;
}
.cache-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.2;
}
.cache-card-status {
    font-size: 0.75rem;
    color: #7f8c8d;
}
.cache-card-status.status-ok { color: #27ae60; }
.cache-card-status.status-error { color: #c0392b; }
.cache-card-status.status-warn { color: #e67e22; }
.cache-card-status.status-pending { color: #3498db; }
.cache-card-delete {
    margin-top: auto;
    background: #fdf2f2;
    border: 1px solid #e8c4c4;
    border-radius: 8px;
    padding: 0.45rem 0;
    font-size: 0.8rem;
    color: #c0392b;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.cache-card-delete:hover, .cache-card-delete:active {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

/* Card menu button (⋯) — inherits from .card-menu-btn, just override position */
.cache-card-menu-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
}
.cache-card-menu-btn:hover, .cache-card-menu-btn:active {
    background: rgba(0,0,0,0.06);
    color: #2c3e50;
}
.cache-card-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    z-index: 200;
    white-space: nowrap;
    overflow: hidden;
}
.cache-card-dropdown a,
.cache-card-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    color: #2c3e50;
}
.cache-card-dropdown button {
    color: #c0392b;
}
.cache-card-dropdown a:hover,
.cache-card-dropdown button:hover {
    background: #f5f5f5;
}

/* Progress overlay on cover */
.cache-progress-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    padding: 6px;
}
.cache-progress-bar {
    height: 4px;
    background: #c0392b;
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s;
}
.cache-progress-text {
    color: #fff;
    font-size: 0.7rem;
    text-align: center;
    margin-top: 2px;
}

/* Series blocks */
.cache-universe-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: #5a6c7d;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e8ecf1;
}
.cache-series-block {
    margin-bottom: 2rem;
}
.cache-series-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.cache-series-name {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
}
.cache-series-name small {
    font-weight: 400;
    color: #7f8c8d;
}
.cache-delete-series {
    background: none;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    color: #c0392b;
    cursor: pointer;
    transition: background 0.2s, border-color 0.15s;
}
.cache-delete-series:hover {
    background: #fdf2f2;
    border-color: #c0392b;
}

/* Offline cache button on detail page */
.btn-cache-wrap {
    display: inline-flex;
    align-items: stretch;
    position: relative;
    margin-bottom: 1.2rem;
    margin-left: 0.5rem;
    vertical-align: baseline;
}
.btn-cache {
    display: inline-block;
    background: #2c3e50;
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-cache:hover {
    background: #1a252f;
}
.btn-cache.cached {
    background: #27ae60;
    border-radius: 8px 0 0 8px;
}
.btn-cache.cached:hover {
    background: #27ae60;
}
.btn-cache:disabled {
    opacity: 0.9;
    cursor: default;
}
.btn-cache-arrow {
    display: inline-flex;
    align-items: center;
    background: #219a52;
    color: #fff;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.3);
    padding: 0 0.7rem;
    border-radius: 0 8px 8px 0;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-cache-arrow:hover {
    background: #1a7a40;
}
.btn-cache-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    white-space: nowrap;
}
.btn-cache-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: #c0392b;
    font-weight: 500;
}
.btn-cache-dropdown button:hover {
    background: #fdf0ef;
}

/* ===== Masquer les éléments offline quand pas de SW ===== */
body.no-sw [data-sw-only] { display: none !important; }

/* ===== Désactiver la recherche visuelle Edge sur les images ===== */
img { pointer-events: none; }
