/* =====================================================================
   css/style.css  —  identité visuelle du laboratoire : verre dépoli,
   vignette, viseur, pastilles d'état, feuille de relevés « papier »,
   chat, avatar de sélection.
   ===================================================================== */
:root {
    --glass: rgba(13, 17, 27, 0.58);
    --glass-brd: rgba(255, 255, 255, 0.09);
    --cyan: #22d3ee;
    --amber: #fbbf24;
    --green: #34d399;
    --red: #f87171;
    --paper: #f7f2e3;
    --ink: #2c3450;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    overscroll-behavior: none;
}

body {
    font-family: "Space Grotesk", system-ui, sans-serif;
    background: #05060a;
    color: #e5eaf3;
    overflow: hidden;
}

.noselect {
    -webkit-user-select: none;
    user-select: none;
}

.mono {
    font-family: "JetBrains Mono", monospace;
}
.hand {
    font-family: "Caveat", cursive;
}
.dim {
    color: #94a3b8;
}
.dim2 {
    color: #64748b;
}
.cy {
    color: var(--cyan);
}
.tc {
    text-align: center;
}
.grow {
    flex: 1;
}
.mt2 {
    margin-top: 10px;
}
.hidden {
    display: none !important;
}
.spacer {
    flex: 1;
}
canvas {
    display: block;
}

#app {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.ic {
    width: 16px;
    height: 16px;
}
.ic-sm {
    width: 14px;
    height: 14px;
}
.ic-cyan {
    color: #67e8f9;
}
.ic-amber {
    color: #fcd34d;
}
.ic-green {
    color: #6ee7b7;
}

/* ---------- vignette + scanlines ---------- */
#vignette {
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    background: radial-gradient(
        ellipse at center,
        transparent 52%,
        rgba(0, 0, 0, 0.42) 100%
    );
}
#vignette::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background: repeating-linear-gradient(
        0deg,
        #fff 0 1px,
        transparent 1px 3px
    );
}

/* ---------- effet loupe ---------- */
#zoomfx {
    position: fixed;
    inset: 0;
    z-index: 21;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.28s ease;
    background: radial-gradient(
        ellipse at center,
        transparent 38%,
        rgba(0, 0, 0, 0.5) 92%
    );
    box-shadow: inset 0 0 180px rgba(0, 0, 0, 0.6);
}
body.zoomed #zoomfx {
    opacity: 1;
}
body.zoomed #crosshair .ring {
    transform: scale(0.8);
    border-color: rgba(255, 255, 255, 0.35);
}

/* ---------- flash rouge quand on est frappé ---------- */
#hurtfx {
    position: fixed;
    inset: 0;
    z-index: 22;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(248, 60, 60, 0.18) 20%,
        rgba(200, 20, 20, 0.55) 100%
    );
    transition: opacity 0.45s ease-out;
}
#hurtfx.hit {
    opacity: 1;
    transition: opacity 0.05s;
}

/* ---------- panneaux en verre ---------- */
.glass {
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px) saturate(1.25);
    backdrop-filter: blur(16px) saturate(1.25);
    border: 1px solid var(--glass-brd);
    border-radius: 16px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.glass-soft {
    background: rgba(13, 17, 27, 0.4);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
}
.hud {
    position: fixed;
    z-index: 30;
    pointer-events: none;
}
.hud .interactive, .hud button {
    pointer-events: auto;
}
.tl {
    top: 16px;
    left: 16px;
}
.tr {
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.br {
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.bc {
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.panel-brand {
    padding: 14px;
    width: 290px;
}
.panel-missions {
    padding: 14px;
    width: 290px;
    margin-top: 12px;
}
.brandrow {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        135deg,
        rgba(34, 211, 238, 0.3),
        rgba(34, 211, 238, 0.05)
    );
    border: 1px solid rgba(103, 232, 249, 0.3);
    color: #67e8f9;
}
.brand {
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
    margin: 0;
}
.brandsub {
    font-size: 10px;
    color: #94a3b8;
    margin: 5px 0 0;
    letter-spacing: 0.08em;
}
.sechead {
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- onglets de niveau ---------- */
.tabs {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}
.tab {
    padding: 7px 13px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    color: #9aa5b8;
    transition: all 0.2s;
    pointer-events: auto;
}
.tab:hover {
    color: #e5eaf3;
}
.tab.active {
    color: #081018;
    background: linear-gradient(135deg, #67e8f9, #22d3ee);
    box-shadow: 0 4px 18px rgba(34, 211, 238, 0.35);
}
.tab.active-b {
    color: #181200;
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    box-shadow: 0 4px 18px rgba(251, 191, 36, 0.3);
}

/* ---------- objectifs ---------- */
.mission {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 7px 9px;
    border-radius: 10px;
    transition: background 0.2s;
}
.mission + .mission {
    margin-top: 2px;
}
.mission .txt {
    font-size: 12.5px;
    line-height: 1.35;
    color: #c3cbdb;
}
.mission.done .txt {
    color: #6ee7b7;
    text-decoration: line-through;
    text-decoration-color: rgba(110, 231, 183, 0.5);
}
.mission.done {
    background: rgba(52, 211, 153, 0.06);
}
.mission svg {
    width: 15px;
    height: 15px;
    margin-top: 1px;
    flex: none;
}

/* ---------- pastilles ---------- */
.chiprow {
    display: flex;
    gap: 8px;
}
.chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 11.5px;
}
.chip .dotline {
    width: 7px;
    height: 7px;
    border-radius: 99px;
    background: #64748b;
}
.led-on {
    background: var(--green) !important;
    box-shadow: 0 0 8px var(--green);
}
.led-off {
    background: #64748b !important;
}
.led-warn {
    background: var(--amber) !important;
    box-shadow: 0 0 8px var(--amber);
}
.led-err {
    background: var(--red) !important;
    box-shadow: 0 0 8px var(--red);
}
#chipZoom {
    color: #a5f3fc;
}
#chipTarget {
    color: #cbd5e1;
}
.lbl-am {
    color: #fcd34d;
    font-size: 11px;
}
.lbl-gr {
    color: #6ee7b7;
    font-size: 11px;
}

/* ---------- boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
    padding: 9px 14px;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    transition: all 0.18s;
    cursor: pointer;
    color: #e5eaf3;
    font-family: inherit;
    pointer-events: auto;
}
.btn:hover {
    background: rgba(255, 255, 255, 0.13);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.22);
}
.btn:active {
    transform: translateY(0) scale(0.98);
}
.btn.small {
    padding: 7px 11px;
    font-size: 12px;
    border-radius: 10px;
}
.btn.big {
    margin: 26px auto 0;
    padding: 14px 32px;
    font-size: 15px;
    border-radius: 16px;
}
.btn-accent {
    background: linear-gradient(
        135deg,
        rgba(34, 211, 238, 0.25),
        rgba(34, 211, 238, 0.1)
    );
    border-color: rgba(34, 211, 238, 0.4);
    color: #a5f3fc;
}
.btn-accent:hover {
    background: linear-gradient(
        135deg,
        rgba(34, 211, 238, 0.4),
        rgba(34, 211, 238, 0.18)
    );
}
.btn-amber {
    background: linear-gradient(
        135deg,
        rgba(251, 191, 36, 0.22),
        rgba(251, 191, 36, 0.08)
    );
    border-color: rgba(251, 191, 36, 0.4);
    color: #fde68a;
}
.btn-pen {
    background: linear-gradient(
        135deg,
        rgba(110, 231, 183, 0.2),
        rgba(110, 231, 183, 0.06)
    );
    border-color: rgba(110, 231, 183, 0.38);
    color: #a7f3d0;
}
.btn svg {
    width: 16px;
    height: 16px;
}

.toolrow {
    padding: 10px;
    display: flex;
    gap: 8px;
}
.qualitybar {
    padding: 9px 11px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.palettebar {
    padding: 11px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.qhead {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}
.qgroup {
    display: flex;
    gap: 4px;
}
.fps {
    font-size: 10px;
    color: #64748b;
    width: 48px;
    text-align: right;
}

.qbtn {
    padding: 5px 10px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: #93a0b5;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    transition: all 0.18s;
    font-family: inherit;
}
.qbtn:hover {
    color: #e5eaf3;
    background: rgba(255, 255, 255, 0.1);
}
.qbtn.sel {
    color: #081018;
    background: linear-gradient(135deg, #a7f3d0, #34d399);
    border-color: transparent;
    box-shadow: 0 3px 14px rgba(52, 211, 153, 0.3);
}

.palette {
    display: flex;
    gap: 8px;
}
.swatch {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    pointer-events: auto;
}
.swatch:hover {
    transform: scale(1.15);
}
.swatch.sel {
    border-color: #fff;
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.18),
        0 0 14px rgba(255, 255, 255, 0.25);
    transform: scale(1.12);
}

/* ---------- viseur ---------- */
#crosshair {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    z-index: 32;
    pointer-events: none;
    transition: opacity 0.25s;
}
#crosshair .dot {
    position: absolute;
    left: -3px;
    top: -3px;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
    transition: transform 0.15s, background 0.15s;
}
#crosshair .ring {
    position: absolute;
    left: -13px;
    top: -13px;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1.5px solid transparent;
    transform: scale(0.55);
    transition:
        transform 0.18s cubic-bezier(0.2, 1.4, 0.4, 1),
        border-color 0.15s;
}
#grabIcon {
    position: absolute;
    left: -17px;
    top: -17px;
    opacity: 0;
    transform: scale(0.5) rotate(-25deg);
    transition: opacity 0.18s, transform 0.22s cubic-bezier(0.2, 1.5, 0.4, 1);
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.8));
}
#crosshair.grab #grabIcon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
#crosshair.grab .ring {
    border-color: rgba(103, 232, 249, 0.55);
    transform: scale(1.25);
}
#crosshair.on .dot {
    transform: scale(1.5);
    background: var(--amber);
}
#crosshair.on .ring {
    border-color: var(--amber);
    transform: scale(1);
}
#crosshair.ctrl .dot {
    transform: scale(1.5);
    background: var(--cyan);
}
#crosshair.ctrl .ring {
    border-color: var(--cyan);
    transform: scale(1);
}
#crosshair.pending .ring {
    border-color: var(--green);
    transform: scale(1.15);
    animation: pulse 1.1s infinite;
}
#crosshair.off {
    opacity: 0.12;
}
body.dragging #crosshair {
    opacity: 1 !important;
}
body.dragging #crosshair .ring {
    border-color: #67e8f9;
    transform: scale(1.3);
}
body.dragging #crosshair .dot {
    background: #67e8f9;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1.35);
    }
}

/* ---------- infobulle ---------- */
#tooltip {
    position: fixed;
    left: 50%;
    top: calc(50% + 30px);
    transform: translateX(-50%);
    z-index: 32;
    pointer-events: none;
    transition: opacity 0.15s;
    opacity: 0;
    white-space: nowrap;
}
#tooltip.show {
    opacity: 1;
}
.tipbubble {
    padding: 6px 12px;
    font-size: 11.5px;
    color: rgba(207, 250, 254, 0.95);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ---------- toasts (Repositionnés en haut au centre pour éviter tout chevauchement) ---------- */
#toasts {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    pointer-events: none;
    max-width: 480px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    font-size: 10px;
    line-height: 1.3;
    max-width: 240px;
    border-radius: 8px;
    animation: toastIn 0.25s cubic-bezier(0.2, 1.2, 0.3, 1) both;
}
.toast svg {
    width: 11px;
    height: 11px;
    flex: none;
    opacity: 0.8;
}
.toast svg {
    width: 13px;
    height: 13px;
    flex: none;
    opacity: 0.8;
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.toast.bye {
    animation: toastOut 0.35s ease both;
}
@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(-6px) scale(0.96);
    }
}

.hintbox {
    padding: 8px 16px;
    font-size: 12px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- chat ---------- */
#chatbar {
    position: fixed;
    left: 50%;
    bottom: 74px;
    transform: translateX(-50%);
    z-index: 46;
    width: min(560px, 92vw);
}
.chatinner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
}
#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e8f6ff;
    font-family: "Space Grotesk", sans-serif;
    font-size: 14px;
}
#chatInput::placeholder {
    color: #7c8aa3;
}

/* ==================== ÉCRAN D'ACCUEIL ==================== */
#start {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(
            1200px 600px at 50% -10%,
            rgba(34, 211, 238, 0.12),
            transparent
        ),
        radial-gradient(
        900px 500px at 80% 110%,
        rgba(251, 191, 36, 0.08),
        transparent
    ),
        #05060a;
    transition: opacity 0.6s, visibility 0.6s;
    overflow: auto;
    padding: 24px 0;
}
#start.gone {
    opacity: 0;
    visibility: hidden;
}
.grid-bg {
    position: absolute;
    inset: 0;
    opacity: 0.35;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.07) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(
        ellipse at center,
        #000 30%,
        transparent 75%
    );
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.startcard {
    position: relative;
    max-width: 640px;
    width: 94%;
    padding: 34px 38px;
    text-align: center;
}
.badge {
    display: inline-block;
    padding: 5px 13px;
    border-radius: 999px;
    font-size: 10.5px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(165, 243, 252, 0.92);
    margin-bottom: 14px;
    background: rgba(13, 17, 27, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.07);
    font-family: "JetBrains Mono", monospace;
}
.title-grad {
    margin: 0;
    font-size: clamp(30px, 5vw, 46px);
    font-weight: 700;
    line-height: 1.08;
    background: linear-gradient(120deg, #e0f2fe 10%, #67e8f9 45%, #fcd34d 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.sub {
    margin: 14px auto 0;
    max-width: 54ch;
    color: rgba(203, 213, 225, 0.92);
    font-size: 13.5px;
    line-height: 1.55;
}
.startgrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 22px;
    text-align: left;
}
.p3 {
    padding: 11px;
}
.mini {
    margin: 8px 0 0;
    font-size: 11px;
    color: #cbd5e1;
    line-height: 1.45;
}
.mini .dim {
    font-size: 10px;
}
@media (max-width: 640px) {
    .startgrid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.namerow {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}
.namelabel {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #94a3b8;
}
.nameinput {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 11px;
    padding: 9px 13px;
    color: #e8f6ff;
    font-size: 14px;
    width: 170px;
    outline: none;
}
.nameinput:focus {
    border-color: rgba(34, 211, 238, 0.6);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}
.swatches {
    display: flex;
    gap: 7px;
}
.swatches .swatch {
    width: 22px;
    height: 22px;
}
.tip {
    margin: 16px 0 0;
    font-size: 11px;
    color: #94a3b8;
}
.tip .hl {
    color: #67e8f9;
}
.tip + .tip {
    margin-top: 6px;
}

/* ==================== FEUILLE DE RELEVÉS (modal papier) ==================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(3, 5, 10, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    transition: opacity 0.25s, visibility 0.25s;
}
.modal.hiddenx {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.sheet {
    position: relative;
    width: 940px;
    max-width: 96vw;
    max-height: 92vh;
    overflow: auto;
    padding: 30px 38px 24px 62px;
    border-radius: 4px 14px 6px 10px;
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        repeating-linear-gradient(
            180deg,
            transparent 0 31px,
            rgba(70, 120, 180, 0.18) 31px 32px
        ),
        radial-gradient(
        120% 80% at 12% 0%,
        rgba(255, 255, 255, 0.75),
        transparent 60%
    ),
        radial-gradient(
        90% 70% at 100% 100%,
        rgba(150, 130, 90, 0.16),
        transparent 70%
    );
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.6),
        0 2px 0 rgba(255, 255, 255, 0.5) inset;
    transform: translateY(0) scale(1);
    transition: transform 0.3s cubic-bezier(0.2, 1.1, 0.3, 1);
    -webkit-user-select: text;
    user-select: text;
}
.modal.hiddenx .sheet {
    transform: translateY(26px) scale(0.97);
}
/* marge rouge du cahier */
.sheet::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 44px;
    width: 2px;
    background: rgba(200, 70, 70, 0.38);
}
/* coins cornés */
.sheet::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 34px;
    height: 34px;
    background: linear-gradient(
        225deg,
        rgba(0, 0, 0, 0.13) 0 50%,
        transparent 50%
    );
}

.paperhead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.handtitle {
    margin: 0;
    font-family: "Caveat", cursive;
    font-size: 40px;
    line-height: 1;
    color: #22304f;
}
.handsub {
    margin: 6px 0 0;
    font-family: "Caveat", cursive;
    font-size: 20px;
    color: rgba(44, 52, 80, 0.72);
}
.penbtn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(44, 52, 80, 0.25);
    background: rgba(255, 255, 255, 0.5);
    color: #3b4568;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
}
.penbtn:hover {
    background: rgba(44, 52, 80, 0.12);
    transform: rotate(90deg);
}
.penbtn svg {
    width: 17px;
    height: 17px;
}

.ident {
    display: flex;
    gap: 18px;
    margin: 18px 0 6px;
    flex-wrap: wrap;
}
.field {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.field label {
    font-family: "Caveat", cursive;
    font-size: 20px;
    color: rgba(44, 52, 80, 0.7);
}
.handin {
    border: none;
    border-bottom: 1.4px dashed rgba(44, 52, 80, 0.38);
    background: transparent;
    outline: none;
    font-family: "Caveat", cursive;
    font-size: 22px;
    color: #1f2942;
    padding: 1px 6px;
    min-width: 130px;
}
.handin::placeholder {
    color: rgba(44, 52, 80, 0.32);
}
.handin:focus {
    border-bottom-color: rgba(30, 90, 170, 0.75);
    background: rgba(255, 255, 255, 0.45);
}

.livediv {
    margin: 16px 0 6px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    background: rgba(44, 52, 80, 0.06);
    border: 1px dashed rgba(44, 52, 80, 0.25);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.livetag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(44, 52, 80, 0.55);
    font-family: "JetBrains Mono", monospace;
}
.handvals {
    font-family: "Caveat", cursive;
    font-size: 23px;
    color: #26324f;
    line-height: 1.25;
}
.handvals b {
    color: #0f4c5c;
}
.handvals .warn {
    color: #a3402a;
}

.tablewrap {
    margin-top: 12px;
}
.paper-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
.paper-table th {
    text-align: left;
    padding: 6px 8px;
    font-family: "Caveat", cursive;
    font-size: 19px;
    font-weight: 700;
    color: rgba(44, 52, 80, 0.78);
    border-bottom: 1.6px solid rgba(44, 52, 80, 0.4);
    white-space: nowrap;
}
.paper-table td {
    padding: 2px 4px;
    border-bottom: 1px dashed rgba(44, 52, 80, 0.22);
    vertical-align: middle;
}
.paper-table tr:hover td {
    background: rgba(255, 255, 255, 0.4);
}
.paper-table .num {
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    color: rgba(44, 52, 80, 0.5);
    text-align: center;
}
.cellin {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    padding: 5px 6px;
    font-family: "Caveat", cursive;
    font-size: 21px;
    color: #1c2740;
    border-radius: 4px;
}
.cellin::placeholder {
    color: rgba(44, 52, 80, 0.26);
}
.cellin:focus {
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 1.5px rgba(30, 90, 170, 0.45);
}
.rowdel {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: rgba(44, 52, 80, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.rowdel:hover {
    color: #b03030;
    background: rgba(176, 48, 48, 0.1);
}
.rowdel svg {
    width: 14px;
    height: 14px;
}
.empty {
    padding: 34px 0;
    text-align: center;
    color: rgba(44, 52, 80, 0.45);
    font-size: 23px;
}

.paperactions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    align-items: center;
}
.paperactions .btn {
    color: #2c3450;
    border-color: rgba(44, 52, 80, 0.22);
    background: rgba(255, 255, 255, 0.55);
}
.paperactions .btn:hover {
    background: rgba(255, 255, 255, 0.85);
}
.paperactions .btn-accent {
    color: #0b3b46;
    border-color: rgba(15, 118, 130, 0.35);
    background: rgba(103, 232, 249, 0.35);
}
.paperactions .btn-amber {
    color: #5c3d05;
    border-color: rgba(180, 130, 20, 0.4);
    background: rgba(252, 211, 77, 0.38);
}
.paperactions .btn-pen {
    color: #14532d;
    border-color: rgba(20, 120, 70, 0.3);
    background: rgba(110, 231, 183, 0.28);
}
.footnote {
    margin: 16px 0 0;
    font-size: 19px;
    color: rgba(44, 52, 80, 0.55);
    text-align: right;
}

/* ---------- barre de défilement de la feuille ---------- */
.sheet::-webkit-scrollbar {
    width: 8px;
}
.sheet::-webkit-scrollbar-thumb {
    background: rgba(44, 52, 80, 0.25);
    border-radius: 99px;
}

/* ---------- petits écrans ---------- */
@media (max-width: 900px) {
    .panel-brand, .panel-missions {
        width: 236px;
    }
    .br {
        transform: scale(0.92);
        transform-origin: bottom right;
    }
}

/* =====================================================================
   MISE À JOUR « taille des outils, rotation, solo, éclairage, feuille »
   ===================================================================== */

/* ---- sélecteur de mode de jeu (écran d'accueil) ---- */
.moderow {
    margin-top: 22px;
    text-align: center;
}
.modelabel {
    display: block;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 9px;
}
.modeseg {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
}
.modebtn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: #b6c2d6;
    font: 600 13px/1 "Space Grotesk", sans-serif;
    cursor: pointer;
    transition: 0.18s;
}
.modebtn:hover {
    color: #eef3fb;
    background: rgba(255, 255, 255, 0.08);
}
.modebtn.sel {
    color: #062028;
    border-color: rgba(103, 232, 249, 0.55);
    background: linear-gradient(135deg, #7ee7f7, #38bdf8);
    box-shadow: 0 6px 18px rgba(56, 189, 248, 0.28);
}
.modebtn svg {
    width: 15px;
    height: 15px;
}
.modehint {
    margin: 11px auto 0;
    max-width: 470px;
    font-size: 11.5px;
    line-height: 1.6;
    color: #8d9bb3;
}
.modehint b {
    color: #cfe0f5;
    font-weight: 600;
}

/* ---- bouton + volet « éclairage » (discrets, à droite de la Qualité) ---- */
.lightbtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: 2px;
    padding: 0;
    border-radius: 10px;
    cursor: pointer;
    color: #fcd34d;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    transition: 0.18s;
}
.lightbtn:hover {
    background: rgba(252, 211, 77, 0.16);
    border-color: rgba(252, 211, 77, 0.4);
}
.lightbtn.sel {
    background: rgba(252, 211, 77, 0.24);
    border-color: rgba(252, 211, 77, 0.55);
    color: #ffe9a8;
}
.lightbtn svg {
    width: 16px;
    height: 16px;
}
.ic-inl {
    display: inline-block;
    width: 13px;
    height: 13px;
    vertical-align: -2px;
    color: #fcd34d;
}

.lightpop {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    pointer-events: auto; /* le HUD est cliquable uniquement ici */
    width: 232px;
    padding: 12px 13px 13px;
    border-radius: 14px;
    background: rgba(13, 17, 27, 0.78);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
    animation: popin 0.18s ease-out;
}
.lightpop.hidden {
    display: none !important;
}
.lightpop button, .lightpop input {
    pointer-events: auto;
}
@keyframes popin {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.lphead {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 9px;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #94a3b8;
}
.lgroup {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}
.lbtn {
    padding: 7px 6px;
    border-radius: 9px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #b6c2d6;
    font: 600 11.5px/1 "Space Grotesk", sans-serif;
    transition: 0.15s;
}
.lbtn:hover {
    color: #eef3fb;
    background: rgba(255, 255, 255, 0.11);
}
.lbtn.sel {
    color: #2a1f05;
    border-color: rgba(252, 211, 77, 0.6);
    background: linear-gradient(135deg, #ffe9a8, #fbbf24);
}
.lslider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 11px;
    color: #94a3b8;
}
.lslider input[type="range"] {
    flex: 1;
    accent-color: #fbbf24;
    height: 18px;
    cursor: pointer;
}
.lslider .mono {
    font-size: 10.5px;
    color: #cfd9e8;
    min-width: 42px;
    text-align: right;
}

/* la barre qualité devient le point d'ancrage du volet */
.qualitybar {
    position: relative;
}

/* ---- feuille : animation « on tourne la page » ---- */
.sheet.turn {
    animation: sheetturn 0.42s ease-out;
}
@keyframes sheetturn {
    0% {
        transform: translateY(26px) scale(0.97) rotate(-0.6deg);
    }
    45% {
        transform: translateY(-6px) scale(1.006) rotate(0.35deg);
    }
    100% {
        transform: none;
    }
}

/* ---- solo : on masque ce qui concerne les autres élèves ---- */
body.solo #btnChat,
body.solo #chipNet,
body.solo #chipPlayers {
    display: none !important;
}
/* =====================================================================
   MISE À JOUR : Nettoyage Solo Web + Blocage Mobile
   ===================================================================== */

/* 1. تصغير حاوية البداية */
.startcard.clean-mode {
    max-width: 520px;
    padding: 34px 38px;
}
.startcard.clean-mode .startgrid {
    grid-template-columns: repeat(2, 1fr); /* عمودان بدلاً من ثلاثة */
    gap: 12px;
}

/* 2. شاشة منع الهواتف */
#mobile-block {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #05060a;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}
#mobile-block .glass {
    padding: 40px 30px;
    max-width: 400px;
    border-color: rgba(248, 113, 113, 0.4);
    box-shadow: 0 20px 60px rgba(248, 113, 113, 0.15);
}
#mobile-block .ic-block {
    width: 64px;
    height: 64px;
    color: #f87171;
    margin-bottom: 20px;
}
#mobile-block h2 {
    color: #fff;
    margin: 0 0 12px;
    font-size: 22px;
}
#mobile-block p {
    color: #94a3b8;
    line-height: 1.6;
    font-size: 14px;
}

/* 3. إخفاء اللعبة وإظهار التحذير في الهواتف */
@media (max-width: 800px), (pointer: coarse) {
    #mobile-block {
        display: flex;
    }
    #start, #app, .hud, #vignette {
        display: none !important;
    }
}
/* =====================================================================
   Sélecteur de TP dans le HUD (TP1 / TP2)
   ===================================================================== */
.tp-switcher {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.35);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tp-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 9px;
    font: 600 11.5px/1 "Space Grotesk", sans-serif;
    color: #94a3b8;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tp-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.06);
}

.tp-btn.active {
    color: #04121a;
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 3px 12px rgba(14, 165, 233, 0.35);
}

/* Variante de couleur pour l'onglet actif du TP2 */
.tab.active-tp2 {
    color: #04140d;
    background: linear-gradient(135deg, #6ee7b7, #10b981);
    box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35);
}

/* Onglets du TP 3 : cinq manipulations, elles s'enveloppent sur deux lignes */
.tabs.wrap {
    flex-wrap: wrap;
    gap: 6px;
}
.tabs.wrap .tab {
    flex: 1 1 auto;
    min-width: 74px;
    font-size: 11.5px;
    padding: 7px 6px;
}
.tab.active-t3 {
    color: #1a1005;
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    box-shadow: 0 4px 18px rgba(245, 158, 11, 0.35);
}

/* =====================================================================
   Aide-mémoire du TP 3 : cartes de formules (style « fiche manuscrite »)
   ===================================================================== */
.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.fcard {
    background: rgba(255, 255, 255, 0.55);
    border: 1.5px solid rgba(44, 52, 80, 0.25);
    border-left: 4px solid #f59e0b;
    border-radius: 6px;
    padding: 9px 11px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.fcard b {
    display: block;
    font-family: "Space Grotesk", sans-serif;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #b45309;
    margin-bottom: 4px;
}

.fcard p {
    margin: 0;
    font-size: 16px;
    line-height: 1.35;
    color: #1e2942;
}

.fcard p.dim {
    margin-top: 5px;
    font-size: 14px;
    color: #64748b;
}

.fcard sub {
    font-size: 0.72em;
}

/* verdicts des contrôles de calcul (R_Th = V₀/I₀ et ΔV₀) */
#rthVerdict.ok, #incVerdict.ok {
    color: #047857;
}
#rthVerdict.ko, #incVerdict.ko {
    color: #b91c1c;
}

/* table 9 : la manipulation en cours est soulignée, les lignes de calcul
   (que l'élève doit faire lui-même) sont légèrement grisées */
.paper-table tr.nowrow td {
    background: rgba(59, 130, 246, 0.07);
}
.paper-table tr.calcrow td.grandeur {
    color: #64748b;
    font-style: italic;
}
.paper-table td .dim {
    font-size: 13px;
    color: #94a3b8;
    font-style: normal;
}

/* ligne de tableau du TP 3 : la grandeur mesurée est imprimée, la valeur
   reste à écrire au stylo */
.paper-table td.grandeur {
    font-family: "Caveat", cursive;
    font-size: 17px;
    color: #334155;
    white-space: nowrap;
}
.paper-table tr.manip-head td {
    background: rgba(245, 158, 11, 0.12);
    font-family: "Space Grotesk", sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #92400e;
}
.cellin.good {
    background: rgba(110, 231, 183, 0.28);
    border-color: #10b981;
}
.cellin.bad {
    background: rgba(248, 113, 113, 0.22);
    border-color: #ef4444;
}
/* =====================================================================
   Section Diagramme de Bode (Papier semi-logarithmique)
   ===================================================================== */
.bodesection {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1.5px dashed rgba(44, 52, 80, 0.3);
}

.bodehead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.handbode-title {
    font-family: "Caveat", cursive;
    font-size: 26px;
    font-weight: 700;
    color: #1e2942;
}

.bode-legends {
    display: flex;
    gap: 14px;
    font-size: 12px;
    font-family: "Space Grotesk", sans-serif;
    color: #475569;
}

.leg-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.leg-dot {
    width: 12px;
    height: 3px;
    border-radius: 2px;
}

.leg-dot.asymp {
    background: #10b981;
    border: 1px dashed #059669;
}
.leg-dot.theo {
    background: #3b82f6;
}
.leg-dot.exp {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d97706;
}

.bode-canvas-wrap {
    width: 100%;
    background: #fffef9;
    border: 1.5px solid rgba(44, 52, 80, 0.4);
    border-radius: 6px;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

#bodeCanvas {
    display: block;
    width: 100%;
    height: auto;
}

.formule-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    font-size: 22px;
    color: #1e2942;
}

/* ============ ROBOT TUTEUR « OHMIE » ============ */
#tutorFab {
    left: 18px;
    bottom: 18px;
}
#tutorFab .fabbit {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: #ffd9cf;
    border: 1px solid rgba(255, 157, 138, 0.45);
    background: rgba(40, 22, 30, 0.55);
    box-shadow: 0 2px 14px rgba(255, 120, 90, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    pointer-events: auto;
    user-select: none;
}
#tutorFab .fabbit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 120, 90, 0.35);
}
#tutorFab .fabbit i {
    font-style: normal;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(255, 157, 138, 0.18);
    color: #ff9d8a;
}
#tutorFab.hiddenx {
    opacity: 0;
    visibility: hidden;
}

#tutorDock {
    left: 18px;
    bottom: 64px;
    width: 350px;
    max-width: calc(100vw - 36px);
    pointer-events: auto;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 45;
}
#tutorDock.hiddenx {
    opacity: 0;
    transform: translateY(12px);
    visibility: hidden;
    pointer-events: none;
}
.dockwrap {
    display: flex;
    flex-direction: column;
    max-height: min(340px, 38vh); /* Hauteur limitée pour ne jamais toucher le panneau des objectifs */
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 157, 138, 0.28);
    background: rgba(16, 18, 30, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 34px rgba(0, 0, 0, 0.55);
}

/* Sécurité d'affichage pour ordinateurs portables et petits écrans */
@media (max-height: 820px) {
    .dockwrap {
        max-height: 32vh;
    }
}
.dockhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 8px 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: linear-gradient(
        90deg,
        rgba(255, 120, 90, 0.14),
        transparent 70%
    );
}
.dh-name {
    font-size: 13px;
    font-weight: 800;
    color: #ffb3a1;
    letter-spacing: 0.2px;
}
.dh-sub {
    font-weight: 500;
    font-size: 10.5px;
    color: #8b93ab;
    margin-left: 6px;
}
.dh-acts {
    display: flex;
    gap: 4px;
}
.icobtn {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.07);
    color: #cdd3e4;
    font-size: 12px;
    line-height: 1;
    transition: background 0.12s;
}
.icobtn:hover {
    background: rgba(255, 255, 255, 0.16);
}
.icobtn.off {
    opacity: 0.45;
}

.dockbody {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
}
.dockbody .msg {
    max-width: 88%;
    font-size: 12.5px;
    line-height: 1.5;
    padding: 7px 11px;
    border-radius: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}
.dockbody .msg.me {
    align-self: flex-end;
    background: rgba(34, 211, 238, 0.13);
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: #d7f6fd;
    border-bottom-right-radius: 4px;
}
.dockbody .msg.bot {
    align-self: flex-start;
    background: rgba(255, 157, 138, 0.1);
    border: 1px solid rgba(255, 157, 138, 0.28);
    color: #ffe7df;
    border-bottom-left-radius: 4px;
}
.dockbody .msg.err {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.4);
    color: #ffd7d7;
}
.dockbody .msg .who {
    display: block;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    opacity: 0.6;
    margin-bottom: 3px;
}
.dockbody .typing {
    align-self: flex-start;
    color: #ff9d8a;
    font-size: 12px;
    animation: ohmBlink 1s steps(2) infinite;
}
@keyframes ohmBlink {
    50% {
        opacity: 0.35;
    }
}

.dockfoot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}
#tdInput {
    flex: 1;
    min-width: 0;
    padding: 8px 11px;
    border-radius: 9px;
    font-size: 12.5px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #eef1f8;
    outline: none;
}
#tdInput:focus {
    border-color: rgba(255, 157, 138, 0.5);
}
#tdInput::placeholder {
    color: #7d849a;
}
.sendbtn {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: none;
    cursor: pointer;
    flex: none;
    background: linear-gradient(135deg, #ff9d8a, #ff6f52);
    color: #2a0f0a;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(255, 111, 82, 0.35);
}
.sendbtn:disabled {
    opacity: 0.45;
    cursor: default;
}

.dockstats {
    display: flex;
    gap: 10px;
    padding: 5px 12px 7px;
    font-size: 9.5px;
    color: #7f879e;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.dockstats .st {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.dockstats b {
    font-weight: 700;
    color: #a9b1c6;
}
.dockstats .hot b, .dockstats .hot {
    color: #f87171;
}
.dockstats .lim b {
    color: #f59e0b;
}

#tutorModal .tutorwin {
    width: min(760px, 92vw);
    height: min(76vh, 720px);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 157, 138, 0.3);
    background: rgba(14, 16, 28, 0.92);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.6);
    transition: transform 0.18s ease;
}
#tutorModal.hiddenx .tutorwin {
    transform: translateY(24px) scale(0.97);
}
.tw-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 800;
    color: #ffb3a1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(
        90deg,
        rgba(255, 120, 90, 0.16),
        transparent 60%
    );
}
.tw-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.tw-body .msg {
    max-width: 82%;
    font-size: 13.5px;
    line-height: 1.55;
    padding: 9px 13px;
    border-radius: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Style KaTeX LaTeX dans les bulles de discussion */
.msg .msg-content .katex {
    font-size: 1.1em;
    color: #e0f2fe;
}
.msg .msg-content .katex-display {
    margin: 8px 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
}
.msg .msg-content .katex-display > .katex {
    color: #67e8f9;
}
.msg .msg-content em {
    color: #fde047;
    font-style: italic;
}
.msg .msg-content .tutor-code {
    background: rgba(15, 23, 42, 0.7);
    color: #4ade80;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9em;
    border: 1px solid rgba(74, 222, 128, 0.25);
}

#calcModal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 390px;
    max-width: 95vw;
    /* Charcoal / Matte Gunmetal body of a physical scientific calculator */
    background: linear-gradient(145deg, #2a2d34 0%, #1a1c20 100%);
    border: 1px solid #3a3d45;
    border-top: 1px solid #525663;
    border-radius: 24px;
    box-shadow:
        0 30px 70px rgba(0, 0, 0, 0.8),
        inset 0 1px 1px rgba(255, 255, 255, 0.15),
        inset 0 -2px 8px rgba(0, 0, 0, 0.6);
    padding: 20px 18px 24px 18px;
    z-index: 1000;
    color: #e2e8f0;
    user-select: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#calcModal.hiddenx {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.94);
}

/* Top Header & Metallic Branding */
.calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding: 0 4px;
}

.calc-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calc-brand-logo {
    font-family: "Chakra Petch", sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1.5px;
    color: #94a3b8;
    text-transform: uppercase;
    background: linear-gradient(180deg, #ffffff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.calc-sub-logo {
    font-size: 9px;
    font-weight: 600;
    color: #38bdf8;
    letter-spacing: 0.5px;
    background: rgba(56, 189, 248, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.calc-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.calc-close:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.4);
}

/* Realistic Dot Matrix LCD Screen Panel */
.calc-screen-wrapper {
    background: #14171a;
    border-radius: 12px;
    padding: 6px;
    border: 1px solid #0d0f11;
    box-shadow:
        inset 0 3px 6px rgba(0, 0, 0, 0.8),
        0 1px 1px rgba(255, 255, 255, 0.05);
    margin-bottom: 16px;
    position: relative;
}

/* Solar Panel Accent (Casio Style Realism) */
.calc-solar {
    height: 12px;
    background: linear-gradient(90deg, #3a2218 0%, #5a2e22 50%, #3a2218 100%);
    border: 1px solid #22120c;
    border-radius: 3px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-around;
    opacity: 0.9;
}

.calc-solar-cell {
    border-right: 1px solid rgba(0, 0, 0, 0.4);
    width: 25%;
    height: 100%;
}

.calc-screen {
    /* Realistic Dot-Matrix LCD Display Screen background */
    background: linear-gradient(180deg, #8ba888 0%, #7d9e7a 100%);
    border: 2px solid #5a7358;
    border-radius: 6px;
    padding: 8px 12px;
    text-align: right;
    min-height: 72px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
    position: relative;
    overflow: hidden;
}

/* Subtle LCD Grid texture overlay */
.calc-screen {
            /* Écran LCD réaliste à cristaux liquides */
            background: linear-gradient(180deg, #91af8e 0%, #83a580 100%);
            border: 2px solid #536f50;
            border-radius: 8px;
            padding: 10px 14px;
            text-align: right;
            min-height: 86px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.35);
            position: relative;
            overflow: hidden;
        }

        /* Lignes de matrice LCD */
        .calc-screen::before {
            content: "";
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            background: repeating-linear-gradient(
                0deg,
                rgba(0, 0, 0, 0.04),
                rgba(0, 0, 0, 0.04) 1px,
                transparent 1px,
                transparent 2px
            );
            pointer-events: none;
        }

        .calc-expr {
            font-family: 'JetBrains Mono', monospace;
            font-size: 17px;
            font-weight: 600;
            color: #1c301c;
            letter-spacing: 0.5px;
            min-height: 24px;
            word-break: break-all;
            line-height: 1.25;
            text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
        }

        .calc-screen-bottom {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            margin-top: 6px;
        }

        .calc-mode {
            font-family: 'JetBrains Mono', monospace;
            font-size: 13px;
            font-weight: 700;
            color: #173017;
            background: rgba(0, 0, 0, 0.1);
            padding: 2px 7px;
            border-radius: 4px;
            border: 1px solid rgba(0, 0, 0, 0.2);
        }

        .calc-result {
            font-family: 'JetBrains Mono', monospace;
            font-size: 30px;
            font-weight: 800;
            color: #0a140a !important; /* Noir profond LCD */
            word-break: break-all;
            line-height: 1;
            text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
        }

        /* Grille des boutons */
        .calc-pad {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 8px;
        }

        /* Touches de la calculatrice plus lisibles */
        .cbtn {
            position: relative;
            background: linear-gradient(180deg, #373b44 0%, #2b2e35 100%);
            border: 1px solid #1a1b1f;
            border-top: 1px solid #545966;
            color: #ffffff;
            padding: 10px 4px;
            font-size: 16px;
            font-weight: 600;
            border-radius: 8px;
            cursor: pointer;
            font-family: 'Space Grotesk', sans-serif;
            box-shadow: 
                0 3px 0 #141518,
                0 4px 6px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
            transition: all 0.08s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

.cbtn:hover {
    filter: brightness(1.15);
}

.cbtn:active {
    transform: translateY(2px);
    box-shadow:
        0 1px 0 #141518,
        0 2px 3px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Scientific Function Keys (Dark Top Row style) */
.cbtn.fn {
    background: linear-gradient(180deg, #22252c 0%, #181a1f 100%);
    border-top: 1px solid #404552;
    color: #60a5fa;
    font-size: 12px;
    box-shadow:
        0 3px 0 #0d0e11,
        0 4px 5px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Operators (*, -, +, /) */
.cbtn.op {
    background: linear-gradient(180deg, #3b3f4a 0%, #2a2d36 100%);
    color: #fbbf24;
    font-size: 16px;
}

/* Clear & Delete Buttons (Casio Orange/Red accent) */
.cbtn.clear {
    background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
    border-top: 1px solid #f87171;
    border-color: #7f1d1d;
    color: #ffffff;
    font-weight: 700;
    box-shadow:
        0 3px 0 #581c87,
        0 3px 0 #6b21a8,
        0 3px 0 #7f1d1d,
        0 4px 6px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Equals Key (Casio Blue/Teal Accent) */
.cbtn.eq {
    background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
    border-top: 1px solid #38bdf8;
    border-color: #0c4a6e;
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
    grid-column: span 2;
    box-shadow:
        0 3px 0 #075985,
        0 4px 6px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Top Function Mode key switch highlight */
.cbtn[data-val="MODE"] {
    color: #f59e0b;
}

/* Container demo center layout */
.demo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 16px;
    padding: 20px;
}

/* =====================================================================
   Console 3D & Modal du Mur des Croquis
   ===================================================================== */
.wall-modal-card {
    width: 440px;
    max-width: 92vw;
    padding: 22px 24px;
    border-radius: 18px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    background: rgba(13, 17, 27, 0.92);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
    animation: popin 0.2s ease-out;
}

.wall-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.wm-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    color: #e0f2fe;
}

.wall-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wm-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wm-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.wm-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    font-weight: 600;
}

.wm-palette {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
}

.wm-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.wm-swatch:hover {
    transform: scale(1.15);
}

.wm-swatch.sel {
    border-color: #38bdf8;
    transform: scale(1.18);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
}

.wm-tool-status {
    font-size: 12px;
    font-weight: 600;
    color: #38bdf8;
}

.wm-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    padding: 8px 12px;
}

.wm-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #f1f5f9;
    font-size: 13px;
    font-family: inherit;
}

.wm-sync-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 11px;
}