/* labmate.tools — Plate Tracker (1.1) */
:root {
  --paper: #F2EDDF;
  --card: #FAF7EE;
  --ink: #1B2224;
  --muted: #4A5655;
  --teal: #17403D;
  --pass: #2E9E5B;
  --pass-dark: #1F7A45;
  --mint: #9CC7B6;
  --skip-line: #8F897A;
  --serif: "IBM Plex Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --top: 56px;
  --side: 352px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--ink); }
a:hover { color: var(--teal); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }

.pt-mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; }
.pt-muted { color: var(--muted); }

/* ---------- top bar ---------- */
.pt-top {
  position: sticky; top: 0; z-index: 20;
  height: var(--top);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  font-family: var(--mono); font-size: 13px;
}
.pt-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.pt-word { font-family: var(--serif); font-weight: 600; font-size: 20px; color: var(--teal); display: flex; align-items: center; gap: 3px; }
.pt-word i { width: 6px; height: 6px; border-radius: 50%; background: var(--pass); display: inline-block; }
.pt-crumb { color: var(--muted); letter-spacing: 0.08em; white-space: nowrap; }
.pt-spacer { flex: 1; }
.pt-saved { display: flex; align-items: center; gap: 6px; font-size: 12px; letter-spacing: 0.06em; color: var(--pass-dark); white-space: nowrap; }
.pt-saved.is-off { color: var(--muted); }
.pt-saved svg { flex-shrink: 0; }
.pt-plate-name input {
  width: 120px; height: 40px; padding: 0 8px;
  border: 1.5px solid transparent; background: transparent;
  font-family: var(--mono); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em;
}
.pt-plate-name input:hover, .pt-plate-name input:focus { border-color: var(--ink); background: var(--card); outline: none; }

.pt-link {
  height: 40px; padding: 0 8px; border: 0; background: transparent;
  font-family: var(--mono); font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
.pt-link.is-armed { background: var(--ink); color: var(--paper); text-decoration: none; padding: 0 12px; }

/* segmented controls */
.pt-seg { display: flex; }
.pt-seg button {
  min-width: 52px; height: 40px; padding: 0 10px;
  border: 1.5px solid var(--ink); background: transparent;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em;
}
.pt-seg button + button { border-left: 0; }
.pt-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.pt-seg-wide button { flex: 1 1 0; min-width: 0; height: 44px; font-size: 12px; }

/* ---------- app grid ---------- */
.pt-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "stage panels" "stage actions";
  height: calc(100vh - var(--top));
  height: calc(100dvh - var(--top));
  min-height: 560px;
}
.pt-stage { grid-area: stage; padding: 18px 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.pt-panels {
  grid-area: panels;
  border-left: 2px solid var(--ink);
  padding: 16px 20px 8px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; min-height: 0;
}
.pt-actions {
  grid-area: actions;
  border-left: 2px solid var(--ink);
  padding: 8px 20px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 96px 1fr; gap: 10px;
  background: var(--paper);
}
.pt-next-round { grid-column: 1 / -1; }

.pt-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pt-round-now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pt-swatch { width: 30px; height: 30px; flex-shrink: 0; border: 1.5px solid var(--ink); }
.pt-cur-name { font-family: var(--serif); font-size: 30px; font-weight: 500; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-next { display: flex; align-items: center; gap: 12px; font-family: var(--mono); }
.pt-next-id { font-size: 30px; font-weight: 600; min-width: 2.4em; text-align: right; }

.pt-btn-sm {
  height: 40px; padding: 0 10px; border: 1.5px solid var(--ink); background: transparent;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; white-space: nowrap;
}
.pt-btn-sq { width: 44px; height: 40px; border: 1.5px solid var(--ink); background: transparent; font-size: 17px; }
.pt-zonebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pt-zone-nav { display: flex; gap: 8px; }
.pt-chip { background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; padding: 5px 10px; }

/* ---------- plate ---------- */
.pt-frame {
  position: relative;
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: flex-start; justify-content: flex-start;
}
.pt-plate {
  --w: 54px; --g: 6px; --lab: 26px;
  display: grid;
  grid-template-columns: var(--lab) repeat(var(--nc), var(--w));
  grid-template-rows: 20px;
  grid-auto-rows: var(--w);
  gap: var(--g);
  padding: 12px 16px 16px;
  background: var(--card);
  border: 1.5px solid var(--ink);
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.pt-plate .lab {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: clamp(9px, calc(var(--w) * 0.26), 14px); color: var(--muted);
}
.pt-plate .lab.row { font-weight: 600; color: var(--ink); }
.pt-plate .lab.colh { align-self: end; padding-bottom: 2px; }
.pt-plate > .lab.corner { visibility: hidden; }
.pt-plate.has-colh { grid-template-rows: auto; }

.well {
  width: var(--w); height: var(--w);
  padding: 0; margin: 0;
  border-radius: 50%;
  border: 1.5px dashed var(--ink);
  background: var(--card);
  color: var(--muted);
  font-family: var(--mono);
  font-size: clamp(8px, calc(var(--w) * 0.2), 11px);
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .08s linear;
}
.pt-plate.is-square .well { border-radius: 3px; }
.pt-plate.is-tiny .well { font-size: 0; }
.pt-plate.is-tiny .well { border-width: 1px; }
.well.has { background: var(--c); color: var(--ink2, var(--ink)); }
.well.done { border-style: solid; }
.well.next { border: max(3px, calc(var(--w) * 0.07)) solid var(--ink); }
.pt-plate.is-tiny .well.next { border-width: 2.5px; }
.well.skip {
  border: 1.5px solid var(--skip-line); color: transparent;
  background: repeating-linear-gradient(45deg, #CFC9B8 0 3px, var(--card) 3px 7px);
}
@media (hover: hover) {
  .well:hover { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
}

.pt-stamp {
  position: absolute; right: 12px; top: 12px;
  font-family: var(--mono); font-weight: 600; font-size: 15px; letter-spacing: 0.1em;
  color: var(--pass-dark); border: 2px solid var(--pass-dark);
  padding: 4px 10px; transform: rotate(-4deg); background: var(--card);
  pointer-events: none;
}

.pt-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-family: var(--mono); font-size: 12px; color: var(--muted); align-items: center; }
.pt-legend span { display: flex; align-items: center; gap: 6px; }
.lg { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 1.5px solid var(--ink); }
.lg-next { border-width: 4px; }
.lg-todo { border-style: dashed; }
.lg-skip { border-color: var(--skip-line); background: repeating-linear-gradient(45deg, #CFC9B8 0 2px, var(--card) 2px 5px); }

/* ---------- panels ---------- */
.pt-bar {
  display: flex; justify-content: space-between;
  background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; padding: 6px 10px;
}
.pt-rounds { list-style: none; margin: -8px 0 0; padding: 0; }
.pt-round {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 10px;
  border: 2px solid transparent; border-bottom: 1px dotted var(--ink);
  width: 100%; background: transparent; text-align: left;
}
.pt-round.is-active { background: var(--card); border: 2px solid var(--ink); }
.pt-round .sw { width: 20px; height: 20px; flex-shrink: 0; border: 1.5px solid var(--ink); }
.pt-round .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.pt-round .nm { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-round input.nm { border: 0; border-bottom: 1px dashed var(--ink); background: transparent; padding: 2px 0; outline: none; height: 26px; }
.pt-round .ct { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.pt-round .st { font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em; font-weight: 600; width: 74px; text-align: right; color: var(--muted); white-space: nowrap; }
.pt-round .st.ok { color: var(--pass-dark); }

.pt-round-edit { display: flex; gap: 10px; align-items: center; margin-top: -6px; }
.pt-btn-dash {
  flex: 1; height: 40px; border: 1.5px dashed var(--ink); background: transparent;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em;
}
.pt-round-edit .pt-link { font-size: 12px; color: var(--muted); }

.pt-group { display: flex; flex-direction: column; gap: 6px; }
.pt-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--muted); }

.pt-progress { border-top: 1px solid var(--ink); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.pt-count { display: flex; align-items: baseline; gap: 6px; font-family: var(--serif); }
.pt-count b { font-size: 46px; font-weight: 600; line-height: 1; }
.pt-count span { font-size: 22px; color: var(--muted); }
.pt-count em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.pt-meter { height: 8px; border: 1.5px solid var(--ink); background: var(--card); }
.pt-meter i { display: block; height: 100%; width: 0; background: var(--c, var(--mint)); transition: width .15s; }

.pt-wake { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--muted); min-height: 32px; }
.pt-wake input { width: 18px; height: 18px; accent-color: var(--teal); margin: 0; }

.pt-minimap-wrap { display: flex; flex-direction: column; gap: 0; }
.pt-minimap {
  position: relative; align-self: flex-start;
  display: grid; grid-template-columns: repeat(24, 11px); grid-auto-rows: 11px; gap: 1px;
  padding: 8px; background: var(--card); border: 1.5px solid var(--ink); border-top: 0;
}
.pt-minimap .mc { background: var(--card); border: 1px solid #C9C3B3; }
.pt-minimap .mc.has { border: 0; background: var(--c); }
.pt-minimap .mc.skip { background: #D8D2C2; border: 0; }
.pt-minimap .mc.done { border: 0; }
.pt-minimap .mz {
  position: absolute; width: calc(12 * 12px); height: calc(8 * 12px);
  border: 0; background: transparent; padding: 0;
}
.pt-minimap .mz.is-on { outline: 3px solid var(--ink); outline-offset: 0; }

/* ---------- buttons in action bar ---------- */
.pt-btn {
  height: 84px; border: 1.5px solid var(--ink); background: transparent;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.pt-btn:active, .pt-btn-sm:active, .pt-btn-sq:active, .pt-seg button:active { background: var(--ink); color: var(--paper); }

/* the most-tapped control: big, filled, at the bottom where the thumb is */
.pt-mark {
  height: 84px; border: 0; padding: 0 14px;
  background: var(--teal); color: #FAF7EE;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.pt-mark-k { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; opacity: .85; }
.pt-mark-id { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.05; }
.pt-mark:active { background: #0E2B29; }
.pt-mark.is-skip { background: var(--ink); }
.pt-mark:disabled { opacity: 1; background: var(--card); color: var(--muted); border: 1.5px dashed var(--ink); }

/* secondary: change round */
.pt-next-round {
  min-height: 44px; padding: 6px 12px;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
}
.pt-next-round:active { background: var(--ink); color: var(--paper); }
.pt-next-round.is-pass { background: var(--pass-dark); border-color: var(--pass-dark); color: #FAF7EE; font-size: 13px; min-height: 52px; }
button:disabled { opacity: .4; cursor: default; }

/* ---------- about (below the tool) ---------- */
.pt-about { border-top: 2px solid var(--ink); padding: 0 24px 32px; max-width: 1200px; margin: 0 auto; }
.pt-sec { background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; padding: 6px 10px; margin: 28px 0 18px; }
.pt-about-head { display: flex; gap: 24px; align-items: flex-start; padding-bottom: 18px; border-bottom: 1px dotted var(--ink); }
.pt-fig { margin: 0; width: 150px; flex-shrink: 0; background: var(--card); border: 1.5px solid var(--ink); padding: 10px 10px 6px; text-align: center; }
.pt-fig svg { width: 100%; height: auto; display: block; }
.pt-fig figcaption { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 4px; }
.pt-about h1 { font-family: var(--serif); font-weight: 600; font-size: 36px; margin: 0 0 6px; line-height: 1.1; }
.pt-lede { margin: 0 0 8px; max-width: 62ch; color: #3A4244; }
.pt-flow { margin: 0; font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em; }
.pt-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; padding-top: 8px; }
.pt-about h2 { font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--ink); }
.pt-num { margin: 0; padding-left: 1.6em; }
.pt-num li { padding: 4px 0; border-bottom: 1px dotted #9A968A; }
.pt-keys { width: 100%; border-collapse: collapse; }
.pt-keys td { padding: 6px 0; border-bottom: 1px dotted #9A968A; vertical-align: top; }
.pt-keys td:first-child { width: 150px; white-space: nowrap; }
kbd { font-family: var(--mono); font-size: 12px; border: 1.5px solid var(--ink); padding: 1px 6px; background: var(--card); }

.pt-foot {
  border-top: 2px solid var(--ink); margin: 0 24px; padding: 12px 0 24px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
}

/* ---------- tablet portrait & smaller: stack ---------- */
@media (max-width: 899px) {
  .pt-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "stage" "actions" "panels";
    height: auto; min-height: 0;
  }
  .pt-stage { padding: 14px 16px 10px; }
  .pt-frame { flex: none; }
  .pt-panels { border-left: 0; border-top: 2px solid var(--ink); padding: 16px; overflow: visible; }
  .pt-actions {
    position: sticky; bottom: 0; z-index: 10;
    border-left: 0; border-top: 2px solid var(--ink);
    padding: 10px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
    grid-template-columns: 96px 1fr;
  }
  .pt-btn, .pt-mark { height: 72px; }
  .pt-crumb { display: none; }
}

@media (max-width: 600px) {
  :root { --top: 52px; }
  .pt-top { gap: 8px; padding: 0 12px; }
  .pt-word { font-size: 18px; }
  .pt-brand svg { display: none; }
  .pt-saved .txt { display: none; }
  .pt-plate-name { display: none; }
  .pt-seg.pt-format button { min-width: 44px; padding: 0 6px; }
  .pt-cur-name { font-size: 22px; }
  .pt-next-id { font-size: 22px; min-width: 0; }
  .pt-swatch { width: 24px; height: 24px; }
  .pt-stage { padding: 10px 12px 8px; gap: 8px; }
  .pt-plate { padding: 10px; }
  .pt-legend { font-size: 10px; gap: 4px 12px; }
  .pt-legend-tip { display: none !important; }
  .pt-actions { grid-template-columns: 72px 1fr; padding: 8px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); gap: 8px; }
  .pt-mark, .pt-undo { height: 68px; }
  .pt-mark-id { font-size: 26px; }
  .pt-next-round { min-height: 38px; font-size: 11px; }
  .pt-cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .pt-about { padding: 0 16px 24px; }
  .pt-about-head { flex-direction: column; gap: 12px; }
  .pt-about h1 { font-size: 30px; }
  .pt-foot { margin: 0 16px; }
}

@media print {
  .pt-top, .pt-actions, .pt-panels, .pt-about, .pt-foot, .pt-zonebar { display: none !important; }
  .pt-app { display: block; height: auto; }
}

/* ---------- MOVE NEXT pad ---------- */
.pt-pad-wrap { margin-top: auto; display: flex; flex-direction: column; }
.pt-pad-body { display: flex; gap: 12px; align-items: center; padding-top: 10px; }
.pt-pad-help { margin: 0; flex: 1; min-width: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.pt-pad-help b { color: var(--ink); font-family: var(--mono); font-weight: 600; font-size: 11px; }
.pt-pad { flex-shrink: 0; display: grid; grid-template-columns: repeat(3, 50px); grid-auto-rows: 50px; gap: 4px; }
.pt-pad button {
  border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.pt-pad button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: square; }
.pt-pad button:active:not(:disabled) { background: var(--ink); color: var(--paper); }
.pt-pad button:disabled { opacity: 1; color: #B9B4A6; border-color: #C9C3B3; background: transparent; }
.pt-pad .pt-pad-auto { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; background: transparent; }
.pt-pad .pt-pad-auto[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#padState { white-space: nowrap; }
@media (max-width: 899px) {
  .pt-pad-wrap { margin-top: 0; }
  .pt-pad { grid-template-columns: repeat(3, 56px); grid-auto-rows: 56px; }
}

/* ---------- compact side panel (fits 8 rounds + MOVE NEXT on an iPad) ---------- */
.pt-panels { gap: 12px; }
/* flex-shrink: 0 — the side panel scrolls instead; never squeeze the list (it collapsed to 0 on short iPad/phone-landscape screens) */
.pt-rounds { max-height: 204px; max-height: clamp(160px, calc(100dvh - 682px), 204px); overflow-y: auto; overscroll-behavior: contain; flex-shrink: 0; }
.pt-round-edit { margin-top: -4px; }
.pt-round-edit .pt-btn-dash, .pt-round-edit .pt-link { height: 36px; }
.pt-seg-row { display: flex; gap: 8px; }
.pt-seg-row > .pt-seg { flex: 3 1 0; }
.pt-seg-row > .pt-seg-act { flex: 2 1 0; }
.pt-seg-row .pt-seg button { height: 42px; }
.pt-progress { flex-direction: row; align-items: center; gap: 12px; padding-top: 8px; }
.pt-count b { font-size: 32px; }
.pt-count span { font-size: 18px; }
.pt-count em { margin-left: 8px; }
.pt-progress .pt-meter { flex: 1; }
.pt-wake { min-height: 24px; }
.pt-pad { grid-template-columns: repeat(3, 46px); grid-auto-rows: 46px; }
.pt-pad-body { padding-top: 8px; }
@media (max-width: 899px) {
  .pt-rounds { max-height: none; }
  .pt-pad { grid-template-columns: repeat(3, 56px); grid-auto-rows: 56px; }
}

/* ---------- 1:1 ON PLATE ---------- */
.pt-op-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
body.is-op { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
html:has(body.is-op) { overflow: hidden; overscroll-behavior: none; }
body.is-op .pt-about, body.is-op .pt-foot,
body.is-op .pt-stage-head, body.is-op .pt-legend, body.is-op .pt-zonebar { display: none !important; }
body.is-op .pt-app { grid-template-columns: max-content minmax(240px, 1fr); }
body.is-op .pt-stage { padding: 6px 12px 8px; gap: 8px; }
body.is-op .pt-frame { flex: none; }
body.is-op .pt-panels { container-type: inline-size; }

.pt-plate.pt-op {
  display: block; position: relative; padding: 0; border: 0; background: transparent;
  grid-template-columns: none;
}
.pt-op .op-outline {
  position: absolute; box-sizing: border-box;
  border: 2px solid var(--ink); border-radius: calc(var(--k) * 2.5);
  background: var(--card);
}
.pt-op .op-card {
  position: absolute; box-sizing: border-box; z-index: 2; pointer-events: none;
  border: 2px dashed var(--teal); border-radius: calc(var(--k) * 3.18);
  background: rgba(156, 199, 182, .25);
}
.pt-op .op-lab {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--mono); font-size: 10px; line-height: 1; color: var(--muted); white-space: nowrap;
}
.pt-op .op-lab.row { font-weight: 600; color: var(--ink); }
.pt-op .well { position: absolute; z-index: 1; }
.pt-op.is-square .well { border-radius: 1px; }
/* through a plastic plate a thin ring vanishes: the next target is a solid dark fill */
.pt-op .well.next { background: var(--ink); color: var(--paper); border: 2px solid var(--ink); box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.pt-op .well.skip { opacity: .7; }

.pt-op-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--muted);
}
.pt-op-note .pt-link { height: 32px; padding: 0 2px; font-size: 11px; }
.pt-op-tag { background: var(--ink); color: var(--paper); padding: 3px 8px; }
.pt-op-warn { flex-basis: 100%; color: #8A2E1C; font-weight: 600; }

/* narrow side panel next to a real-size plate (iPad mini) */
body.is-op .pt-actions { container-type: inline-size; }
@container (max-width: 300px) {
  .pt-pad-help, .pt-wake { display: none !important; }
  .pt-pad-body { justify-content: center; padding-top: 6px; }
  .pt-pad { grid-template-columns: repeat(3, 40px); grid-auto-rows: 40px; }
  .pt-seg-row { gap: 6px; }
  .pt-seg-row .pt-seg button { padding: 0 2px; font-size: 11px; letter-spacing: 0; }
  .pt-round .st { display: none; }
  .pt-actions { grid-template-columns: 64px minmax(0, 1fr); }
  .pt-mark-id { font-size: 22px; white-space: nowrap; }
  .pt-mark, .pt-undo { height: 72px; }
}

/* ---------- calibration ---------- */
.pt-calib {
  grid-area: panels; grid-row: 1 / -1;
  border-left: 2px solid var(--ink);
  padding: 16px 20px; display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; min-height: 0; background: var(--paper);
}
body.is-calibrating .pt-panels, body.is-calibrating .pt-actions { display: none; }
.pt-calib-steps { margin: 0; padding-left: 1.4em; font-size: 14px; line-height: 1.45; }
.pt-calib-steps li { padding: 4px 0; border-bottom: 1px dotted #9A968A; }
.pt-calib-ctrl { display: grid; grid-template-columns: 52px 52px 1fr 52px 52px; gap: 6px; align-items: stretch; }
.pt-calib-ctrl button {
  height: 56px; border: 1.5px solid var(--ink); background: var(--card);
  font-family: var(--mono); font-size: 20px; font-weight: 600;
}
.pt-calib-ctrl button:active { background: var(--ink); color: var(--paper); }
.pt-calib-ctrl output {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
}
.pt-calib-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.pt-calib-links .pt-link { font-size: 11px; padding: 0; height: 32px; }
.pt-calib-note { margin: 0; font-size: 12px; color: var(--muted); }
.pt-calib-go { margin-top: auto; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.pt-calib-go .pt-next-round { min-height: 56px; font-size: 14px; }

@media (max-width: 899px) {
  body.is-op .pt-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "stage" "panels" "actions";
    height: calc(100dvh - var(--top));
  }
  body.is-op .pt-panels { overflow-y: auto; border-top: 2px solid var(--ink); }
  body.is-op .pt-actions { position: static; }
  .pt-calib { grid-row: auto; border-left: 0; border-top: 2px solid var(--ink); padding: 14px 16px; }
}
@media (max-width: 600px) { .pt-op-btn { display: none; } }

/* ---------- start-up choice ---------- */
.pt-modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(27, 34, 36, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.pt-modal-box { width: min(560px, 100%); background: var(--paper); border: 2px solid var(--ink); }
.pt-modal-body { padding: 18px 22px 20px; }
.pt-modal h2 { font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.15; margin: 0 0 8px; }
.pt-modal p { margin: 0 0 16px; color: #3A4244; }
.pt-modal-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pt-choice {
  min-height: 92px; padding: 12px 14px; text-align: left;
  border: 1.5px solid var(--ink); background: var(--card); color: var(--ink);
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.pt-choice b { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.pt-choice span { font-size: 13px; opacity: .85; }
.pt-choice-main { background: var(--teal); border-color: var(--teal); color: #FAF7EE; }
.pt-choice:active { filter: brightness(1.15); }
.pt-modal-remember { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 13px; color: var(--muted); }
.pt-modal-remember input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--teal); flex-shrink: 0; }
@media (max-width: 480px) { .pt-modal-choices { grid-template-columns: minmax(0, 1fr); } }

/* real-size plate turned to fit a narrow upright screen (iPad mini portrait):
   keep only the essential buttons, in one row */
body.is-op-rot .pt-panels { display: none !important; }
body.is-op-rot .pt-app { grid-template-rows: auto auto auto; grid-template-areas: "stage" "panels" "actions"; height: auto; }
body.is-op-rot .pt-actions { grid-template-columns: 72px minmax(0, 1fr) minmax(0, 1fr); padding: 8px 12px; }
body.is-op-rot .pt-undo { order: 1; height: 64px; }
body.is-op-rot .pt-mark { order: 2; height: 64px; }
body.is-op-rot .pt-next-round { order: 3; grid-column: auto; min-height: 64px; }
body.is-op-rot .pt-calib { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; }
body.is-op-rot .pt-calib > .pt-bar { flex-basis: 100%; }
body.is-op-rot .pt-calib-steps, body.is-op-rot .pt-calib-note, body.is-op-rot .pt-calib-links { display: none !important; }
body.is-op-rot .pt-calib-ctrl { flex: 1 1 320px; }
body.is-op-rot .pt-calib-go { flex: 1 1 260px; margin-top: 0; }
