/* Same palette as the Windows app (Windows 11 style). Light and dark follow the system unless the
   Theme switch in the top bar sets data-theme on <html>. */
:root {
  --bg: #f3f3f3; --card: #fff; --card-stroke: #e5e5e5; --text: #1b1b1b; --text2: #616161;
  --control: #fbfbfb; --control-hover: #f5f5f5; --control-stroke: #ddd; --track: #8a8a8a; --stage: #e9e9e9;
  --accent: #c27c00; --accent-soft: #c27c001c; --on-accent: #fff;
  color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #202020; --card: #2b2b2b; --card-stroke: #1d1d1d; --text: #fff; --text2: #a8a8a8;
    --control: #373737; --control-hover: #3e3e3e; --control-stroke: #454545; --track: #6e6e6e; --stage: #3a3a3a;
    --accent: #f0b53c; --accent-soft: #f0b53c30; --on-accent: #000;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #202020; --card: #2b2b2b; --card-stroke: #1d1d1d; --text: #fff; --text2: #a8a8a8;
    --control: #373737; --control-hover: #3e3e3e; --control-stroke: #454545; --track: #6e6e6e; --stage: #3a3a3a;
    --accent: #f0b53c; --accent-soft: #f0b53c30; --on-accent: #000;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
a { color: var(--accent); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
.top nav { display: flex; gap: 4px; }
.top nav a { color: var(--text); text-decoration: none; padding: 6px 12px; border-radius: 6px; position: relative; }
.top nav a:hover { background: var(--control-hover); }
.top nav a.on { background: var(--control); box-shadow: inset 0 0 0 1px var(--card-stroke); }
.top nav a.on::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--accent); }
.theme { margin-left: auto; display: flex; gap: 2px; padding: 2px; border-radius: 8px; border: 1px solid var(--card-stroke); background: var(--card); }
.theme button { font: inherit; font-size: 13px; color: var(--text2); background: none; border: 0; border-radius: 6px; padding: 4px 10px; cursor: pointer;
  display: flex; align-items: center; gap: 6px; }
.theme svg { width: 16px; height: 16px; }
.theme button:hover { color: var(--text); background: var(--control-hover); }
.theme button[aria-pressed="true"] { color: var(--text); background: var(--control); box-shadow: inset 0 0 0 1px var(--accent); }
.theme button:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.notice { grid-column: 1 / -1; margin: 0; padding: 10px 16px; border-radius: 8px; background: var(--accent-soft); font-size: 14px; }
.view { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 24px; padding: 8px 24px 32px; max-width: 1280px; margin: 0 auto; }
#about { display: flex; flex-direction: column; gap: 16px; }
.controls { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--card-stroke); border-radius: 8px; padding: 18px 20px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 400; color: var(--text2); margin: 16px 0 8px; }
.prose h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.hint { color: var(--text2); font-size: 13px; margin: 8px 0 0; }

.devices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.devices button, .fw, .chips button, .btn, .primary {
  font: inherit; color: var(--text); background: var(--control); border: 1px solid var(--control-stroke);
  border-radius: 6px; cursor: pointer; text-align: left;
}
.devices button { padding: 10px 14px; }
.devices button span, .fw span { display: block; font-size: 12.5px; color: var(--text2); }
.devices button:hover, .fw:hover, .chips button:hover, .btn:hover { background: var(--control-hover); }
.devices button.on, .chips button.on { border: 2px solid var(--accent); background: var(--accent-soft); padding: 9px 13px; }
.devices button.off { opacity: .55; }
.firmwares { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.fw { display: flex; align-items: center; gap: 10px; padding: 9px 14px; width: 100%; }
.fw div { flex: 1; min-width: 0; }
.fw.on { background: var(--accent-soft); border-color: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.fw.off { opacity: .55; }
.badge { font-size: 12px; color: var(--text2); border: 1px solid var(--control-stroke); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { padding: 5px 12px; }
.chips button.on { padding: 4px 11px; }

.rows { padding: 0; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; }
.row + .row { border-top: 1px solid var(--card-stroke); }
.row label { flex: 1; display: flex; flex-direction: column; }
.row label span { font-size: 12.5px; color: var(--text2); }
.row b { font-weight: 400; }
input[type=range] { accent-color: var(--accent); width: 150px; }
output { min-width: 44px; text-align: right; }
.switch { appearance: none; width: 40px; height: 20px; border-radius: 10px; border: 1px solid var(--track); position: relative; cursor: pointer; margin: 0; }
.switch::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; top: 3px; left: 4px; background: var(--track); transition: left .15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { left: 22px; background: var(--on-accent); }

.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; cursor: default; pointer-events: none; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 26px;
  background: var(--accent); color: var(--on-accent); border: none; font-weight: 600; }
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: .5; cursor: default; }

.stagecol { min-width: 0; }
.stage { background: var(--stage); border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 20px; min-height: 420px; height: min(82vh, 1060px); position: relative; }
.stage img, .stage canvas { max-width: 100%; max-height: 100%; width: auto !important; height: auto !important; outline: none; }
.stage img { opacity: .9; }
/* touch devices: a finger on the reader presses its keys and screen, never scrolls, zooms or opens the
   long-press menu (holding is how a word is selected) */
.stage canvas { touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; }
.loading { position: absolute; inset: auto 0 24px; display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--text2); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--track); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.startbar { display: flex; align-items: center; gap: 16px; justify-content: space-between; margin-top: 14px; }
.startbar .title { font-size: 22px; font-weight: 600; }
.guide { grid-column: 1 / -1; padding: 22px 24px 18px; }
.guide-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 16px; }
.guide-head h2 { margin: 0; font-size: 20px; }
.guide-head .hint { margin: 0; font-size: 14px; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; }
.panel { background: var(--bg); border: 1px solid var(--card-stroke); border-radius: 10px; padding: 16px 18px; }
.panel h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 15.5px; font-weight: 600; color: var(--text); }
.panel h3 svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.panel h3 .badge { margin-left: auto; font-weight: 400; }
.ctl { list-style: none; margin: 0; padding: 0; }
.ctl li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; font-size: 15px; }
.ctl li + li { border-top: 1px solid var(--card-stroke); }
.ctl .how { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text); flex-wrap: wrap; }
.ctl .how + span { color: var(--text2); text-align: right; }
.ctl .g { display: inline-grid; place-items: center; min-width: 26px; height: 26px; margin-right: 6px; padding: 0 4px; border-radius: 13px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; }
kbd { display: inline-block; min-width: 26px; padding: 2px 7px; border: 1px solid var(--control-stroke); border-bottom-width: 2px;
  border-radius: 6px; background: var(--card); font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.4;
  text-align: center; color: var(--text); }
.ctl .older { opacity: .75; }
.touchrows .how { flex-wrap: nowrap; }
.ctl .g { flex: none; }
.panel h4 { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.models { margin: 0; display: grid; gap: 10px; }
.models dt { font-size: 14px; font-weight: 600; }
.models dd { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.panel > .hint { margin-top: 10px; font-size: 12.5px; }
.gestures { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--card-stroke); }
.chipbtn { font: inherit; font-size: 18px; font-weight: 600; min-width: 48px; height: 44px; border-radius: 22px; cursor: pointer;
  background: var(--card); color: var(--text); border: 1px solid var(--control-stroke); touch-action: manipulation; }
.chipbtn.wide { font-size: 15px; padding: 0 18px; }
.chipbtn:hover { background: var(--accent-soft); border-color: var(--accent); }
.chipbtn:active { transform: scale(.96); }
.tip { margin: 14px 0 0; padding: 12px 14px; border-radius: 8px; background: var(--accent-soft); font-size: 14px; line-height: 1.5; }
@media (hover: none) and (pointer: coarse) { .kbd-panel { display: none; } }
@media (max-width: 560px) { .guide { padding: 18px 16px; } .ctl li { font-size: 14.5px; } }
.social { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 18px; text-decoration: none;
  color: var(--text); background: var(--control); border: 1px solid var(--control-stroke); font-weight: 600; font-size: 14px; }
.social:hover { background: var(--accent-soft); border-color: var(--accent); }
.social svg { width: 18px; height: 18px; fill: currentColor; }
/* About */
.about-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: center; padding: 28px 32px; }
.eyebrow { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.about-hero h1 { margin: 0 0 10px; font-size: 32px; line-height: 1.15; letter-spacing: -.01em; }
.lead { margin: 0; max-width: 62ch; font-size: 16px; line-height: 1.55; color: var(--text2); }
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 18px; color: var(--text2); font-size: 14px; }
.stats b { font-size: 22px; color: var(--text); margin-right: 2px; }
.maker { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px 20px; min-width: 240px;
  background: var(--bg); border: 1px solid var(--card-stroke); border-radius: 10px; }
.maker-label { font-size: 12.5px; color: var(--text2); }
.maker-name { font-size: 18px; }
.maker-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.source { font-size: 13.5px; text-decoration: none; }
.source:hover { text-decoration: underline; }
.about-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
.about-col { display: flex; flex-direction: column; gap: 16px; }
.about-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; }
.about-head h2 { margin: 0; }
.about-head .hint { margin: 0; }
.fwlist { list-style: none; margin: 0; padding: 0; }
.fwlist li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 0; border-top: 1px solid var(--card-stroke); }
.fwlist li:first-child { border-top: 0; }
.fw-main a { font-weight: 600; font-size: 15.5px; text-decoration: none; color: var(--text); }
.fw-main a:hover { color: var(--accent); }
.fw-by { display: block; font-size: 13px; color: var(--text2); margin-top: 2px; }
.fw-meta { display: flex; align-items: center; gap: 10px; grid-row: 1; grid-column: 2; }
.fw-lic { font-size: 13px; }
.fw-versions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.vchip { font-size: 12.5px; padding: 2px 9px; border-radius: 10px; background: var(--accent-soft); color: var(--text); }
.lic { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px; margin-left: 2px;
  border: 1px solid var(--control-stroke); color: var(--text2); text-decoration: none; vertical-align: 1px; }
.info h2 { display: flex; align-items: center; gap: 10px; }
.info h2 svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.info p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--text2); }
.info p b { color: var(--text); }
.parts { margin: 0; }
.parts dt { font-size: 12.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--text2); margin-top: 14px; }
.parts dt:first-child { margin-top: 4px; }
.parts dd { margin: 4px 0 0; font-size: 14.5px; line-height: 1.5; }
.about-inside > .hint { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--card-stroke); }
@media (max-width: 1100px) { .about-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .about-firmwares { grid-column: 1 / -1; } }
@media (max-width: 720px) {
  .about-hero { grid-template-columns: minmax(0, 1fr); padding: 22px 18px; }
  .about-hero h1 { font-size: 26px; }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
}
.prose ul { padding-left: 20px; }
.prose li { margin: 4px 0; }

.realrow { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.realrow label { flex: 1; display: flex; flex-direction: column; }
.realrow label span { font-size: 12.5px; color: var(--text2); }
.realrow b { font-weight: 400; }
.linkbtn { font: inherit; font-size: 13px; color: var(--accent); background: none; border: none; padding: 4px; cursor: pointer; text-decoration: underline; }
/* Real size: the picture gets its true width (set by app.js); a reader wider than the screen scrolls. */
.stage.real { height: auto; min-height: 0; max-height: none; aspect-ratio: auto; overflow: auto; justify-content: safe center; }
.stage.real img, .stage.real canvas { width: var(--real-w) !important; max-width: none; max-height: none; flex: none; }
dialog { background: var(--card); color: var(--text); border: 1px solid var(--card-stroke); border-radius: 8px; padding: 18px 20px; max-width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: #0006; }
.cardwrap { display: flex; justify-content: center; margin: 16px 0; padding: 0 0 22px 0; overflow: hidden; }
/* a bank card drawn at the size being tried, with its fixed real size written on it */
#cardBox { flex: none; position: relative; box-sizing: border-box; border: 2px solid var(--accent); background: var(--accent-soft); }
#cardBox .chip { position: absolute; left: 22%; top: 14%; width: 22%; height: 11%; border-radius: 15%; border: 1px solid var(--accent); }
#cardBox span { position: absolute; font-size: 12px; color: var(--text2); white-space: nowrap; }
#cardBox .w { left: 0; right: 0; bottom: -20px; text-align: center; }
#cardBox .h { top: 50%; right: 6px; transform: translateY(-50%) rotate(90deg); transform-origin: center; }
.measurebar { display: flex; align-items: center; gap: 8px; }
.measurebar input { flex: 1; width: auto; }
@media (max-width: 900px) {
  .top { padding: 10px 16px; gap: 12px; }
  .theme button { padding: 6px; }
  .theme button span { display: none; }  /* icons only on phones; aria-label keeps the names */
  .view { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 24px; gap: 16px; }
  .stagecol { order: -1; }
  .notice { order: -2; }
  .stage { height: auto; min-height: 0; aspect-ratio: 3 / 4.6; max-height: 78vh; padding: 10px; margin: 0 auto; }
  .stage.real { aspect-ratio: auto; max-height: none; padding: 4px; }
  .devices button { padding: 8px 10px; }
  .devices button.on { padding: 7px 9px; }
  input[type=range] { width: 110px; }
}

/* SD card browser */
.sd { margin-top: 12px; border: 1px solid var(--control-stroke); border-radius: 8px; overflow: hidden; }
.sd-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; background: var(--control); border-bottom: 1px solid var(--control-stroke); }
.sd-path { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-path button { background: none; border: none; padding: 2px 3px; color: var(--accent); font: inherit; cursor: pointer; }
.sd-path span { color: var(--text2); }
.sd-tools { display: flex; gap: 2px; flex: none; }
.iconbtn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; border: none; background: none; color: var(--text); cursor: pointer; }
.iconbtn:hover { background: var(--control-hover); }
.iconbtn:disabled, .iconbtn[aria-disabled=true] { opacity: .4; pointer-events: none; }
.iconbtn svg, .sd-list svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sd-list { list-style: none; margin: 0; padding: 4px 0; max-height: 260px; overflow-y: auto; }
.sd-list li { display: flex; align-items: center; gap: 10px; padding: 3px 6px 3px 12px; font-size: 13.5px; }
.sd-list li:hover { background: var(--control-hover); }
.sd-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: none; padding: 4px 0; text-align: left; color: var(--text); font: inherit; cursor: default; }
.sd-list .dir .name { cursor: pointer; font-weight: 600; }
.sd-list .hidden .name { color: var(--text2); }
.sd-list .size { color: var(--text2); font-size: 12px; flex: none; }
.sd-list .kind { color: var(--text2); flex: none; display: grid; }
.sd-list .iconbtn { width: 28px; height: 28px; }
.sd-empty { color: var(--text2); padding: 14px 12px !important; }
.sd.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* support link: Buy Me a Coffee's own button picture; if it cannot load, a button in its usual yellow */
.bmc { display: inline-block; margin: 2px 0 4px; line-height: 0; border-radius: 10px; text-decoration: none; }
.bmc-img { height: 44px; width: auto; display: block; }
.bmc-text { display: none; }
.bmc.fallback .bmc-img { display: none; }
.bmc.fallback .bmc-text { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 10px; line-height: normal;
  background: #ffdd00; color: #000; font-weight: 600; font-size: 14px; box-shadow: 0 1px 2px #0002; }
.bmc:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bmc svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 480px) {  /* phones: brand, Simulator / About and the theme icons fit on one line */
  .top { gap: 8px; }
  .top nav a { padding: 6px 8px; }
  .theme button { padding: 4px; }
}
