
@font-face{font-family:'Archivo';src:url('/fonts/Archivo-VF.ttf') format('truetype-variations');font-weight:100 900;font-display:swap;}
@font-face{font-family:'JetBrains Mono';src:url('/fonts/JetBrainsMono-VF.ttf') format('truetype-variations');font-weight:100 800;font-display:swap;}
@font-face{font-family:'IBM Plex Sans';src:url('/fonts/IBMPlexSans-Regular.ttf') format('truetype');font-weight:400;font-display:swap;}
@font-face{font-family:'IBM Plex Sans';src:url('/fonts/IBMPlexSans-Medium.ttf') format('truetype');font-weight:500;font-display:swap;}
@font-face{font-family:'IBM Plex Sans';src:url('/fonts/IBMPlexSans-SemiBold.ttf') format('truetype');font-weight:600;font-display:swap;}
@font-face{font-family:'IBM Plex Sans';src:url('/fonts/IBMPlexSans-Bold.ttf') format('truetype');font-weight:700;font-display:swap;}

:root {
    --bg: #F2F2F7;
    --bg-card: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --text: #1C1C1E;
    --text-secondary: #6E6E73;
    --text-tertiary: #AEAEB2;
    --separator: rgba(60,60,67,0.12);
    --accent: #FF3B30;
    --green: #34C759;
    --orange: #FF9500;
    --red: #FF3B30;
    --pink: #FF2D55;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.06);
    --radius: 14px;
    --radius-lg: 20px;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --bg-card: #1C1C1E;
        --bg-elevated: #2C2C2E;
        --text: #FFFFFF;
        --text-secondary: #98989F;
        --text-tertiary: #6C6C70;
        --separator: rgba(84,84,88,0.65);
        --shadow: 0 1px 3px rgba(0,0,0,0.4);
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-bottom: calc(80px + var(--safe-bottom));
    overscroll-behavior-y: contain;
}

/* ─── HEADER ───────────────────────────────────────────────────────────── */
header.app-header {
    position: sticky;
    top: 0;
    background: var(--bg);
    padding: calc(var(--safe-top) + 12px) 20px 12px;
    border-bottom: 0.5px solid var(--separator);
    z-index: 100;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
}
header.app-header .nav-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 32px;
}
header.app-header .back-btn {
    color: var(--accent);
    font-size: 17px;
    font-weight: 400;
    text-decoration: none;
    padding: 4px 8px 4px 0;
    margin-left: -4px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
header.app-header h1 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    flex: 1;
    text-align: center;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
header.app-header .spacer { width: 60px; }

/* ─── HOME : titre large + search ──────────────────────────────────────── */
.home-hero {
    padding: 24px 20px 0;
}
.home-hero h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 4px;
}
.home-hero .subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin: 0 0 20px;
}
.search-bar {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 10px 14px;
    margin: 0 20px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}
.search-bar svg {
    width: 18px; height: 18px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}
.search-bar input {
    flex: 1;
    border: 0;
    background: transparent;
    font-size: 17px;
    color: var(--text);
    outline: none;
    font-family: inherit;
}
.search-bar input::placeholder { color: var(--text-tertiary); }

/* ─── SECTION HEADERS ──────────────────────────────────────────────────── */
.section-header {
    padding: 24px 20px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── GRID CARDS (home) ────────────────────────────────────────────────── */
.section-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 20px;
}
.section-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 110px;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease;
    border-left: 4px solid var(--card-color);
}
.section-card:active { transform: scale(0.97); }
.section-card .icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--card-color) 15%, transparent);
    color: var(--card-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.section-card .icon svg { width: 22px; height: 22px; }
.svg-icon { width: 22px; height: 22px; }
.h2-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-right: 10px;
    flex-shrink: 0;
}
.h2-icon svg { width: 18px; height: 18px; }
.fiche-content h2 {
    display: flex;
    align-items: center;
}
.tab-bar svg { width: 22px; height: 22px; }
.tab-bar a { color: var(--text-tertiary); }
.tab-bar a.active svg { color: var(--accent); }
.back-btn svg { width: 22px; height: 22px; vertical-align: middle; }
.section-card .label {
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
}
.section-card .count {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ─── ALERT CARDS (à vérifier en priorité) ────────────────────────────── */
.alert-card {
    background: linear-gradient(135deg, #FF3B30 0%, #FF6B6B 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 0 20px 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    display: block;
}
.alert-card.warn { background: linear-gradient(135deg, #FF9500 0%, #FFCC00 100%); }
.alert-card .alert-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.alert-card .alert-title {
    font-size: 22px;
    font-weight: 700;
    margin: 8px 0 4px;
}
.alert-card .alert-desc {
    font-size: 14px;
    opacity: 0.92;
}

/* ─── LIST CELLS (section page : liste fiches) ────────────────────────── */
.fiche-list {
    margin: 0 20px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.fiche-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 0.5px solid var(--separator);
    gap: 12px;
    min-height: 44px;
}
.fiche-row:last-child { border-bottom: 0; }
.fiche-row:active { background: var(--bg-elevated); }
.fiche-row .row-num {
    font-size: 13px;
    color: var(--text-tertiary);
    font-feature-settings: "tnum";
    min-width: 36px;
}
.fiche-row .row-title {
    flex: 1;
    font-size: 16px;
}
.fiche-row .row-prio {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    color: white;
}
.fiche-row .row-prio.P1 { background: var(--red); }
.fiche-row .row-prio.P2 { background: var(--orange); }
.fiche-row .row-prio.P3 { background: var(--text-tertiary); }
.fiche-row .chevron { color: var(--text-tertiary); display: inline-flex; align-items: center; }
.fiche-row .chevron svg { width: 16px; height: 16px; }
.section-hero-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.section-hero-icon svg { width: 38px; height: 38px; }

/* ─── FICHE CONTENT (lecture) ─────────────────────────────────────────── */
.fiche-meta {
    padding: 16px 20px 0;
    color: var(--text-secondary);
    font-size: 13px;
}
.fiche-meta .badge-section {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 12px;
    margin-right: 6px;
}
.fiche-meta .badge-prio {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    background: var(--red);
    color: white;
    font-weight: 700;
    font-size: 12px;
    margin-right: 6px;
}
.fiche-meta .badge-prio.P2 { background: var(--orange); }
.fiche-meta .badge-prio.P3 { background: var(--text-tertiary); }
.fiche-content {
    padding: 8px 20px 32px;
    font-size: 17px;
    line-height: 1.55;
}
.fiche-content h1:first-child {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 8px 0 4px;
}
.fiche-content h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 28px 0 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent-color, var(--accent));
    scroll-margin-top: 80px;
}
.fiche-content h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--text);
}
.fiche-content blockquote {
    margin: 0 0 16px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    border-left: 3px solid var(--text-tertiary);
}
.fiche-content p { margin: 0 0 12px; }
.fiche-content ul, .fiche-content ol {
    padding-left: 22px;
    margin: 0 0 16px;
}
.fiche-content li { margin-bottom: 6px; }
.fiche-content strong { font-weight: 600; }
.fiche-content code {
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 5px;
    font-family: "SF Mono", "Menlo", monospace;
    font-size: 0.9em;
}
.fiche-content a {
    color: var(--accent);
    text-decoration: none;
}
.fiche-content a:active { text-decoration: underline; }

/* Tableaux : scroll horizontal sur mobile */
.table-wrap {
    margin: 0 -20px 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 20px;
}
.fiche-content table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    margin: 0 0 16px;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: 14px;
}
.fiche-content th, .fiche-content td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 0.5px solid var(--separator);
    vertical-align: top;
}
.fiche-content th {
    background: var(--bg-elevated);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}
.fiche-content tr:last-child td { border-bottom: 0; }

/* Marqueurs structurels colorés (🚨🎯👁🧪📊💊🚦⚠️📚💡) */
.fiche-content h2 { position: relative; }
.fiche-content h2[data-marker="🚨"] { background: linear-gradient(90deg, rgba(255,59,48,0.10), var(--bg-card) 60%); border-left-color: #FF3B30; }
.fiche-content h2[data-marker="⚠️"] { background: linear-gradient(90deg, rgba(255,149,0,0.10), var(--bg-card) 60%); border-left-color: #FF9500; }
.fiche-content h2[data-marker="💊"] { background: linear-gradient(90deg, rgba(52,199,89,0.10), var(--bg-card) 60%); border-left-color: #34C759; }
.fiche-content h2[data-marker="🚦"] { background: linear-gradient(90deg, rgba(0,122,255,0.10), var(--bg-card) 60%); border-left-color: #007AFF; }
.fiche-content h2[data-marker="📚"] { background: var(--bg-card); border-left-color: var(--text-tertiary); opacity: 0.85; }
.fiche-content h2[data-marker="💡"] { background: linear-gradient(90deg, rgba(255,204,0,0.10), var(--bg-card) 60%); border-left-color: #FFCC00; }
.fiche-content h2[data-marker="🎯"] { background: linear-gradient(90deg, rgba(175,82,222,0.10), var(--bg-card) 60%); border-left-color: #AF52DE; }
.fiche-content h2[data-marker="👁"] { background: linear-gradient(90deg, rgba(100,210,255,0.10), var(--bg-card) 60%); border-left-color: #64D2FF; }
.fiche-content h2[data-marker="🧪"] { background: linear-gradient(90deg, rgba(48,209,88,0.10), var(--bg-card) 60%); border-left-color: #30D158; }
.fiche-content h2[data-marker="📊"] { background: linear-gradient(90deg, rgba(0,199,190,0.10), var(--bg-card) 60%); border-left-color: #00C7BE; }

/* Marqueurs [À VÉRIFIER MANUEL] en badge orange */
.verify-tag {
    display: inline-block;
    background: rgba(255,149,0,0.15);
    color: #C77700;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: 500;
    vertical-align: middle;
}
@media (prefers-color-scheme: dark) {
    .verify-tag { background: rgba(255,149,0,0.20); color: #FFB340; }
}

/* ─── BOTTOM NAV (tab bar iOS) ────────────────────────────────────────── */
nav.tab-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid var(--separator);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 calc(6px + var(--safe-bottom));
    z-index: 100;
}
nav.tab-bar a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: var(--text-tertiary);
    padding: 6px 0;
    font-size: 10px;
}
nav.tab-bar a .tab-icon {
    display: block;
    font-size: 22px;
    line-height: 1.1;
    margin-bottom: 2px;
}
nav.tab-bar a.active { color: var(--accent); }

/* ─── SEARCH RESULTS ──────────────────────────────────────────────────── */
#search-results {
    margin: 0 20px;
}
#search-results .result-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text);
    display: block;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--card-color, var(--accent));
}
#search-results .result-section {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
#search-results .result-title {
    font-size: 16px;
    font-weight: 600;
    margin: 2px 0 4px;
}
#search-results .result-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
}
#search-results mark {
    background: rgba(255,204,0,0.35);
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}
.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: 60px 20px;
    font-size: 15px;
}

@media (min-width: 768px) {
    body { max-width: 720px; margin: 0 auto; }
    .section-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ═══ DESIGN FICHE "vade-mecum" (surcharge — bandeaux colorés, pilules-doses, réfs) ═══ */
.fiche-content, .fiche-hd { font-family: 'IBM Plex Sans', -apple-system, system-ui, sans-serif; }

/* Header de fiche */
.fiche-hd { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; border-bottom: 2px solid var(--sc, var(--accent)); }
.fiche-hd-ic { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fiche-hd-ic svg { width: 25px; height: 25px; color: #fff; }
.fiche-hd-titles { flex: 1; min-width: 0; }
.fiche-hd-eyebrow { font-family: 'Archivo', sans-serif; font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--sc, var(--accent)); }
.fiche-hd-title { font-family: 'Archivo', sans-serif; font-weight: 800; font-size: 23px; line-height: 1.07; letter-spacing: -.01em; color: var(--text); margin-top: 2px; }
.fiche-hd-title .hd-sub { display: block; font-family: 'IBM Plex Sans', sans-serif; font-weight: 500; font-size: 14px; color: var(--text-secondary); margin-top: 3px; }
.fiche-hd-prio { flex-shrink: 0; align-self: flex-start; font-family: 'Archivo', sans-serif; font-weight: 800; font-size: 13px; color: #fff; background: var(--text-tertiary); padding: 3px 9px; border-radius: 8px; }
.fiche-hd-prio.P1 { background: #FF3B30; } .fiche-hd-prio.P2 { background: #FF9500; } .fiche-hd-prio.P3 { background: var(--text-tertiary); }

/* H2 = bandeau coloré plein (icône blanche intégrée) */
.fiche-content h2 {
    display: flex; align-items: center; gap: 8px;
    font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 14.5px;
    letter-spacing: .04em; text-transform: uppercase; color: #fff;
    background: var(--bar, #6E6E73);
    padding: 9px 14px; border-radius: 12px; border-left: none; box-shadow: none;
    margin: 24px 0 12px; scroll-margin-top: 76px;
}
.fiche-content h2 .h2-icon { width: 22px; height: 22px; background: transparent !important; margin-right: 0; border-radius: 0; flex-shrink: 0; }
.fiche-content h2 .h2-icon svg { width: 20px; height: 20px; color: #fff !important; stroke: #fff !important; }

/* Corps : listes, titres */
.fiche-content { font-size: 16px; line-height: 1.5; }
.fiche-content h3 { font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 16px; margin: 18px 0 7px; color: var(--text); }
.fiche-content p, .fiche-content li { font-size: 15px; }
.fiche-content ul { list-style: none; padding-left: 2px; margin: 0 0 14px; }
.fiche-content ul li { position: relative; padding-left: 18px; margin-bottom: 7px; }
.fiche-content ul li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); }
.fiche-content strong { color: var(--text); font-weight: 600; }

/* Carte rouge red flags */
.fiche-content h2[data-marker-color="#FF3B30"] + ul {
    background: rgba(215,0,21,0.07); border: 1px solid rgba(215,0,21,0.22);
    border-radius: 14px; padding: 14px 16px 12px;
}
.fiche-content h2[data-marker-color="#FF3B30"] + ul li::before { background: #FF3B30; }

/* Pilules-doses */
.fiche-content .dose { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 13px; background: rgba(48,180,90,0.16); color: #1B9E48; padding: 1px 7px; border-radius: 7px; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .fiche-content .dose { color: #5CE08A; } }

/* Cartes-doses (PEC) */
.fiche-content li.dose-row { list-style: none; background: var(--bg-card); border: 1px solid var(--separator); border-left: 4px solid #34C759; border-radius: 12px; padding: 11px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.fiche-content li.dose-row::before { display: none; }

/* Marqueur à vérifier */
.fiche-content .verify-tag { display: inline-block; background: rgba(255,149,0,0.18); color: var(--orange); font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; }

/* Références en fin de fiche */
.refs-section { margin: 28px 0 0; padding-top: 14px; border-top: 1px solid var(--separator); }
.refs-section h2.refs-title { display: block; background: none; color: var(--text-secondary); font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; padding: 0; margin: 0 0 8px; border: none; box-shadow: none; }
.refs-section h2.refs-title .h2-icon { display: none; }
.refs-list { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; }
.refs-list ul { padding-left: 16px; list-style: disc; }
.refs-list ul ul { padding-left: 14px; }
.refs-list li { margin-bottom: 5px; }
.refs-list li::before { display: none; }
.refs-list strong { color: var(--text); }
.refs-list code { background: none; padding: 0; color: var(--text-tertiary); font-family: inherit; font-size: inherit; }

.fiche-content h2[data-marker-color="#FF3B30"]{--bar:#D70015;}
.fiche-content h2[data-marker-color="#AF52DE"]{--bar:#8A3FC8;}
.fiche-content h2[data-marker-color="#64D2FF"]{--bar:#0A78B8;}
.fiche-content h2[data-marker-color="#30D158"]{--bar:#1E9B4C;}
.fiche-content h2[data-marker-color="#00C7BE"]{--bar:#067A72;}
.fiche-content h2[data-marker-color="#34C759"]{--bar:#137A38;}
.fiche-content h2[data-marker-color="#007AFF"]{--bar:#0A66C0;}
.fiche-content h2[data-marker-color="#FF9500"]{--bar:#B25A00;}
.fiche-content h2[data-marker-color="#8E8E93"]{--bar:#6E6E73;}
.fiche-content h2[data-marker-color="#FFCC00"]{--bar:#9A7B00;}
