/* RISCy Probe. Light and dark follow prefers-color-scheme. System fonts only (works offline).
 * App shell: header, connection bar and status area keep a fixed height; the tab panels and
 * the log scroll inside their own areas, so clicking around never moves the page. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --border-strong: #c5ccd5;
  --text: #15181d;
  --muted: #5d6571;
  --accent: #c2501a;
  --accent-hover: #a94415;
  --accent-text: #ffffff;
  --accent-soft: rgba(194, 80, 26, .1);
  --ok: #1b7f45;
  --ok-soft: rgba(27, 127, 69, .12);
  --warn: #9a6100;
  --warn-soft: rgba(176, 112, 0, .13);
  --error: #c0262d;
  --error-soft: rgba(192, 38, 45, .09);
  --focus: #c2501a;
  --focus-ring: rgba(194, 80, 26, .28);
  --selection: rgba(194, 80, 26, .22);
  --scroll-thumb: #c9ced6;
  --scroll-thumb-hover: #aab1bb;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%235d6571' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gap: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e2229;
    --border: #2a2f37;
    --border-strong: #3a414b;
    --text: #e6e9ee;
    --muted: #949ba6;
    --accent: #ff914d;
    --accent-hover: #ffa66d;
    --accent-text: #1c0d03;
    --accent-soft: rgba(255, 145, 77, .13);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, .12);
    --warn: #f4b740;
    --warn-soft: rgba(244, 183, 64, .13);
    --error: #ff7b72;
    --error-soft: rgba(255, 123, 114, .1);
    --focus: #ff914d;
    --focus-ring: rgba(255, 145, 77, .3);
    --selection: rgba(255, 145, 77, .3);
    --scroll-thumb: #343943;
    --scroll-thumb-hover: #4a5158;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23949ba6' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: 13px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.error-text { color: var(--error); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--selection); }
/* thin, themed scrollbars (as logger-web) */
/* Chrome ignores the ::-webkit-scrollbar rules (and draws arrows) once scrollbar-width or
   scrollbar-color is set, so those are only for browsers without the pseudo-elements. */
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; } }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; min-height: 32px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }
[hidden] { display: none !important; }

/* ---- shell ----
 * The app is centred with a maximum width and height: on a big screen it stays compact instead
 * of stretching cards into empty boxes. Header on top; below it the main column and the log
 * column share one height. */
body { display: flex; justify-content: center; }
/* Up to 1920 px wide the app is at most 1600 px; above that it grows to 1800 px and the extra
   goes to the log column. It always fills the window height with constant margins. */
.app {
  width: 100%; max-width: clamp(1600px, calc(100vw - 520px), 1800px); height: 100vh; height: 100dvh;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 10px;
}
.shell { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.main-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.side-col { display: none; }
/* footer (as logger-web): one quiet line under the shell */
.foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap;
  margin-top: -2px; padding-top: 6px; border-top: 1px solid var(--border);
  font: 11.5px/1.4 var(--mono); color: var(--muted);
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--text); text-decoration: underline; }
.foot a.foot-build { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); }
.foot-icon { width: 11px; height: 11px; flex: none; color: var(--muted); }
@media (min-width: 1100px) and (min-height: 600px) {
  .shell { grid-template-columns: minmax(0, 1fr) calc(clamp(360px, 28%, 440px) + max(0px, 100% - 1568px)); }
  .side-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
  .narrow-only { display: none !important; }
}

/* ---- header ---- */
.top { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; height: 32px; }
.logo { flex: 0 0 auto; display: block; }
.brand { min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand p { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .badge { margin-left: auto; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; min-width: 0; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--error); border-color: color-mix(in srgb, var(--error) 45%, var(--border)); }
.btn.danger:hover:not(:disabled) { background: var(--error-soft); }
.btn.danger.solid { background: var(--error); border-color: var(--error); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger.solid { color: #230404; } }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.icon { width: 34px; padding: 0; color: var(--muted); }
.btn.icon:hover:not(:disabled) { color: var(--text); }
.btn svg { display: block; flex: 0 0 auto; }
/* bare icon buttons (pick another probe, settings): no outline until hovered */
.icon-plain { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; flex: 0 0 auto; transition: color .12s, background .12s; }
.icon-plain:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.icon-plain:disabled { opacity: .4; cursor: not-allowed; }
.icon-plain svg { display: block; }

/* role=switch buttons */
.switch { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 4px 2px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch-track { width: 34px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch[aria-checked="true"] .switch-track { background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { left: 16px; }
.switch.unknown .switch-track { background: repeating-linear-gradient(45deg, var(--border-strong) 0 4px, var(--surface-2) 4px 8px); }
.switch.unknown .switch-knob { left: 9px; }
.switch-state { display: inline-block; min-width: 2.4em; font-weight: 500; color: var(--muted); font-size: 13px; }

/* ---- layout helpers ---- */
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-start; }
.row.tight { gap: 8px; align-items: center; }
.grow { flex: 1 1 160px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 28px; }
@media (max-width: 860px) { .grid2, .mem-top { grid-template-columns: minmax(0, 1fr); } }
.block { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin-bottom: 14px; }
.block h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.block > p, .panel > p { max-width: 78ch; }
.panel > p:first-child { margin-bottom: 10px; }
h4 { font-size: 13px; font-weight: 700; color: var(--muted); }
.panel-head { display: flex; align-items: center; gap: 4px 14px; margin-bottom: 10px; min-height: 34px; }
.panel-head .stale-note { flex: 1 1 200px; }
.stale-note, .fixed-line { min-height: 1.45em; font-size: 13px; }
.stale-note { color: var(--warn); }
.panel-notice { font-size: 13px; color: var(--warn); }
.panel-notice:empty { display: none; }

/* ---- form fields ---- */
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, input[type="text"], select {
  min-height: 34px; padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background-color: var(--surface); min-width: 0; max-width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
/* Plain `select` only: a stronger selector here would beat appearance: base-select below. */
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 10px center; background-size: 11px 8px;
}
select.compact { min-height: 30px; padding-top: 3px; padding-bottom: 3px; font-size: 13px; }
select:hover:not(:disabled), input[type="text"]:hover:not(:disabled) { border-color: var(--muted); }
input[type="text"]:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); outline: none; }
/* No ring on a select; keyboard focus only darkens its border, like hover. */
select:focus { outline: none; box-shadow: none; }
select:focus-visible { border-color: var(--muted); }
select:disabled, input:disabled { cursor: not-allowed; }
select option { background: var(--surface); color: var(--text); }
/* The open list in the page's style where the browser allows it (Chrome 135+, the browsers
   WebUSB needs anyway); elsewhere the native list stays. */
@supports (appearance: base-select) {
  select, select::picker(select) { appearance: base-select; }
  select::picker-icon { display: none; } /* the chevron is the background image */
  select::picker(select) {
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    padding: 4px; margin: 4px 0; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); min-width: anchor-size(width);
    position-area: block-end span-inline-end; position-try-order: normal; position-try-fallbacks: flip-block;
  }
  select option { padding: 6px 10px; border-radius: 4px; font-size: inherit; background: transparent; cursor: pointer; }
  select option:hover, select option:focus-visible { background: var(--surface-2); outline: none; }
  select option:checked { color: var(--accent); font-weight: 600; }
  select option::checkmark { display: none; }
}
.field input { width: 240px; }
.field input.w-addr { width: 210px; }
.field input.w-num { width: 130px; }
.field input.w-byte { width: 88px; }
.field input.w-word { width: 140px; }
.check-field { padding-top: 22px; }
.field input { font-family: var(--mono); font-size: 14px; }
.field input:disabled { opacity: .6; }
.field select { max-width: 100%; padding-right: 30px; }
input[aria-invalid="true"] { border-color: var(--error); }
.field-hint { font-size: 12px; color: var(--muted); max-width: 36ch; }
.field-error { font-size: 11.5px; line-height: 14px; color: var(--error); min-height: 14px; } /* reserved: an error does not push the form */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: 0 0 auto; cursor: pointer; }
.check input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.check:has(input:disabled) { opacity: .5; cursor: not-allowed; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
fieldset:disabled { opacity: .55; }
.checks { display: flex; flex-direction: column; gap: 8px; }

/* ---- connection ---- */
.connection { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
.conn-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mode-row { border-top: 1px solid var(--border); padding-top: 8px; justify-content: flex-start; gap: 18px; }
.mode { display: flex; align-items: center; gap: 8px; }
.warn-text { color: var(--warn) !important; }
.mode-row .icon-plain { margin-left: auto; }
.conn-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.conn-main-btn { min-width: 120px; }
.switch.pending { opacity: .7; }
.state { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.state-lines { display: flex; flex-direction: column; min-width: 0; }
.state-lines > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 19px; line-height: 19px; }
.state-text { font-size: 15px; }
.state-sub { font-size: 13px; color: var(--muted); }
.state-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border-strong); flex: 0 0 auto; }
.state-dot.probe { background: #7c8cf8; }
.state-dot.halted { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.state-dot.running { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.state-dot.broken { background: var(--error); box-shadow: 0 0 0 4px var(--error-soft); }
.power { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.mode-row { min-height: 38px; }



/* ---- status (activity) ---- */
.activity { flex: 0 0 auto; height: 90px; padding: 8px 14px; display: grid; grid-template-rows: 26px 38px 6px; row-gap: 2px; align-content: start; overflow: hidden; }
.act-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.act-icon { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; background: var(--border-strong); position: relative; }
.activity[data-mode="busy"] .act-icon { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.activity[data-mode="ok"] .act-icon { background: var(--ok); }
.activity[data-mode="ok"] .act-icon::after { content: ""; position: absolute; left: 5px; top: 2.5px; width: 4px; height: 8px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.activity[data-mode="error"] .act-icon { background: var(--error); }
.activity[data-mode="error"] .act-icon::after { content: "!"; position: absolute; inset: 0; color: var(--surface); font: 700 12px/16px var(--sans); text-align: center; }
.activity[data-mode="error"] .act-title { color: var(--error); }
@keyframes pulse { 50% { opacity: .35; } }
.act-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.act-time { font-family: var(--mono); font-size: 13px; color: var(--muted); flex: 0 0 auto; }
.act-more { flex: 0 0 auto; }
.act-text { font-size: 13px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 19px; max-height: 38px; overflow-wrap: anywhere; }
.activity[data-mode="error"] .act-text { color: var(--text); }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; position: relative; align-self: end; }
.activity:not([data-mode="busy"]) .bar { visibility: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .12s linear; }
.bar.indeterminate .bar-fill { width: 30% !important; position: absolute; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { left: -30%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .bar.indeterminate .bar-fill { animation: none; left: 0; width: 100% !important; opacity: .5; }
  .activity[data-mode="busy"] .act-icon { animation: none; }
}

/* ---- tabs ---- */
.tabs { flex: 1 1 auto; min-height: 0; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.tablist { flex: 0 0 auto; display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--border); padding: 6px 8px 0; scrollbar-width: none; }
.tablist::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px 8px; margin-bottom: -1px;
  font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; border-radius: 6px 6px 0 0; flex: 0 0 auto;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.panels { flex: 1 1 auto; min-height: 0; position: relative; }
.panel { height: 100%; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding: 14px 16px; overscroll-behavior: contain; display: flex; flex-direction: column; }
.panel > * { flex-shrink: 0; }
#panel-log { padding: 0; overflow: hidden; display: flex; }
.log-tab .log { flex: 1 1 auto; border: 0; border-radius: 0; box-shadow: none; }

/* ---- segmented control (radio group) ---- */
.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border); align-self: flex-start; max-width: 100%; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label { padding: 6px 11px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; transition: color .12s, background .12s; }
.segmented label:hover { color: var(--text); }
.segmented input:disabled + label { opacity: .45; cursor: not-allowed; }
.segmented.compact { padding: 2px; }
.segmented.compact label { padding: 4px 10px; }
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow); outline: 1px solid var(--border); }
.segmented input:focus-visible + label { outline: 2px solid var(--focus); }
.range-info { min-height: 19px; line-height: 19px; }

/* ---- memory ---- */
.mem-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; }
.mem-top .block { margin-bottom: 10px; }
.mem > .read-out { flex: 1 1 auto; min-height: 96px; flex-shrink: 1; }
.mem-top .field-error { display: none; } /* shown in the range line instead */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 6px 8px 6px 14px; height: 52px;
  display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); transition: background .12s, border-color .12s;
}
.dropzone .dropzone-label { flex: 1 1 auto; text-align: left; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.write-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.write-options .opt { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.file-info { font-size: 13px; height: 19px; line-height: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.read-out { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.read-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.read-summary { font-size: 14px; overflow-wrap: anywhere; }
.read-out.is-stale .hexview { opacity: .55; }
.hexview, .trace, .terminal, .debug-out {
  margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; overflow: auto; font-size: 12.5px; line-height: 1.5;
}
.hexview { flex: 1 1 auto; min-height: 48px; white-space: pre; }
.read-out .stale-note { min-height: 19px; line-height: 19px; }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.table.regs td { padding: 1px 6px; font-size: 13px; }
.table.regs .btn.small { min-height: 24px; }
.table-wrap { overflow-x: auto; }
/* Columns of fixed-width groups: side by side when there is room, stacked when not; extra
   width stays empty instead of stretching the groups. */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 6px 36px; align-items: start; align-content: start; max-width: 940px; }
.cols > * { min-width: 0; }

/* ---- info ---- */
.deflist { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 3px 16px; margin: 0; }
.deflist dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.deflist dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .deflist { grid-template-columns: minmax(0, 1fr); gap: 0; } .deflist dd { margin-bottom: 8px; } }

/* ---- option bytes ---- */
.raw { overflow-wrap: anywhere; }
.raw .changed { color: var(--accent); font-weight: 700; text-decoration: underline; }
.changes { margin: 0; padding: 6px 8px 6px 26px; height: 5.8em; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.prot-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 24px; }
.loaded-line { min-height: 3em; }

/* ---- control ---- */
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 170px)); gap: 8px; }

/* ---- terminal, debug ---- */
.terminal { height: 320px; white-space: pre-wrap; word-break: break-word; margin: 10px 0 8px; }
.term > .terminal { flex: 1 1 auto; height: auto; min-height: 160px; flex-shrink: 1; }
.term-input { margin-bottom: 10px; }
.term-input input { flex: 1 1 160px; }
.debug-out { height: 150px; white-space: pre-wrap; }

/* ---- log ---- */
.log { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.log-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; flex: 0 0 auto; }
.log-head h2 { font-size: 16px; }
.log-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.log-body { flex: 1 1 0; min-height: 0; position: relative; display: flex; }
.log-list { flex: 1 1 auto; overflow: auto; scrollbar-gutter: stable; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 0; }
.log-entry { display: flex; gap: 10px; padding: 1px 12px; }
.log-entry time { color: var(--muted); flex: 0 0 auto; }
.log-entry span { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.log-entry.detail span { color: var(--muted); }
.log-entry.ok span { color: var(--ok); }
.log-entry.warn span { color: var(--warn); }
.log-entry.error span { color: var(--error); font-weight: 700; }
.log-jump { position: absolute; right: 18px; bottom: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.trace-note { flex: 0 0 auto; }
.trace { flex: 1 1 0; min-height: 0; white-space: pre; }

/* ---- dialog ---- */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.dialog::backdrop { background: rgba(10, 12, 16, .55); }
.dialog h2 { font-size: 18px; margin-bottom: 12px; }
.dialog ul { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.dialog-body { display: flex; flex-direction: column; gap: 12px; max-height: 65vh; overflow: auto; margin: -6px -6px 10px; padding: 6px; }
.dlg-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.details-pre { margin: 0; white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm); }
.driver-note ol { margin: 6px 0; padding-left: 20px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.error { background: var(--error-soft); color: var(--error); border-color: transparent; }

/* ---- phones ---- */
@media (max-width: 640px) {
  :root { --gap: 8px; }
  .app { padding: 8px 8px; }
  .main-col { gap: 8px; }
  .top { height: 30px; }
  .logo { width: 26px; height: 26px; }
  .brand h1 { font-size: 17px; }
  .brand p { display: none; }
  .card { padding: 10px 12px; }
  .connection { gap: 6px; }
  .conn-main-btn { min-width: 0; font-size: 13px; padding: 0 10px; }
  .mode-row { flex-wrap: wrap; gap: 8px 12px; }
  .mode-row .power { gap: 6px; }
  .mode-row .power > .muted, .mode > .muted { display: none; }
  .switch-state { min-width: 1.4em; }
  .activity { height: 94px; padding: 8px 12px; grid-template-rows: 28px 38px 6px; }
  .panel { padding: 12px; }
  .mem-top { grid-template-columns: minmax(0, 1fr); }
  .mem > .read-out { flex: none; }
  .hexview { flex: none; height: 360px; }
  .term > .terminal { flex: none; height: 260px; }
  .panel-head { flex-direction: column; align-items: flex-start; }
  .panel-head .stale-note { flex: 0 0 auto; }
  .panel-head .stale-note:empty { display: none; }
  .field input.w-addr { width: 180px; }
}

/* Too short for a fixed shell (landscape phone): the page scrolls as a whole. */
@media (max-height: 599px) {
  body { overflow: auto; display: block; }
  .app { height: auto; max-height: none; }
  .mem > .read-out { flex: none; }
  .hexview { flex: none; height: 360px; }
  .term > .terminal { flex: none; height: 260px; }
  .tabs { flex: none; }
  .panel { height: auto; overflow: visible; }
  #panel-log { height: 70vh; }
}
@media (max-width: 640px) { .wide-only { display: none; } }
