/* ==========================================================================
   Codice (js/code/*): file, editor, terminale
   ========================================================================== */
:root {
  --cd-bg: #161618; --cd-side: var(--raised); --cd-line: rgba(255, 255, 255, 0.07);
  --cd-kw: #ff7ab2; --cd-str: #ff8170; --cd-num: #d9c97c; --cd-com: #7f8c98; --cd-fn: #67b7a4;
  --cd-type: #acf2e4; --cd-meta: #fd8f3f; --cd-prop: #78c2b3; --cd-op: #c5c5ca;
  --cd-run: #30d158; --cd-run-ink: #0b2e14;
}
:root[data-theme="light"] {
  --cd-bg: #fbfbfd; --cd-line: rgba(0, 0, 0, 0.07);
  --cd-kw: #ad3da4; --cd-str: #c41a16; --cd-num: #1c00cf; --cd-com: #707f8c; --cd-fn: #326d74;
  --cd-type: #0b4f79; --cd-meta: #643820; --cd-prop: #3f6e74; --cd-op: #3c3c43;
  --cd-run: #248a3d; --cd-run-ink: #fff;
}

.view[data-view="codice"] { padding: 0; }
.cd-loading, .cd-fail { display: grid; place-items: center; gap: 10px; min-height: 50vh; color: var(--ink-3); text-align: center; }
.cd-app {
  --th: 38%; --side: 250px;
  position: relative; display: grid; grid-template-columns: var(--side) minmax(0, 1fr);
  height: calc(100dvh - 70px - var(--sat)); min-height: 420px;
  border: 1px solid var(--stroke); border-radius: 14px; overflow: hidden; overflow: clip; background: var(--cd-bg);
  transition: grid-template-columns 0.22s var(--ease);
}
.cd-app.side-closed { grid-template-columns: 0 minmax(0, 1fr); }
/* a tutto schermo: tutta la finestra (sopra la barra laterale e la barra in basso del sito) */
.cd-app.full {
  position: fixed; z-index: 75; inset: var(--sat, 0px) var(--sar, 0px) var(--sab, 0px) var(--sal, 0px);
  height: auto; min-height: 0; border: 0; border-radius: 0; --side: 272px;
}
@media (min-width: 1400px) { .cd-app.full { --side: 300px; } }
.view.cd-fullview { animation: none !important; transform: none !important; }
/* .cd-ib: senza, .cd-ib più sotto (fondo trasparente) vinceva a pari peso */
.cd-ib.cd-fullbtn { background: var(--fill); }
.cd-fullbtn[aria-pressed="true"] { background: var(--fill-3); color: var(--ink); }
.cd-fullbtn svg { transition: transform 0.3s cubic-bezier(.3, 1.6, .5, 1); }
.cd-fullbtn:hover svg { transform: scale(1.12); }
.cd-fullbtn:active svg { transform: scale(0.9); }
@media (max-width: 980px) { .cd-app { height: calc(100dvh - 52px - var(--sat)); border-radius: 0; border-left: 0; border-right: 0; } }

/* barra laterale */
.cd-side { min-width: 0; display: flex; flex-direction: column; background: var(--cd-side); border-right: 1px solid var(--stroke); overflow: hidden; }
.side-closed .cd-side { border-right: 0; }
.cd-side-head { display: flex; align-items: center; gap: 2px; padding: 8px 6px 6px 14px; min-height: 46px; }
.cd-side-head b { flex: 1; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.cd-ib { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); cursor: pointer; flex: none; transition: background 0.15s, color 0.15s; }
.cd-ib svg { width: 19px; height: 19px; }
.cd-ib:hover { background: var(--fill-2); color: var(--ink); }
.cd-ib.sm { width: 28px; height: 28px; }
.cd-ib.sm svg { width: 16px; height: 16px; }
.cd-tree { flex: 1; overflow: auto; padding: 2px 6px 16px; -webkit-overflow-scrolling: touch; }
/* trascinamento di file */
.cd-drop { position: absolute; inset: 8px; z-index: 6; display: grid; place-items: center; pointer-events: none; border: 2px dashed var(--cd-run); border-radius: 14px; background: color-mix(in srgb, var(--cd-bg) 82%, transparent); animation: rise 0.15s var(--ease) both; }
.cd-drop[hidden] { display: none; }
.cd-drop-in { display: grid; justify-items: center; gap: 6px; padding: 18px 26px; border-radius: 14px; background: var(--raised); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25); color: var(--ink); }
.cd-drop-in svg { width: 30px; height: 30px; color: var(--cd-run); }
.cd-drop-in b { font-size: 16px; }
.cd-drop-to { font: 500 13px/1 'SF Mono', ui-monospace, Menlo, monospace; color: var(--ink-3); }
.cd-row.drop-target { background: color-mix(in srgb, var(--cd-run) 22%, transparent); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--cd-run); }
.cd-app.dropping .cd-tree { position: relative; z-index: 7; }
.cd-tree-empty { padding: 12px 10px; font-size: 13px; color: var(--ink-3); }
.cd-row {
  position: relative; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 calc(6px + var(--depth) * 16px);
  border-radius: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.cd-row:hover { background: var(--fill); color: var(--ink); }
.cd-row.active { background: var(--fill-3); color: var(--ink); }
/* programmi compilati: cartella discreta */
.cd-row.bin { opacity: 0.6; font-size: 13px; }
.cd-row.bin:hover, .cd-row.bin.active { opacity: 1; }
.cd-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-chev { width: 14px; height: 14px; flex: none; color: var(--ink-3); transition: transform 0.15s var(--ease); }
.cd-chev svg { width: 14px; height: 14px; display: block; }
.cd-chev.open { transform: rotate(90deg); }
/* ⋯ della riga: l'aspetto è quello comune (.ui-more in notebook.css); qui la misura della riga */
.cd-rowmore.ui-more { width: 32px; height: 32px; margin: 0 -2px 0 0; }
.cd-rowmore svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .cd-row.active .cd-rowmore { opacity: 1; } }
@media (pointer: coarse) { .cd-row { height: 40px; } .cd-rowmore.ui-more { width: 44px; height: 44px; margin: -2px -4px -2px 0; } }
/* trascinare per riordinare (js/drag.js): la riga si stacca, il posto vuoto è uno slot
   tratteggiato che scivola dove cadrà e rientra al livello di arrivo */
.cd-row.cd-folded { display: none; }
.cd-tree.cd-sorting .cd-row:hover { background: transparent; color: var(--ink-2); }
.cd-tree.cd-sorting .cd-row.active { background: var(--fill-2); }
.cd-tree.cd-sorting .cd-rowmore { opacity: 0; }
.cd-tree .cd-row.dg-hole, .cd-tree.cd-sorting .cd-row.dg-hole { opacity: 1; filter: none; background: transparent; }
.cd-tree .cd-row.dg-hole > * { visibility: hidden; }
.cd-tree .cd-row.dg-hole::after {
  content: ""; position: absolute; top: 3px; bottom: 3px; right: 4px; left: calc(4px + var(--depth) * 16px);
  border: 1.5px dashed color-mix(in srgb, var(--solid) 45%, transparent); border-radius: 8px;
  background: color-mix(in srgb, var(--solid) 7%, transparent);
  transition: left 0.28s cubic-bezier(.3, 1.45, .5, 1);
}
.cd-row.cd-dest { background: color-mix(in srgb, var(--solid) 9%, transparent); color: var(--ink); }
.cd-row.cd-dest .cd-ic-dir { color: var(--solid); }
.cd-row.dg-into { color: var(--ink); }
.cd-row .cd-ic-dir { transition: transform 0.3s cubic-bezier(.3, 1.6, .5, 1), color 0.15s; }
.cd-row.dg-into .cd-ic-dir { transform: scale(1.22) rotate(-6deg); color: var(--solid); }
.cd-row.dg-ghost, .cd-row.dg-ghost.active {
  background: var(--raised); color: var(--ink); border-radius: 9px;
  box-shadow: 0 16px 34px -10px rgba(0, 0, 0, 0.42), 0 3px 10px rgba(0, 0, 0, 0.16), 0 0 0 1px var(--stroke-2, var(--stroke));
}
.cd-row.dg-ghost .cd-rowmore { opacity: 0; }
/* una cartella portata via con il suo contenuto: quanti elementi ha dentro */
.cd-row.dg-ghost[data-count]::after {
  content: attr(data-count); position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--solid); color: var(--on-solid); font: 700 11px/20px var(--font, system-ui); text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
/* dove è finito */
.cd-row.cd-landed { animation: cdLand 0.65s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes cdLand {
  0% { background: color-mix(in srgb, var(--solid) 22%, transparent); transform: scale(1.025); }
  100% { transform: none; }
}
.cd-tab.dg-ghost, .cd-tab.dg-ghost.active { background: var(--raised); color: var(--ink); border-radius: 9px; }
.cd-tab.dg-hole { opacity: 0.3; }
@media (prefers-reduced-motion: reduce) { .cd-row.cd-landed { animation: none; } .cd-tree .cd-row.dg-hole::after { transition: none; } }
.cd-ic { width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: var(--ink-3); }
.cd-ic svg { width: 17px; height: 17px; }
.cd-ic-dir { color: #5ab0f5; }
.cd-ic-exe { color: var(--cd-run); }
.cd-ic-tag { width: auto; min-width: 18px; height: 16px; padding: 0 3px; border-radius: 4px; background: var(--lc); color: #fff; font: 700 9px/16px var(--mono, ui-monospace, monospace); letter-spacing: -0.02em; }

/* zona principale */
.cd-scrim { display: none; }
.cd-main {
  min-width: 0; min-height: 0; display: grid; position: relative;
  grid-template-rows: auto minmax(0, 1fr) 6px var(--th);
}
.cd-app.term-max .cd-main { grid-template-rows: auto 0 6px minmax(0, 1fr); }
.cd-app.term-max .cd-edwrap { visibility: hidden; }
.cd-top { display: flex; align-items: center; gap: 6px; padding: 6px 8px; min-height: 46px; border-bottom: 1px solid var(--stroke); background: var(--cd-side); }
.cd-tabs { flex: 1; min-width: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.cd-tabs::-webkit-scrollbar { display: none; }
.cd-tab {
  display: flex; align-items: center; gap: 6px; flex: none; max-width: 210px; height: 32px; padding: 0 4px 0 10px;
  border-radius: 9px; font-size: 13.5px; color: var(--ink-3); cursor: pointer; white-space: nowrap;
}
.cd-tab:hover { background: var(--fill); color: var(--ink-2); }
.cd-tab.active { background: var(--fill-3); color: var(--ink); }
.cd-tabname { overflow: hidden; text-overflow: ellipsis; }
.cd-tabx { width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--ink-3); cursor: pointer; position: relative; }
.cd-tabx svg { width: 12px; height: 12px; }
.cd-tabx:hover { background: var(--fill-2); color: var(--ink); }
/* modifiche non ancora salvate: un pallino al posto della x */
.cd-tabx.dirty svg { opacity: 0; }
.cd-tabx.dirty::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); }
.cd-tabx.dirty:hover svg { opacity: 1; }
.cd-tabx.dirty:hover::after { display: none; }
.cd-run, .cd-stop {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 14px 0 11px;
  border: 0; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s var(--ease), opacity 0.15s, filter 0.15s;
}
.cd-run { background: var(--cd-run); color: var(--cd-run-ink); }
.cd-run:disabled { opacity: 0.35; cursor: default; }
.cd-stop { background: var(--ko); color: #fff; }
.cd-run:not(:disabled):hover, .cd-stop:hover { filter: brightness(1.08); }
.cd-run:not(:disabled):active, .cd-stop:active { transform: scale(0.95); }
.cd-run svg, .cd-stop svg { width: 15px; height: 15px; }
.cd-run[hidden], .cd-stop[hidden] { display: none; }
/* errori e avvisi del file aperto */
.cd-lint { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border: 0; border-radius: 9px; background: var(--fill); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; flex: none; }
.cd-lint[hidden] { display: none; }
.cd-lint:hover { background: var(--fill-2); }
.cd-lint span { display: inline-flex; align-items: center; gap: 4px; }
.cd-lint svg { width: 15px; height: 15px; }
.cd-lint .err { color: var(--ko); }
.cd-lint .warn { color: #ff9f0a; }
.cd-editor .cm-panel.cm-panel-lint ul { max-height: 140px; font-size: 13px; }
.cd-editor .cm-panel.cm-panel-lint [aria-selected] { background: var(--fill-3); }
.cd-editor .cm-diagnostic { white-space: pre-wrap; }
.cd-editor .cm-diagnostic-error { border-left-color: var(--ko); }
.cd-editor .cm-diagnostic-warning { border-left-color: #ff9f0a; }

/* editor */
.cd-edwrap { position: relative; min-height: 0; overflow: hidden; background: var(--cd-bg); }
.cd-editor, .cd-editor .cm-editor { height: 100%; }
.cd-editor[hidden] { display: none; }
.cd-editor .cm-editor { background: var(--cd-bg); color: var(--ink); font-size: 14.5px; }
.cd-editor .cm-editor.cm-focused { outline: none; }
.cd-editor .cm-scroller { font-family: 'SF Mono', ui-monospace, Menlo, 'Cascadia Mono', Consolas, monospace; line-height: 1.55; }
.cd-editor .cm-content { caret-color: var(--ink); padding: 10px 0 40vh; }
.cd-editor .cm-cursor { border-left-color: var(--ink); border-left-width: 2px; }
.cd-editor .cm-gutters { background: var(--cd-bg); color: var(--ink-4); border-right: 0; }
.cd-editor .cm-activeLineGutter { background: transparent; color: var(--ink-2); }
.cd-editor .cm-activeLine { background: var(--cd-line); }
.cd-editor .cm-selectionBackground, .cd-editor .cm-focused .cm-selectionBackground, .cd-editor ::selection { background: rgba(10, 132, 255, 0.28) !important; }
.cd-editor .cm-matchingBracket { background: rgba(10, 132, 255, 0.2); color: inherit !important; outline: 1px solid rgba(10, 132, 255, 0.45); }
.cd-editor .cm-searchMatch { background: rgba(255, 214, 10, 0.25); }
.cd-editor .cm-foldPlaceholder { background: var(--fill-2); border: 0; color: var(--ink-3); }
.cd-editor .cm-tooltip { background: var(--raised); color: var(--ink); border: 1px solid var(--stroke-2); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); overflow: hidden; }
.cd-editor .cm-tooltip-autocomplete > ul { font-family: 'SF Mono', ui-monospace, Menlo, monospace; font-size: 13.5px; max-height: 15em; }
.cd-editor .cm-tooltip-autocomplete > ul > li { padding: 3px 10px 3px 6px; line-height: 1.5; }
.cd-editor .cm-tooltip-autocomplete > ul > li[aria-selected] { background: rgba(10, 132, 255, 0.85); color: #fff; }
.cd-editor .cm-tooltip-autocomplete > ul > li[aria-selected] .cm-completionDetail { color: rgba(255, 255, 255, 0.8); }
.cd-editor .cm-completionDetail { margin-left: 10px; font-family: var(--font, system-ui); font-style: normal; font-size: 12px; color: var(--ink-3); }
.cd-editor .cm-completionMatchedText { text-decoration: none; font-weight: 700; }
.cd-editor .cm-completionIcon { opacity: 0.7; width: 1.2em; }
.cd-editor .cm-tooltip.cm-completionInfo { padding: 6px 10px; max-width: 320px; }
.cd-editor .cm-panels { background: var(--raised); color: var(--ink); border-color: var(--stroke); }
.cd-editor .cm-panels input, .cd-editor .cm-panels button { font: inherit; font-size: 13px; color: var(--ink); background: var(--fill); border: 1px solid var(--stroke-2); border-radius: 6px; }
.cd-editor .cm-diagnostic { padding: 6px 10px; font-size: 13px; }
.cd-editor .cm-lintRange-error { background-image: none; text-decoration: underline wavy var(--ko); text-underline-offset: 3px; }
.cd-editor .cm-lintRange-warning { background-image: none; text-decoration: underline wavy #ff9f0a; text-underline-offset: 3px; }

.cd-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto; }
.cd-empty[hidden] { display: none; }
.cd-empty-in { max-width: 520px; text-align: center; }
.cd-empty-in h2 { margin: 0 0 6px; font-size: 22px; }
.cd-empty-in p { margin: 0 0 18px; color: var(--ink-3); }
.cd-empty-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.cd-empty-row .btn svg { width: 16px; height: 16px; margin-right: 4px; vertical-align: -3px; }
.cd-empty-in .cd-empty-tip { margin: 12px 0 0; font-size: 13px; }
.cd-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 16px; }
.cd-qbtn { display: grid; justify-items: center; gap: 6px; padding: 16px 10px 14px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--raised); color: var(--ink); font: inherit; cursor: pointer; transition: transform 0.15s var(--ease), border-color 0.15s; }
.cd-qbtn:hover { border-color: var(--lc); transform: translateY(-2px); }
.cd-qbtn .cd-ic-tag { height: 22px; min-width: 30px; font-size: 11px; line-height: 22px; border-radius: 6px; }
.cd-qbtn b { font-size: 15px; }
.cd-qbtn small { font-size: 12px; color: var(--ink-3); }

/* divisore e terminale */
.cd-split { cursor: row-resize; background: var(--cd-side); border-top: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke); touch-action: none; position: relative; }
.cd-split::after { content: ""; position: absolute; left: 50%; top: 50%; width: 40px; height: 4px; margin: -2px 0 0 -20px; border-radius: 2px; background: var(--ink-4); opacity: 0.6; }
.cd-split::before { content: ""; position: absolute; inset: -8px 0; } /* più facile da prendere col dito */
.cd-termwrap { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--cd-bg); }
.cd-termhead { display: flex; align-items: center; gap: 6px; padding: 2px 6px 2px 12px; height: 34px; }
.cd-termtitle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.cd-termtitle svg { width: 16px; height: 16px; }
.cd-termstate { font-size: 12.5px; color: var(--cd-run); }
.cd-termstate:empty { display: none; }
.cd-termstate::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: currentColor; animation: cdPulse 1.2s ease-in-out infinite; }
@keyframes cdPulse { 50% { opacity: 0.3; } }
.cd-grow { flex: 1; }
.cd-term { min-height: 0; padding: 0 0 6px 10px; overflow: hidden; }
.cd-term .xterm { height: 100%; }
.cd-term .xterm-viewport { background: transparent !important; scrollbar-width: thin; }
.cd-term .xterm .xterm-screen { touch-action: pan-y; }

/* tasti sopra la tastiera dell'iPad */
.cd-keys {
  position: fixed; left: 0; right: 0; top: 0; z-index: 80; display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none;
  background: var(--raised); border-top: 1px solid var(--stroke-2); box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.15);
}
.cd-keys::-webkit-scrollbar { display: none; }
.cd-keys[hidden] { display: none; }
.cd-key { flex: none; min-width: 38px; height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: var(--fill-2); color: var(--ink); font: 500 16px/1 'SF Mono', ui-monospace, Menlo, monospace; cursor: pointer; }
.cd-key.wide { font-family: inherit; font-size: 14px; min-width: 46px; }
.cd-key.on { background: var(--solid); color: var(--on-solid); }
.cd-key:active { background: var(--fill-3); }

/* schermi stretti: i file diventano un pannello che si apre sopra */
@media (max-width: 820px) {
  .cd-app, .cd-app.side-closed { grid-template-columns: minmax(0, 1fr); }
  .cd-side { position: absolute; z-index: 5; top: 0; bottom: 0; left: 0; width: min(300px, 82vw); box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25); transform: translateX(-102%); transition: transform 0.24s var(--ease); }
  .cd-app { position: relative; }
  .cd-app:not(.side-closed) .cd-side { transform: none; }
  .cd-app:not(.side-closed) .cd-scrim { display: block; position: absolute; inset: 0; z-index: 4; background: rgba(0, 0, 0, 0.3); }
  .cd-run span, .cd-stop span { display: none; }
  .cd-run, .cd-stop { padding: 0 11px; }
}

/* grafica dei programmi (sopra l'editor) */
.cd-gfx { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; background: var(--cd-bg); }
.cd-gfx[hidden] { display: none; }
.cd-gfx-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; height: 36px; border-bottom: 1px solid var(--stroke); }
.cd-gfx-head b { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.cd-gfx-size { font: 500 12px/1 'SF Mono', ui-monospace, monospace; color: var(--ink-3); }
.cd-gfx-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 10px; overflow: hidden; }
.cd-gfx-canvas { display: block; background: #000; border-radius: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); outline: none; touch-action: none; }
.cd-gfx-canvas:focus-visible { box-shadow: 0 0 0 2px var(--cd-run), 0 10px 30px rgba(0, 0, 0, 0.35); }
.cd-gfx.pixel .cd-gfx-canvas { image-rendering: pixelated; }
.cd-gfx-pad { display: none; align-items: center; justify-content: center; gap: 10px; padding: 8px; border-top: 1px solid var(--stroke); user-select: none; -webkit-user-select: none; touch-action: none; }
@media (pointer: coarse) { .cd-gfx-pad { display: flex; } }
.cd-gfx-pad button { min-width: 52px; height: 46px; border: 0; border-radius: 12px; background: var(--fill-2); color: var(--ink); font: 600 15px/1 -apple-system, system-ui, sans-serif; touch-action: none; }
.cd-gfx-pad button.wide { min-width: 96px; }
.cd-gfx-pad button.on { background: var(--solid); color: var(--on-solid); }
.cd-gfx-arrows { display: grid; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 40px); gap: 4px; }
.cd-gfx-arrows button { min-width: 0; height: auto; font-size: 14px; }
.cd-gfx-arrows [data-gk="128"] { grid-column: 2; grid-row: 1; }
.cd-gfx-arrows [data-gk="130"] { grid-column: 1; grid-row: 2; }
.cd-gfx-arrows [data-gk="129"] { grid-column: 2; grid-row: 2; }
.cd-gfx-arrows [data-gk="131"] { grid-column: 3; grid-row: 2; }

/* debugger di Python */
.cd-dbgbtn { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 12px 0 10px; border: 1px solid var(--stroke-2); border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.cd-dbgbtn svg { width: 17px; height: 17px; color: #ff9f0a; }
.cd-dbgbtn:hover { background: var(--fill-2); }
.cd-dbgbtn[hidden] { display: none; }
@media (max-width: 820px) { .cd-dbgbtn span { display: none; } .cd-dbgbtn { padding: 0 9px; } }
.cd-dbg { position: absolute; z-index: 2; top: 0; right: 0; bottom: 0; width: min(310px, 60%); display: flex; flex-direction: column; background: var(--cd-side); border-left: 1px solid var(--stroke); box-shadow: -10px 0 30px rgba(0, 0, 0, 0.18); }
.cd-dbg[hidden] { display: none; }
.cd-app.debugging .cd-editor .cm-editor { margin-right: min(310px, 60%); }
.cd-dbg-head { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 12px; border-bottom: 1px solid var(--stroke); }
.cd-dbg-head b { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.cd-dbg-head b svg { width: 16px; height: 16px; color: #ff9f0a; }
.cd-dbg-where { font: 600 12.5px/1 'SF Mono', ui-monospace, monospace; color: #ff9f0a; }
.cd-dbg-ctrl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 8px; }
.cd-dbg-ctrl button { display: grid; justify-items: center; gap: 2px; padding: 7px 2px 6px; border: 0; border-radius: 10px; background: var(--fill-2); color: var(--ink); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.cd-dbg-ctrl button svg { width: 18px; height: 18px; }
.cd-dbg-ctrl button:not(:disabled):hover { background: var(--fill-3); }
.cd-dbg-ctrl button:disabled { opacity: 0.35; cursor: default; }
.cd-dbg-auto { display: flex; align-items: center; gap: 6px; padding: 0 12px 8px; font-size: 13px; color: var(--ink-2); }
.cd-dbg-auto input[type=range] { flex: 1; min-width: 0; }
.cd-dbg-ms { font: 500 12px/1 'SF Mono', ui-monospace, monospace; color: var(--ink-3); min-width: 38px; text-align: right; }
.cd-dbg-body { flex: 1; overflow: auto; padding: 0 10px 12px; border-top: 1px solid var(--stroke); }
.cd-dbg-h { margin: 10px 2px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.cd-dbg-vars { width: 100%; border-collapse: collapse; font-size: 13px; }
.cd-dbg-vars th { width: 34%; padding: 5px 6px; text-align: left; vertical-align: top; font: 600 13px/1.3 'SF Mono', ui-monospace, monospace; color: var(--ink); overflow-wrap: anywhere; }
.cd-dbg-vars td { padding: 5px 6px; vertical-align: top; }
.cd-dbg-vars code { display: block; font: 13px/1.35 'SF Mono', ui-monospace, monospace; color: var(--cd-num); overflow-wrap: anywhere; }
.cd-dbg-vars small { font-size: 11px; color: var(--ink-3); }
.cd-dbg-vars tr { border-bottom: 1px solid var(--stroke); }
.cd-dbg-vars tr.chg { background: color-mix(in srgb, #ff9f0a 18%, transparent); animation: rise 0.25s var(--ease) both; }
.cd-dbg-vars tr.new { background: color-mix(in srgb, #30d158 14%, transparent); }
.cd-dbg-none { color: var(--ink-3); font-size: 13px; padding: 8px 4px; }
.cd-dbg-stack { margin: 0; padding-left: 20px; font: 13px/1.6 'SF Mono', ui-monospace, monospace; }
.cd-dbg-stack span { color: var(--ink-3); font-size: 12px; }
.cd-dbg-tip { margin: 12px 2px 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
.cd-editor .cd-dbg-line { background: color-mix(in srgb, #ff9f0a 22%, transparent) !important; box-shadow: inset 3px 0 0 #ff9f0a; }
.cd-editor .cd-bp-gutter { width: 16px; cursor: pointer; }
.cd-editor .cd-bp-gutter .cm-gutterElement { display: grid; place-items: center; }
.cd-bp { display: block; width: 10px; height: 10px; border-radius: 50%; background: #ff453a; box-shadow: 0 0 0 2px color-mix(in srgb, #ff453a 30%, transparent); }
.cd-editor .cd-bp-gutter .cm-gutterElement:hover:not(:has(.cd-bp))::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #ff453a; opacity: 0.25; }
@media (max-width: 820px) { .cd-dbg { width: 100%; top: auto; height: 55%; border-left: 0; border-top: 1px solid var(--stroke); } .cd-app.debugging .cd-editor .cm-editor { margin-right: 0; } }
.cd-phone { max-width: 420px; margin: 0 auto; padding: 24px 8px; }
.cd-phone h2 { margin: 0; color: var(--ink); font-size: 21px; }
.cd-phone p { margin: 0; line-height: 1.5; }
.cd-phone > svg { width: 44px; height: 44px; color: var(--ink-3); }

/* aiuto sui parametri (malloc(size_t size) …) */
.cd-sig { position: absolute; left: 0; top: 0; z-index: 30; max-width: min(460px, calc(100% - 8px)); padding: 8px 11px; border: 1px solid var(--stroke-2); border-radius: 10px; background: var(--raised); color: var(--ink); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); pointer-events: none; font: 13px/1.45 var(--font); }
.cd-sig[hidden] { display: none; }
.cd-sig-line { font: 13px/1.45 'SF Mono', ui-monospace, Menlo, monospace; color: var(--ink-2); overflow-wrap: anywhere; }
.cd-sig-fn { color: var(--cd-fn, #5ab0f5); font-weight: 600; }
.cd-sig-line .on { color: var(--ink); font-weight: 700; background: color-mix(in srgb, #ff9f0a 26%, transparent); border-radius: 4px; padding: 0 2px; }
.cd-sig-ret { color: var(--ink-3); }
.cd-sig-hint { margin-top: 4px; color: var(--ink-2); }
.cd-sig-hint b { font: 600 12.5px/1.4 'SF Mono', ui-monospace, monospace; color: var(--ink); }
.cd-sig-desc { margin-top: 3px; font-size: 12px; color: var(--ink-3); }
