/* Redstone 2D — thème sombre */
:root {
  --bg: #121418;
  --bg2: #16181d;
  --panel: #1c1f26;
  --panel2: #232731;
  --line: #2e333f;
  --line2: #3a4050;
  --text: #e4e6eb;
  --muted: #9097a6;
  --accent: #ff4a3d;
  --accent2: #ff7a5c;
  --ok: #57c26b;
  --warn: #f2b84b;
  --focus: #5aa9ff;
  --top-h: 48px;
  --status-h: 26px;
  --pal-w: 236px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  display: grid;
  grid-template-columns: var(--pal-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) 1fr var(--status-h);
  grid-template-areas: "top top" "pal stage" "status status";
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Barre du haut ---------- */
#top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  white-space: nowrap;
}
.brand {
  font-weight: 700;
  letter-spacing: .3px;
  padding-right: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.brand-dot {
  width: 12px; height: 12px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent), inset -3px -3px 0 rgba(0,0,0,.35);
  border-radius: 2px;
}
.tb-group {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  border-left: 1px solid var(--line);
  flex: none;
}
.tb-right { margin-left: auto; }
.tb {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line2);
  border-radius: 6px;
  background: var(--panel2);
  cursor: pointer;
  line-height: 1;
  transition: background .12s, border-color .12s;
}
.tb:hover { background: #2c313d; border-color: #4a5265; }
.tb:active { transform: translateY(1px); }
.tb:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.tb.on, .tb.toggle.on { background: #4a2420; border-color: var(--accent); color: #fff; }
.tb.txt { font-size: 13px; }
.tb:disabled { opacity: .4; cursor: default; }
.tb-speed select {
  height: 32px;
  border: 1px solid var(--line2);
  border-radius: 6px;
  background: var(--panel2);
  padding: 0 6px;
}
.tb-info { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding: 0 4px; }
#tickInfo { min-width: 120px; display: inline-block; }

/* ---------- Palette ---------- */
#palette {
  grid-area: pal;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pal-search { padding: 8px; border-bottom: 1px solid var(--line); }
.pal-search input {
  width: 100%;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--bg2);
  padding: 0 10px;
}
#palList { overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; flex: 1; }
.pal-group h3 {
  margin: 10px 2px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
}
.pal-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 4px; }
.pal-item {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--panel2);
  cursor: pointer;
  padding: 0;
}
.pal-item:hover { border-color: var(--line2); background: #2a2f3a; }
.pal-item.on { border-color: var(--accent); background: #3a2422; box-shadow: 0 0 0 1px var(--accent) inset; }
.pal-item canvas, .pal-item .ico {
  width: 32px; height: 32px;
  image-rendering: pixelated;
  pointer-events: none;
}
.pal-item .ico {
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
}
.pal-item .slot-n {
  position: absolute; right: 2px; bottom: 1px;
  font-size: 10px; color: var(--warn); font-weight: 700;
  pointer-events: none;
}
.pal-empty { color: var(--muted); padding: 12px 4px; font-size: 13px; }

/* ---------- Scène ---------- */
#stage { grid-area: stage; position: relative; overflow: hidden; min-width: 0; min-height: 0; background: #1a1b1e; }
#cv {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: crosshair;
}
#cv.c-hand { cursor: pointer; }
#cv.c-pan { cursor: grabbing; }
#cv.c-pick { cursor: copy; }

/* Panneau d'info */
.info {
  position: absolute;
  top: 10px; right: 10px;
  width: 250px;
  max-height: calc(100% - 90px);
  overflow-y: auto;
  background: rgba(28,31,38,.94);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
}
.info-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.info-head canvas { width: 32px; height: 32px; image-rendering: pixelated; flex: none; }
.info-title { font-weight: 700; }
.info-coord { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.info table { width: 100%; border-collapse: collapse; }
.info td { padding: 2px 0; vertical-align: top; }
.info td:first-child { color: var(--muted); padding-right: 8px; white-space: nowrap; }
.info td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.info .ctl { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.info .ctl label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; }
.info .ctl input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.info .ctl .row { display: flex; gap: 4px; flex-wrap: wrap; }
.info .ctl .row .tb { height: 28px; min-width: 28px; }
.info .pw { color: var(--accent2); font-weight: 700; }
.info .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.info.pinned { border-color: var(--accent2); }
.info-tt { flex: 1; min-width: 0; }
.info .info-btn { flex: none; min-width: 26px; height: 26px; padding: 0 4px; font-size: 13px; }
.info .info-btn.on { background: #4a2420; border-color: var(--accent); }
/* Deuxième niveau de la case (le bloc sous un composant posé dessus) */
.info-sub { display: flex; align-items: center; gap: 6px; margin: 8px 0 4px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 13px; }
.info-sub canvas { width: 20px; height: 20px; image-rendering: pixelated; flex: none; }
.info-sub-t { color: var(--muted); }

/* Bouton « Tourner » de l'outil (utile sans clavier) */
.fab {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 4;
  height: 36px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(35,39,49,.94);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  font-size: 14px;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.fab #rotLbl { font-size: 13px; }

/* Barre rapide */
#hotbar {
  position: absolute;
  left: 50%; bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  padding: 4px;
  background: rgba(18,20,24,.85);
  border: 1px solid var(--line2);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
}
.hb-slot {
  position: relative;
  width: 44px; height: 44px;
  border: 2px solid #3b4150;
  border-radius: 5px;
  background: #23262e;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
}
.hb-slot.on { border-color: #f4f4f4; box-shadow: 0 0 0 1px #000 inset; }
.hb-slot canvas, .hb-slot .ico { width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.hb-slot .ico { display: flex; align-items: center; justify-content: center; font-size: 20px; }
.hb-slot .n { position: absolute; left: 3px; top: 1px; font-size: 10px; color: var(--muted); pointer-events: none; }

/* Notification */
#toast {
  position: absolute;
  left: 50%; top: 14px;
  transform: translateX(-50%);
  background: rgba(30,33,41,.96);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  max-width: min(90%, 520px);
  text-align: center;
  white-space: pre-line;
}
#toast.show { opacity: 1; }
#toast.err { border-color: var(--accent); }

/* ---------- Barre d'état ---------- */
#status {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 10px;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
#status .st-right { margin-left: auto; }
#stTool { color: var(--text); }

/* ---------- Fenêtres ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(5,6,8,.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 10px;
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-card.narrow { width: min(440px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 14px 16px 18px; overflow-y: auto; }
.modal-body h3 { margin: 18px 0 6px; font-size: 14px; color: var(--accent2); }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { margin: 6px 0; }
.modal-body ul { margin: 4px 0; padding-left: 20px; }
.modal-body li { margin: 3px 0; }
.modal-body kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--line2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel2);
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  text-align: center;
}
.modal-body table.keys { border-collapse: collapse; width: 100%; }
.modal-body table.keys td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.modal-body table.keys td:first-child { white-space: nowrap; width: 1%; }
.form-row { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; align-items: center; }
.form-row input[type=text], .modal-body textarea {
  flex: 1;
  min-width: 160px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--bg2);
  padding: 0 10px;
}
.modal-body textarea {
  width: 100%;
  height: 120px;
  padding: 8px 10px;
  resize: vertical;
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  word-break: break-all;
}
.btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line2);
  background: var(--panel2);
  cursor: pointer;
}
.btn:hover { background: #2c313d; }
.btn.primary { background: #8a231c; border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #a42a21; }
.btn.danger { border-color: #7a2a2a; color: #ff9a8f; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.slots { list-style: none; padding: 0 !important; margin: 6px 0 !important; }
.slots li {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 4px 0 !important;
  background: var(--panel2);
}
.slots .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slots .dt { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.mat-table { width: 100%; border-collapse: collapse; }
.mat-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.mat-table td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mat-table canvas { width: 24px; height: 24px; image-rendering: pixelated; vertical-align: middle; }
.mat-table td.st { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }

.fatal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: var(--bg); color: var(--text); z-index: 100; margin: 0;
}

/* ---------- Commandes : tchat, champ de commande, HUD ---------- */
.chat {
  position: absolute;
  left: 10px; bottom: 66px;
  width: min(640px, calc(100% - 20px));
  z-index: 6;
  pointer-events: none;
  display: flex; flex-direction: column;
}
.chat-log {
  max-height: 40vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  font: 14px/1.35 ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  color: #fff;
  text-shadow: 1px 1px 0 #3f3f3f;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-line { background: rgba(0,0,0,.45); padding: 1px 6px; transition: opacity .6s; }
.chat-line.old { opacity: 0; }
.chat.open { bottom: 8px; pointer-events: auto; }
.chat.open .chat-log { overflow-y: auto; background: rgba(0,0,0,.35); scrollbar-width: thin; }
.chat.open .chat-line { background: transparent; }
.chat.open .chat-line.old { opacity: 1; }
.chat:not(.open) .chat-line.old { display: none; }
.chat-bar { margin-top: 4px; }
.chat-line [title] { cursor: help; }

.cmdf { position: relative; }
.cmdf-in, .cmdf-hl {
  font: 14px/20px ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  padding: 5px 7px;
  border: 1px solid transparent;
  white-space: pre;
  letter-spacing: 0;
}
.cmdf-in {
  position: relative;
  width: 100%;
  height: 32px;
  background: transparent;
  color: transparent;
  caret-color: #fff;
  border-color: var(--line2);
  border-radius: 4px;
  outline: none;
  z-index: 1;
}
.cmdf-in::placeholder { color: #8a8f9c; }
.cmdf-in:focus { border-color: var(--focus); }
.cmdf-in::selection { background: rgba(90,169,255,.45); color: transparent; }
.cmdf-hl {
  position: absolute; inset: 0;
  height: 32px;
  overflow: hidden;
  color: #e8e8e8;
  background: rgba(0,0,0,.72);
  border-radius: 4px;
  pointer-events: none;
}
.cmdf-pop {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 0;
  z-index: 3;
  min-width: 160px;
  max-width: min(560px, 100%);
  background: rgba(0,0,0,.86);
  color: #aaa;
  font: 13px/18px ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  padding: 2px 0;
  border-radius: 2px;
  white-space: pre;
  overflow: hidden;
}
.cmdf.below .cmdf-pop { bottom: auto; top: calc(100% + 2px); }
.cmdf-item { padding: 0 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.cmdf-item.on { color: #ffff55; }
.cmdf-item:hover { background: rgba(255,255,255,.08); }
.cmdf-more { padding: 0 8px; color: #777; }
.cmdf-tip { padding: 2px 8px 0; margin-top: 2px; border-top: 1px solid #333; color: #aaa; white-space: normal; }
.cmdf-err { padding: 0 8px; color: #ff5555; white-space: pre-wrap; }
.cmdf-usage { padding: 0 8px; color: #aaa; }

.hud-bossbars {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  width: min(364px, calc(100% - 40px));
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; z-index: 3;
}
.bb-name { text-align: center; font-size: 13px; color: #fff; text-shadow: 1px 1px 0 #3f3f3f; }
.bb-bar { position: relative; height: 7px; border: 1px solid #fff; background-color: rgba(0,0,0,.55); border-radius: 1px; overflow: hidden; }
.bb-fill { position: absolute; left: 0; top: 0; bottom: 0; }
.hud-sidebar {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  min-width: 120px; max-width: 46%;
  background: rgba(0,0,0,.42);
  color: #fff;
  font: 13px/18px ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-shadow: 1px 1px 0 #3f3f3f;
  pointer-events: none; z-index: 2;
}
.sb-title { text-align: center; background: rgba(0,0,0,.25); padding: 1px 6px; }
.sb-row { display: flex; gap: 14px; justify-content: space-between; padding: 0 4px; }
.sb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-val { color: #ff5555; flex: none; }
.hud-title {
  position: absolute; left: 0; right: 0; top: 30%;
  text-align: center; pointer-events: none; z-index: 4;
  text-shadow: 3px 3px 0 #3f3f3f;
}
#titleMain { font-size: clamp(28px, 6vw, 56px); font-weight: 700; color: #fff; line-height: 1.15; }
#titleSub { font-size: clamp(16px, 3vw, 26px); color: #fff; margin-top: 6px; }
.hud-actionbar {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%);
  max-width: calc(100% - 20px);
  text-align: center; color: #fff; font-size: 15px;
  text-shadow: 1px 1px 0 #3f3f3f; pointer-events: none; z-index: 4;
}
.hud-debug {
  position: absolute; left: 10px; top: 54px; margin: 0;
  padding: 4px 6px;
  background: rgba(0,0,0,.55); color: #e0e0e0;
  font: 12px/16px ui-monospace, "Cascadia Mono", Consolas, monospace;
  pointer-events: none; z-index: 3;
  max-width: calc(100% - 20px); overflow: hidden;
}
.mc-loading {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  background: rgba(28,31,38,.94); border: 1px solid var(--line2); border-radius: 16px;
  padding: 5px 12px; font-size: 12px; color: var(--muted); pointer-events: none;
}
.mc-loading .spin { width: 12px; height: 12px; border: 2px solid var(--line2); border-top-color: var(--accent2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Panneau d'info : entité, bloc de commande */
.info .nbt {
  margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line);
  font: 11.5px/1.4 ui-monospace, Consolas, monospace;
  white-space: pre-wrap; word-break: break-all;
  background: rgba(0,0,0,.3); padding: 4px 6px; border-radius: 4px; max-height: 220px; overflow: auto;
}
.info .cb-cmd { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }

/* Écran du bloc de commande */
.modal-body.cbe .cbe-lab { color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.modal-body.cbe .cmdf-in, .modal-body.cbe .cmdf-hl { font-size: 13px; }
.cbe-out-row { display: flex; gap: 6px; align-items: stretch; }
.cbe-out {
  flex: 1; min-height: 30px; padding: 5px 8px; border: 1px solid var(--line2); border-radius: 4px;
  background: rgba(0,0,0,.5); font: 13px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.cbe-trk { width: 34px; font-weight: 700; }
.cbe-modes .btn { min-width: 150px; }
.cbe-mode.m-impulse { border-color: #c6702a; }
.cbe-mode.m-chain { border-color: #2f9e8f; }
.cbe-mode.m-repeat { border-color: #7a4bc0; }
.modal-body p.small { font-size: 12px; }

/* Pack de données */
.modal-card.wide { width: min(1000px, 100%); }
.dp-cols { display: grid; grid-template-columns: 230px 1fr; gap: 12px; }
.dp-list { list-style: none; padding: 0 !important; margin: 0 !important; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.dp-item { padding: 4px 8px !important; margin: 0 !important; cursor: pointer; font: 12.5px/1.4 ui-monospace, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-item:hover { background: #2a2f3a; }
.dp-item.on { background: #3a2422; color: #fff; }
.dp-item.bad::after { content: ' ⚠'; color: var(--warn); }
.dp-title { font: 600 13px ui-monospace, Consolas, monospace; margin-bottom: 4px; color: var(--accent2); }
.dp-ed { position: relative; height: 300px; border: 1px solid var(--line2); border-radius: 6px; overflow: hidden; background: #0e0f12; }
.dp-hl, .modal-body .dp-ta {
  position: absolute; inset: 0; margin: 0; width: 100%; height: 100%;
  padding: 8px 10px; border: 0; border-radius: 0;
  font: 13px/19px ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  white-space: pre; overflow: auto; tab-size: 2; min-height: 0; resize: none;
}
.dp-hl { color: #e8e8e8; pointer-events: none; overflow: hidden; }
.modal-body .dp-ta { background: transparent; color: transparent; caret-color: #fff; outline: none; }
.modal-body .dp-ta::selection { background: rgba(90,169,255,.4); }
.dp-hl .c-com { color: #7f8796; font-style: italic; }
.dp-hl .c-mac { color: #d7a7ff; }
.dp-err { color: #ff8a80; font-size: 12px; min-height: 16px; margin-top: 4px; white-space: pre-wrap; }
.dp-tags { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dp-tag { display: grid; gap: 4px; font: 12px ui-monospace, Consolas, monospace; color: var(--muted); }
.dp-tag textarea { min-height: 64px; font: 12.5px/1.4 ui-monospace, Consolas, monospace; }
.dp-num { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.dp-num input { height: 30px; padding: 0 6px; background: #12141a; border: 1px solid var(--line2); border-radius: 6px; color: var(--text); }
label.ck { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; margin-right: 10px; cursor: pointer; }
.modal-body textarea.export-ta { min-height: 220px; font: 12.5px/1.45 ui-monospace, Consolas, monospace; white-space: pre; }
.import-res .ok { color: var(--ok); }
.import-res .err { color: #ff8a80; }
.import-res code { font-size: 12px; color: var(--muted); }

@media (max-width: 760px) {
  .chat { bottom: 8px; }
  .hud-actionbar { bottom: 20px; }
  .hud-sidebar { top: auto; bottom: 50%; transform: none; font-size: 11px; }
  .dp-cols, .dp-tags { grid-template-columns: minmax(0, 1fr); }
  #status #stMc { display: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  :root { --top-h: 46px; --status-h: 22px; }
  body {
    /* minmax(0, 1fr) : sinon le minimum auto de 1fr prend la largeur de la rangée de la palette (≈ 4000 px)
       et Chrome mobile élargit le viewport de mise en page (fenêtres et console hors de l'écran). */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top-h) 1fr auto var(--status-h);
    grid-template-areas: "top" "stage" "pal" "status";
  }
  .brand { display: none; }
  .tb { min-width: 34px; height: 34px; }
  #palette {
    border-right: 0;
    border-top: 1px solid var(--line);
    flex-direction: row;
    align-items: stretch;
    height: 78px;
  }
  .pal-search { padding: 6px; border-bottom: 0; border-right: 1px solid var(--line); width: 96px; flex: none; display: flex; align-items: center; }
  .pal-search input { padding: 0 6px; font-size: 12px; }
  #palList {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px;
    gap: 10px;
    align-items: center;
  }
  .pal-group { display: flex; align-items: center; gap: 4px; flex: none; }
  .pal-group h3 { writing-mode: vertical-rl; transform: rotate(180deg); margin: 0 2px; font-size: 9px; }
  .pal-items { display: flex; gap: 4px; }
  .pal-item { width: 52px; height: 52px; flex: none; }
  #hotbar { display: none; }
  .info { width: auto; left: 8px; right: 8px; top: auto; bottom: 8px; max-height: 40%; }
  .fab { top: 8px; left: 8px; height: 40px; min-width: 44px; }
  #status #stSel, #status #stPerf { display: none; }
}
