/* style.css - how the app looks.
   The whole instrument is drawn at a fixed 800x480 (a 7-inch touchscreen) and then scaled
   to fit your window, so what you design here is what the real device will show.
   All colours are defined once, just below. */

:root {
  --body: #18191c;
  --edge: #2e3035;
  --screen: #0b0c0e;
  --glass-a: #121417;
  --glass-b: #0e1013;
  --line: #1f2226;
  --line-2: #2b2e33;
  --text: #ecebe6;
  --bone: #d9d7cf;
  --dim: #82858c;
  --faint: #4a4d54;
  --signal: #ff5b22; /* the one accent colour: recording, playhead, warnings */
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: radial-gradient(ellipse at 50% 35%, #1a1b1e 0%, #0b0b0c 70%);
  color: var(--text);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, .knob:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.hidden { display: none !important; }

/* ---------- the hardware ---------- */

#stage { position: fixed; inset: 0; --s: 1; }

.device {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 840px;
  height: 520px;
  padding: 20px;
  transform: translate(-50%, -50%) scale(var(--s));
  border-radius: 28px;
  background: linear-gradient(160deg, #222428, #17181b 55%, #141517);
  border: 1px solid var(--edge);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -2px 0 rgba(0, 0, 0, 0.4);
}

.screw {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4c52, #26282c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.screw::after {
  content: "";
  position: absolute;
  left: 1.5px;
  right: 1.5px;
  top: 4px;
  height: 1px;
  background: rgba(0, 0, 0, 0.6);
  transform: rotate(35deg);
}
.screw.tl { left: 6px; top: 6px; }
.screw.tr { right: 6px; top: 6px; }
.screw.bl { left: 6px; bottom: 6px; }
.screw.br { right: 6px; bottom: 6px; }

.screen {
  position: relative;
  width: 800px;
  height: 480px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--screen);
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #1a1c20;
  display: grid;
  grid-template-rows: 44px 436px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}


.state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3a3c41;
}
.led.idle { background: var(--bone); box-shadow: 0 0 6px rgba(217, 215, 207, 0.45); }
.led.review { background: #8a8d94; box-shadow: 0 0 5px rgba(138, 141, 148, 0.4); }
.led.armed { background: var(--signal); box-shadow: 0 0 6px rgba(255, 91, 34, 0.6); }
.led.recording { background: var(--signal); box-shadow: 0 0 10px var(--signal); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

.input-btn {
  margin-left: 8px;
  height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 230px;
  background: #15171a;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.input-btn::after { content: "\25BE"; color: var(--dim); }
.input-btn:disabled { opacity: 0.45; cursor: default; }
.set-btn::after { content: none; }
.input-tag { color: var(--dim); font-size: 10px; letter-spacing: 0.2em; }
.input-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }

/* ---------- main area ---------- */

.body {
  display: grid;
  grid-template-columns: 1fr 216px;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.glass {
  min-width: 0;
  min-height: 0;
  padding: 10px 14px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 8px;
  border: 1px solid #1c1f23;
  border-radius: 10px;
  background: linear-gradient(var(--glass-a), var(--glass-b));
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

.readout { display: flex; align-items: center; justify-content: space-between; }

.timer {
  font-size: 46px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.timer.live { color: var(--signal); }

.info { text-align: right; font-size: 11px; line-height: 1.7; letter-spacing: 0.08em; color: var(--dim); white-space: nowrap; }
.info .k, .knob-label .k { color: var(--faint); margin-right: 4px; }

/* ---------- the gain knob ---------- */

.knob-group { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.knob-label { font-size: 10px; letter-spacing: 0.12em; color: var(--dim); white-space: nowrap; }

.knob {
  --p: 0; /* how far the knob is turned, from 0 to 1 (set by app.js) */
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: ns-resize;
  touch-action: none;
}
.knob.locked { opacity: 0.4; pointer-events: none; }

.knob-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: conic-gradient(from 225deg, var(--signal) calc(var(--p) * 270deg), #24272b 0 270deg, transparent 0);
  -webkit-mask: radial-gradient(closest-side, transparent 84%, #000 86%);
  mask: radial-gradient(closest-side, transparent 84%, #000 86%);
}

.knob-cap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4d5056, #25272b 70%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: rotate(calc(-135deg + var(--p) * 270deg));
}
.knob-mark {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 3px;
  height: 11px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--signal);
}

/* ---------- scope, meter, tag line ---------- */

.scope-wrap {
  position: relative;
  min-height: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(to bottom, transparent calc(50% - 0.5px), #1f2227 calc(50% - 0.5px), #1f2227 calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    repeating-linear-gradient(to right, transparent 0 59px, #15171a 59px 60px);
}
#scope, #edit-scope { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#scope.seekable, #edit-scope { cursor: ew-resize; }
.scope-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 52px;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--faint);
  pointer-events: none;
}

.strip { min-height: 14px; }
.meter { display: flex; gap: 3px; height: 12px; margin-top: 1px; }
.seg { flex: 1; background: #1a1d21; border-radius: 2px; }
.seg.on { background: var(--bone); }
.seg.on.hot { background: var(--signal); }

.tagline {
  height: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.tagline .star { color: var(--signal); }
.tagline .empty { color: var(--faint); }

.message {
  height: 16px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.message.error { color: var(--signal); }

/* ---------- recent takes ---------- */

.takes {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #1c1f23;
  border-radius: 10px;
  background: #101113;
  overflow: hidden;
}
.takes-head {
  height: 30px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.takes-list {
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #2b2e33 transparent;
}
.take-row {
  width: 100%;
  height: 54px;
  padding: 0 10px 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border-bottom: 1px solid #17191c;
  border-left: 3px solid transparent;
}
.take-row:active { background: #17191c; }
.take-row.active { border-left-color: var(--signal); background: #15171a; }
.take-main { flex: 1; min-width: 0; }
.take-time { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; letter-spacing: 0.02em; }
.take-date { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; letter-spacing: 0.1em; color: var(--dim); text-transform: uppercase; }
.take-side { flex: none; text-align: right; }
.take-dur { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.take-star { margin-top: 3px; font-size: 11px; color: var(--signal); }
.takes-empty {
  padding: 28px 12px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.22em;
  line-height: 1.8;
  color: var(--faint);
}

/* ---------- control deck ---------- */

.deck {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  background: linear-gradient(#101113, #0c0d0f);
}
.deck-left { justify-self: start; display: flex; gap: 8px; }
.deck-right { justify-self: end; display: flex; gap: 8px; }

.rec-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 5px solid #2a2c30;
  background: radial-gradient(circle at 35% 30%, #ff8a63, var(--signal) 58%, #b83a10);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), inset 0 -4px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s;
}
.rec-btn:active { transform: scale(0.95); }
.rec-btn:disabled { opacity: 0.5; cursor: wait; }
.rec-btn.recording {
  background: #191a1d;
  border-color: var(--signal);
  color: var(--signal);
  box-shadow: 0 0 18px rgba(255, 91, 34, 0.35), inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.key {
  height: 56px;
  min-width: 84px;
  padding: 0 8px;
  background: linear-gradient(#2c2e32, #222428);
  border: 1px solid #3a3d42;
  border-bottom: 3px solid #121315;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.key-wide { min-width: 100px; }
.key:active { transform: translateY(1px); border-bottom-width: 2px; }
.key:disabled { opacity: 0.32; cursor: default; }
.key.on { color: var(--signal); }
.key-primary { border-color: var(--signal); color: var(--signal); }

/* ---------- pop-up sheet ---------- */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 8, 9, 0.84);
}
.sheet-panel {
  width: 440px;
  max-height: 440px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  background: #15171a;
  border: 1px solid #2c2f34;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.sheet-panel.wide { width: 740px; }
.sheet-title { margin: 0 0 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.26em; color: var(--dim); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; font-size: 13px; line-height: 1.6; color: var(--bone); }
.sheet-body p { margin: 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.sheet-actions .key { height: 48px; min-width: 110px; }
.sheet-actions .push-left { margin-right: auto; }

.sheet-row {
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-size: 13px;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #1c1e22;
}
.sheet-row:active { background: #1c1e22; }
.sheet-row .dot { width: 10px; height: 10px; flex: none; border-radius: 50%; border: 1px solid var(--faint); }
.sheet-row.selected .dot { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 8px var(--signal); }
.sheet-row .state-text { margin-left: auto; font-size: 11px; letter-spacing: 0.16em; color: var(--dim); }
.sheet-row.selected .state-text { color: var(--signal); }
.sheet-note { margin-top: 10px; font-size: 11px; line-height: 1.6; color: var(--dim); }

/* the TAKE INFO form */

.info-form { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.field-label { margin: 0 0 6px; font-size: 10px; letter-spacing: 0.22em; color: var(--dim); }
.field-gap { margin-top: 14px; }

input, textarea { user-select: text; -webkit-user-select: text; }
.text-field {
  width: 100%;
  padding: 0 12px;
  background: #0f1012;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
input.text-field { height: 40px; }
textarea.text-field { height: 84px; padding-top: 10px; line-height: 1.5; resize: none; }
.text-field:focus { outline: none; border-color: var(--signal); }
.text-field::placeholder { color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  height: 32px;
  padding: 0 12px;
  background: #1a1c20;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.chip.on { border-color: var(--signal); color: var(--signal); background: #211611; }

/* ================= pages, top bar additions ================= */

.pages { position: relative; height: 436px; min-height: 0; }
.page { height: 436px; display: grid; grid-template-rows: 336px 100px; min-height: 0; }

.back-btn {
  height: 32px;
  padding: 0 12px;
  background: #15171a;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
}
.back-btn:active { background: #1c1e22; }
.top-title { margin-left: 14px; font-size: 13px; font-weight: 700; letter-spacing: 0.34em; }
.top-spacer { flex: 1; }
.top-extra { display: flex; }

.badges { display: flex; gap: 6px; margin-left: 8px; }
.badge {
  height: 24px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #23262a;
  border-radius: 12px;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--faint);
  white-space: nowrap;
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: #34373c; }
.badge.lit { color: var(--dim); border-color: #2b2e33; }
.badge.lit i { background: var(--bone); box-shadow: 0 0 5px rgba(217, 215, 207, 0.5); }
.badge.searching i { background: var(--signal); animation: blink 0.8s infinite; }
.badge.warn { color: var(--signal); border-color: #4a2b1f; }
.badge.warn i { background: var(--signal); }

.toast {
  position: absolute;
  left: 50%;
  bottom: 112px;
  z-index: 20;
  max-width: 560px;
  padding: 10px 18px;
  background: #1c1e22;
  border: 1px solid #3a3d42;
  border-radius: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--signal); color: var(--signal); }

/* ================= home ================= */

.page-home { display: flex; flex-direction: column; padding: 0 24px 22px; }
.wordmark { height: 148px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.wordmark-name { font-size: 40px; font-weight: 700; letter-spacing: 0.3em; text-indent: 0.3em; line-height: 1; white-space: nowrap; }
.wordmark-sub { font-size: 10px; letter-spacing: 0.3em; color: var(--faint); }

.tiles { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; min-height: 0; }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 10px 14px;
  background: linear-gradient(#1a1c20, #121417);
  border: 1px solid #2b2e33;
  border-bottom: 4px solid #0c0d0f;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: center;
}
.tile:active { transform: translateY(2px); border-bottom-width: 2px; }
.tile-num { position: absolute; left: 12px; top: 10px; font-size: 10px; letter-spacing: 0.2em; color: var(--faint); }
.tile-icon { width: 64px; height: 64px; margin-bottom: 14px; fill: none; stroke: var(--bone); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tile-icon .signal { fill: var(--signal); stroke: none; }
.tile-icon .signal-line { stroke: var(--signal); }
.tile-name { font-size: 15px; font-weight: 700; letter-spacing: 0.26em; text-indent: 0.26em; }
.tile-sub { margin-top: 6px; font-size: 9px; letter-spacing: 0.14em; color: var(--dim); }
.tile-status { margin-top: 12px; padding-top: 10px; width: 100%; border-top: 1px solid var(--line); font-size: 10px; letter-spacing: 0.16em; color: var(--faint); }
.tile-status.lit { color: var(--bone); }
.tile-status.warn { color: var(--signal); }

/* ================= round deck buttons that are not REC ================= */

.rec-btn.bone {
  background: radial-gradient(circle at 35% 30%, #f1efe8, var(--bone) 58%, #a9a79f);
  color: #1a1b1e;
}
.rec-btn.bone.playing { background: #191a1d; border-color: var(--bone); color: var(--bone); }
.rec-btn.bone:disabled { opacity: 0.35; }
.key.key-primary:disabled { border-color: #3a3d42; }

/* ================= edit ================= */

.edit-glass { grid-template-rows: auto 1fr auto auto; }
.params { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.param { min-width: 0; padding: 5px 5px 5px; background: #0f1012; border: 1px solid #1c1f23; border-radius: 8px; }
.param.off { opacity: 0.4; }
.param-label { margin-bottom: 3px; text-align: center; font-size: 9px; letter-spacing: 0.14em; color: var(--dim); white-space: nowrap; }
/* each setting: its value on top, then a minus and a plus key side by side */
.param-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.param-val { grid-column: 1 / -1; order: -1; height: 18px; min-width: 0; font-size: 12px; letter-spacing: 0.04em; text-align: center; color: var(--text); white-space: nowrap; overflow: hidden; }
.param-val:disabled { cursor: default; opacity: 1; }
.step {
  height: 28px;
  min-width: 0;
  background: linear-gradient(#2c2e32, #222428);
  border: 1px solid #3a3d42;
  border-bottom-width: 2px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
}
.step:active { transform: translateY(1px); }
.step:disabled { opacity: 0.35; cursor: default; }
.param-row > .param-val:only-child { height: 42px; background: linear-gradient(#2c2e32, #222428); border: 1px solid #3a3d42; border-bottom-width: 2px; border-radius: 6px; font-weight: 600; }
.param-val.on { color: var(--signal); border-color: var(--signal) !important; }

/* ================= glove ================= */

.glove-glass { grid-template-rows: auto auto 1fr auto; }
.glove-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-top: 4px; }
.glove-state { font-size: 30px; font-weight: 600; letter-spacing: 0.12em; color: var(--dim); }
.glove-state.lit { color: var(--bone); }
.glove-state.warn { color: var(--signal); }
.glove-detail { margin-top: 8px; font-size: 11px; letter-spacing: 0.04em; line-height: 1.5; color: var(--dim); max-width: 330px; }
.glove-battery { width: 120px; text-align: right; }
.k-label { font-size: 9px; letter-spacing: 0.16em; color: var(--dim); }
.sim-tag { margin-left: 4px; padding: 1px 4px; border: 1px solid var(--faint); border-radius: 3px; font-size: 8px; color: var(--faint); }
.battery { height: 10px; margin: 8px 0 6px; background: #1a1d21; border-radius: 3px; overflow: hidden; }
.battery-fill { height: 100%; width: 0; background: var(--bone); }
.battery-val { font-size: 11px; color: var(--dim); }

.glove-map { display: flex; flex-direction: column; gap: 6px; }
.map-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #0f1012; border: 1px solid #1c1f23; border-radius: 8px; }
.gesture { width: 70px; font-size: 12px; font-weight: 700; letter-spacing: 0.16em; }
.arrow { color: var(--faint); }
.map-val { flex: 1; text-align: center; font-size: 11px; letter-spacing: 0.1em; }
.sim-note { margin: 0; font-size: 10px; line-height: 1.5; letter-spacing: 0.04em; color: var(--faint); }
.log-row { padding: 10px 12px; border-bottom: 1px solid #17191c; font-size: 10px; letter-spacing: 0.08em; line-height: 1.4; }
.log-row.ignored { color: var(--dim); }

/* ================= library ================= */

.lib-glass { grid-template-rows: auto 1fr auto; padding: 10px 0 10px 0; gap: 6px; }
.lib-head { display: flex; justify-content: space-between; padding: 0 14px; font-size: 10px; letter-spacing: 0.2em; color: var(--dim); }
.lib-legend { font-size: 9px; letter-spacing: 0.12em; color: var(--faint); }
.lib-legend .d { margin: 0 4px 0 10px; }
.lib-list { margin: 0; padding: 0; list-style: none; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: #2b2e33 transparent; border-top: 1px solid var(--line); }
.lib-glass .message { padding: 0 14px; }
.lib-row {
  width: 100%;
  height: 54px;
  padding: 0 14px 0 11px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border-bottom: 1px solid #17191c;
  border-left: 3px solid transparent;
}
.lib-row:active { background: #17191c; }
.lib-row.active { border-left-color: var(--signal); background: #15171a; }
.ver { flex: none; padding: 3px 7px; border: 1px solid var(--faint); border-radius: 4px; font-size: 9px; letter-spacing: 0.14em; color: var(--dim); }
.ver.edit { border-color: var(--signal); color: var(--signal); }
.dots { flex: none; display: flex; gap: 8px; width: 56px; justify-content: flex-end; }
.d { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--faint); background: transparent; }
.d.on { background: var(--bone); border-color: var(--bone); }
.d.stale { border-color: var(--signal); background: transparent; box-shadow: inset 0 0 0 2px #0e1013, inset 0 0 0 5px var(--signal); }
.lib-detail .detail-body { padding: 12px; overflow-y: auto; }
.detail-title { margin-bottom: 6px; font-size: 14px; line-height: 1.3; word-break: break-word; }
.detail-tags { margin-bottom: 10px; font-size: 10px; letter-spacing: 0.1em; color: var(--dim); text-transform: uppercase; line-height: 1.5; }
.detail-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #17191c; font-size: 10px; letter-spacing: 0.1em; }
.detail-row .k { color: var(--faint); }
.detail-row .v { color: var(--text); }
.detail-row .v.ok { color: var(--bone); }
.detail-row .v.warn { color: var(--signal); }
.detail-progress { margin-top: 14px; height: 4px; background: #1a1d21; border-radius: 2px; overflow: hidden; }
.detail-progress div { height: 100%; width: 0; background: var(--signal); }

/* ================= phone and tablet (the installed app) ================= */

html { overscroll-behavior: none; }
body { touch-action: manipulation; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }

/* No metal frame: the 800x480 screen itself fills the display. */
#stage.bare .device {
  width: 800px;
  height: 480px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
#stage.bare .screw { display: none; }
#stage.bare .screen { border-radius: 0; box-shadow: none; }

/* An upright phone: ask for it to be turned sideways. */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: #0b0c0e;
  font-size: 12px;
  letter-spacing: 0.26em;
  color: var(--dim);
}
.rotate-icon {
  width: 46px;
  height: 78px;
  border: 3px solid var(--bone);
  border-radius: 9px;
  animation: turn 2.4s ease-in-out infinite;
}
@keyframes turn { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 700px) { .rotate { display: flex; } }

/* The glove's highlight (focus.js): the button the glove will press with a thumb tap. */
.glove-focus { outline: 3px solid var(--signal) !important; outline-offset: 3px; box-shadow: 0 0 0 6px rgba(255, 91, 34, 0.25) !important; position: relative; z-index: 2; }
.map-val.fixed { color: var(--text); opacity: 0.75; }
.battery-fill.rec { background: var(--signal); }

/* glove page v0.5: more gesture rows, so the list scrolls inside its panel */
.glove-glass { min-height: 0; overflow: hidden; }
.glove-map { min-height: 0; overflow-y: auto; gap: 4px; padding: 4px 6px 4px 0; scrollbar-width: thin; scrollbar-color: #2b2e33 transparent; }
.glove-map .map-row { flex: 0 0 auto; padding: 5px 10px; }
.glove-map .gesture { width: 190px; flex: 0 0 190px; font-size: 11px; letter-spacing: 0.12em; }
.glove-head .glove-state { font-size: 26px; }

/* glove pointer v0.6: one ring that glides between buttons, plus a soft dot where the hand points */
.glove-focus { outline: none !important; box-shadow: none !important; }
#glove-ring {
  position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: 9998; pointer-events: none;
  border: 2px solid var(--signal); border-radius: 10px; opacity: 0;
  box-shadow: 0 0 0 5px rgba(255, 91, 34, 0.16), 0 0 26px rgba(255, 91, 34, 0.35);
  transition: left 0.24s cubic-bezier(0.22, 0.9, 0.3, 1), top 0.24s cubic-bezier(0.22, 0.9, 0.3, 1),
              width 0.24s cubic-bezier(0.22, 0.9, 0.3, 1), height 0.24s cubic-bezier(0.22, 0.9, 0.3, 1),
              border-radius 0.24s, opacity 0.2s, transform 0.12s;
}
#glove-ring.on { opacity: 1; }
#glove-ring.press { transform: scale(0.94); background: rgba(255, 91, 34, 0.12); }
#glove-dot {
  position: fixed; left: 0; top: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px; z-index: 9999;
  pointer-events: none; border-radius: 50%; opacity: 0; will-change: transform; transition: opacity 0.3s;
  background: radial-gradient(circle, rgba(255, 91, 34, 1) 0 22%, rgba(255, 91, 34, 0.28) 24% 62%, rgba(255, 91, 34, 0) 64%);
}
#glove-dot.on { opacity: 1; }
.map-head { margin: 8px 0 0; font-size: 9px; letter-spacing: 0.2em; color: var(--dim); flex: 0 0 auto; }
