:root {
  --bg: #0000a8;          /* blu newt */
  --win: #c0c0c0;         /* grigio finestra */
  --win-dark: #8a8a8a;
  --ink: #000;
  --title: #a80000;       /* rosso titoli / selezione */
  --sel-ink: #fff;
  --shadow: #000;
  --field: #0000a8;
  --field-ink: #fff;
  --help: #fff;
  --pink: #ff5fd7;
  --cyan: #00a8a8;
  --yellow: #ffff55;
  --ok: #00a800;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #000070; --win: #b4b4b4; }
}
:root[data-theme="dark"] { --bg: #000070; --win: #b4b4b4; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "IBM Plex Mono", "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  display: flex; flex-direction: column; min-height: 100vh;
}
.topbar {
  color: var(--help); padding: 6px 16px; display: flex; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.15); font-weight: 600;
}
.topbar .kao { color: var(--pink); }
.helpbar { color: var(--help); padding: 6px 16px; font-size: 13px; text-align: left; }

#screen {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  padding: 28px 16px 24px;
}

/* ---------- finestra stile newt ---------- */
.dlg-wrap { display: flex; gap: 28px; align-items: flex-start; width: 100%; max-width: 1180px; justify-content: center; }
.dlg {
  background: var(--win); color: var(--ink);
  box-shadow: 14px 14px 0 var(--shadow);
  width: 100%; max-width: 820px; position: relative;
  padding: 22px 26px 18px;
  border: 2px solid var(--win);
  outline: 1px solid #fff; outline-offset: -8px;
}
.dlg::before {           /* bordo interno scuro, effetto doppia linea */
  content: ""; position: absolute; inset: 8px; border-right: 1px solid var(--win-dark);
  border-bottom: 1px solid var(--win-dark); pointer-events: none;
}
.dlg h1 {
  position: absolute; top: -2px; left: 50%; transform: translate(-50%, -50%);
  margin: 0; font-size: 15px; font-weight: 600; background: var(--win); padding: 0 10px;
  color: var(--title); white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.dlg h1::before { content: "┤ "; color: var(--ink); }
.dlg h1::after  { content: " ├"; color: var(--ink); }
.dlg p { margin: 0 0 12px; }
.dlg .note { color: #303030; font-size: 13.5px; }
.dlg b.hl { color: var(--title); }
.dlg code { background: #d8d8d8; padding: 0 4px; }

/* lista selezionabile (radio / checkbox) */
.list {
  background: var(--win); border: 1px solid var(--win-dark);
  border-right-color: #fff; border-bottom-color: #fff;
  padding: 6px 0; margin: 4px 0 14px; max-height: 340px; overflow: auto;
}
.opt {
  display: flex; gap: 10px; padding: 3px 12px; cursor: pointer; align-items: baseline;
  outline: none; user-select: none;
}
.opt .mark { white-space: pre; flex: none; }
.opt .lbl { flex: 1; }
.opt .lbl small { display: block; color: #3a3a3a; font-size: 12.5px; }
.opt:hover { background: #d0d0d0; }
.opt:focus { background: var(--title); color: var(--sel-ink); }
.opt:focus small { color: #ffd6d6; }

.list .grp { padding: 6px 12px 2px; color: var(--title); font-weight: 600; font-size: 13px; }
.opt.off .lbl { color: #666; }

/* campi */
.field { margin: 0 0 12px; }
.field > label { display: block; margin-bottom: 3px; }
textarea, input[type=text], input[type=number], select {
  width: 100%; font: inherit; background: var(--field); color: var(--field-ink);
  border: none; padding: 6px 8px; border-radius: 0; outline: none;
}
textarea { min-height: 220px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--yellow); outline-offset: 0; }
::placeholder { color: #8f8fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 22px; }
.inline-opts { display: flex; flex-wrap: wrap; gap: 0 4px; margin: 2px 0 10px; }
.inline-opts .opt { padding: 2px 8px; }
fieldset { border: 1px solid var(--win-dark); margin: 0 0 14px; padding: 8px 12px 4px; }
legend { padding: 0 6px; color: var(--title); font-weight: 600; }

/* pulsanti newt: barra sempre visibile in fondo allo schermo */
.btns {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  position: sticky; bottom: 0; z-index: 3; background: var(--win);
  margin: 16px -12px -10px; padding: 10px 12px; border-top: 1px solid var(--win-dark);
}
.btns .right { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.btns .keyhint { font-size: 12px; color: #444; }
button.nb {
  font: inherit; background: #d8d8d8; border: 1px solid var(--win-dark); padding: 4px 12px; cursor: pointer;
  color: var(--ink); outline: none; min-height: 34px;
}
button.nb::before { content: "<"; }
button.nb::after  { content: ">"; }
button.nb:hover { background: #e8e8e8; }
button.nb.primary { font-weight: 600; background: var(--title); color: var(--sel-ink); border-color: #600; }
button.nb.primary:hover { background: #c40000; }
button.nb:focus-visible, button.nb:focus { outline: 3px solid var(--yellow); outline-offset: 1px; }
button.nb:disabled { color: #777; cursor: default; background: transparent; }
.dlg > .btns:not(:last-child), .field .btns, .btns[style] { position: static; margin: 0; padding: 0; border: 0; background: none; }

/* catgirl */
.cat {
  flex: none; color: var(--help); display: flex; flex-direction: column; align-items: center;
  padding-top: 8px; min-width: 250px;
}
.cat pre { margin: 0; font-size: 13px; line-height: 1.2; color: #ffd7f5; text-shadow: 0 0 6px rgba(255,95,215,.35); }
.cat pre .ear { color: var(--pink); }
.cat pre .eye { color: var(--yellow); }
.bubble {
  background: #fff; color: #000; padding: 8px 12px; max-width: 250px; font-size: 13px;
  position: relative; margin-bottom: 14px; box-shadow: 6px 6px 0 var(--shadow);
}
.bubble::after {
  content: ""; position: absolute; bottom: -10px; left: 50%; border: 6px solid transparent;
  border-top-color: #fff; border-left-color: #fff;
}
.cat .name { font-size: 12px; margin-top: 6px; color: var(--pink); }

/* barra di avanzamento debian */
.pbar {
  border: 1px solid var(--ink); height: 26px; position: relative; background: var(--win);
  margin: 12px 0 6px;
}
.pbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--title); width: 0; transition: width .3s; }
.pbar .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; mix-blend-mode: difference; color: #fff; font-weight: 600; }
.log {
  background: #000; color: #c0c0c0; height: 260px; overflow: auto; padding: 6px 10px;
  font-size: 12.5px; white-space: pre-wrap; word-break: break-word; margin-top: 10px;
}
.log .ok { color: #55ff55; } .log .err { color: #ff5555; } .log .dim { color: #888; }

/* risultati */
.magnets { min-height: 180px; font-size: 12px; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.tbl-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--win-dark); margin: 8px 0 14px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 3px 8px; vertical-align: top; border-bottom: 1px solid #a8a8a8; }
th { position: sticky; top: 0; background: #a8a8a8; }
td.miss { color: var(--title); }
td .rel { color: #222; word-break: break-all; }
.tag { display: inline-block; background: var(--bg); color: #fff; padding: 0 5px; margin: 1px 2px 1px 0; font-size: 11px; }
.tag.ita { background: var(--ok); } .tag.warn { background: var(--title); } .tag.v { background: #555; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; }
.stats b { color: var(--title); }
.toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: #000; color: #fff; padding: 6px 14px; border: 1px solid #fff; }

.err-box { background: var(--title); color: #fff; padding: 8px 12px; margin: 8px 0; white-space: pre-wrap; }

@media (max-width: 980px) {
  .dlg-wrap { flex-direction: column-reverse; align-items: center; gap: 18px; }
  .cat { flex-direction: row; gap: 14px; min-width: 0; padding-top: 0; }
  .cat pre { font-size: 10px; }
  .bubble { margin-bottom: 0; }
  .bubble::after { display: none; }
}
@media (max-width: 640px) {
  .btns .keyhint { display: none; }
  body { font-size: 14px; }
  .dlg { padding: 20px 14px 14px; box-shadow: 8px 8px 0 var(--shadow); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .cat pre { display: none; }
  .cat .name { display: none; }
  .bubble { max-width: none; }
  .helpbar { display: none; }
  .topbar .kao { display: none; }
}
