@font-face { font-family: "Courier Prime"; src: url(/fonts/CourierPrime-Regular.woff2) format("woff2"); font-display: swap; }
/* Esthétique jeudi.wang : Courier Prime, noir sur blanc, angles droits, pas d'ombres, inversion au survol */
:root { --ink: #000; --paper: #fff; --mute: #777; --faint: #bbb; --board: #f4f4f2; --dot: #cfcfcb; --danger: #c8102e; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Courier Prime", "Courier New", Courier, monospace; font-size: 14px; color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: 0; padding: 7px 14px; text-transform: uppercase; letter-spacing: .04em; text-decoration: none; display: inline-block; }
.primary:hover { background: var(--paper); color: var(--ink); }
a { color: var(--ink); }

/* ---------- Accueil ---------- */
body.home { background: var(--board); display: flex; align-items: center; justify-content: center; }
.home-box { width: min(580px, 92vw); background: var(--paper); padding: 36px; border: 1px solid var(--ink); }
.brand-title { margin: 0 0 8px; font-size: 22px; font-weight: normal; text-transform: uppercase; letter-spacing: .02em; }
.sub { color: var(--mute); margin: 0 0 24px; line-height: 1.5; }
#create { display: flex; gap: 8px; flex-wrap: wrap; }
#create input { flex: 1; min-width: 200px; padding: 9px 10px; border: 1px solid var(--ink); border-radius: 0; outline: none; }
#create button { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); padding: 9px 16px; text-transform: uppercase; letter-spacing: .04em; }
#create button:hover { background: var(--paper); color: var(--ink); }
#recent-box h2, .invite-box h2 { font-size: 13px; font-weight: normal; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin: 28px 0 8px; }
#recent { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--ink); }
#recent a { display: block; padding: 9px 10px; border-bottom: 1px solid var(--ink); text-decoration: none; }
#recent a:hover { background: var(--ink); color: var(--paper); }
#recent a { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
#recent small { color: var(--mute); font-size: 11px; white-space: nowrap; }
#recent a:hover small { color: inherit; }
#recent { max-height: 40vh; overflow: auto; }
.invite-box { margin-top: 28px; }
.invite-box .sub { font-size: 12px; margin-bottom: 12px; }
.invite-box button { background: var(--paper); border: 1px solid var(--ink); padding: 8px 14px; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
.invite-box button:hover { background: var(--ink); color: var(--paper); }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#pw { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
#pw[hidden] { display: none; }
#pw input { flex: 1; min-width: 160px; padding: 8px; border: 1px solid var(--ink); outline: none; }
#pw .sub { flex-basis: 100%; margin: 0; }
.login-box { width: min(420px, 92vw); }
.login-box form { display: flex; flex-direction: column; gap: 14px; }
.login-box form[hidden] { display: none; }
.login-box .sub { margin: 0 0 4px; }
.login-box label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.login-box input { padding: 9px 10px; border: 1px solid var(--ink); outline: none; font-size: 15px; text-transform: none; letter-spacing: 0; }
.login-box input:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.login-box .primary { padding: 10px; margin-top: 4px; }
.form-err { color: var(--danger); margin: 14px 0 0; }
.form-err[hidden] { display: none; }

/* ---------- Planche ---------- */
body.board { overflow: hidden; background: var(--board); touch-action: none; -webkit-touch-callout: none; }
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--paper); border-bottom: 1px solid var(--ink); z-index: 20; }
.brand { font-size: 14px; letter-spacing: .02em; text-transform: uppercase; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand[href]:hover { text-decoration: underline; }
.brand:not([href]) { cursor: default; }
.title-wrap { position: absolute; left: 50%; transform: translateX(-50%); }
#board-title { text-align: center; background: transparent; font-size: 15px; border: 1px solid transparent; border-radius: 0; padding: 5px 8px; min-width: 80px; width: 300px; max-width: 40vw; outline: none; }
#board-title:hover { border-color: var(--faint); }
#board-title:focus { border-color: var(--ink); }
.status { width: 8px; height: 8px; border-radius: 50%; background: #1f9d48; }
.status.off { background: var(--danger); }
.spacer { flex: 1; }
.users { display: flex; }
.avatar { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; border: 2px solid var(--paper); margin-left: -6px; text-transform: uppercase; }

.toolbar { position: fixed; top: 64px; left: 12px; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--ink); z-index: 20; }
.toolbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; border-bottom: 1px solid #e6e6e6; padding: 8px 2px 6px; width: 76px; color: var(--ink); }
.toolbar button:focus { outline: none; }
.toolbar button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.toolbar button span { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.toolbar button:hover, .toolbar button.active { background: var(--ink); color: var(--paper); }
.toolbar hr { border: 0; border-top: 1px solid var(--ink); margin: 0; width: 100%; }
.colors { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; }
.colors button { width: 20px; height: 20px; border-radius: 0; border: 1px solid var(--ink); padding: 0; }

#viewport { position: fixed; inset: 52px 0 0 0; overflow: hidden; cursor: grab;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 24px 24px; }
#viewport.panning { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
/* les cartes à défilement (overflow: auto) rendaient le geste au navigateur : au doigt, le glisser s’arrêtait au premier pixel */
#world, #world * { touch-action: none; }
#cursors { position: absolute; inset: 0; pointer-events: none; }
#empty-hint { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--mute); line-height: 1.7; pointer-events: none; }

.zoom, .history { position: fixed; bottom: 12px; display: flex; background: var(--paper); border: 1px solid var(--ink); z-index: 20; }
.zoom { right: 12px; }
.history { right: 228px; }
.zoom button, .history button { background: none; border: 0; padding: 7px 12px; font-size: 15px; color: var(--ink); }
.zoom button + button, .history button + button { border-left: 1px solid #e6e6e6; }
.zoom button:hover, .history button:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.history button:disabled { color: var(--faint); cursor: default; }

/* ---------- Cartes ---------- */
.card { position: absolute; background: var(--paper); border: 1px solid var(--ink); cursor: default; display: flex; flex-direction: column; }
.card.selected { outline: 2px solid var(--ink); outline-offset: 3px; }
.card.dragging { box-shadow: 6px 6px 0 var(--ink); }
.card .body { flex: 1; overflow: auto; padding: 12px 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; outline: none; }
.card .body[contenteditable="true"] { cursor: text; }
.card .body:empty::before { content: attr(data-placeholder); color: var(--faint); }
.card .author { position: absolute; bottom: -18px; left: 0; font-size: 11px; color: var(--mute); white-space: nowrap; pointer-events: none; }
.card .del { position: absolute; top: -11px; right: -11px; width: 22px; height: 22px; border: 0; border-radius: 0; background: var(--ink); color: var(--paper); font-size: 12px; line-height: 22px; padding: 0; display: none; transform: scale(var(--inv, 1)); z-index: 2; }
.card .del:hover { background: var(--danger); }
.card.selected > .del { display: block; }
.card:not(.selected):not(:hover) > .resize { display: none; } /* poignée à taille fixe : on ne l'affiche que là où on travaille */
.card .resize { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--ink) 50%) no-repeat right bottom / 12px 12px; transform: scale(var(--inv, 1)); transform-origin: bottom right; }

.card.heading { background: transparent; border-color: transparent; }
.card.heading .body { font-size: 28px; line-height: 1.2; padding: 4px 6px; }
.card.heading.selected { background: rgba(255,255,255,.6); }

.card.image { border: 0; }
.card.image .body, .card.file .body, .card.link .body.media { padding: 0; }
.card.image img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; user-select: none; }

.img-orig { position: absolute; left: 6px; top: 6px; display: none; background: var(--ink); color: var(--paper); font-size: 11px; padding: 3px 8px; text-decoration: none; text-transform: uppercase; letter-spacing: .04em; }
.card.image.selected > .img-orig { display: block; }

.file-box { display: flex; gap: 12px; align-items: center; padding: 14px; height: 100%; }
.file-icon { width: 44px; height: 54px; flex: none; background: var(--ink); color: var(--paper); font-size: 12px; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; }
.file-meta { min-width: 0; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--mute); margin: 2px 0 6px; }
.file-meta a { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.link-box { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; height: 100%; }
.link-host { font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.link-host img { width: 16px; height: 16px; filter: grayscale(1); }
.link-title { outline: none; }
.link-title:empty::before { content: attr(data-placeholder); color: var(--faint); }
.link-box a { font-size: 12px; word-break: break-all; }

.todo-box { padding: 10px 12px; }
.todo-title { text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; outline: none; }
.todo-title:empty::before { content: attr(data-placeholder); color: var(--faint); }
.todo-row { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.todo-row input[type=checkbox] { margin-top: 3px; accent-color: var(--ink); }
.todo-row span { flex: 1; outline: none; }
.todo-row.done span { text-decoration: line-through; color: var(--mute); }
.todo-row .x { border: 0; background: none; color: var(--faint); padding: 0 4px; visibility: hidden; }
.todo-row:hover .x { visibility: visible; }
.todo-add { border: 0; background: none; padding: 4px 0; font-size: 12px; text-decoration: underline; }

/* ---------- Annotations ---------- */
.card.label { background: transparent; border-color: transparent; }
.card.label .body { font-size: 16px; line-height: 1.35; padding: 3px 5px; }
.card.label:hover:not(.selected) { border-color: var(--faint); border-style: dashed; }
.card.label:not(.selected) .resize { display: none; }

/* ---------- Flèches ---------- */
.card.arrow { background: none; border: 0; pointer-events: none; }
.card.arrow.selected { outline: none; }
.card.arrow svg { position: absolute; left: 0; top: 0; overflow: visible; }
.card.arrow .line { fill: none; stroke: var(--ink); stroke-linecap: round; }
.card.arrow .head { fill: var(--ink); }
.card.arrow .hit { fill: none; stroke: transparent; stroke-width: calc(18px * var(--inv, 1)); pointer-events: stroke; cursor: move; }
.card.arrow.selected .line { stroke-dasharray: 6 4; }
.ah { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--paper); border: 2px solid var(--ink); pointer-events: auto; cursor: crosshair; display: none; transform: scale(var(--inv, 1)); }
.card.arrow.selected .ah { display: block; }
.card.arrow .author, .card.arrow .del { display: none; }
.arrow-target { outline: 2px dashed var(--ink) !important; outline-offset: 4px; }
body[data-tool="arrow"] #viewport { cursor: crosshair; }
body[data-tool="arrow"] .card { pointer-events: none !important; }

/* ---------- Colonnes ---------- */
.card.column { background: var(--paper); padding: 0 10px 10px; gap: 10px; }
.col-title { font-size: 22px; line-height: 1.2; text-transform: uppercase; letter-spacing: .03em; padding: 12px 2px 10px; outline: none; border-bottom: 2px solid var(--ink); word-wrap: break-word; }
.col-title:empty::before { content: attr(data-placeholder); color: var(--faint); }
.col-title[contenteditable="true"] { cursor: text; background: #f7f7f7; }
.col-list { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; align-items: start; }
.col-empty { display: none; border: 1px dashed var(--mute); padding: 18px 10px; text-align: center; color: var(--mute); font-size: 12px; }
.col-list:not(:has(> .card)) + .col-empty { display: block; }
.col-list > .card { position: relative; min-width: 0; }
.col-list > .card .author, .col-list > .card .resize { display: none; }
.col-list > .card.image .body { overflow: visible; }
.col-list > .card.image img { height: auto; }
.col-list > .card.file { height: 84px; }
.card.column.drop-target { outline: 2px dashed var(--ink); outline-offset: 3px; }
.col-ph { border: 1px dashed var(--ink); background: rgba(0,0,0,.04); pointer-events: none; }
/* bord droit d'une colonne : poignée pour l'élargir (flèche ↔ au survol) */
.col-edge { --w: calc(16px * var(--inv, 1)); position: absolute; top: 0; right: calc(var(--w) / -2); width: var(--w); height: 100%; cursor: ew-resize; z-index: 3; }
.col-edge::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: calc(2px * var(--inv, 1)); transform: translateX(-50%); background: var(--ink); opacity: 0; transition: opacity .12s; }
.col-edge::after { content: "↔"; position: absolute; top: var(--y, 40px); left: 50%; width: 22px; height: 22px; line-height: 21px; text-align: center; font-size: 14px; background: var(--ink); color: var(--paper); transform: translate(-50%, -50%) scale(var(--inv, 1)); opacity: 0; transition: opacity .12s; pointer-events: none; }
.col-edge:hover::before, .col-edge:hover::after, .card.column.widening .col-edge::before, .card.column.widening .col-edge::after { opacity: 1; }
.col-badge { position: absolute; bottom: 100%; right: 0; margin-bottom: 4px; transform: scale(var(--inv, 1)); transform-origin: bottom right; background: var(--ink); color: var(--paper); font-size: 11px; padding: 3px 8px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; display: none; }
.card.column.widening .col-badge { display: block; }
.card.column.widening { user-select: none; }

/* ---------- Glisser un outil sur la planche ---------- */
.toolbar [data-add], #btn-upload { cursor: grab; touch-action: none; }
.tool-ghost { position: fixed; left: 0; top: 0; margin: -18px 0 0 -18px; padding: 9px 14px; background: var(--paper); border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-size: 13px; text-transform: uppercase; pointer-events: none; z-index: 100; white-space: nowrap; }
.tool-ghost.off { opacity: .4; }

/* ---------- Sélection multiple ---------- */
#marquee { position: absolute; border: 1px dashed var(--ink); background: rgba(0,0,0,.04); pointer-events: none; z-index: 5; }
#marquee[hidden] { display: none; }
body[data-tool="marquee"] #viewport { cursor: crosshair; }
body[data-tool="marquee"] #viewport .card { cursor: move; }

/* ---------- Crayon ---------- */
body[data-tool="pen"] #viewport { cursor: crosshair; }
body[data-tool="eraser"] #viewport { cursor: cell; }
body[data-tool="pen"] .card, body[data-tool="eraser"] .card { pointer-events: none; }
body[data-tool="eraser"] .card.drawing .hit { pointer-events: stroke; }
.card.drawing { background: none; border: 0; pointer-events: none; }
.card.drawing svg { position: absolute; left: 0; top: 0; overflow: visible; }
.card.drawing path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.card.drawing path.hit { stroke: transparent; pointer-events: stroke; cursor: move; }
.card.drawing .del { pointer-events: auto; }
.card.drawing .author { display: none; }
.card.drawing.selected > .author { display: block; }
.pen-panel { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: var(--paper); border: 1px solid var(--ink); padding: 6px 8px; z-index: 25; }
.pen-panel[hidden] { display: none; }
.pen-colors, .pen-sizes { display: flex; gap: 6px; align-items: center; }
.pen-color { width: 22px; height: 22px; border-radius: 0; border: 1px solid var(--ink); padding: 0; }
.pen-color.active { outline: 2px solid var(--ink); outline-offset: 2px; }
.pen-sizes button { width: 30px; height: 30px; border: 0; background: none; display: flex; align-items: center; justify-content: center; }
.pen-sizes button.active { outline: 1px solid var(--ink); }
.pen-sizes i { display: block; border-radius: 50%; }

/* ---------- Curseurs distants ---------- */
.rcursor { position: absolute; left: 0; top: 0; transition: transform .08s linear; }
.rcursor svg { display: block; }
.rcursor span { position: absolute; left: 14px; top: 14px; color: #fff; font-size: 11px; padding: 2px 6px; white-space: nowrap; }

/* ---------- Langue ---------- */
.lang-select { font-size: 12px; text-transform: uppercase; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); padding: 4px 4px; cursor: pointer; }
.lang-choice { display: flex; gap: 0; margin-bottom: 18px; border: 1px solid var(--ink); }
.lang-btn { flex: 1; background: var(--paper); border: 0; padding: 8px 2px; font-size: 12px; white-space: nowrap; }
.lang-btn + .lang-btn { border-left: 1px solid var(--ink); }
.lang-btn.on { background: var(--ink); color: var(--paper); }

/* ---------- Visionneuse d'images ---------- */
#lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(255,255,255,.55); backdrop-filter: blur(16px) grayscale(.6); -webkit-backdrop-filter: blur(16px) grayscale(.6); animation: lb-in .18s ease-out; }
#lightbox[hidden] { display: none; }
@keyframes lb-in { from { opacity: 0; } }
#lb-stage { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
#lb-stage.panning { cursor: grabbing; }
#lb-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; box-shadow: 0 0 0 1px var(--ink); transition: opacity .15s; }
.lb-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px; pointer-events: none; }
#lb-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lb-count { font-size: 13px; letter-spacing: .04em; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 72px; border: 1px solid var(--ink); background: var(--paper); font-size: 34px; line-height: 1; z-index: 2; }
.lb-nav:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.lb-nav:disabled { opacity: .25; cursor: default; }
.lb-nav[hidden] { display: none; }
#lb-prev { left: 16px; }
#lb-next { right: 16px; }
@media (max-width: 640px) { .lb-nav { width: 40px; height: 56px; font-size: 26px; } #lb-prev { left: 6px; } #lb-next { right: 6px; } }
#lb-close { pointer-events: auto; width: 38px; height: 38px; border: 1px solid var(--ink); background: var(--paper); font-size: 16px; }
#lb-close:hover { background: var(--ink); color: var(--paper); }
.lb-bar { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; background: var(--paper); border: 1px solid var(--ink); white-space: nowrap; }
.lb-bar button { background: none; border: 0; border-right: 1px solid #e6e6e6; padding: 7px 14px; font-size: 15px; }
.lb-bar button:hover { background: var(--ink); color: var(--paper); }
#lb-fit { font-size: 12px; text-transform: uppercase; }
#lb-dl { border: 0; font-size: 12px; padding: 9px 14px; }

/* ---------- Menu contextuel ---------- */
.ctx-menu { position: fixed; z-index: 90; min-width: 230px; background: var(--paper); border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 4px 0; animation: ctx-in .08s ease-out; user-select: none; }
.ctx-menu[hidden] { display: none; }
@keyframes ctx-in { from { opacity: 0; } }
.ctx-menu hr { border: 0; border-top: 1px solid #e6e6e6; margin: 4px 0; }
.ctx-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 7px 14px; font-size: 13px; text-align: left; color: var(--ink); }
.ctx-item:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.ctx-item:disabled { color: var(--faint); cursor: default; }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger); color: var(--paper); }
.ctx-icon { display: none; }
.ctx-label { flex: 1; }
.ctx-hint { font-size: 11px; color: var(--mute); }
.ctx-item:hover .ctx-hint { color: inherit; }
.ctx-colors { display: flex; gap: 6px; padding: 6px 14px; }
.ctx-colors button { width: 20px; height: 20px; border-radius: 0; border: 1px solid var(--ink); padding: 0; }
.ctx-colors button.on { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (max-width: 640px) { .ctx-item { padding: 11px 14px; font-size: 14px; } .ctx-hint { display: none; } }

#drop-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.6); border: 2px dashed var(--ink); display: none; align-items: center; justify-content: center; font-size: 22px; text-transform: uppercase; letter-spacing: .06em; z-index: 50; pointer-events: none; }
#drop-overlay.on { display: flex; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 9px 16px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
#toast.on { opacity: 1; }

dialog { border: 1px solid var(--ink); border-radius: 0; padding: 24px; box-shadow: 6px 6px 0 var(--ink); width: min(440px, 92vw); }
dialog::backdrop { background: rgba(255,255,255,.6); backdrop-filter: blur(4px); }
dialog h3 { margin: 0 0 6px; font-weight: normal; text-transform: uppercase; letter-spacing: .04em; }
dialog p { color: var(--mute); margin: 0 0 14px; font-size: 13px; }
dialog input { width: 100%; padding: 9px; border: 1px solid var(--ink); border-radius: 0; margin-bottom: 12px; outline: none; }
dialog button { width: 100%; padding: 10px; }

/* ---------- Écrans tactiles : cibles plus grandes, pas de survol « collant » après une tape ---------- */
@media (pointer: coarse) {
  .card .del { width: 30px; height: 30px; line-height: 30px; top: -15px; right: -15px; font-size: 14px; }
  .card .resize { width: 30px; height: 30px; }
  .ah { width: 22px; height: 22px; margin: -11px 0 0 -11px; }
  .col-edge { --w: calc(28px * var(--inv, 1)); }
  .card.column.selected > .col-edge::before, .card.column.selected > .col-edge::after { opacity: 1; }
  .card.column:not(.selected) > .col-edge { pointer-events: none; } /* au doigt, le bord ne happe pas un glisser destiné à la planche */
  .colors button, .ctx-colors button { width: 28px; height: 28px; }
}
@media (hover: none) {
  .toolbar button:hover:not(.active), .zoom button:hover, .history button:hover, .lb-bar button:hover, #lb-close:hover, .lb-nav:hover { background: none; color: var(--ink); }
  #lb-close:hover, .lb-nav:hover { background: var(--paper); }
  .primary:hover { background: var(--ink); color: var(--paper); }
  .toolbar button:active, .zoom button:active, .history button:active:not(:disabled) { background: var(--ink); color: var(--paper); }
}

/* ---------- Téléphone en portrait ---------- */
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .brand, .spacer { display: none; }
  .title-wrap { position: static; transform: none; flex: 1; min-width: 0; }
  #board-title { width: 100%; max-width: none; min-width: 0; text-align: left; font-size: 16px; padding: 5px 4px; }
  .users .avatar:nth-child(n+4) { display: none; }
  .lang-select { padding: 6px 2px; }
  #share { padding: 7px 10px; font-size: 12px; }

  /* barre d'outils : pleine largeur en bas, icônes seules, au-dessus de la barre d'accueil de l'iPhone */
  .toolbar { top: auto; left: 0; right: 0; bottom: 0; flex-direction: row; border-width: 1px 0 0; padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar button { flex: 1 0 36px; width: auto; height: 52px; padding: 0; justify-content: center; border-bottom: 0; border-right: 1px solid #e6e6e6; }
  .toolbar button:last-of-type { border-right: 0; }
  .toolbar button svg { width: 24px; height: 24px; }
  .toolbar button span { display: none; }
  .toolbar hr, .colors { display: none; } /* couleurs : appui long sur la carte */

  /* zoom et annuler : petits blocs juste au-dessus de la barre ; les + / − laissent la place au pincement */
  .zoom, .history { bottom: calc(64px + env(safe-area-inset-bottom)); top: auto; }
  .history { left: 12px; right: auto; }
  .zoom { right: 12px; }
  #zoom-out, #zoom-in { display: none; }
  .zoom button, .history button { min-width: 44px; height: 40px; padding: 0 10px; font-size: 16px; }
  #zoom-reset { font-size: 13px; }

  .pen-panel { top: 60px; left: 8px; right: 8px; transform: none; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .pen-color { width: 28px; height: 28px; }
  #pen-done { flex: 1 0 100%; padding: 9px; }

  #toast { bottom: calc(120px + env(safe-area-inset-bottom)); max-width: 90vw; text-align: center; }
  .lb-bar { bottom: calc(14px + env(safe-area-inset-bottom)); }
  .lb-bar button { padding: 10px 16px; }
  .lb-top { padding-top: max(12px, env(safe-area-inset-top)); }
  #lb-close { width: 44px; height: 44px; }
}

/* ---------- Téléphone en paysage : peu de hauteur ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { height: 44px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  #viewport { top: 44px; }
  .brand-sub { display: none; }
  /* outils sur deux colonnes : tout tient dans la hauteur, sans défilement */
  .toolbar { top: 52px; left: max(8px, env(safe-area-inset-left)); display: grid; grid-template-columns: 46px 46px; }
  .toolbar button { width: 46px; height: 46px; padding: 0; justify-content: center; border-right: 1px solid #e6e6e6; }
  .toolbar button span, .toolbar hr, .colors { display: none; }
  .zoom, .history { bottom: max(8px, env(safe-area-inset-bottom)); }
  .zoom { right: max(8px, env(safe-area-inset-right)); }
  .history { right: calc(max(8px, env(safe-area-inset-right)) + 220px); }
  .pen-panel { top: 52px; }
}
}
