/* The designed UI (DESIGN.md, "Designed UI"). Colours as tokens, redefined
   for dark mode; the computer's own fonts, nothing loaded from elsewhere. */

:root {
  --bg: #f3f4f2; --panel: #ffffff; --fg: #1d2321; --muted: #5f6864; --line: #d9ddd9; --dim: #9aa19d;
  --accent: #c2410c; --on-accent: #ffffff;
  --save: #1f6f8b; --save-soft: #d6eaf1;
  --warn: #c2410c; --warn-soft: #fde3d3;
  /* The list's range: chosen (blue) and to be overwritten (orange), brighter
     than the -soft tints so a range stands out (developer, 2026-10-05). */
  --sel-fill: #a8d5ea; --over-fill: #fbc49f;
  --ok: #2f7d4f; --bad: #b42318; --bad-soft: #fde2df;
  --off: #c9cdca; --off-fg: #6f7773;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --narrow: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, Consolas, "Cascadia Mono", Menlo, monospace;
  /* Text sizes (developer, 2026-10-02: bigger, a little scrolling is fine). */
  --text: 16px; /* page text */
  --ui: 15px;   /* controls, summaries, progress */
  /* The patch list: the largest size up to 14px at which every column fits
     a 16-character name (the longest the pedal stores), never below 12px.
     Measured: a column is 10.75 font-sizes wide (129px at 12px). 8 columns
     + 7 gaps of 14px + 32px gutters + an 18px page scrollbar (100vw includes
     it), plus 2px spare: 86 x fs + 150px <= window width. Narrower than
     1200px (12px would not fit 8 columns), the list switches to 4 columns. */
  --fs: clamp(12px, calc((100vw - 150px) / 86), 14px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161a19; --panel: #1f2422; --fg: #e4e8e5; --muted: #a0aaa5; --line: #323a37; --dim: #6c7671;
    --accent: #f0884e; --on-accent: #1b120c;
    --save: #6cb8d3; --save-soft: #173440; --warn: #f0884e; --warn-soft: #4a2a18;
    --sel-fill: #1d5a74; --over-fill: #7a3d1c;
    --ok: #6cc08f; --bad: #ff8a80; --bad-soft: #4a1c18;
    --off: #2c3331; --off-fg: #7a8480;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161a19; --panel: #1f2422; --fg: #e4e8e5; --muted: #a0aaa5; --line: #323a37; --dim: #6c7671;
  --accent: #f0884e; --on-accent: #1b120c;
  --save: #6cb8d3; --save-soft: #173440; --warn: #f0884e; --warn-soft: #4a2a18;
  --sel-fill: #1d5a74; --over-fill: #7a3d1c;
  --ok: #6cc08f; --bad: #ff8a80; --bad-soft: #4a1c18;
  --off: #2c3331; --off-fg: #7a8480;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; padding-inline: 16px; background: var(--bg); color: var(--fg); font: var(--text)/1.45 var(--sans); }
[hidden] { display: none !important; }
a { color: inherit; }
.wrap { display: flex; flex-direction: column; gap: 10px; min-height: 100%; }

header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 28px; padding-top: 10px; border-bottom: 1px solid var(--line); }
header h1 { font-size: 22px; font-weight: 600; margin: 0 0 8px; }
header h1 a { text-decoration: none; } /* back to the home page */
header h1 a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a { color: var(--muted); text-decoration: none; font-weight: 500; padding: 4px 10px 7px; border-bottom: 3px solid transparent; }
nav a:hover { color: var(--fg); }
nav a.on { color: var(--fg); border-bottom-color: var(--accent); }
.conn { margin-left: auto; display: flex; gap: 10px; align-items: baseline; padding-bottom: 6px; }
.conn-status { font-size: var(--ui); color: var(--muted); }
.conn-status::before { content: "\25CF  "; }
.conn-status.ok { color: var(--ok); }

.banner { margin: 0; padding: 8px 12px; border-radius: 6px; font-size: var(--text); }
.banner.error { background: var(--bad-soft); color: var(--fg); border: 1px solid var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--fg); border: 1px solid var(--warn); }

.intro { font-size: var(--text); margin: 0 0 8px; }
.strip { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: var(--ui); }
.grp { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
label { font-size: var(--ui); color: var(--muted); }
.grp label:has(input[type=radio]), .grp label:has(input[type=checkbox]) { color: var(--fg); }
.grp label input { vertical-align: -2px; margin: 0 4px 0 0; }
input[type=text] { font-family: var(--mono); font-size: var(--ui); width: 4.6em; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--fg); text-transform: uppercase; }
input[type=text]::placeholder { color: var(--dim); }
input:focus-visible, button:focus-visible, select:focus-visible, nav a:focus-visible, .cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select { font: var(--ui) var(--sans); background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; }
button { font: 600 var(--ui) var(--sans); padding: 5px 14px; border-radius: 4px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; }
button.save { background: var(--save); border-color: var(--save); }
button.quiet { background: transparent; color: var(--fg); border-color: var(--line); font-weight: 500; }
button:disabled { background: var(--off); border-color: var(--off); color: var(--off-fg); cursor: not-allowed; }
button.quiet:disabled { background: transparent; border-color: var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--muted); font-weight: 500; padding: 3px 10px; }
.seg button.on { background: var(--warn-soft); color: var(--fg); }
.seg button:disabled { background: transparent; color: var(--off-fg); }

.sum { font-size: var(--ui); margin: 8px 2px 0; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.why { font-size: var(--ui); color: var(--muted); font-style: italic; }
.files { font-size: var(--ui); }
.warnline { color: var(--warn); }
.warnings { margin: 4px 0 0; padding-left: 20px; font-size: var(--ui); color: var(--warn); }
.warnings:empty { display: none; }
.warnings li.error { color: var(--bad); }

.prog { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: var(--ui); font-variant-numeric: tabular-nums; min-height: 1.4em; }
.bar { width: 220px; max-width: 100%; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--warn); }
.bar.save i { background: var(--save); }
.done { color: var(--ok); }
.failed { color: var(--bad); }

/* The patch list: 256 entries flowing down 8 columns of 8 banks. */
.listbox { overflow-x: auto; font-size: var(--fs); }
.list { display: grid; grid-auto-flow: column; grid-template-rows: repeat(32, auto); grid-template-columns: repeat(8, max-content); column-gap: 14px; font-family: var(--narrow); }
/* No browser text selection in the list: a drag selects a range instead,
   and a stray highlight looked like a range on every screen (developer,
   2026-10-05). */
.list { -webkit-user-select: none; user-select: none; }
.cell { display: flex; gap: 6px; padding: 0 4px; white-space: nowrap; border-radius: 2px; cursor: pointer; line-height: 1.45; }
.cell:hover { outline: 1px solid var(--line); }
.cell.bankstart { border-top: 1px solid var(--line); }
.cell .lab { font-family: var(--mono); color: var(--muted); font-size: .9em; min-width: 3.4em; font-variant-numeric: tabular-nums; }
.cell.def, .cell.def .lab, .cell.unread { color: var(--dim); }
.cell.unread .nm { font-style: italic; }
/* The chosen range, the same on Back up and Template; on Template the
   slots that will be written are orange instead. */
.cell.sel { background: var(--sel-fill); color: var(--fg); }
.cell.sel .lab { color: var(--fg); }
.cell.sel.end { box-shadow: inset 0 0 0 1.5px var(--save); }
.cell.sel.def, .cell.sel.def .lab { color: var(--muted); }
.cell.over { background: var(--over-fill); color: var(--fg); }
.cell.over .lab { color: var(--fg); }
.cell.over.end { box-shadow: inset 0 0 0 1.5px var(--warn); }
.cell.new .nm { font-style: italic; }
.cell.start { box-shadow: inset 0 0 0 1px var(--warn); }
.cell.bad, .cell.bad.over { background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.cell.bad .nm::after { content: " \2717"; color: var(--bad); }
.list.busy .cell { cursor: default; }
@media (max-width: 1199px) {
  /* 4 columns of 16 banks: 43 x fs + 92px <= window width */
  :root { --fs: clamp(12px, calc((100vw - 92px) / 43), 14px); }
  .list { grid-template-rows: repeat(64, auto); grid-template-columns: repeat(4, max-content); }
}

.help { max-width: 72ch; line-height: 1.55; font-size: var(--text); }
.help h2 { font-size: 19px; margin: 18px 0 4px; }
.help h3 { font-size: 16px; margin: 12px 0 2px; }
.help ul, .help ol { margin: 4px 0; padding-left: 20px; }
.help p { margin: 6px 0; }

.devlog { border: 1px dashed var(--line); border-radius: 6px; padding: 8px 12px; }
.devlog pre { max-height: 22em; overflow: auto; font: 12px/1.4 var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px; margin: 8px 0 0; white-space: pre-wrap; }

dialog { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); padding: 16px 18px; max-width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog h3 { margin: 0 0 8px; font-size: 18px; }
dialog p { margin: 6px 0; font-size: var(--text); line-height: 1.45; }
.dlgbtns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

footer { margin-top: auto; border-top: 1px solid var(--line); padding-block: 8px 10px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 18px; }
footer a { color: var(--muted); }

/* The welcome panel: what the app does and one control, Connect, with a
   drawing of the pedal beside it (below it on a narrow window). */
.welcome { display: grid; grid-template-columns: minmax(0, 66ch) minmax(0, 380px); gap: 8px 40px; align-items: start; font-size: var(--text); line-height: 1.55; }
@media (max-width: 900px) { .welcome { grid-template-columns: minmax(0, 66ch); } .pedal-art { max-width: 320px; } }
.welcome .lead { font-size: 19px; margin: 14px 0 6px; }
.welcome ul { margin: 4px 0; padding-left: 22px; }
.welcome p { margin: 8px 0; }
.welcome .strip { margin: 10px 0; }
button.big { font-size: 18px; padding: 10px 26px; border-radius: 6px; margin-top: 6px; }
.connect-msg { color: var(--bad); min-height: 1.5em; }
.report-msg { min-height: 1.5em; }
.note { color: var(--muted); font-size: var(--ui); }
.connected-note { color: var(--ok); font-weight: 500; }
.connected-note a { color: var(--fg); }
.pedal-art { width: 100%; height: auto; margin-top: 18px; }
