/* What the loop needs beyond style.css, which is the stylesheet of the matrioska lab, unchanged. Same tokens and
   same conventions: code green, model blue, prompt amber, errors red. */
.sections { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body[data-section="etichette"] { --accent: var(--code); }
.sec.etichette[aria-selected="true"] i { background: var(--code); color: var(--panel); }
.chain { grid-template-columns: minmax(0, .85fr) 58px minmax(0, 1fr) 58px minmax(0, 1.25fr) 58px minmax(0, 1.35fr); }
.srow.err-soft { border-left-color: var(--warn); } .srow.warn-row { border-left-color: var(--warn); }
.lk-json { --c: var(--log); --cb: var(--log-bg); }
.lk-distillato, .lk-scelta { --c: var(--code); --cb: var(--code-bg); }
.lk-modello { --c: var(--model); --cb: var(--model-bg); }
.lk-body .chip { margin: 2px 2px 0 0; }
.prov.p-typesafe { background: var(--cons-bg); color: var(--cons); }
.prov.p-finto { background: var(--grid); color: var(--muted); }
.qtag { display: inline-block; font-family: var(--f-mono); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--grid); color: var(--muted); white-space: nowrap; }
.qtag.a { background: var(--prompt-bg); color: var(--prompt); }
.qtags { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; overflow: hidden; }

/* the case: its JSON, before any run */
.case-json { display: grid; gap: 10px; margin-top: 14px; }
.case-json:empty { display: none; }
.in-json { display: flex; gap: 12px; align-items: center; background: var(--code-bg); color: var(--code); border-radius: 12px; padding: 10px 14px; }
.in-json p { margin: 0; color: var(--ink); font-size: 13px; }
.srow .chars { white-space: nowrap; }

/* JSON files load from anywhere */
.drop-veil { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none; background: color-mix(in srgb, var(--accent) 22%, transparent); backdrop-filter: blur(2px); animation: fadein .15s var(--ease); }
.drop-veil > div { display: grid; gap: 4px; text-align: center; background: var(--panel); border: 2px dashed var(--accent); border-radius: 16px; padding: 28px 40px; box-shadow: var(--shadow); }
.drop-veil b { font-size: 20px; color: var(--accent); } .drop-veil span { color: var(--muted); }
body.dragging .drop { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.files li { cursor: pointer; } .files li:hover { border-color: var(--muted); }
.files li.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.empty .drop { width: min(560px, 100%); }
/* the left column: the elements of the case, and under the open one its runs */
.runcard.item { gap: 6px; }
.runcard.item:not(.on) { background: var(--raise); }
.rr-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 5px; }
.rr { display: grid; gap: 4px; padding: 7px 8px; border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); cursor: pointer; }
.rr:hover { border-color: var(--muted); }
.rr.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.rr-top { display: flex; gap: 6px; align-items: start; justify-content: space-between; }
.rr-top b { font-size: 12.5px; line-height: 1.3; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rr-series { display: grid; gap: 5px; border-left: 3px solid var(--analisi); padding-left: 6px; }
.rr-series > .rc-meta { justify-content: space-between; }
.rr-series .rr-list { margin: 0; }
.rail .addvar { width: 100%; }
#cmp-head .filters button small { opacity: .75; }
dialog.wizard.mx { width: min(820px, calc(100vw - 24px)); }
.mx-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding-bottom: 4px; }
.mx-name { display: grid; min-width: 0; } .mx-name small { color: var(--muted); font-size: 12px; font-weight: 400; overflow-wrap: anywhere; }
.mx-run { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.mx-run:hover { background: var(--grid); } .mx-run.on { background: color-mix(in srgb, var(--accent) 10%, transparent); } .mx-run.off { opacity: .6; cursor: default; }

/* the three queues */
.qtiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.qtile { display: grid; gap: 2px; text-align: left; border-radius: 12px; padding: 10px 12px; border: 1px solid var(--rule); border-top: 4px solid var(--c); background: var(--panel); }
.qtile b { font-size: 24px; font-variant-numeric: tabular-nums; }
.qtile small { color: var(--muted); font-size: 12px; font-weight: 400; }
.qtile.q1 { --c: var(--ok); } .qtile.q2 { --c: var(--warn); } .qtile.q3 { --c: var(--red); }
.qtile.on { box-shadow: 0 0 0 2px var(--c); }

/* thresholds */
.rule-head, .rule { display: grid; grid-template-columns: minmax(120px, 1fr) 70px 120px minmax(180px, 1.6fr) minmax(190px, 1.3fr) 76px; gap: 10px; align-items: center; }
.rule-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 12px; }
.rules { display: grid; gap: 4px; }
.rule { background: var(--panel); border: 1px solid var(--rule); border-radius: 9px; padding: 8px 12px; font-size: 13px; }
.rule select, .rule input[type="number"] { padding: 4px 6px; border: 1px solid var(--rule); border-radius: 7px; background: var(--panel); }
.rule code { overflow: hidden; text-overflow: ellipsis; }
.rule .ck { display: inline-flex; gap: 5px; align-items: center; color: var(--muted); font-size: 12.5px; }
.rule .cks { display: grid; gap: 3px; } .rule .cks .ck { font-size: 11.5px; line-height: 1.2; }
.rule .off-n { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
.cur { display: grid; grid-template-columns: minmax(60px, 1fr) 66px; gap: 8px; align-items: center; }
.cur input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }
.cur input[type="number"] { width: 66px; font-family: var(--f-mono); font-size: 12px; }
.hist { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px; height: 42px; align-items: end; position: relative; border-bottom: 1px solid var(--rule); }
.hist .bin { display: flex; flex-direction: column; min-height: 0; border-radius: 2px 2px 0 0; overflow: hidden; }
.hist i { display: block; background: var(--model); min-height: 0; }
.hist i.pass { background: var(--code); }
.hist b { position: absolute; top: -3px; bottom: 0; width: 2px; background: var(--ink); }
.change { min-height: 19px; }

/* the choice of the code, in the drawer */
.choice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
table.calls td.pass { color: var(--ok); font-weight: 600; } table.calls td.fail { color: var(--red); font-weight: 600; }
table.calls td.off { color: var(--muted); }
.qedit { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.reads { display: grid; gap: 6px; } .reads h5 { margin: 0; }
.reads .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.reads .seg button { align-content: start; }
.ck-line { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; }
.mc-head.pick { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.2fr); }
.mc-head.pick.lang { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.2fr) auto; }
.mc-head.pick.lang .row { display: inline-flex; gap: 4px; align-items: center; }
.mcard.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mcard.off { opacity: .7; }
.mcard input[type="text"] { width: 100%; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 7px; background: var(--panel); font-family: var(--f-mono); font-size: 12px; }
@media (max-width: 1100px) { .chain { grid-template-columns: minmax(0, 1fr); } .rule-head { display: none; } .rule { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .hist, .cur { grid-column: 1 / -1; } }
@media (max-width: 900px) { .qtiles { grid-template-columns: minmax(0, 1fr); } .mc-head.pick { grid-template-columns: auto minmax(0, 1fr); } .mc-head.pick .mc-now { grid-column: 1 / -1; } }

/* two views in one section */
.a-views { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, max-content)); margin-bottom: 12px; }
.a-views button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); color: var(--accent); border-color: var(--accent); }
.case-view { display: grid; gap: 12px; }

/* the case: everything at once */
.ca-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.ca-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpis b s { color: var(--muted); font-weight: 500; font-size: .75em; margin-right: 2px; }
table.ca-table td, table.ca-table th { white-space: nowrap; } table.ca-table td:nth-child(2) { white-space: normal; min-width: 240px; }
table.ca-table tr.on td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
table.ca-table tfoot td { border-top: 2px solid var(--rule); }
.ca-b { color: var(--analisi); }
.ca-off { align-items: center; }
.ca-off button { display: inline-flex; gap: 4px; align-items: center; }
.ca-preset { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.ca-preset select { padding: 4px 6px; border: 1px solid var(--rule); border-radius: 7px; background: var(--panel); }
.err-t { color: var(--red); font-weight: 600; } .warn-t { color: var(--warn); font-weight: 600; }
table.ca-eps tbody tr { cursor: pointer; } table.ca-eps tbody tr:hover td { background: var(--grid); }
table.ca-eps td.ca-el { max-width: 190px; } table.ca-eps td s { color: var(--muted); }
table.ca-eps td span.chip { display: inline-flex; margin: 0 2px 2px 0; } table.ca-eps td span.qtag { display: inline-block; }

/* labels */
.lb-body { display: grid; gap: 12px; }
.lb-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.lb-progress { display: grid; gap: 3px; min-width: 220px; flex: 1; } .lb-progress small { color: var(--muted); font-size: 11.5px; }
.lb-progress .bar { display: block; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; } .lb-progress .bar i { display: block; height: 100%; background: var(--accent); }
.lb-item { display: grid; gap: 1px; padding: 7px 9px; border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); cursor: pointer; font-size: 12.5px; }
.lb-item:hover { border-color: var(--muted); } .lb-item.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.lb-item .t { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } .lb-item small { color: var(--muted); font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lb-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.lb-nav { display: inline-flex; gap: 6px; align-items: center; }
.lb-form { display: grid; gap: 8px; }
.lb-verdicts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.lb-verdicts button.ok[aria-pressed="true"] { background: var(--code-bg); border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.lb-verdicts button.bad[aria-pressed="true"] { background: color-mix(in srgb, var(--red) 10%, var(--panel)); border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.lb-verdicts button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.lb-defects { display: flex; flex-wrap: wrap; gap: 5px; }
.lb-defects button { display: inline-flex; gap: 5px; align-items: center; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-family: var(--f-mono); }
.lb-defects button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
kbd { font-family: var(--f-mono); font-size: 10.5px; padding: 0 4px; border: 1px solid var(--rule); border-radius: 4px; color: var(--muted); background: var(--raise); font-weight: 400; }
.lb-history { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
.lb-chip { font-size: 11px; }
.lb-data { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.lb-body .acard { align-content: start; }
.lb-bars { display: grid; gap: 4px; } .lb-bars > div { display: grid; grid-template-columns: 140px minmax(0, 1fr) 36px; gap: 8px; align-items: center; font-size: 12.5px; } .lb-bars b { text-align: right; }
.lb-bars .kb-track { display: block; height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; } .lb-bars .kb-track i { display: block; height: 100%; background: var(--accent); }
/* the labelling room: the page header gives way, and list, dialogue, points and verdict stay in view together */
body[data-section="etichette"].lb-work .hero { padding-top: 8px; padding-bottom: 8px; }
body[data-section="etichette"].lb-work #crumbs, body[data-section="etichette"].lb-work #hero-title, body[data-section="etichette"].lb-work #hero-text { display: none; }
body[data-section="etichette"].lb-work #lb-views button small { display: none; }
.lb-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 12px; align-items: stretch; min-height: 0; }
.lb-queue { list-style: none; margin: 0; padding: 0 4px 0 0; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.lb-queue .lb-item { flex: none; }
.lb-group { flex: none; display: flex; justify-content: space-between; gap: 6px; padding: 8px 2px 2px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.lb-group:first-child { padding-top: 0; }
.lb-group small { font-size: 11px; font-weight: 700; color: var(--ink); }
.lb-card { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 12px 14px; min-width: 0; min-height: 0; }
.lb-where { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.lb-show { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; padding: 4px 10px; border-radius: 8px; }
.lb-two { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 14px; align-items: stretch; min-height: 0; }
.lb-source, .lb-episode { display: grid; gap: 8px; min-width: 0; min-height: 0; }
.lb-source { grid-template-rows: auto minmax(0, 1fr); }
.lb-episode { grid-template-rows: minmax(0, 1fr) auto; }
.lb-read, .lb-ep-scroll { overflow: auto; min-height: 0; padding-right: 4px; }
.lb-read pre.mono { min-height: 100%; }
.lb-dialogue { display: grid; gap: 7px; align-content: start; font-size: 13.5px; line-height: 1.5; }
.lb-say { padding: 6px 10px 8px; border-radius: 8px; border-left: 3px solid var(--rule); background: var(--raise); overflow-wrap: anywhere; min-width: 0; }
.lb-say > div { white-space: pre-wrap; } .lb-say code { font-size: 12px; }
.lb-say small { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 1px; }
.lb-say.u { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.lb-say.u small { color: var(--accent); }
.dr-why { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; line-height: 1.35; margin-top: 2px; }
.lb-say.c { border-left-style: dashed; font-size: 12px; line-height: 1.4; color: var(--muted); }
.lb-title { margin: 0 0 8px; font-size: 15px; line-height: 1.35; }
.lb-pts { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13.5px; line-height: 1.42; }
.lb-pts li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 4px; padding: 4px 6px; border-radius: 7px; border-left: 3px solid transparent; }
.lb-pts li > b { font-family: var(--f-mono); font-size: 11.5px; font-weight: 600; color: var(--muted); padding-top: 2px; }
.lb-pts li small { display: block; font-size: 10.5px; color: var(--muted); }
.lb-pts li.u { border-left-color: var(--accent); }
.lb-pts li.hit { background: color-mix(in srgb, var(--prompt) 15%, var(--panel)); }
.lb-others { display: grid; gap: 5px; padding: 8px 10px; margin-bottom: 10px; border: 1px dashed var(--rule); border-radius: 9px; background: var(--raise); }
.lb-others h5 { margin: 0; } .lb-others .lb-history { margin: 0; } .lb-others .lb-history small { font-size: 12.5px; line-height: 1.4; color: var(--ink); } .lb-model { margin: 0; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12.5px; }
.lb-verdicts button { display: inline-flex; justify-content: center; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 10px; font-weight: 600; }
.lb-note-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.lb-note-row input { min-width: 0; width: 100%; }
.lb-hint { margin: 0; font-size: 11.5px; color: var(--muted); min-height: 1.3em; }
.lb-form { padding-top: 8px; border-top: 1px solid var(--rule); }
.drawer .lb-form { border-top: 0; padding-top: 0; }
@media (max-width: 1100px) { .lb-layout, .lb-two, .lb-card, .lb-source, .lb-episode { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; } .lb-queue { max-height: 240px; } .lb-read, .lb-ep-scroll { overflow: visible; } }
