/* Cards&Freaks — mobile d'abord. Les règles de base visent le téléphone ; @media (min-width: 900px) adapte à l'ordinateur. */
:root {
    --bg: #f6f5ff;
    --surface: #ffffff;
    --surface-2: #eeedfb;
    --text: #1b1a2e;
    --muted: #6b6a85;
    --border: #dcdaf2;
    --primary: #3730a3;
    --primary-text: #ffffff;
    --accent: #f59e0b;
    --ok: #15803d;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --ok-bg: #dcfce7;
    --warn: #92400e;
    --warn-bg: #fef3c7;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(30, 27, 75, .08), 0 4px 14px rgba(30, 27, 75, .06);
    --tabs-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1020;
        --surface: #1a1b30;
        --surface-2: #25274a;
        --text: #ececff;
        --muted: #9a9bbd;
        --border: #2f3156;
        --primary: #818cf8;
        --primary-text: #0f1020;
        --ok: #4ade80;
        --danger: #fca5a5;
        --danger-bg: #4c1d1d;
        --ok-bg: #14391f;
        --warn: #fcd34d;
        --warn-bg: #4a3512;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg); color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans CJK JP", sans-serif;
    font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h1:focus { outline: none; }
p { margin: .4rem 0; }
.muted { color: var(--muted); font-size: .9rem; }

/* ---------- Démarrage ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: .75rem; }
.boot-logo { width: 72px; height: 72px; border-radius: 18px; background: var(--primary); color: var(--primary-text); display: grid; place-content: center; font-weight: 800; font-size: 1.4rem; }
.boot-text { color: var(--muted); }

/* ---------- Coque de l'application ---------- */
.shell { min-height: 100vh; padding-bottom: calc(var(--tabs-h) + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
    padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top, 0px)); background: var(--primary); color: var(--primary-text); }
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; font-weight: 700; }
.brand-mark { background: var(--accent); color: #3730a3; border-radius: 8px; padding: .1rem .4rem; font-weight: 800; font-size: .9rem; }
.topbar-user { font-size: .9rem; opacity: .9; }
.content { max-width: 1100px; margin: 0 auto; }
.page { padding: 1rem; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface);
    border-top: 1px solid var(--border); padding-bottom: var(--safe-b); height: calc(var(--tabs-h) + var(--safe-b)); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: .7rem; min-height: 48px; }
.tab { position: relative; }
.tab-ico { font-size: 1.35rem; line-height: 1; }
.tab-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--danger); color: var(--surface); font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
@media (min-width: 900px) { .tab-badge { position: static; margin-left: auto; } }
.tab.active { color: var(--primary); font-weight: 700; }

@media (min-width: 900px) {
    .shell { padding-bottom: 0; padding-left: 220px; }
    .topbar { margin-left: -220px; }
    .tabs { top: 56px; bottom: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start; height: auto;
        border-top: 0; border-right: 1px solid var(--border); padding: 1rem .75rem; gap: .25rem; }
    .tab { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: .75rem; padding: .65rem .85rem; border-radius: 10px; font-size: 1rem; }
    .tab.active { background: var(--surface-2); }
    .page { padding: 1.5rem; }
}

/* ---------- Écrans de connexion ---------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; background: var(--primary); color: var(--primary-text); display: grid; place-content: center; font-weight: 800; margin: 0 auto .5rem; }
.auth-card h1 { text-align: center; }
.tagline { text-align: center; color: var(--muted); margin-bottom: 1rem; }

/* ---------- Formulaires ---------- */
label.field { display: block; margin: .75rem 0; font-size: .9rem; color: var(--muted); }
label.field > span { display: block; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
    width: 100%; padding: .7rem .8rem; font-size: 1rem; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; min-height: 46px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.check { display: flex; gap: .6rem; align-items: flex-start; margin: .9rem 0; font-size: .95rem; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.row { display: flex; gap: .6rem; }
.row > * { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 46px; padding: .6rem 1.1rem;
    border: 0; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; background: var(--primary); color: var(--primary-text); text-decoration: none; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.small { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.alert { padding: .7rem .9rem; border-radius: 10px; margin: .75rem 0; font-size: .95rem; }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Puces, onglets internes ---------- */
.chips { display: flex; gap: .45rem; overflow-x: auto; padding: .25rem 0 .6rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: .45rem .9rem; border-radius: 999px; background: var(--surface-2); color: var(--text); border: 0; font-size: .9rem; cursor: pointer; min-height: 38px; }
.chip.on { background: var(--primary); color: var(--primary-text); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: .75rem; }
.stat { background: var(--surface); border-radius: var(--radius); padding: .7rem .5rem; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: .75rem; color: var(--muted); }

/* ---------- Grille de cartes ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; } }

.tile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.tile.clickable { cursor: pointer; }
.tile-img { position: relative; aspect-ratio: 5 / 7; background: var(--surface-2); display: grid; place-content: center; }
.tile-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-fallback { font-size: 2.2rem; font-weight: 800; color: var(--muted); }
.badge-corner { position: absolute; top: 6px; right: 6px; background: var(--accent); color: #3a2a00; font-weight: 700; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; }
.tile-body { padding: .5rem .6rem .65rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.tile-name { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.tile-meta { font-size: .78rem; color: var(--muted); }
.tile-price { font-size: .85rem; }
.tile-actions { display: flex; gap: .4rem; margin-top: auto; padding-top: .4rem; }
.tile-actions .btn { flex: 1; padding: .3rem .4rem; }
.tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .2rem; }
.tag { font-size: .72rem; padding: .08rem .45rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.sale { background: var(--ok-bg); color: var(--ok); }
.tag.trade { background: var(--accent); color: #3a2a00; }

/* ---------- Progression ---------- */
.set-row { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem; margin-bottom: .6rem; }
.set-row-head { display: flex; justify-content: space-between; gap: .5rem; font-weight: 600; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: .5rem 0; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------- Fenêtre (feuille du bas sur mobile) ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(10, 10, 30, .55); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; min-height: min(78vh, 680px); max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 1rem 1rem calc(1rem + var(--safe-b)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.modal-head h2 { margin: 0; }
.modal-close { background: none; border: 0; font-size: 1.6rem; color: var(--muted); cursor: pointer; min-width: 44px; min-height: 44px; }
.modal-card { display: flex; gap: .8rem; align-items: center; margin-bottom: .5rem; }
.modal-card img { width: 88px; border-radius: 6px; }
/* ---------- Radar et propositions ---------- */
.item { display: flex; gap: .8rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: .7rem; margin-bottom: .7rem;
        color: inherit; text-decoration: none; }
.item-img { position: relative; width: 84px; flex: none; aspect-ratio: 5 / 7; border-radius: 6px; overflow: hidden; background: var(--surface-2);
            display: grid; place-content: center; }
.item-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.item-actions { margin-top: auto; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.chips.wrap { flex-wrap: wrap; overflow-x: visible; }
.item.meeting { border-left: 4px solid var(--primary); }
.item.meeting.set { border-left-color: var(--ok); }
.item.meeting.declined { border-left-color: var(--danger); }
.link-btn { background: none; border: 0; padding: 0 .4rem 0 0; margin-left: .5rem; color: var(--muted); font-size: .8rem; text-decoration: underline; cursor: pointer; }
.thread li { align-items: flex-start; }
.qr-box { background: #fff; border-radius: 12px; padding: .6rem; max-width: 320px; margin: .5rem auto; }
.qr-box svg { display: block; width: 100%; height: auto; }
.payload { display: block; word-break: break-all; font-size: .75rem; padding: .5rem; margin-top: .4rem; background: var(--surface-2); border-radius: 8px; color: var(--text); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 .4rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 .9rem .9rem; display: flex; flex-direction: column; gap: .1rem; }
.timeline li::before { content: ""; position: absolute; left: -.42rem; top: .35rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--primary); }
.cm-row .btn { margin-right: .4rem; }
.private-note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: .6rem .8rem; margin: .4rem 0; font-size: .9rem; }
.private-note .muted { color: inherit; opacity: .8; }
.stats.one { grid-template-columns: 1fr; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
a.stat { color: inherit; text-decoration: none; }
.amount { font-weight: 700; white-space: nowrap; }
.amount.plus { color: var(--ok); }
.amount.minus { color: var(--danger); }
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.people { list-style: none; margin: .2rem 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.people li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.prop-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.prop-cards { display: flex; gap: .6rem; flex-wrap: wrap; }
.prop-card { display: flex; gap: .4rem; align-items: center; font-size: .8rem; }
.prop-card .item-img { width: 44px; }
.cm-row { margin: 0 0 .75rem; }
.cm-link { display: inline-block; text-decoration: none; }
.card-picture { background: none; border: 0; padding: 0; cursor: zoom-in; flex: 0 0 auto; }
.card-picture img { display: block; }
/* Image agrandie : la fenêtre de détails ne garde que son titre et l'image, qui la remplit (la fenêtre s'ajuste à l'image). */
.viewer { position: relative; display: flex; justify-content: center; cursor: zoom-out; }
/* Une carte fait 63 x 88 mm : la plus grande largeur qui tient dans la fenêtre (92vh, moins marges et titre). */
.viewer img { width: min(100%, calc((92vh - 6rem) * .716)); height: auto; border-radius: 4.5% / 3.2%; }
.modal:has(.viewer) > :not(.modal-head):not(.modal-card) { display: none; }
.modal:has(.viewer) .modal-card { display: block; margin: 0; }
.modal:has(.viewer) .modal-card > :not(.viewer) { display: none; }
.viewer-close { position: absolute; top: 8px; right: 8px; z-index: 1; /* au-dessus de l'image */ width: 44px; height: 44px; border: 0; border-radius: 50%;
                background: rgba(0, 0, 0, .55); color: #fff; font-size: 1.8rem; line-height: 1; cursor: pointer; }
@media (min-width: 700px) {
    .modal-backdrop { align-items: center; }
    .modal { max-width: 460px; border-radius: 20px; padding-bottom: 1rem; }
}

/* ---------- Scan ---------- */
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-guide { position: absolute; inset: 8% 14%; border: 3px dashed rgba(255, 255, 255, .85); border-radius: 14px; pointer-events: none; }
.scan-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: #fff; font-size: .8rem; text-shadow: 0 1px 3px #000; }
.scanner-off { aspect-ratio: auto; padding: 1.2rem; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.scan-actions { display: flex; gap: .6rem; margin: .75rem 0; flex-wrap: wrap; }
.scan-actions .btn { flex: 1 1 140px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.read-text { font-family: ui-monospace, monospace; font-size: .8rem; background: var(--surface-2); padding: .5rem; border-radius: 8px; white-space: pre-wrap; max-height: 5rem; overflow: auto; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.4rem; }

.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); z-index: 120; background: var(--text); color: var(--bg);
    padding: .7rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow); width: max-content; max-width: 90vw; text-align: center; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

#blazor-error-ui { background: var(--danger-bg); color: var(--danger); bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
