/* Même environnement graphique que CADEAU et INVENTAIRE : thème sombre par défaut, clair si choisi (bouton ☀️ / 🌙),
   fin filet bleu roi autour des onglets et des fenêtres. */
:root {
  --bg: #2f333a; --card: #3a3f48; --ink: #f2f4f7; --muted: #bcc3ce; --line: #555c68;
  --accent: #4169e1; --link: #a3b8f8; --ok: #5fc39e; --frame: #4169e1;
  --danger: #ff7b72; --danger-bg: #4a2f33; --warn: #f2c66d; --warn-bg: #4a4232;
  --tip-bg: #33405a; --tip: #a3b8f8; --radius: 12px; --shadow: none;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef0f3; --card: #fff; --ink: #1d2027; --muted: #5b6270; --line: #d5d9e0;
  --accent: #3157d4; --link: #2a4fc4; --ok: #1e6b52;
  --danger: #a61b1b; --danger-bg: #fdecec; --warn: #7a4b00; --warn-bg: #fff6e0;
  --tip-bg: #eaf0ff; --tip: #2a4fc4;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--link); }
img { max-width: 100%; display: block; }
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 64px; outline: none; }

/* --- en-tête --- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; }
.brand img { width: 28px; height: 28px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a { color: var(--muted); text-decoration: none; padding: .45em .8em; border-radius: 8px; font-size: 15px; border: 1px solid var(--frame); }
.tabs a.on { background: var(--bg); color: var(--ink); font-weight: 600; }
.tabs .n { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .3em; border-radius: 99px; background: #d9534f; color: #fff; font-size: .8em; font-weight: 600; line-height: 1.4em; text-align: center; }

/* --- barre de recherche & filtres --- */
.toolbar { display: grid; gap: 12px; margin-bottom: 16px; }
.search { position: relative; }
.search input { width: 100%; padding: 12px 14px 12px 40px; font: inherit; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .c { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.chip[aria-pressed="true"] .c { color: inherit; opacity: .7; }
.summary { color: var(--muted); font-size: 13px; }

/* --- grille de cartes --- */
.section-title { display: flex; align-items: center; gap: 8px; margin: 28px 0 10px; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.section-title .dot { width: 10px; height: 10px; border-radius: 3px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card { position: relative; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.thumb { aspect-ratio: 4/3; background: #fff; display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.ph { background: color-mix(in srgb, var(--c) 12%, var(--card)); }
.thumb.ph svg { width: 44px; height: 44px; stroke: var(--c); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.card .body { padding: 10px 12px 12px; display: grid; gap: 2px; }
.card .name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: 12.5px; }
.qty { position: absolute; top: 8px; right: 8px; background: rgba(15,23,42,.82); color: #fff; font-size: 12px; font-weight: 650;
  padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.flag { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 50%; background: #f59e0b; color: #1e293b;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* --- fiche détaillée --- */
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--ink); }
.detail { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 760px) {
  .detail { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .gallery .main { aspect-ratio: 4/3; }
  .gallery .main.ph { aspect-ratio: 3/1; }
  .gallery .main.ph svg { width: 48px; height: 48px; }
  .head h1 { font-size: 22px; }
  ul.res .u { display: none; }
}
@media (max-width: 520px) {
  .top { gap: 8px; }
  .tabs { margin-left: 0; width: 100%; }
  .tabs a { padding: 5px 10px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
.gallery { position: sticky; top: 72px; display: grid; gap: 8px; }
@media (max-width: 760px) { .gallery { position: static; } }
.gallery .main { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; }
.gallery .main img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.gallery .main.ph { background: color-mix(in srgb, var(--c) 10%, var(--card)); }
.gallery .main.ph svg { width: 90px; height: 90px; stroke: var(--c); fill: none; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.gallery .main.ph p { margin: 0; color: var(--muted); font-size: 13px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs button { width: 64px; height: 64px; padding: 0; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; overflow: hidden; }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: contain; }

.head h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
.head .lead { margin: 0; font-size: 16px; color: var(--muted); }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); font-size: 13px; }
.tag b { font-weight: 650; }
.tag .dot { width: 8px; height: 8px; border-radius: 50%; }
.tag.missing { color: var(--muted); border-style: dashed; }

.block { margin-top: 22px; }
.block h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 15px; font-weight: 650; }
.block h2 svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.block p { margin: 0; }
.callout { padding: 12px 14px; border-radius: 10px; font-size: 14px; display: grid; grid-template-columns: 20px 1fr; gap: 10px; }
.callout svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.callout.danger { background: var(--danger-bg); color: var(--danger); }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
.callout.tip { background: var(--tip-bg); color: var(--tip); }

.links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.mini { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); text-decoration: none; color: var(--ink); font-size: 13px; }
.mini:hover { border-color: var(--accent); }
.mini img, .mini .ic { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: #fff; }
.mini .ic { display: grid; place-items: center; background: color-mix(in srgb, var(--c) 15%, var(--card)); }
.mini .ic svg { width: 15px; height: 15px; stroke: var(--c); fill: none; stroke-width: 2; }

table.kv, table.var { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.kv th, table.kv td, table.var th, table.var td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv tr:last-child > *, table.var tr:last-child > * { border-bottom: 0; }
table.kv th { width: 38%; color: var(--muted); font-weight: 500; }
table.var thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.var td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; width: 60px; }
table.var .note { display: block; color: var(--muted); font-size: 12.5px; }

ul.res { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.res a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); }
ul.res a:hover { border-color: var(--accent); }
ul.res .k { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 5px; min-width: 56px; text-align: center; }
ul.res .k.doc { background: #e0e7ff; color: #3730a3; } ul.res .k.pdf { background: #fee2e2; color: #991b1b; }
ul.res .k.tuto { background: #dcfce7; color: #166534; } ul.res .k.video { background: #fce7f3; color: #9d174d; }
ul.res .k.achat { background: #fef3c7; color: #92400e; } ul.res .k.wiki { background: #e2e8f0; color: #334155; }
ul.res .k.search { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
ul.res .u { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.src { margin-top: 28px; font-size: 12.5px; color: var(--muted); }

/* --- projets --- */
.projets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.projet { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 10px; align-content: start; }
.projet h3 { margin: 0; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.projet .lvl { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.projet p { margin: 0; font-size: 14px; }
.intro { color: var(--muted); margin: 0 0 16px; }

/* --- visionneuse --- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: grid; place-items: center; z-index: 50; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: 6px; }

/* ====================== v2 : édition ====================== */
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.back .i { width: 16px; height: 16px; }
.tabs .n:empty { display: none; }
.hdr-actions { display: flex; gap: 6px; align-items: center; }
.top > .hdr-actions { margin-left: auto; }
@media (max-width: 520px) { .hide-sm { display: none; } .hdr-actions { margin-left: auto; } .top .brand { order: 0; } .hdr-actions { order: 1; } .tabs { order: 2; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: .55em 1em; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 550; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.sm { padding: 6px 11px; font-size: 13.5px; }
.btn.big { padding: 14px 20px; font-size: 16px; flex: 1 1 220px; }
.btn.big .i { width: 22px; height: 22px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--bg); border-color: var(--line); }
.btn:focus-visible, .chip:focus-visible, .tabs a:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
.theme-toggle { padding: .35em .6em; line-height: 1; font-size: 16px; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.ai:not(.primary) { color: #c4b5fd; border-color: color-mix(in srgb, #7c3aed 45%, var(--line)); }
:root[data-theme="light"] .btn.ai:not(.primary) { color: #6d28d9; }
.btn.primary.ai { background: linear-gradient(135deg, #4169e1, #7c3aed); border-color: transparent; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.qtag { gap: 8px; }
.step { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; line-height: 1; }
.step:hover { border-color: var(--accent); }
.phc { display: grid; place-items: center; gap: 8px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); max-width: 760px; margin: 0 auto; display: grid; gap: 14px; }
.panel h1 { margin: 0; font-size: 22px; }
.panel.login { max-width: 380px; margin-top: 40px; }
.intro, .hint { color: var(--muted); }
.hint { font-size: 13px; }
.small { font-size: 13px; }
.err { color: var(--danger); margin: 0; min-height: 0; }
.err:empty { display: none; }
.ptitle { margin: 4px 0 6px; font-size: 24px; }

label, .fld { display: grid; gap: 5px; font-size: 13.5px; font-weight: 550; color: var(--muted); }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 12px; align-items: end; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row .fld { flex: 0 0 120px; }
.row .grow, .grow { flex: 1 1 0; }
@media (max-width: 520px) { .row:not(.wrap) { flex-wrap: wrap; } .row .fld.grow { flex-basis: 100%; } }

fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; min-width: 0; }
legend { padding: 0 6px; font-weight: 650; font-size: 14px; color: var(--ink); }
legend .hint { font-weight: 400; }
.formhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rows { display: grid; gap: 8px; }
.rows:empty { display: none; }
.r { display: grid; gap: 6px; align-items: center; }
.r.v { grid-template-columns: 2fr 70px 2fr 34px; }
.r.s { grid-template-columns: 1fr 1.6fr 34px; }
.r.l { grid-template-columns: 90px 1.2fr 2fr 34px; }
@media (max-width: 620px) { .r.v, .r.l { grid-template-columns: 1fr 1fr 34px; } .r.v [data-f="nom"], .r.l [data-f="u"] { grid-column: 1 / 3; } }
.rm, .docchip button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.rm:hover, .docchip button:hover { background: var(--danger-bg); color: var(--danger); }
.mini .rm { width: 22px; height: 22px; margin-left: 2px; }
.mini .rm .i { width: 14px; height: 14px; }
.docchip { display: inline-flex; align-items: center; gap: 2px; padding-left: 8px; border: 1px solid var(--line); border-radius: 999px; }
.docchip button { width: 24px; height: 24px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--card); padding: 12px 0 4px; margin-bottom: -6px; border-top: 1px solid var(--line); }

.shots { display: flex; gap: 10px; flex-wrap: wrap; }
.shots:empty { display: none; }
.shot { position: relative; width: 104px; height: 104px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot.first { outline: 2px solid var(--accent); outline-offset: 1px; }
.shot button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(15,23,42,.75); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.shot button .i { width: 14px; height: 14px; }
.shot .mk { right: auto; left: 4px; }
.shot .turn { width: 22px; height: 22px; right: 6px; }
.shot .turn.l { top: 33px; }
.shot .turn.r { top: 58px; }
.shot.turning { opacity: .45; pointer-events: none; }
.shot .badge { position: absolute; left: 4px; bottom: 4px; background: var(--accent); color: #fff; font-size: 10.5px; padding: 1px 6px; border-radius: 5px; font-weight: 600; }
.shot.add { display: grid; place-items: center; background: var(--bg); border-style: dashed; cursor: pointer; color: var(--muted); }
.shot.add .i { width: 28px; height: 28px; }
.shot.add:hover { border-color: var(--accent); color: var(--accent); }
.shot.busy { display: grid; place-items: center; background: var(--bg); }

.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.spin.lg { width: 48px; height: 48px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.6); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px); }
.ovbox { background: var(--card); border-radius: 16px; padding: 28px 32px; display: grid; justify-items: center; gap: 10px; text-align: center; max-width: 360px; }
.ovbox p { margin: 0; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--bg); padding: .7em 1.2em; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
.toast.err { background: var(--danger); color: #fff; }
fieldset > .btn { justify-self: start; }
.cost { margin: 6px 0 4px; padding-top: 6px; border-top: 1px solid color-mix(in srgb, currentColor 20%, transparent); font-size: 13.5px; }
.cost-sum { text-align: right; margin: 0; }

/* ====================== sécurité du compte ====================== */
.grid1 { display: grid; gap: 12px; }
.center { text-align: center; margin: -6px 0 0; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.sep::before, .sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.linkbtn { background: none; border: 0; color: var(--link); font: inherit; font-size: 13.5px; cursor: pointer; padding: 4px 0; text-align: left; }
.otp { font-size: 22px; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; max-width: 240px; }
.dlg { width: min(400px, 100%); justify-items: stretch; text-align: left; }
.dlg h2 { margin: 0; font-size: 18px; }
.dlg .row { margin-top: 4px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 18px; }
.steps li { padding-left: 4px; }
.qr { margin: 12px 0 8px; width: 220px; padding: 10px; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.qr img { width: 100%; image-rendering: pixelated; }
.secret { font-size: 15px; letter-spacing: .08em; word-break: break-all; user-select: all; }
details summary { cursor: pointer; color: var(--link); font-size: 13.5px; }
.codes { columns: 2; margin: 4px 0; padding-left: 28px; font-size: 17px; line-height: 2; }
.codes code { letter-spacing: .06em; user-select: all; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.check input { width: 18px; height: 18px; }
.secgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); gap: 14px; align-items: start; }
.sec { max-width: none; margin: 0; }
.sec.wide { grid-column: 1 / -1; }
.sec h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sec h2 .hint { font-weight: 400; }
.sec p { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.pill { font-size: 11px; font-weight: 650; background: var(--accent); color: #fff; padding: 1px 7px; border-radius: 999px; }
.ok-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #16a34a; margin-right: 8px; }
.warnline { color: var(--warn); background: var(--warn-bg); padding: 6px 10px; border-radius: 8px; }
table.log th { width: 130px; white-space: nowrap; font-size: 13px; }
table.log tr.bad td { color: var(--danger); }
[hidden] { display: none !important; }

/* Fin filet bleu roi autour des onglets et des fenêtres (comme CADEAU) */
.card, .panel, .projet, .ovbox, fieldset, table.kv, table.var, .gallery .main, .search input, .empty { border: 1px solid var(--frame); }
.empty { border-style: dashed; border-radius: var(--radius); background: var(--card); }
.card:hover { border-color: var(--link); }
.ok-dot { background: var(--ok); }
.pill { background: var(--accent); }

/* Photos trouvées sur internet / choix de la vignette */
.shot .badge.web { bottom: auto; top: 34px; background: rgba(15,23,42,.75); }
.webpick { margin-top: 10px; }
.webpick .shots { margin-top: 6px; }
.shot.cand { padding: 0; cursor: pointer; border: 1px dashed var(--frame); }
.shot.cand:hover { outline: 2px solid var(--accent); }
.shot.cand.busy img { opacity: .4; }
.gallery .setthumb { margin-top: 8px; }
#webfind.busy { opacity: .6; }

/* Import d'un fichier d'objets */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; }
details.map { margin: 8px 0 12px; }
details.map summary { cursor: pointer; color: var(--link); }
.imp-wrap { max-height: 55vh; overflow: auto; margin: 8px 0; border-radius: 10px; }
table.imp { width: 100%; }
table.imp td, table.imp th { vertical-align: top; }
table.imp tr.dup td { opacity: .55; }
table.imp .missing { color: #f59e0b; font-weight: 600; }
.chk { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 4px; cursor: pointer; }
.chk input { margin-top: 3px; }
.pbar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0 12px; }
.pbar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#plist { max-height: 60vh; overflow: auto; }

/* Configuration : catégories et sous-catégories */
.cfg { display: grid; gap: 14px; margin-top: 14px; }
.cfgcat { display: grid; gap: 10px; }
.cfghead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cfghead .grow { flex: 1; min-width: 150px; }
.cic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, var(--card)); flex: none; }
.cic svg { width: 20px; height: 20px; stroke: var(--c); fill: none; stroke-width: 2; }
.chip.sc { cursor: default; padding-right: 4px; }
.chip.sc button { border: 0; background: none; color: var(--muted); padding: 2px; cursor: pointer; display: grid; place-items: center; border-radius: 50%; }
.chip.sc button:hover { color: var(--accent); background: var(--bg); }
.chip.sc .i { width: 13px; height: 13px; }
.addsous input { flex: 1; min-width: 160px; }
.icopick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.icopick label { cursor: pointer; }
.icopick input { position: absolute; opacity: 0; pointer-events: none; }
.icopick .i { width: 36px; height: 36px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; }
.icopick input:checked + .i { border-color: var(--accent); background: var(--accent); color: #fff; }
.icopick input:focus-visible + .i { outline: 2px solid var(--accent); }
.chips.sub { margin-top: -2px; }
.chips.sub .chip { font-size: 13px; padding: 3px 10px; }
.dlg input[type=color] { width: 60px; height: 34px; padding: 2px; }
.tabs a[hidden], .chips[hidden] { display: none; }

/* emplacements, code-barres, scanner, étiquettes */
.searchrow { gap: 8px; align-items: stretch; flex-wrap: wrap; }
.searchrow .search { min-width: 220px; }
.flieu { position: relative; display: flex; }
.flieu .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; pointer-events: none; }
.flieu select { padding: 10px 12px 10px 32px; font: inherit; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); max-width: 240px; }
.summary a { color: var(--accent); }
.summary a .i, .tag .i, .chip.sc a .i, .section-title .i, .lab small .i { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; vertical-align: -2px; }
a.tag { color: inherit; text-decoration: none; }
a.tag:hover { border-color: var(--accent); }
.chip.sc a { color: var(--muted); padding: 2px; display: grid; place-items: center; border-radius: 50%; }
.chip.sc a:hover { color: var(--accent); background: var(--bg); }
.addlieu { margin-top: 10px; gap: 8px; }
.addlieu input { flex: 1; min-width: 0; padding: 8px 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.fldbtn { align-self: end; margin-bottom: 2px; }
.scanbox { max-width: 440px; width: 100%; text-align: left; justify-items: stretch; }
.scanbox h2 { display: flex; gap: 8px; align-items: center; margin: 0; font-size: 18px; }
.scanbox p.hint { font-weight: 400; }
.scanbox form { gap: 8px; }
.scanbox form input { padding: 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.scanview { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanview .aim { position: absolute; inset: 22% 14%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.labcfg h1 { display: flex; gap: 10px; align-items: center; }
.labcfg details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.labcfg summary { cursor: pointer; font-weight: 650; }
.labcfg summary .c { color: var(--accent); }
.labcfg select { padding: 8px 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.chk-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 16px; max-height: 340px; overflow: auto; }
.chk-list .chk { margin: 6px 0; }
.labels { display: grid; gap: 0; margin-top: 18px; background: #fff; color: #000; }
.labels.s { grid-template-columns: repeat(3, 1fr); }
.labels.m { grid-template-columns: repeat(2, 1fr); }
.lab { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px dashed #9ca3af; break-inside: avoid; page-break-inside: avoid; min-height: 30mm; }
.lab img { width: 24mm; height: 24mm; flex: none; }
.labels.m .lab { min-height: 45mm; }
.labels.m .lab img { width: 36mm; height: 36mm; }
.lab div { display: grid; gap: 3px; min-width: 0; }
.lab b { font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
.labels.m .lab b { font-size: 16px; }
.lab small { font-size: 11px; color: #374151; overflow-wrap: anywhere; }
.lab.lieu b { font-size: 18px; }
.labels.m .lab.lieu b { font-size: 24px; }
@media print {
  @page { margin: 10mm; }
  body { background: #fff !important; }
  .top, .tabs, .noprint, #toast, .toast { display: none !important; }
  main, #app { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .labels { margin: 0; }
}

/* caméra du PC (prise de photo) */
.cambox { max-width: 560px; }
.cambox .camsel { gap: 8px; align-items: center; }
.cambox select { padding: 8px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); min-width: 0; }
.camview { aspect-ratio: 16 / 9; }
.camview video { object-fit: contain; }
.camview video.flash { animation: camflash .35s ease-out; }
@keyframes camflash { from { filter: brightness(2.5); } to { filter: none; } }
.cambox #camshots:empty { display: none; }
.cambox [hidden] { display: none !important; }

/* adresses web dans le texte des fiches */
a.autolink { color: var(--link); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

/* Cadrage de la vignette */
.thumb { position: relative; }
.thumb img.cad { position: absolute; max-width: none; object-fit: fill; }
.gallery .setthumb { gap: 8px; }
.cropbox { max-width: 620px; }
.cropframe { position: relative; aspect-ratio: 4/3; overflow: hidden; background: #fff; border-radius: 10px; box-shadow: 0 0 0 2px var(--accent); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.cropframe:active { cursor: grabbing; }
.cropframe:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cropframe img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.cropzoom { align-items: center; gap: 10px; font-weight: 700; }
.cropzoom input { flex: 1; accent-color: var(--accent); }

/* Menu du clic droit sur une vignette */
.ctxmenu { position: fixed; z-index: 70; min-width: 200px; max-width: 280px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 12px 32px rgba(15,23,42,.28); display: grid; gap: 2px; }
.ctxmenu .ctxtitle { margin: 4px 8px 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctxmenu button { display: flex; gap: 10px; align-items: center; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; cursor: pointer; }
.ctxmenu button:hover, .ctxmenu button:focus-visible { background: var(--bg); outline: none; }
.ctxmenu button .i { width: 18px; height: 18px; }
.dlg p.hint { font-weight: 400; }
.dlg .chk { font-weight: 400; font-size: 14px; line-height: 1.4; text-align: left; }
.dlg .chk input { width: auto; flex: none; padding: 0; margin: 3px 0 0; }

/* ======================= Cave à vin ======================= */
:root { --wine: #b83a5c; --m-ok: #5fc39e; --m-top: #2fa27a; --m-wait: #8aa6e8; }
:root[data-theme="light"] { --wine: #8b1e3f; --m-ok: #1e8a63; --m-top: #11694a; --m-wait: #3157d4; }
.tabs { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { white-space: nowrap; }
@media (max-width: 760px) { .tabs { margin-left: 0; width: 100%; } .tabs a { padding: .4em .65em; font-size: 14px; } }

/* cartes */
.card.wine .thumb { aspect-ratio: 3/4; }
.card.empty-stock { opacity: .55; }
.card .sub2 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.cdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 0; }
.fav { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 50%; background: rgba(15,23,42,.82); display: grid; place-items: center; }
.fav .i { width: 15px; height: 15px; stroke: #ff7b9a; fill: #ff7b9a; }
.score { font-size: 12px; font-weight: 650; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; margin-left: 4px; }
.vint { font-weight: 500; color: var(--muted); }

/* maturité : libellé texte + couleur (jamais la couleur seule) */
.mat { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.mat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.meta .mat { font-size: 13px; padding: 3px 10px; border-radius: 6px; }
.m-passe { color: var(--danger); } .m-vite { color: var(--warn); } .m-apogee { color: var(--m-top); }
.m-pret { color: var(--m-ok); } .m-jeune { color: var(--m-wait); } .m-inconnu { color: var(--muted); border-style: dashed; }

/* fiche */
.stockbox { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 16px 0 4px; padding: 14px 16px; background: var(--card); border: 1px solid var(--frame); border-radius: var(--radius); }
.stockbox .big { font-size: 34px; font-weight: 750; line-height: 1; display: grid; }
.stockbox .big small { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 4px; }
.tl { position: relative; height: 14px; border-radius: 7px; background: var(--line); margin: 10px 0 4px; overflow: hidden; }
.tl .seg { position: absolute; top: 0; bottom: 0; }
.tl .seg.ok { background: color-mix(in srgb, var(--m-ok) 55%, transparent); }
.tl .seg.top { background: var(--m-top); }
.tl .now { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1.5px; background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 2px var(--card); }
.tlx { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.h3 { font-size: 14px; margin: 14px 0 6px; }
#hist summary { display: flex; align-items: center; gap: 8px; font-weight: 650; cursor: pointer; }
#hist summary .i { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.neg { color: var(--danger); } .pos { color: var(--ok); }

/* formulaire */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } .grid4 { grid-template-columns: 1fr 1fr; } }
.fldbtn { display: flex; gap: 6px; }
.fldbtn input { flex: 1; min-width: 0; }
label.btn { cursor: pointer; }

/* journal */
.jrow { display: grid; grid-template-columns: 64px 42px 1fr; gap: 8px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.jd { color: var(--muted); font-size: 13px; }
.jq { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.jc { font-style: italic; color: var(--muted); }

/* envies */
.wishes { list-style: none; padding: 0; display: grid; gap: 8px; }
.wishes li { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.wishes li.done { opacity: .55; }
.wishes li.done b { text-decoration: line-through; }
.wishes input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; }

/* statistiques : une seule série, une seule teinte, valeurs écrites en texte */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 13px; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.statgrid .panel { max-width: none; margin: 0; }
.statgrid h2 { margin: 0; font-size: 15px; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 40px; gap: 8px; align-items: center; font-size: 13px; padding: 2px 0; border-radius: 4px; }
.bar:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt { height: 12px; }
.bt span { display: block; height: 100%; min-width: 2px; background: var(--wine); border-radius: 0 4px 4px 0; }
.bv { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ajustements après relecture visuelle */
.searchrow { display: flex; }
.searchrow .search { flex: 1 1 260px; }
.searchrow .flieu { flex: 0 1 auto; }
@media (max-width: 520px) { .searchrow .flieu { flex: 1 1 45%; } .flieu select { max-width: none; width: 100%; } }
label.chip.toggle { cursor: pointer; }
label.chip.toggle input { width: auto; margin: 0; accent-color: var(--accent); }
.card.wine .thumb { aspect-ratio: 1; }
.card.wine .thumb:not(.ph) img { object-fit: cover; }
.statgrid .panel { align-content: start; }
.bars { align-content: start; }
