﻿/* Stage A: neutral harness. Grayscale, system font, no retro styling.
   Contrast: ink #000 on #fff (21:1); secondary #444 (9.7:1); disabled #767676 (4.5:1). */
:root {
  --ink: #000;
  --paper: #fff;
  --mid: #444;
  --dis: #767676;
  --soft: #f0f0f0;
  --harness: #e9e9e9;
  --gut: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--paper); color: var(--ink);
  font: 17px/1.25 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body, button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, input { font: inherit; color: inherit; }
button {
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 10px;
  min-height: 44px; min-width: 44px; padding: 0 8px; margin: 0; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
button:disabled { color: var(--dis); border-color: var(--dis); border-style: dashed; }
input { -webkit-user-select: text; user-select: text; }
b { font-weight: 700; }

#app {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- harness chrome (not counted) ---------- */
.hbar {
  flex: none; display: flex; gap: 4px; padding: 4px 8px; background: var(--harness);
  border-bottom: 2px dashed var(--mid);
}
.hb { font-size: 14px; border-width: 1px; border-radius: 8px; padding: 0 10px; background: var(--paper); }
.hb.on { background: var(--ink); color: var(--paper); }
.hb-grid { flex: 1; }
.banner {
  flex: none; height: 60px; display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 12px; background: var(--harness); font-size: 13px; line-height: 1.25;
}
.banner .bt { flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.banner.run { background: #d6d6d6; }
.hsheet {
  position: fixed; inset: 0; z-index: 50; background: #f7f7f7; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hhead { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-bottom: 2px solid var(--ink); }
.hhead b { flex: 1; text-align: center; font-size: 16px; }
.hbody { flex: 1; overflow-y: auto; padding: 12px var(--gut) 24px; -webkit-overflow-scrolling: touch; }
.hrow { display: block; width: 100%; text-align: left; padding: 8px 12px; margin: 0 0 8px; min-height: 56px; border-width: 1px; }
.hrow span { display: block; font-size: 13px; color: var(--mid); margin-top: 2px; }
.hbig { display: block; width: 100%; min-height: 56px; margin: 12px 0; background: var(--ink); color: var(--paper); font-weight: 700; }
.hbig:disabled { background: var(--paper); }
.hmeta { font-size: 14px; color: var(--mid); margin: 8px 0; display: block; }
.htask { font-size: 20px; line-height: 1.3; margin: 8px 0 12px; }
.hnote { font-size: 13px; color: var(--mid); }
.hwarn { font-size: 15px; font-weight: 700; }
.hinput { width: 100%; min-height: 48px; font-size: 17px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 10px; margin: 4px 0 16px; }
.hscroll { overflow-x: auto; }
.ht { border-collapse: collapse; font-size: 14px; width: 100%; margin: 8px 0; font-variant-numeric: tabular-nums; }
.ht th, .ht td { border-bottom: 1px solid #bbb; padding: 6px 4px; text-align: left; vertical-align: top; }

/* ---------- app area ---------- */
.main { flex: 1; min-height: 0; position: relative; display: flex; overflow: hidden; }
.v { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 var(--gut); }
.ex-name { font-size: 24px; font-weight: 700; line-height: 1.15; }
.ex-meta { font-size: 14px; color: var(--mid); margin-top: 2px; }
.empty { margin: auto 0 24px; text-align: center; }
.big { width: 100%; min-height: 56px; font-weight: 700; }

/* ---------- shared control panel (V2/V3) ---------- */
.panel { flex: none; display: grid; gap: 8px; padding: 8px 0; }
.p-sec { height: 48px; display: grid; grid-template-columns: 110px 1fr 150px; gap: 8px; align-items: center; }
.p-sec .sec { height: 48px; font-size: 15px; }
.p-label { text-align: center; font-size: 15px; font-weight: 700; }
.p-ro { height: 64px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 10px; }
.ro { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 4px; }
.pm { height: 64px; font-size: 28px; padding: 0; position: relative; }
.ro-val { height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 2px; line-height: 1; }
.ro-val b { font-size: 30px; font-variant-numeric: tabular-nums; }
.ro-val small { font-size: 12px; color: var(--mid); margin-top: 4px; white-space: nowrap; }
.ro-val.active { background: var(--ink); color: var(--paper); }
.ro-val.active small { color: var(--paper); }
.p-swap { height: 196px; }
.chips { height: 52px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.chip { height: 52px; font-size: 18px; padding: 0; }
.chip.on { background: var(--ink); color: var(--paper); }
.chip-empty { display: block; }
.chips-none { display: flex; align-items: center; font-size: 14px; color: var(--mid); grid-template-columns: none; }
.grid { height: 136px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: 64px 64px; gap: 8px; }
.rep { font-size: 26px; position: relative; padding: 0; }
.rep.on { background: var(--ink); color: var(--paper); }
.tmark {
  position: absolute; top: 3px; right: 5px; font-size: 11px; font-style: normal; font-weight: 700;
  line-height: 1; padding: 2px 3px; border: 1px solid currentColor; border-radius: 3px;
}
.pm .tmark { top: 2px; right: 2px; font-size: 10px; }
.log { width: 100%; height: 64px; background: var(--ink); color: var(--paper); font-size: 22px; font-weight: 700; }
.log:disabled { background: var(--paper); }

/* ---------- pad ---------- */
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pad-grid { height: 196px; grid-template-rows: repeat(4, 1fr); }
.key { font-size: 24px; padding: 0; min-height: 44px; }
.key-fn { background: var(--soft); }
.key-wide { grid-column: span 4; font-size: 17px; font-weight: 700; background: var(--soft); }
.key-half { grid-column: span 2; font-size: 17px; font-weight: 700; background: var(--soft); }
.pad-sheet { grid-template-rows: repeat(4, 56px); gap: 6px; }
.padsheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--paper);
  border-top: 2px solid var(--ink); padding: 8px var(--gut) 8px;
}
.padsheet-head { height: 36px; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.padsheet-head b { font-size: 24px; }

/* ---------- V2 ---------- */
.v2-info { flex: none; padding-top: 10px; }
.setline { margin-top: 8px; }
.inset { display: flex; flex-wrap: wrap; gap: 4px 16px; border: 2px solid var(--ink); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.strip { flex: none; height: 52px; margin-top: 10px; display: flex; gap: 8px; align-items: center; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip-chip { flex: none; height: 44px; font-size: 16px; padding: 0 12px; }
.strip-chip small { font-size: 12px; color: var(--mid); }
.strip-chip.editing { background: var(--ink); color: var(--paper); }
.strip-chip.editing small { color: var(--paper); }
.strip-empty { font-size: 14px; color: var(--mid); }
.fill { flex: 1; min-height: 0; }

/* ---------- V3 (and collapsed exercises in V1) ---------- */
.v3-top { flex: 1; min-height: 0; overflow-y: auto; padding-top: 8px; -webkit-overflow-scrolling: touch; }
.v3-done { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 6px; min-height: 44px; border-width: 1px; font-size: 14px; text-align: left; }
.v3-done span { color: var(--mid); font-size: 13px; text-align: right; }
.v3-head { margin: 6px 0 8px; }
.v3-row {
  width: 100%; min-height: 48px; display: grid; grid-template-columns: 36px auto 1fr; align-items: center; gap: 8px;
  border: 2px solid transparent; border-radius: 10px; padding: 0 10px; margin: 0 0 6px; text-align: left; font-size: 18px;
}
.v3-row .pos { font-size: 14px; font-weight: 700; }
.v3-row .st { font-size: 12px; text-align: right; color: var(--mid); }
.v3-row.logged { border: 1px solid var(--ink); }
.v3-row.active, .v3-row.editing { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.v3-row.active .st, .v3-row.editing .st { color: var(--paper); }
.v3-row.upcoming { border: 1px dashed var(--dis); color: var(--mid); }

/* ---------- V1 ---------- */
.v1-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-top: 8px; -webkit-overflow-scrolling: touch; }
.v1-head { margin: 4px 0 8px; }
.v1-row { height: 132px; border: 2px dashed var(--dis); border-radius: 12px; padding: 8px; margin: 0 0 8px; }
.v1-row.next { border: 2px solid var(--ink); }
.v1-row.editing { border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.v1-top { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.v1-top .pos { font-weight: 700; font-size: 15px; width: 28px; }
.v1-top .hint { flex: 1; font-size: 12px; color: var(--mid); line-height: 1.2; }
.v1-log { width: auto; min-width: 150px; height: 48px; font-size: 17px; }
.v1-top .sec { height: 48px; font-size: 14px; }
.v1-ctl { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px 44px minmax(0, 0.75fr) 44px; gap: 4px; margin-top: 6px; }
.v1-ctl .pm, .v1-ctl .ro-val { height: 56px; }
.v1-ctl .ro-val b { font-size: 24px; }
.v1-logged { width: 100%; height: 132px; display: grid; grid-template-columns: 36px auto 1fr; align-items: center; gap: 8px; margin: 0 0 8px; border-width: 1px; text-align: left; font-size: 18px; }
.v1-logged .pos { font-size: 14px; font-weight: 700; }
.v1-logged .st { font-size: 12px; color: var(--mid); text-align: right; }
.add { width: 100%; min-height: 48px; border-style: dashed; margin: 0 0 16px; }
.v1-bar { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 0; }
.v1-bar .sec { height: 56px; }

/* ---------- sheets (picker, new machine) ---------- */
.sheet-backdrop { position: absolute; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.35); }
.sheet-backdrop.light { background: rgba(0, 0, 0, 0.12); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; top: 10%; z-index: 30; background: var(--paper);
  border-top: 2px solid var(--ink); border-radius: 14px 14px 0 0; display: flex; flex-direction: column; padding: 0 var(--gut) 8px;
}
.sheet-head { flex: none; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head b { flex: 1; text-align: center; }
.sheet-head .sec { font-size: 15px; height: 44px; }
.sec-sp { width: 64px; }
.search { flex: none; width: 100%; height: 48px; font-size: 17px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 10px; }
.list { flex: 1; min-height: 0; overflow-y: auto; margin: 8px 0; -webkit-overflow-scrolling: touch; }
.row { width: 100%; min-height: 60px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; border-width: 1px; margin: 0 0 6px; padding: 6px 12px; }
.row-name { font-size: 18px; font-weight: 700; }
.row-meta { font-size: 13px; color: var(--mid); }
.row-meta em { font-style: normal; font-weight: 700; color: var(--ink); }
.none { color: var(--mid); font-size: 15px; }
.sheet-foot { flex: none; }
.form { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 8px; }
.fl { display: block; font-size: 13px; color: var(--mid); margin: 12px 0 6px; }
.req, .opt { font-weight: 700; color: var(--ink); }
.opt { font-weight: 400; }
.cg { display: flex; flex-wrap: wrap; gap: 8px; }
.cg .chip { height: 44px; font-size: 15px; padding: 0 12px; }
