/* JFruit (c) 2026 Pete Walton - SPDX-License-Identifier: AGPL-3.0-or-later; see LICENSE */
:root {
  --bg: #111;
  --panel: #1a1a1a;
  --panel-2: #222;
  --line: #333;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --accent: #5fbf6a;
  --warn: #e0a040;
  --bad: #f07070;
  /* (the themes: these, then [data-theme] blocks at the end of this file and the designer CSS use them) */
  --btn-bg: var(--panel-2);
  --btn-line: #4a4a4a;
  --btn-hover: #2c2c2c;
  --btn-hover-line: #666;
  --field-bg: var(--panel-2);
  --well: #111;
  --kbd-line: #555;
  --hover: #2a2a2a;
  --sel: #1f4060;
  --sel-line: #3b7bb0;
  --edit-line: #5a2a22;
  --ok-bg: #24502a;
  --warn-bg: #3a3010;
  --info-bg: #1d2a33;
  --info: #8fd0ff;
  --good: #6fd0a0;
  --hi: #ffcf8a;
  --badge-fg: #111;
  --on-fg: #000;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
body.dropping { outline: 3px dashed var(--accent); outline-offset: -6px; }

/* ---- top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 4px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand h1 { line-height: 0; }
.brand img { height: 48px; width: auto; display: block; } /* the logo: no taller than the buttons' row needs */
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: 0.02em; }
.topbar h1 span, .about h2 span { color: var(--accent); }
.tagline { font-size: 11px; color: var(--muted); letter-spacing: 0.03em; }
.topbar > .row { margin: 0; }
.loadbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gameinfo { flex: 1 1 180px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 180px; } /* (wide enough for the name: squeezed to nothing by the buttons beside it, it wrapped to a letter a line) */
#gameName { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.systemname { font-size: 12px; color: var(--muted); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--warn); color: var(--badge-fg); font-weight: 600; }
.badge.paused { background: #888; }
.status { margin: 0; color: var(--muted); font-size: 13px; min-height: 1.6em; }
.play > .meters { margin: 0 0 8px; }

/* ---- buttons and fields */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--btn-bg); border: 1px solid var(--btn-line); border-radius: 5px; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--btn-hover); border-color: var(--btn-hover-line); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { padding: 4px 9px; font-size: 13px; }
select, input[type='number'] {
  font: inherit; font-size: 14px; color: var(--text); background: var(--field-bg);
  border: 1px solid var(--btn-line); border-radius: 5px; padding: 5px 7px;
}
input[type='number'] { width: 7.5em; }

/* ---- main area: machine on the left, settings on the right */
.workspace { display: flex; align-items: flex-start; gap: 16px; padding: 0 16px 16px; }
.play { flex: 1; min-width: 0; }
#stage {
  position: relative; overflow: auto; max-width: 100%; width: fit-content;
  background: #000; border: 1px solid var(--line); line-height: 0;
}
#machine { position: relative; overflow: hidden; }
#machineInner { position: absolute; left: 0; top: 0; transform-origin: 0 0; } /* layout size, scaled */
#layoutCanvas { display: block; max-width: none; }
.empty { width: min(720px, 90vw); padding: 80px 32px; line-height: 1.5; color: var(--muted); text-align: center; }
.empty b { color: var(--text); font-size: 18px; }
.empty .resume { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 18px; } /* app.js offerResume */
.empty .needs { color: var(--text); border: 1px solid var(--warn); border-radius: 6px; padding: 10px 14px; } /* a JFruit-only game opened without its layout (app.js needsLayout) */
.control { position: absolute; z-index: 2; padding: 0; border: 0; background: transparent; cursor: pointer; opacity: 0; } /* invisible: the lamp or button underneath shows the press */
.control { -webkit-tap-highlight-color: transparent; outline: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; } /* (no square from the browser while a button is held: phones' tap highlight, the focus ring, the long-press menu) */
/* an Astra linked game's players (app.js installLinkedPick): a click on a cabinet gives that player the keyboard and the coin bar; the active one outlined and labelled */
.linkedpick { position: absolute; z-index: 1; box-sizing: border-box; cursor: pointer; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
.linkedpick > span { display: none; position: absolute; left: 6px; top: 6px; padding: 1px 8px; border-radius: 9px; font: 600 12px/1.5 system-ui, sans-serif; white-space: nowrap; color: #000; background: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); pointer-events: none; }
.linkedpick.on { box-shadow: inset 0 0 0 2px var(--accent); }
.linkedpick.on > span { display: block; }
body.editing .linkedpick { display: none; }

.meters {
  display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; padding: 6px 12px; width: fit-content; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px; font-variant-numeric: tabular-nums;
}
.meters:has(.vals:empty) { display: none; }
.meters .vals { display: contents; }
.meters .view { align-self: center; }
.coinbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.coinbar small { color: var(--muted); margin-right: 4px; }
/* (Barcrest MPU6's LCD meter box, under the machine - app.js showLcdMeter. Its colours are a
   device's, the same in every theme: a generic backlit character LCD - the real unit's look isn't
   known) */
.lcdmeter { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.lcdmeter small { color: var(--muted); }
.lcdmeter .lcd {
  display: inline-flex; flex-direction: column; padding: 6px 10px; border-radius: 4px;
  background: #9fbf3a; border: 3px solid #2a2d26; box-shadow: inset 0 0 8px rgba(0, 40, 0, 0.45);
  font: 600 16px/1.15 ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace; color: #17240c;
  letter-spacing: 0.08em; max-width: 100%;
}
.lcdmeter .row { white-space: pre; }
.lcdmeter .row.pick { text-decoration: underline; text-underline-offset: 3px; }
.meters small { color: var(--muted); }
.meters b.neg { color: var(--bad); }

/* ---- settings panel */
.settings {
  flex: 0 0 330px; position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.settings section { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.settings section:last-child { border-bottom: 0; }
.settings h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.settings h3 { font-size: 13px; margin: 12px 0 6px; display: flex; align-items: center; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.row.tight { gap: 4px; margin: 0; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.field input[type='range'] { flex: 1; max-width: 170px; accent-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.switch input:disabled + span { opacity: 0.45; }
.note { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
pre {
  white-space: pre-wrap; word-break: break-word; margin: 0; padding: 8px; max-height: 260px; overflow: auto;
  font-size: 11px; background: var(--well); border: 1px solid var(--line); border-radius: 4px;
}

/* DIP switch banks, drawn like the real thing: switch 1 on the left, ON is up */
.dipbank { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.diplabel { width: 3.2em; font-size: 13px; }
.dipblock { display: flex; gap: 3px; padding: 4px 5px 2px; background: #b22; border-radius: 3px; }
.dip:has(input:disabled) { opacity: 0.45; cursor: default; }
.dip { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.dip input { position: absolute; opacity: 0; pointer-events: none; }
.dip .lever { width: 14px; height: 24px; background: #eee; border-radius: 2px; position: relative; }
.dip .lever::after {
  content: ''; position: absolute; left: 2px; right: 2px; height: 9px; bottom: 2px;
  background: #444; border-radius: 1px; transition: bottom 0.1s;
}
.dip input:checked + .lever::after { bottom: 13px; }
.dip input:focus-visible + .lever { outline: 2px solid var(--accent); }
.dip .num { font-size: 9px; line-height: 12px; color: #fff; }
.dipvalue { font-size: 12px; color: var(--muted); }
.dipvalue.changed { color: var(--warn); }

.multgrid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px 8px; align-items: center; margin: 6px 0; }
.multgrid input { width: 5.5em; }
.multgrid .head { color: var(--muted); font-size: 12px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.keys:not(:has(span)) { display: block; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 4px; text-align: center; font: 12px ui-monospace, monospace;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--kbd-line); border-bottom-width: 2px; border-radius: 3px;
}

/* ---- logos */
.logos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.logos a { display: inline-block; line-height: 0; border-radius: 6px; transition: transform 0.15s; }
.logos a:hover { transform: scale(1.04); }
.logos a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.logos img { height: 34px; width: auto; max-width: 100%; }

@media (max-width: 900px) {
  .workspace { flex-direction: column; }
  .settings { position: static; flex-basis: auto; width: 100%; max-height: none; }
}

/* notes shown only when a System 80 game is loaded */
.sys80-note { display: none; }
body[data-system='sys80'] .sys80-note { display: block; }

/* a toggled switch in the switch bar, and the Crop button while on */
.coinbar .btn.on, #cropToggle.on {
  background: var(--accent, #3c7);
  color: var(--on-fg);
}

/* ---- about box */
.about {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.about::backdrop { background: rgba(0, 0, 0, 0.6); }
.about form { padding: 18px 22px 20px; }
.about-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.about-logo { height: 72px; width: auto; }
.about-head > div { flex: 1; }
.about h2 { margin: 0; font-size: 26px; letter-spacing: 0.02em; }
.about h2 small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.about .tagline { margin: 2px 0 0; font-size: 13px; }
.about .copy { margin: 14px 0 4px; font-size: 14px; }
.about h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.about ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.55; }
.about .tech { width: 100%; border-collapse: collapse; font-size: 13px; }
.about .tech th { text-align: left; white-space: nowrap; padding: 5px 12px 5px 0; vertical-align: top; font-weight: 600; }
.about .tech td { padding: 5px 0; color: var(--muted); line-height: 1.4; }
.about .tech tr + tr th, .about .tech tr + tr td { border-top: 1px solid var(--line); }
.about em { color: var(--warn); font-style: normal; }
.about .note { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
@media (max-width: 480px) { .about .tech th { white-space: normal; } }

/* ---- layout notes (MFME 20's splash screen: its picture and the author's notes; MFME 2's notes) */
.notes { width: min(1000px, calc(100vw - 32px)); }
.notes-body { display: flex; gap: 18px; align-items: flex-start; margin-top: 14px; }
.notes-pic:empty { display: none; }
.notes-pic { flex: 0 1 auto; max-width: 50%; }
.notes-pic canvas { display: block; max-width: 100%; height: auto; border-radius: 4px; }
.notes-main { flex: 1 1 0; min-width: 0; }
.notes-info:has(tbody:empty) { display: none; }
.notes-info { margin-bottom: 12px; }
.notes-text {
  flex: 1 1 0; min-width: 0; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 13px/1.5 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; color: var(--text);
  max-height: none; overflow: visible; padding: 0; background: none; border: 0; border-radius: 0;
}
.notes { overflow: auto; }
.notes-text:empty { display: none; }
@media (max-width: 700px) {
  .notes-body { flex-direction: column; }
  .notes-pic { max-width: 100%; align-self: center; }
}

.stagerow { display: block; }

/* ---- reel bands (the Reels button): a floating, draggable window - not modal, so the machine
   can still be played (nudged) while it's open */
.reels-panel {
  position: fixed; top: 64px; right: 16px; z-index: 50; display: flex; flex-direction: column;
  max-height: calc(100vh - 80px); max-width: calc(100vw - 32px);
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.reels-panel[hidden] { display: none; }
.reels-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); cursor: move; user-select: none; touch-action: none;
}
.reels-head h2 { margin: 0; font-size: 14px; letter-spacing: 0.04em; }
.reels-strips { display: flex; gap: 10px; padding: 10px 12px 12px; overflow: auto; }
.reels-strip { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.reels-strip span { font-size: 12px; color: var(--muted); }
.reels-strip canvas { display: block; width: 72px; height: auto; border: 1px solid #000; border-radius: 3px; background: #fff; }

/* ---- the controls hidden (phones): the corner button (#bareToggle, app.js) hides everything but
   the machine, and brings it back */
#bareToggle {
  display: none; position: fixed; top: max(6px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right));
  z-index: 60; width: 34px; height: 34px; padding: 0; font-size: 18px; line-height: 1;
  color: var(--text); background: rgba(30, 30, 30, 0.55); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 50%;
  cursor: pointer; opacity: 0.6; -webkit-tap-highlight-color: transparent;
}
#bareToggle:hover, #bareToggle:focus-visible { opacity: 1; }
/* Full screen (app.js setFull): the machine alone on black, filling the screen - no top bar, meters, coin or
   switch rows, settings or reel bands; Escape (or the corner button on a touch screen) brings them back */
body.full { background: #000; overflow: hidden; }
body.full :is(.topbar, #meters, #coinBar, #switchBar, #settings, #reelsPanel, #bareToggle) { display: none !important; }
body.full .workspace { display: flex; align-items: center; justify-content: center; padding: 0; height: 100vh; height: 100dvh; }
body.full .play { flex: 0 0 auto; }
body.full #stage { border: 0; margin: 0; background: #000; }
#fullExit { display: none; position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); z-index: 50; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 18px; opacity: 0.35; cursor: pointer; }
#fullExit:hover, #fullExit:focus-visible { opacity: 1; }
@media (pointer: coarse) { body.full #fullExit { display: block; } }
@media (max-width: 900px), (pointer: coarse) { #bareToggle { display: block; } }
/* (from the start, before a game is loaded: the small buttons include Open files) */
/* (the meters kept, small, on one centred line under the buttons) */
body.bare .play > .meters { margin: 0; padding: 2px 4px; gap: 2px 7px; font-size: 10px; justify-content: center; align-items: center; width: 100%; border: 0; border-radius: 0; background: none; }
body.bare .meters .btn { padding: 0 5px; font-size: 10px; }
/* (the buttons kept, small: the top bar's on one thin row without the logos and game name, the coin
   and switch rows under the machine) */
body.bare .topbar { padding: 4px; display: grid; grid-template-columns: repeat(4, auto); justify-content: center; gap: 4px; min-height: 0; } /* (two rows: Open files, Reels, Notes, Sound / Crop, About, Settings) */
body.bare :is(.topbar .row, .loadbar) { display: contents; }
body.bare .topbar > :is(.brand, .gameinfo, .logos) { display: none !important; }
body.bare :is(.topbar, #coinBar, #switchBar) .btn { padding: 3px 7px; font-size: 12px; gap: 3px; border-radius: 4px; white-space: nowrap; justify-content: center; }
body.bare .topbar select { font-size: 11px; padding: 1px 4px; }
body.bare :is(#coinBar, #switchBar) { gap: 4px; margin-top: 4px; justify-content: center; }
body.bare :is(#coinBar, #switchBar) small { font-size: 11px; }
body.bare #bareToggle { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); } /* (the top row is the buttons' now) */
body.bare .workspace { display: block; padding: 0; } /* (the machine's column the full width, so Fit sizes it to the screen) */
body.bare #stage { border: 0; margin: 0 auto; }

/* ---- cropped (the Crop button): the machine centred in the window, its coin and switch rows under it */
body.cropped #stage { margin-left: auto; margin-right: auto; }
body.cropped :is(#coinBar, #switchBar) { justify-content: center; }

/* ---- the theme picker (Settings → Display; app.js applyTheme) */
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; margin: 4px 0 10px; padding: 0; border: 0; }
.themes legend { padding: 0; margin: 0 0 4px; }
.themes label { display: flex; align-items: center; gap: 6px; padding: 3px 5px; font-size: 13px; border-radius: 4px; cursor: pointer; }
.themes label:has(:checked) { background: var(--hover); box-shadow: inset 0 0 0 1px var(--accent); }
.themes input { margin: 0; accent-color: var(--accent); }
.themes .sw { flex: none; width: 14px; height: 14px; border: 1px solid var(--line); border-radius: 3px; background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%); }

/* ---- themes: data-theme on <html> (none = Dark, above). The colours first, then each theme's own
   buttons and frames. Never the machine itself (#stage stays black). html[data-lowpower] (app.js
   applyLowPower) drops the blurred shadows and transitions. */
html[data-theme='light'] {
  --bg: #eceff3; --panel: #fff; --panel-2: #f5f6f8; --line: #d3d8df; --text: #1b1f24; --muted: #57606b;
  --accent: #23783a; --warn: #9a5800; --bad: #c0282d;
  --btn-bg: #fff; --btn-line: #c8cfd8; --btn-hover: #fff; --btn-hover-line: #aab4c0; --field-bg: #fff; --well: #f6f7f9;
  --kbd-line: #b9c0ca; --hover: #e8edf3; --sel: #cfe2f8; --sel-line: #4a8fd0; --edit-line: #d9a79c; --ok-bg: #d4eed9;
  --warn-bg: #fff1d0; --info-bg: #e3edf7; --info: #0b5aa8; --good: #17734a; --hi: #94530a; --badge-fg: #fff; --on-fg: #fff;
  color-scheme: light; scrollbar-color: #b4bcc6 transparent;
}
html[data-theme='oled'] {
  --bg: #000; --panel: #000; --panel-2: #000; --line: #262626; --text: #b4b4b4; --muted: #808080;
  --accent: #46d26a; --warn: #c88a30; --bad: #e06464;
  --btn-bg: #000; --btn-line: #2f6b40; --btn-hover: #46d26a; --btn-hover-line: #46d26a; --field-bg: #000; --well: #000;
  --kbd-line: #333; --hover: #101010; --sel: #0c2a3e; --sel-line: #2e7fb8; --edit-line: #4a1e18; --ok-bg: #0f3018;
  --warn-bg: #241c06; --info-bg: #08141c; --info: #7cc0ec; --good: #5cc490; --hi: #e0b070; --badge-fg: #000; --on-fg: #000;
  color-scheme: dark; scrollbar-color: #2a2a2a #000;
}
html[data-theme='cabinet'] {
  --bg: #260404; --panel: #560b0b; --panel-2: #430808; --line: #9a6a1c; --text: #fcefd0; --muted: #e6c27e;
  --accent: #f2c230; --warn: #ffb24a; --bad: #ff9a8a;
  --btn-bg: #430808; --btn-line: #b08a2a; --btn-hover: #5e1010; --btn-hover-line: #f2c230; --field-bg: #2e0505; --well: #2a0404;
  --kbd-line: #b08a2a; --hover: #6e1414; --sel: #8a3010; --sel-line: #f2c230; --edit-line: #d4a52a; --ok-bg: #22501e;
  --warn-bg: #4a3008; --info-bg: #3a1010; --info: #a8dcff; --good: #a0eaa8; --hi: #ffd860; --badge-fg: #2a1400; --on-fg: #2a1400;
  color-scheme: dark; scrollbar-color: #c9a227 #3a0606;
}
html[data-theme='mfme'] {
  --bg: #c0c0c0; --panel: #c0c0c0; --panel-2: #c0c0c0; --line: #808080; --text: #000; --muted: #3c3c3c;
  --accent: #000080; --warn: #6a4000; --bad: #a00000;
  --btn-bg: #c0c0c0; --btn-line: #808080; --btn-hover: #c0c0c0; --btn-hover-line: #808080; --field-bg: #fff; --well: #fff;
  --kbd-line: #808080; --hover: #d6d6d6; --sel: #b9c8ef; --sel-line: #000080; --edit-line: #800000; --ok-bg: #a8d8a8;
  --warn-bg: #f2e2a8; --info-bg: #dde4f2; --info: #000080; --good: #005e00; --hi: #800000; --badge-fg: #fff; --on-fg: #fff;
  color-scheme: light; scrollbar-color: #c0c0c0 #e4e4e4;
  font-family: 'MS Sans Serif', 'Microsoft Sans Serif', Tahoma, Geneva, 'Segoe UI', sans-serif;
}
/* (the start-up message sits in the machine's black frame: on the theme's panel instead) */
html[data-theme] .empty { background: var(--panel); }

/* Light: soft raised pills that lift on hover */
html[data-theme='light'] :is(.btn, .editbar button, .editpalette button, .editprops button, .editlayers header button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt)) {
  border-radius: 999px; background-image: linear-gradient(#fff, #f2f4f7);
  box-shadow: 0 1px 2px rgba(20, 35, 60, 0.14), 0 2px 6px rgba(20, 35, 60, 0.07); transition: transform 0.12s, box-shadow 0.12s;
}
html[data-theme='light'] :is(.btn, .editbar button, .editpalette button, .editprops button, .editlayers header button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt, :disabled)):hover {
  transform: translateY(-1px); box-shadow: 0 3px 10px rgba(20, 35, 60, 0.18);
}
html[data-theme='light'] :is(.btn, .editbar button, .editpalette button, .editprops button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt)):active {
  transform: none; box-shadow: inset 0 1px 3px rgba(20, 35, 60, 0.2);
}
html[data-theme='light'] :is(.btn.on, button.on, button.ok, button.fix) { background-image: none; }
html[data-theme='light'] .topbar { box-shadow: 0 1px 4px rgba(20, 35, 60, 0.08); }
html[data-theme='light'] :is(.settings, .meters) { box-shadow: 0 1px 3px rgba(20, 35, 60, 0.06); }

/* OLED black: thin outlines in the accent colour with a faint glow, filled on hover */
html[data-theme='oled'] :is(.btn, .editbar button, .editpalette button, .editprops button, .editlayers header button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt, .on, .ok, .fix)) {
  color: var(--accent); background: transparent; border-color: rgba(70, 210, 106, 0.6); border-radius: 3px;
  box-shadow: 0 0 6px rgba(70, 210, 106, 0.28); transition: background-color 0.15s, color 0.15s;
}
html[data-theme='oled'] :is(.btn, .editbar button, .editpalette button, .editprops button, .editlayers header button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt, .on, .ok, .fix, :disabled)):hover {
  color: #000; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px rgba(70, 210, 106, 0.55);
}
html[data-theme='oled'] .btn:where(:not(:disabled)):active { background: #2c9a4a; }
html[data-theme='oled'] .settings h2 { color: #6a6a6a; }

/* Classic cabinet: chunky glossy gold push buttons (chrome for the small ones), pressed in */
html[data-theme='cabinet'] .btn:where(:not(.small, .on)) {
  color: #3a1d00; font-weight: 700; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  background: linear-gradient(#fff6c8, #f7d25a 42%, #dca21c 58%, #c08410); border: 1px solid #6a4400; border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 3px 0 #5a3600, 0 5px 8px rgba(0, 0, 0, 0.45);
}
html[data-theme='cabinet'] .btn:where(:not(.small, .on, :disabled)):hover {
  background: linear-gradient(#fffbe2, #fbdc72 42%, #e6b02a 58%, #c88c14); border-color: #6a4400;
}
html[data-theme='cabinet'] :is(.btn.small, .editbar button, .editpalette button, .editprops button, .editlayers header button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt, .on, .ok, .fix)) {
  color: #1c1c1c; text-shadow: 0 1px 0 #fff; border: 1px solid #4a4a4a; border-radius: 6px;
  background: linear-gradient(#fff, #d8d8d8 45%, #a9a9a9 55%, #e6e6e6);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #2a0000;
}
html[data-theme='cabinet'] :is(.btn.small, .editbar button, .editpalette button, .editprops button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt, .on, .ok, .fix, :disabled)):hover {
  background: linear-gradient(#fff, #e6e6e6 45%, #bcbcbc 55%, #f2f2f2); border-color: #4a4a4a;
}
html[data-theme='cabinet'] :is(.btn, .editbar button, .editpalette button, .editprops button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt, .on, :disabled)):active {
  transform: translateY(2px); box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
  background: linear-gradient(#b07a08, #d49c1a 50%, #ecc040);
}
html[data-theme='cabinet'] :is(.btn.small, .editbar button, .editpalette button, .editprops button, .editdlg button, .edtool button, .circuit-ed button, .iomon button):where(:not(.x, .link, .opt, .on, :disabled)):active {
  background: linear-gradient(#9a9a9a, #c4c4c4 50%, #e0e0e0);
}
html[data-theme='cabinet'] .topbar { background: linear-gradient(#741010, #4a0707); border-bottom: 3px solid #d4a52a; }
html[data-theme='cabinet'] .settings { border: 2px solid #b08a2a; }
html[data-theme='cabinet'] a { color: var(--info); }
html[data-theme='cabinet'] :is(.settings h2, .about h3, details summary) { color: var(--accent); }

/* MFME classic: Windows 98 - grey faces, bevelled 3D edges, navy title bars */
html[data-theme='mfme'] :is(.btn, .editbar button, .editpalette button, .editprops button, .editlayers header button, .editdlg button, .edtool button, .circuit-ed button, .iomon button, .reels-head .btn):where(:not(.x, .link, .opt)) {
  color: #000; background: #c0c0c0; border: 0; border-radius: 0;
  box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
}
html[data-theme='mfme'] :is(.btn, button):where(:not(.x, .link, .opt, :disabled)):is(:active, .on) {
  box-shadow: inset 1px 1px #0a0a0a, inset -1px -1px #fff, inset 2px 2px #808080, inset -2px -2px #dfdfdf;
}
html[data-theme='mfme'] :is(.btn, button):where(:not(.x, .link, .opt)).on { background: #dcdcdc; color: #000; }
html[data-theme='mfme'] :is(.btn, button):focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
html[data-theme='mfme'] :is(select, input[type='number'], input:not([type]), input[type='text'], textarea, .edtool input, .edtool textarea) {
  color: #000; background: #fff; border: 0; border-radius: 0;
  box-shadow: inset 1px 1px #808080, inset -1px -1px #fff, inset 2px 2px #0a0a0a, inset -2px -2px #dfdfdf;
}
html[data-theme='mfme'] :is(.settings, .meters, .about, .reels-panel, .editprops, .editlayers, .editdlg, .edtool, .editbar, .editpalette, .editinspector, .iomon, .circuit-ed, .zoomlist, .reloadbar) {
  border: 1px solid; border-color: #dfdfdf #0a0a0a #0a0a0a #dfdfdf; border-radius: 0;
  box-shadow: inset 1px 1px #fff, inset -1px -1px #808080;
}
html[data-theme='mfme'] .settings h2 {
  margin: -12px -14px 10px; padding: 3px 8px; font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: none;
  color: #fff; background: linear-gradient(90deg, #000080, #1084d0);
}
html[data-theme='mfme'] .settings section { border-bottom-color: #808080; box-shadow: 0 1px #fff; }
html[data-theme='mfme'] :is(.reels-head, .edtool > header, .editlayers header) {
  color: #fff; background: linear-gradient(90deg, #000080, #1084d0); border-bottom: 0;
}
html[data-theme='mfme'] .edtool .x { color: #fff; }
html[data-theme='mfme'] .topbar { border-bottom: 1px solid #808080; box-shadow: 0 1px #fff; }
html[data-theme='mfme'] .topbar::before {
  content: 'JFruit'; flex: 0 0 calc(100% + 32px); order: -1; margin: -4px -16px 0; padding: 3px 8px;
  font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(90deg, #000080, #1084d0);
}
html[data-theme='mfme'] body.bare .topbar::before { display: none; }
html[data-theme='mfme'] :is(.badge, kbd, .about) { border-radius: 0; }
html[data-theme='mfme'] .about::backdrop { background: rgba(0, 0, 0, 0.3); }

/* Low-power mode: no blurred shadows or transitions (the solid edges and bevels are cheap) */
html[data-lowpower][data-theme] :is(.btn, button, .topbar, .settings, .meters) { transition: none !important; }
html[data-lowpower][data-theme='light'] :is(.btn, button, .topbar, .settings, .meters) { box-shadow: none !important; transform: none !important; }
html[data-lowpower][data-theme='oled'] :is(.btn, button) { box-shadow: none !important; }
html[data-lowpower][data-theme='cabinet'] .btn:where(:not(.small, .on, :active)) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 3px 0 #5a3600; }

/* the Brightness slider: vertical swipes over it scroll Settings (app.js: only a sideways drag from its knob moves it) */
#brightness {
  touch-action: pan-y;
}
