/* =====================================================================
   EGO — feuille de style. Thème : cyberpunk sombre, néon cyan / magenta.
   ===================================================================== */
:root {
    --bg:        #07090f;
    --bg-2:      #0c1019;
    --panel:     #0f1421;
    --panel-2:   #131a2b;
    --line:      #1f2a40;
    --line-soft: #18202f;
    --txt:       #d7e0ef;
    --txt-dim:   #7d8aa3;
    --txt-faint: #4d5870;

    --cyan:      #22e3d6;
    --cyan-dim:  #0e8c84;
    --magenta:   #ff3d8b;
    --magenta-dim:#a82460;
    --amber:     #ffb648;
    --green:     #46e08a;
    --red:       #ff5a52;

    --ego:       var(--cyan);
    --sleeve:    var(--magenta);
    --psy:       #b46bff;

    --radius:    4px;
    --mono:      'IBM Plex Mono', ui-monospace, monospace;
    --disp:      'Chakra Petch', sans-serif;
    --body:      'IBM Plex Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--body);
    color: var(--txt);
    background:
        radial-gradient(900px 500px at 85% -10%, rgba(255,61,139,.10), transparent 60%),
        radial-gradient(900px 600px at 10% 0%,  rgba(34,227,214,.10), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    line-height: 1.5;
    min-height: 100vh;
}

/* fine grille de scanlines */
.scanlines {
    position: fixed; inset: 0; z-index: 9999; pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(255,255,255,.015) 0 1px, transparent 1px 3px);
    mix-blend-mode: overlay;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: #6df3e9; }

/* ---------- barres haut / bas ---------- */
.topbar, .botbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem 1.4rem;
    border-bottom: 1px solid var(--line);
    background: rgba(7,9,15,.7);
    backdrop-filter: blur(8px);
}
.botbar { border-bottom: 0; border-top: 1px solid var(--line); color: var(--txt-faint); font-size: .8rem; }
.topbar { position: sticky; top: 0; z-index: 50; }
.brand {
    font-family: var(--disp); font-weight: 700; font-size: 1.35rem; letter-spacing: .14em;
    color: var(--txt); text-shadow: 0 0 18px rgba(34,227,214,.5);
}
.brand span { color: var(--cyan); }
.topbar nav a { font-family: var(--mono); font-size: .85rem; color: var(--txt-dim); letter-spacing: .06em; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 1.8rem 1.2rem 4rem; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.kicker { font-family: var(--mono); color: var(--cyan); letter-spacing: .35em; text-transform: uppercase; font-size: .72rem; margin: 0 0 .4rem; }
.hero h1 {
    font-family: var(--disp); font-weight: 700; font-size: clamp(3.5rem, 14vw, 7rem);
    margin: 0; letter-spacing: .08em; line-height: .9;
    color: var(--txt);
}
.glitch { position: relative; text-shadow: 0 0 30px rgba(34,227,214,.4); }
.glitch::before, .glitch::after {
    content: attr(data-text); position: absolute; inset: 0; opacity: .7;
}
.glitch::before { color: var(--magenta); transform: translate(-3px, 1px); mix-blend-mode: screen; }
.glitch::after  { color: var(--cyan);    transform: translate(3px, -1px); mix-blend-mode: screen; }
.tagline { color: var(--txt-dim); font-style: italic; margin-top: 1rem; }

/* ---------- boutons ---------- */
.btn {
    font-family: var(--mono); font-size: .85rem; letter-spacing: .04em;
    padding: .55rem 1.1rem; border-radius: var(--radius); cursor: pointer;
    border: 1px solid var(--line); background: var(--panel-2); color: var(--txt);
    transition: .15s; display: inline-flex; align-items: center; gap: .4rem;
}
.btn:hover { border-color: var(--cyan-dim); }
.btn-accent {
    background: linear-gradient(180deg, var(--cyan), var(--cyan-dim));
    color: #04110f; font-weight: 600; border-color: transparent;
    box-shadow: 0 0 18px rgba(34,227,214,.35);
}
.btn-accent:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; }
.btn-big { font-size: 1rem; padding: .8rem 2rem; }
.btn-icon {
    background: transparent; border: 1px solid var(--line); color: var(--txt-dim);
    width: 30px; height: 30px; border-radius: var(--radius); cursor: pointer; font-size: .9rem;
}
.btn-icon:hover { color: var(--red); border-color: var(--magenta-dim); }

/* ---------- panneaux ---------- */
.panel {
    background: linear-gradient(180deg, var(--panel), var(--bg-2));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.2rem 1.3rem;
    margin-bottom: 1.2rem;
    position: relative;
}
.panel::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
    background: linear-gradient(var(--cyan), transparent); opacity: .5;
}
.panel-title {
    font-family: var(--disp); font-weight: 600; font-size: 1.05rem; letter-spacing: .08em;
    margin: 0 0 1rem; display: flex; align-items: center; gap: .55rem; text-transform: uppercase;
}
.panel-title small { font-family: var(--mono); font-weight: 400; color: var(--txt-faint); text-transform: none; letter-spacing: 0; font-size: .75rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--txt-dim); box-shadow: 0 0 10px currentColor; }
.dot-ego    { background: var(--ego);    color: var(--ego); }
.dot-sleeve { background: var(--sleeve); color: var(--sleeve); }
.dot-psy    { background: var(--psy);    color: var(--psy); }

/* ---------- accueil ---------- */
.new-perso .inline-form { display: flex; gap: .6rem; }
.inline-form input[type=text] { flex: 1; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.empty { color: var(--txt-dim); font-style: italic; }
.card {
    position: relative; background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); transition: .15s; overflow: hidden;
}
.card:hover { border-color: var(--cyan-dim); transform: translateY(-2px); }
.card-main { display: block; padding: 1.1rem 1.2rem; color: var(--txt); }
.card-main h2 { font-family: var(--disp); margin: 0 0 .6rem; font-size: 1.25rem; }
.card-sub { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .6rem; }
.tag {
    font-family: var(--mono); font-size: .68rem; padding: .15rem .5rem; border-radius: 2px;
    border: 1px solid var(--line); color: var(--txt-dim); letter-spacing: .03em;
}
.tag-ego    { border-color: var(--cyan-dim);    color: var(--cyan); }
.tag-sleeve { border-color: var(--magenta-dim); color: var(--magenta); }
.tag-psy    { border-color: var(--psy);         color: var(--psy); }
.card-meta { font-family: var(--mono); font-size: .72rem; color: var(--txt-faint); margin: 0; }
.card-del { position: absolute; top: .6rem; right: .6rem; }

/* ---------- feuille ---------- */
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.perso-name {
    font-family: var(--disp); font-size: 1.8rem; font-weight: 700; color: var(--txt);
    background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: .2rem 0; width: 100%; max-width: 460px;
}
.perso-name:focus { outline: none; border-bottom-color: var(--cyan); }
.head-meta { display: flex; gap: 1rem; margin-top: .6rem; flex-wrap: wrap; }
.mini { font-family: var(--mono); font-size: .7rem; color: var(--txt-faint); letter-spacing: .08em; text-transform: uppercase; display: flex; flex-direction: column; gap: .2rem; }
.mini input { font-size: .85rem; }
.head-actions { display: flex; gap: .6rem; }

.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 760px) { .sheet-grid { grid-template-columns: 1fr; } }
.col-ego::before    { background: linear-gradient(var(--ego), transparent); opacity: .8; }
.col-sleeve::before { background: linear-gradient(var(--sleeve), transparent); opacity: .8; }

/* champs génériques */
input, select, textarea {
    font-family: var(--body); font-size: .9rem; color: var(--txt);
    background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .5rem .6rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan-dim); box-shadow: 0 0 0 2px rgba(34,227,214,.12); }
textarea { resize: vertical; font-family: var(--body); }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.field > span { font-family: var(--mono); font-size: .7rem; color: var(--txt-dim); letter-spacing: .06em; text-transform: uppercase; }
.full { width: 100%; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--txt-dim) 50%), linear-gradient(135deg, var(--txt-dim) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 1.8rem; }

/* ---------- caractéristiques (pips) ---------- */
.caracs { display: flex; flex-direction: column; gap: .7rem; }
.carac-head { display: flex; align-items: baseline; justify-content: space-between; }
.carac-label { font-family: var(--mono); font-size: .82rem; letter-spacing: .05em; cursor: help; }
.carac-val { font-family: var(--disp); font-size: 1.4rem; font-weight: 700; color: var(--cyan); line-height: 1; }
.col-sleeve .carac-val { color: var(--magenta); }
.pips { display: flex; gap: .3rem; margin-top: .25rem; }
.pip { flex: 1; cursor: pointer; }
.pip input { position: absolute; opacity: 0; pointer-events: none; }
.pip span {
    display: block; height: 10px; border-radius: 2px;
    background: var(--line-soft); border: 1px solid var(--line); transition: .12s;
}
.pip.on span { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 8px rgba(34,227,214,.5); }
.col-sleeve .pip.on span { background: var(--magenta); border-color: var(--magenta); box-shadow: 0 0 8px rgba(255,61,139,.5); }
.pip:hover span { border-color: var(--txt-dim); }

/* ---------- valeurs dérivées ---------- */
.derived { margin-top: 1rem; }
.derived-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; }
.derived-label { font-family: var(--mono); font-size: .7rem; color: var(--txt-dim); letter-spacing: .08em; text-transform: uppercase; display: block; }
.derived-formula { font-family: var(--mono); font-size: .74rem; color: var(--txt-faint); margin: .15rem 0; }
.derived-val { font-family: var(--disp); font-size: 1.5rem; font-weight: 700; color: var(--cyan); display: flex; align-items: center; gap: .5rem; }

/* ---------- blessures / stress ---------- */
.wounds, .stress { margin-top: 1rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; }
.wounds-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.wounds-thresholds { font-family: var(--mono); font-size: .72rem; color: var(--txt-dim); }
.wounds-thresholds b { color: var(--amber); }
.wounds-rule { font-family: var(--mono); font-size: .68rem; color: var(--txt-faint); margin: .3rem 0 .5rem; }
.marks { display: flex; flex-wrap: wrap; gap: .35rem; }
.mark { width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 3px; background: var(--line-soft); cursor: pointer; transition: .12s; position: relative; }
.mark:hover { border-color: var(--magenta-dim); }
.mark.on { background: var(--magenta); border-color: var(--magenta); box-shadow: 0 0 8px rgba(255,61,139,.45); }
.mark.on::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: #1a0410; font-size: .8rem; font-weight: 700; }
.num-fallback { display: none; } /* utilisé seulement si JS est actif pour le state */

/* ---------- compétences ---------- */
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.2rem; }
.skill-cat h3 { font-family: var(--disp); font-size: .95rem; letter-spacing: .05em; margin: 0 0 .6rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }
.skill { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: .55rem; padding: .3rem 0; }
.skill-info { display: flex; flex-direction: column; min-width: 0; }
.skill-name { font-size: .88rem; cursor: help; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-carac { font-family: var(--mono); font-size: .62rem; color: var(--txt-faint); text-transform: uppercase; letter-spacing: .06em; }
.skill-rang { width: 52px; padding: .3rem; text-align: center; }
.skill-bonus { font-family: var(--disp); font-weight: 700; font-size: 1.05rem; color: var(--cyan); min-width: 30px; text-align: right; }
.roll-mini { background: var(--panel-2); border: 1px solid var(--line); color: var(--cyan); width: 28px; height: 28px; border-radius: var(--radius); cursor: pointer; font-size: .95rem; line-height: 1; }
.roll-mini:hover { border-color: var(--cyan); box-shadow: 0 0 8px rgba(34,227,214,.4); }

/* ---------- implants ---------- */
.implants { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .9rem; }
.impl-row { display: grid; grid-template-columns: 1.4fr 1fr .8fr .8fr .8fr 70px 30px; gap: .4rem; align-items: center; }
.impl-row .impl-desc { grid-column: 1 / -1; }
.impl-head { font-family: var(--mono); font-size: .65rem; color: var(--txt-faint); text-transform: uppercase; letter-spacing: .06em; }
.impl-head span { padding-left: .2rem; }
.impl-row.warn input { border-color: var(--magenta-dim); }
.impl-row.warn::after { content: '⚠ Interface insuffisante'; grid-column: 1 / -1; font-family: var(--mono); font-size: .65rem; color: var(--amber); }
.impl-intf { text-align: center; }
@media (max-width: 760px) { .impl-row { grid-template-columns: 1fr 1fr; } .impl-head { display: none; } }

/* ---------- psyker ---------- */
.panel-psy .psy-body { display: none; }
.panel-psy.active .psy-body { display: block; }
.panel-psy.active { border-color: rgba(180,107,255,.4); }
.panel-psy::before { background: linear-gradient(var(--psy), transparent); }
.disciplines { margin: 1rem 0; }
.disc-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.disc-chip { position: relative; cursor: pointer; }
.disc-chip input { position: absolute; opacity: 0; }
.disc-chip span {
    display: block; font-family: var(--mono); font-size: .78rem; padding: .35rem .8rem;
    border: 1px solid var(--line); border-radius: 20px; color: var(--txt-dim); transition: .12s;
}
.disc-chip input:checked + span { border-color: var(--psy); color: var(--psy); background: rgba(180,107,255,.12); box-shadow: 0 0 10px rgba(180,107,255,.25); }
.stress-control { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; }
.stress-control input { width: 70px; text-align: center; font-family: var(--disp); font-size: 1.1rem; }
.btn-step { width: 34px; height: 34px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--txt); font-size: 1.1rem; cursor: pointer; }
.btn-step:hover { border-color: var(--psy); }
.stress-state { font-family: var(--mono); font-size: .8rem; padding: .25rem .7rem; border-radius: 3px; letter-spacing: .04em; text-transform: uppercase; }
.state-stable      { color: var(--green);   border: 1px solid var(--green); }
.state-instabilite { color: var(--amber);   border: 1px solid var(--amber); }
.state-fracture    { color: var(--magenta); border: 1px solid var(--magenta); }
.state-rupture     { color: var(--red);     border: 1px solid var(--red); background: rgba(255,90,82,.12); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- pied ---------- */
.sheet-foot { text-align: center; margin-top: 1.5rem; }
.toast {
    background: rgba(70,224,138,.12); border: 1px solid var(--green); color: var(--green);
    font-family: var(--mono); font-size: .82rem; padding: .5rem .9rem; border-radius: var(--radius);
    margin-bottom: 1rem; transition: opacity .4s;
}

/* ---------- lanceur de dés ---------- */
.roller { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(3,5,10,.78); backdrop-filter: blur(4px); }
.roller[hidden] { display: none; }
.roller-card { background: var(--panel); border: 1px solid var(--cyan-dim); border-radius: 6px; padding: 1.6rem 1.8rem; width: min(92vw, 380px); text-align: center; position: relative; box-shadow: 0 0 50px rgba(34,227,214,.25); }
.roller-close { position: absolute; top: .6rem; right: .7rem; background: transparent; border: 0; color: var(--txt-dim); font-size: 1rem; cursor: pointer; }
.roller-name { font-family: var(--disp); font-size: 1.2rem; letter-spacing: .05em; margin: 0 0 1rem; }
.roller-dice { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-bottom: 1rem; }
.die { width: 54px; height: 54px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--cyan-dim); display: grid; place-items: center; font-family: var(--disp); font-size: 1.6rem; font-weight: 700; color: var(--cyan); }
.die.rolling { animation: shake .4s; }
@keyframes shake { 25% { transform: translateY(-6px) rotate(-8deg); } 75% { transform: translateY(4px) rotate(6deg); } }
.die-op { font-family: var(--disp); font-size: 1.4rem; color: var(--txt-dim); }
.die-bonus { font-family: var(--disp); font-size: 1.6rem; font-weight: 700; color: var(--magenta); }
.roller-total { font-family: var(--mono); font-size: 1rem; margin: .4rem 0 1rem; }
.roller-total b { font-family: var(--disp); font-size: 1.8rem; color: var(--txt); }
.roller-diffs { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin-bottom: 1.1rem; }
.diff-chip { font-family: var(--mono); font-size: .7rem; padding: .25rem .55rem; border-radius: 3px; border: 1px solid var(--line); color: var(--txt-dim); }
.diff-chip.pass { border-color: var(--green); color: var(--green); background: rgba(70,224,138,.1); }
.diff-chip.fail { opacity: .4; }
