/* ===== LevelPlan V8 · composants ===== */

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: var(--r-m); font-weight: 650; font-size: 15px; white-space: nowrap; transition: transform .12s ease, background .15s ease, border-color .15s ease; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--ac); color: var(--actx); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ac) 88%, #fff); }
.btn.secondary { background: var(--s3); border: 1px solid var(--line2); color: var(--tx); }
.btn.secondary:hover:not(:disabled) { border-color: var(--mu2); }
.btn.ghost { color: var(--acs); padding: 0 10px; }
.btn.ghost:hover:not(:disabled) { background: var(--acbg); }
.btn.vg { background: var(--vgbg); color: var(--vgs); border: 1px solid color-mix(in srgb, var(--vg) 40%, transparent); }
.btn.danger { color: var(--ko); background: transparent; border: 1px solid color-mix(in srgb, var(--ko) 40%, transparent); }
.btn.danger.armed { background: var(--ko); color: var(--kotx); border-color: var(--ko); }
.btn.sm { min-height: 36px; padding: 0 13px; font-size: 13.5px; border-radius: var(--r-s); }
.btn.xs { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }
/* cibles tactiles : les petites commandes gardent leur taille visuelle, une zone invisible
   porte la cible à 44 px de haut (recommandation iOS / WCAG 2.5.5) sans chevaucher le texte voisin */
.btn.xs, .btn.sm, .pill, .sech .more, .orbstat, .rankline .chip { position: relative; }
.btn.xs::after, .btn.sm::after, .pill::after, .sech .more::after, .orbstat::after, .rankline .chip::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btns.end { justify-content: flex-end; }
.btns > .btn { flex: 1 1 auto; }
.link { color: var(--acs); font-weight: 600; font-size: 13.5px; padding: 6px 0; }
.link:hover { text-decoration: underline; }

/* ---------- puces, étiquettes ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 650; background: var(--s3); color: var(--tx2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.ac { background: var(--acbg); color: var(--acs); }
.chip.vg { background: var(--vgbg); color: var(--vgs); }
.chip.ok { background: var(--okbg); color: var(--ok); }
.chip.ko { background: var(--kobg); color: var(--ko); }
.chip.warn { background: var(--warnbg); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--mu)); flex: none; vertical-align: middle; }
.choice button .cdot { margin-right: 7px; }
/* badge de rareté : encre claire ou foncée selon le dégradé (≥ 4,5:1 sur chaque arrêt du dégradé) */
.rar { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .2px; padding: 2px 7px 2px 6px; border-radius: 6px; color: var(--ri, #fff); background: var(--rg); border: 1px solid color-mix(in srgb, var(--rc) 45%, transparent); line-height: 1.35; white-space: nowrap; vertical-align: middle; }
.rar em { font-style: normal; font-weight: 650; }
.rar.long { font-size: 12px; padding: 3px 9px 3px 7px; }
/* V10.2 · raretés de la planche : Commun, Rare, Épique, Légendaire, Mythique (gemme + nom) */
.rar-N, .rf-N { --rc: #a7b0bd; --rg: linear-gradient(135deg, #1b212c, #141922); --ri: #c3cad4; }
.rar-R, .rf-R { --rc: #4a9cff; --rg: linear-gradient(135deg, #12223d, #0e192e); --ri: #7fb8ff; }
.rar-SR, .rf-SR { --rc: #a46bff; --rg: linear-gradient(135deg, #22173c, #190f2e); --ri: #c39bff; }
.rar-SSR, .rf-SSR { --rc: #f0b84a; --rg: linear-gradient(135deg, #2c2110, #1f170b); --ri: #f3c96a; }
.rar-LR, .rf-LR { --rc: #ff4d6d; --rg: linear-gradient(135deg, #34111c, #250b14); --ri: #ff8098; }
.stc { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 99px; background: var(--s3); color: var(--tx2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stc i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.stc.up { color: var(--ok); background: var(--okbg); }
.stc.down { color: var(--ko); background: var(--kobg); }
.pips { display: inline-flex; gap: 2px; vertical-align: middle; }
.pips i { width: 4px; height: 10px; border-radius: 2px; background: var(--line2); }
.pips i.on { background: var(--pc, var(--ac)); }

/* ---------- contrôle segmenté ---------- */
.seg { display: flex; gap: 3px; padding: 3px; background: var(--s2); border: 1px solid var(--line); border-radius: calc(var(--r-s) + 3px); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; min-height: 36px; padding: 0 12px; border-radius: var(--r-s); font-size: 13.5px; font-weight: 600; color: var(--mu); white-space: nowrap; text-align: center; }
.seg button[aria-selected=true] { background: var(--s4); color: var(--tx); box-shadow: 0 1px 0 #ffffff0d inset, 0 2px 8px #0003; }
.seg .n { color: var(--mu2); font-weight: 600; margin-left: 3px; }

/* ---------- cartes et listes ---------- */
.card { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px; }
.card.tight { padding: 12px 14px; }
.card.raised { box-shadow: var(--shadow-s); }
.card + .card { margin-top: 10px; }
.list { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; width: 100%; text-align: left; position: relative; }
.item + .item { border-top: 1px solid var(--line); }
button.item:hover, a.item:hover { background: color-mix(in srgb, var(--s2) 70%, transparent); }
.item .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--s3); flex: none; font-size: 17px; overflow: hidden; }
.item .ic svg { width: 100%; height: 100%; display: block; }
.item .ic:not(.chk) > svg[stroke] { width: 20px; height: 20px; color: var(--tx2); }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tx span { display: block; font-size: 12.5px; color: var(--mu); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .end { flex: none; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mu); font-variant-numeric: tabular-nums; }
.item .chev { color: var(--mu2); font-size: 18px; }

/* ---------- progression ---------- */
.bar { height: 8px; border-radius: 6px; background: var(--s3); overflow: hidden; position: relative; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--vg); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar.brass > i { background: linear-gradient(90deg, var(--ac2), var(--ac)); }
.bar.thin { height: 5px; }
.bar .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--tx); opacity: .45; border-radius: 1px; }
.meter { height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--sc) 16%, var(--s3)); overflow: hidden; position: relative; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--sc); transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.meter .cap { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--tx); opacity: .6; }
.meter .mt { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: var(--s1); opacity: .55; }
.meter .mt.got { background: #fff; opacity: .85; }

/* ---------- formulaires ---------- */
.fl { display: block; font-size: 13px; font-weight: 600; color: var(--mu); margin: 16px 2px 7px; }
.field { width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-s); border: 1px solid var(--line2); background: var(--bg2); color: var(--tx); font-size: 16px; outline: 0; }
.field:focus { border-color: var(--vg); box-shadow: 0 0 0 3px var(--vgbg); }
.field::placeholder { color: var(--mu2); }
textarea.field { min-height: 120px; resize: vertical; line-height: 1.45; }
select.field { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mu) 50%), linear-gradient(135deg, var(--mu) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid2 > * { min-width: 0; }
.grid2 .full { grid-column: 1 / -1; }
.choice { display: flex; gap: 7px; flex-wrap: wrap; }
.choice button { min-height: 38px; padding: 0 13px; border-radius: 99px; background: var(--s2); border: 1px solid var(--line2); color: var(--tx2); font-size: 13.5px; font-weight: 600; }
.choice button[aria-pressed=true], .choice button[aria-checked=true], .choice button.sel { background: var(--vgbg); border-color: var(--vg); color: var(--tx); }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--line2); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 6px #0005; }
.switch[aria-checked=true] { background: var(--vg); }
.switch[aria-checked=true]::after { transform: translateX(20px); }
.setgroup { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-l); padding: 0 14px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 56px; padding: 10px 0; }
.setrow + .setrow, .setgroup > .blk + .setrow, .setgroup > .setrow + .blk { border-top: 1px solid var(--line); }
.setrow > div { min-width: 0; }
.setrow b { display: block; font-weight: 600; font-size: 14.5px; }
.setrow span { display: block; font-size: 12.5px; color: var(--mu); margin-top: 2px; }
.setrow select.field { width: auto; min-width: 140px; max-width: 52%; min-height: 40px; font-size: 14px; padding-top: 8px; padding-bottom: 8px; }
.blk { padding: 14px 0; }
.hint { font-size: 12.5px; color: var(--mu); margin: 8px 2px 0; }

/* ---------- feuilles (bottom sheets) ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: #050a0eb3; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; }
:root[data-mode=light] .scrim { background: #16222c66; }
.sheet { width: min(620px, 100%); max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--s1); border: 1px solid var(--line2); border-bottom: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 8px calc(18px + var(--safe-r)) calc(22px + var(--safe-b)) calc(18px + var(--safe-l)); box-shadow: 0 -18px 50px #0006; }
@media (prefers-reduced-motion: no-preference) { :root:not([data-motion=reduced]) .sheet { animation: sheetup .26s cubic-bezier(.2, .8, .2, 1); } }
@keyframes sheetup { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet.full { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; padding-top: calc(8px + var(--safe-t)); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line2); margin: 2px auto 10px; }
.sheethead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; position: sticky; top: -8px; z-index: 2; background: var(--s1); padding: 6px 0; }
.sheethead h2 { font-family: var(--font-d); font-size: 22px; font-weight: 600; }
.sheet .sub { color: var(--mu); font-size: 14px; margin: 4px 0 0; }
.close { width: 40px; height: 40px; border-radius: 50%; background: var(--s3); display: grid; place-items: center; flex: none; color: var(--tx2); }
.close svg { width: 18px; height: 18px; }
@media (min-width: 760px) {
  .scrim:not(.scrim-center) { align-items: center; }
  .sheet { border-radius: var(--r-xl); border-bottom: 1px solid var(--line2); max-height: 88vh; padding-bottom: 22px; }
  .sheet.full { height: auto; max-height: 92vh; border-radius: var(--r-xl); padding-top: 8px; }
}
.scrim-center { align-items: center; padding: 16px; }
.scrim.top { z-index: 90; }
.modal { width: min(440px, 100%); max-height: 90vh; overflow-y: auto; background: var(--s1); border: 1px solid var(--line2); border-radius: var(--r-xl); padding: 22px 20px 20px; box-shadow: var(--shadow); text-align: center; position: relative; }

/* ---------- messages : toast, bannière, conseil ---------- */
.toast { position: fixed; z-index: 120; left: calc(14px + var(--safe-l)); right: calc(14px + var(--safe-r)); margin: 0 auto; width: fit-content; max-width: 560px; bottom: calc(var(--nav-h) + var(--nav-sb) + 16px); transform: translateY(12px); display: flex; align-items: center; gap: 12px; padding: 11px 12px 11px 16px; border-radius: 14px; background: var(--inv); color: var(--invtx); box-shadow: var(--shadow); font-size: 14px; font-weight: 600; line-height: 1.35; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast > span { min-width: 0; }
.toast .tact { flex: none; padding: 6px 10px; border-radius: 9px; font-weight: 750; color: inherit; background: color-mix(in srgb, var(--invtx) 12%, transparent); }
@media (min-width: 1024px) { .toast { left: calc(var(--nav-w) + 14px); bottom: 24px; } }
#bannerBox { position: fixed; z-index: 110; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%); width: min(560px, calc(100% - 20px)); }
.banner { background: var(--s2); border: 1px solid var(--line2); border-radius: var(--r-l); padding: 12px 14px; box-shadow: var(--shadow); }
@media (prefers-reduced-motion: no-preference) { .banner { animation: drop .3s cubic-bezier(.2, .8, .2, 1); } }
@keyframes drop { from { transform: translateY(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.banner .bt { font-weight: 700; margin: 2px 0; }
.banner .bb { font-size: 13.5px; color: var(--tx2); }
.coach { position: fixed; z-index: 70; left: 50%; bottom: calc(var(--nav-h) + var(--nav-sb) + 14px); transform: translateX(-50%); width: min(520px, calc(100% - 24px)); background: var(--s2); border: 1px solid var(--acline); border-radius: var(--r-l); padding: 16px 16px 14px; box-shadow: var(--shadow); }
@media (prefers-reduced-motion: no-preference) { .coach { animation: coachin .32s cubic-bezier(.2, .8, .2, 1); } }
@keyframes coachin { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.coach .ct { display: flex; gap: 12px; align-items: flex-start; }
.coach .cic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--acbg); color: var(--acs); flex: none; font-size: 19px; }
.coach h3 { font-family: var(--font-d); font-size: 17px; margin: 1px 0 3px; }
.coach p { margin: 0; color: var(--tx2); font-size: 14px; line-height: 1.45; }
.coach .btns { margin-top: 12px; }
@media (min-width: 1024px) { .coach { left: calc(50% + var(--nav-w) / 2); bottom: 24px; } }

/* ---------- états vides ---------- */
.empty { padding: 22px 18px; border-radius: var(--r-l); border: 1px dashed var(--line2); text-align: center; color: var(--mu); }
.empty h3 { font-family: var(--font-d); font-size: 18px; color: var(--tx); margin: 0 0 6px; }
.empty p { margin: 0 auto; max-width: 42ch; font-size: 14px; line-height: 1.5; }
.empty .btn { margin-top: 14px; }
.empty .art { width: 64px; height: 64px; margin: 0 auto 10px; color: var(--acs); opacity: .9; }

/* ---------- divers ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--mu); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.note-w { font-size: 12.5px; color: var(--warn); margin-top: 6px; }
.lock { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--mu); }
.lock svg { width: 13px; height: 13px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.tag-new { position: absolute; top: 6px; left: 6px; z-index: 1; font-size: 9.5px; font-weight: 800; background: var(--ac); color: var(--actx); border-radius: 6px; padding: 1px 5px; }
.typing { display: inline-flex; gap: 4px; padding: 3px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--vg); animation: blinkd 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blinkd { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.fab { position: fixed; z-index: 25; right: calc(16px + var(--safe-r)); bottom: calc(var(--nav-h) + var(--nav-sb) + 16px); width: 56px; height: 56px; border-radius: 18px; background: var(--ac); color: var(--actx); display: grid; place-items: center; box-shadow: 0 10px 24px #0000004d; }
.fab svg { width: 26px; height: 26px; }
@media (min-width: 1024px) { .fab { bottom: 28px; right: 28px; } }
.loading { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--bg); color: var(--mu); }

/* V9 · clavier virtuel ouvert (iOS) : la barre de navigation s'efface, la saisie reste au-dessus du clavier */
body.kb .nav, body.kb .fab { visibility: hidden; }
body.kb .composer { bottom: var(--kb, 0px); }
body.kb[data-route=orb] .app { padding-bottom: calc(var(--kb, 0px) + 150px); }
body.kb .scrim { padding-bottom: var(--kb, 0px); }
body.kb .sheet { max-height: calc(100dvh - var(--kb, 0px) - 8px); }
body.kb .sheet.full { height: calc(100dvh - var(--kb, 0px)); }
