/* Bind map. Field-manual theme: keys are ink-outlined keycaps on paper, bound keys are white with
   ink text, disputed keys carry red text, the active layer chip is red, and the mouse is drawn in
   ink outlines on a white well. Tokens come from site.css. */

/* ---------- layer switcher ---------- */
.layer-tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .6rem; }
.ltab { display: inline-flex; align-items: baseline; gap: .5rem; font-family: var(--mono); font-weight: 700; font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; padding: .5rem .8rem; background: var(--plate); color: var(--ink); border: 1px solid var(--ink); cursor: pointer; line-height: 1; }
.ltab:hover { background: var(--ink); color: var(--paper); }
.ltab[aria-selected="true"] { background: var(--red); border-color: var(--red); color: #FBF6EA; }
.ltab-n { font-size: .66rem; font-weight: 400; font-variant-numeric: tabular-nums; opacity: .8; }

/* ---------- diagram panel ---------- */
.kb-panel { background: var(--plate); border: 1px solid var(--ink); padding: .8rem 1rem 1rem; margin-bottom: 1.4rem; }
.kb-panel-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: baseline; margin-bottom: .8rem; border-bottom: 1px solid var(--ink); padding-bottom: .5rem; }
.kb-title { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; min-width: 0; }
.kb-layer { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; line-height: 1; }
.kb-desc { color: var(--ink-2); font-size: .88rem; max-width: 70ch; }
.kb-legend { display: flex; gap: 1rem; font-family: var(--mono); font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: .4rem; vertical-align: -1px; border: 1px solid var(--ink); background: #fff; }
.lg-unbound::before { background: var(--paper); border-color: var(--rule); }
.lg-disputed { color: var(--red); }
.lg-disputed::before { background: #fff; border-color: var(--red); }
.lg-rebind::before { background: var(--ink); border-color: var(--ink); width: 6px; height: 6px; vertical-align: 1px; margin-left: 2px; margin-right: calc(.4rem + 2px); }

.kb-scroll { overflow-x: auto; }
.kb-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 214px; gap: 1.5rem; align-items: center; min-width: 960px; }
.kb-box { container-type: inline-size; min-width: 0; }

/* One grid, 74 columns: 60 for the main block, 2 gap, 12 for the nav cluster.
   A 1u key spans 4 columns; --kh makes it square. */
.kb { --kgap: 3px; --kh: calc((100cqw - 73 * var(--kgap)) / 74 * 4 + 3 * var(--kgap)); display: grid; grid-template-columns: repeat(74, minmax(0, 1fr)); grid-template-rows: var(--kh) calc(var(--kh) * .3) repeat(5, var(--kh)); gap: var(--kgap); }

.key { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: .18rem; margin: 0; padding: .2rem .22rem; min-width: 0; background: var(--paper); border: 1px solid var(--rule); color: var(--ink-3); font: inherit; text-align: left; cursor: default; overflow: hidden; }
.key .cap { font-family: var(--mono); font-weight: 700; font-size: .66rem; letter-spacing: .02em; line-height: 1; white-space: nowrap; }
.key .act { font-family: var(--serif); font-size: .6rem; line-height: 1.1; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; hyphens: auto; overflow-wrap: break-word; }
.key.is-bound { background: #fff; border-color: var(--ink); color: var(--ink); cursor: pointer; }
.key.is-disputed .cap { color: var(--red); }
.key.is-disputed::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; background: var(--red); }
.key.is-bound:hover, .key:focus-visible, .key.is-pinned { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); background: #fff; color: var(--ink); }
.key.is-bound:hover .act, .key:focus-visible .act, .key.is-pinned .act { color: var(--ink); }
.key:focus-visible { outline-offset: 0; }

/* ========================================================
   MOUSE: an ink line drawing on a white well
   ======================================================== */
.mouse-shower { display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; padding: 12px 0 4px 28px; user-select: none; }
.mouse { position: relative; }
.mouse-chassis {
  position: relative; width: 178px; height: 272px; background: #fff; border: 1px solid var(--ink);
  border-top-left-radius: 54px 64px; border-top-right-radius: 54px 64px; border-bottom-left-radius: 64px 74px; border-bottom-right-radius: 64px 74px;
  display: flex; flex-direction: column; padding: 6px 6px 8px; box-sizing: border-box;
}
.mouse-chassis::before { display: none; }

/* cord */
.mouse-cord { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); width: 14px; height: 9px; background: #fff; border: 1px solid var(--ink); border-bottom: none; border-radius: 3px 3px 0 0; z-index: 2; }
.mouse-cord::before { content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 4px; height: 8px; background: var(--ink); border-radius: 2px 2px 0 0; }

/* thumb wing */
.mouse-flank-left { position: absolute; left: -27px; top: 56px; width: 29px; display: flex; flex-direction: column; align-items: stretch; z-index: 3; }
.mouse-side-btns { display: flex; flex-direction: column; gap: 3px; }
.mouse .key.m-m5, .mouse .key.m-m4 { width: 27px; height: 35px; padding: 2px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--mono); border: 1px solid var(--rule); background: var(--paper); box-sizing: border-box; }
.mouse .key.m-m5.is-bound, .mouse .key.m-m4.is-bound { background: #fff; border-color: var(--ink); }
.mouse .key.m-m5 { border-top-left-radius: 12px; border-bottom-left-radius: 3px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; }
.mouse .key.m-m4 { border-top-left-radius: 3px; border-bottom-left-radius: 12px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; }
.mouse .key.m-m5 .cap, .mouse .key.m-m4 .cap { font-size: .65rem; font-weight: 700; letter-spacing: .02em; }
.mouse .key.m-m5 .act, .mouse .key.m-m4 .act { display: none; }
.mouse .key.m-m5.has-rec::before, .mouse .key.m-m4.has-rec::before { content: ""; position: absolute; top: 3px; left: 3px; width: 4px; height: 4px; background: var(--ink); }

/* grip ribs */
.mouse-thumb-grip { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; padding-left: 6px; }
.mouse-thumb-grip span { display: block; width: 14px; height: 1px; background: var(--rule); }
.mouse-flank-right { position: absolute; right: -5px; top: 86px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.mouse-flank-right span { display: block; width: 3px; height: 12px; background: var(--rule-2); border: 1px solid var(--rule); box-sizing: border-box; }

/* body */
.mouse-main-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mouse-clickers { display: grid; grid-template-columns: 1fr 34px 1fr; gap: 3px; height: 104px; flex-shrink: 0; }
.mouse .key.m-lmb, .mouse .key.m-rmb { position: relative; display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; padding: 8px 8px 6px; background: var(--paper); border: 1px solid var(--rule); }
.mouse .key.m-lmb.is-bound, .mouse .key.m-rmb.is-bound { background: #fff; border-color: var(--ink); }
.mouse .key.m-lmb { border-top-left-radius: 46px 54px; border-top-right-radius: 3px; border-bottom-left-radius: 6px; border-bottom-right-radius: 3px; }
.mouse .key.m-rmb { border-top-right-radius: 46px 54px; border-top-left-radius: 3px; border-bottom-right-radius: 6px; border-bottom-left-radius: 3px; }
.mouse .key.m-lmb .cap, .mouse .key.m-rmb .cap { font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .03em; color: var(--ink); margin-bottom: 2px; }
.mouse .key.m-lmb .act, .mouse .key.m-rmb .act { font-size: .58rem; line-height: 1.15; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-align: left; }

/* wheel well */
.mouse-wheel-well { display: flex; flex-direction: column; align-items: center; justify-content: space-between; background: var(--plate-2); border: 1px solid var(--rule); border-radius: 17px; padding: 2px 1px; box-sizing: border-box; }
.mouse .key.m-wheelup, .mouse .key.m-wheeldown { width: 26px; height: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; background: var(--paper); border: 1px solid var(--rule); color: var(--ink-3); }
.mouse .key.m-wheelup.is-bound, .mouse .key.m-wheeldown.is-bound { background: #fff; border-color: var(--ink); color: var(--ink); }
.mouse .key.m-wheelup { border-radius: 10px 10px 2px 2px; }
.mouse .key.m-wheeldown { border-radius: 2px 2px 10px 10px; }
.mouse .key.m-wheelup .wh-arr, .mouse .key.m-wheeldown .wh-arr { width: 8px; height: 5px; }
.mouse .key.m-wheelup .cap, .mouse .key.m-wheeldown .cap { font-size: .5rem; font-weight: 700; line-height: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.mouse .key.m-wheelup .act, .mouse .key.m-wheeldown .act { display: none; }

/* middle button with ribs */
.mouse .key.m-mmb { width: 26px; height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1px; background: var(--paper); border: 1px solid var(--rule); border-radius: 3px; position: relative; overflow: hidden; }
.mouse .key.m-mmb.is-bound { background: #fff; border-color: var(--ink); }
.mouse .key.m-mmb .wheel-ribs { position: absolute; inset: 2px 3px; background: repeating-linear-gradient(180deg, transparent, transparent 3px, var(--rule-2) 3px, var(--rule-2) 4px); pointer-events: none; }
.mouse .key.m-mmb:hover .wheel-ribs, .mouse .key.m-mmb.is-pinned .wheel-ribs, .mouse .key.m-mmb:focus-visible .wheel-ribs { background: repeating-linear-gradient(180deg, transparent, transparent 3px, var(--rule) 3px, var(--rule) 4px); }
.mouse .key.m-mmb .cap { font-size: .58rem; font-weight: 700; z-index: 1; background: inherit; padding: 0 1px; }
.mouse .key.m-mmb .act { display: none; }

/* palm / sensor ("Move") */
.mouse-palm-area { display: flex; flex-direction: column; flex: 1; margin-top: 4px; min-height: 0; }
.mouse .key.m-move { width: 100%; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 10px; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px 6px 54px 54px; cursor: pointer; text-align: center; position: relative; }
.mouse .key.m-move.is-bound { background: #fff; border-color: var(--ink); }
.mouse .key.m-move .sensor-reticle { width: 28px; height: 28px; color: var(--ink-3); }
.mouse .key.m-move .reticle-svg { width: 100%; height: 100%; display: block; }
.mouse .key.m-move.is-bound .sensor-reticle { color: var(--ink); }
.mouse .key.m-move:hover .sensor-reticle, .mouse .key.m-move.is-pinned .sensor-reticle { color: var(--red); }
.mouse .key.m-move .m-move-text { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.mouse .key.m-move .cap { font-family: var(--mono); font-size: .66rem; font-weight: 700; letter-spacing: .04em; color: var(--ink); }
.mouse .key.m-move .act { font-size: .6rem; line-height: 1.15; color: var(--ink-2); max-width: 124px; text-align: center; -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }

/* stencil under the palm */

/* disputed dot placement on mouse buttons */
.mouse .key.m-move.is-disputed::after { top: 6px; right: 8px; }
.mouse .key.m-lmb.is-disputed::after { top: 6px; right: 5px; }
.mouse .key.m-rmb.is-disputed::after { top: 6px; right: 8px; }

/* rebind recommendation in the readout */
.ro-rebind-banner { margin-top: .5rem; padding: .4rem .65rem; background: #fff; border: 1px solid var(--rule); border-left: 3px solid var(--ink); display: flex; flex-direction: column; gap: .15rem; }
.ro-rebind-tag { font-family: var(--mono); font-size: .65rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--olive); }
.ro-rebind-body { color: var(--ink); font-size: .84rem; line-height: 1.3; }

/* readout: the selected key */
.readout { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1rem; align-items: start; border-top: 1px solid var(--ink); margin-top: .9rem; padding-top: .8rem; min-height: 4rem; }
.ro-cap { font-family: var(--mono); font-weight: 700; font-size: 1rem; padding: .4rem .6rem; border: 1px solid var(--ink); color: var(--ink); background: #fff; min-width: 3rem; text-align: center; white-space: nowrap; }
.ro-cap.is-empty { border-color: var(--rule); color: var(--ink-3); background: transparent; }
.ro-body { min-width: 0; }
.ro-row { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; padding: .15rem 0; }
.ro-act { font-weight: 600; }
.ro-src { color: var(--ink-3); font-family: var(--mono); font-size: .76rem; }
.ro-note { color: var(--ink-2); font-size: .88rem; margin: 0; }
.ro-hint { color: var(--ink-3); font-style: italic; font-size: .88rem; padding-top: .45rem; }
.ro-unbound { color: var(--ink-3); font-style: italic; padding-top: .45rem; }

/* ---------- table ---------- */
.binds-table td.cap { font-family: var(--mono); font-weight: 700; }
.binds-table td.note { white-space: normal; min-width: 26ch; color: var(--ink-2); }
.binds-table td.src { color: var(--ink-2); font-size: .84rem; }
.binds-table td.src a { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 2px; }
.binds-table td.src a:hover { color: var(--red); text-decoration-color: var(--red); }
.binds-table tr.is-mouse td.cap { color: var(--ink-2); }

/* ---------- foot ---------- */
.binds-foot { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.6rem; margin-top: 1.6rem; }
.night-one ol { margin: .5rem 0 0; padding-left: 1.2rem; }
.night-one li { margin-bottom: .6rem; max-width: 72ch; }
.night-one li::marker { font-family: var(--mono); color: var(--ink-3); }
.night-one strong { font-weight: 600; }
.night-one .why { color: var(--ink-2); }
.night-one .src { font-family: var(--mono); font-size: .76rem; color: var(--ink-3); }
.night-one .src a { text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 2px; }
.night-one .src a:hover { color: var(--red); }
.src-list { list-style: none; margin: .5rem 0 0; padding: 0; font-size: .88rem; }
.src-list li { padding: .4rem 0; border-top: 1px solid var(--rule-2); }
.src-list li:first-child { border-top: 1px solid var(--ink); }
.src-list li:last-child { border-bottom: 1px solid var(--rule-2); }
.src-list a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 2px; }
.src-list a:hover { color: var(--red); }

@media (max-width: 900px) {
  .kb-wrap { grid-template-columns: 1fr; min-width: 760px; }
  .mouse-shower { margin: 1.4rem auto 0; }
  .binds-foot { grid-template-columns: 1fr; }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  .layer-tabs .ltab { flex: 1 1 calc(50% - .3rem); justify-content: space-between; }
  .kb-legend { flex-wrap: wrap; gap: .5rem .9rem; white-space: normal; }
  .kb-panel { padding: .6rem .6rem .8rem; }
}
