/* Trim Planner — Gate 1 styles.
 * Dark theme. Big tap targets. Plain words. System fonts only (works offline).
 */
:root {
  --bg: #0f1115;
  --panel: #171b22;
  --panel2: #1f2530;
  --line: #2b3340;
  --text: #f4f6f9;
  --muted: #aab4c2;
  --accent: #f5a623;
  --accent-text: #1a1206;
  --ok: #3fd68c;
  --bad: #ff6b6b;
  --info: #5aa9ff;
  --radius: 12px;
}
/* Light mode */
[data-theme="light"] {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel2: #eef1f5;
  --line: #d5dbe3;
  --text: #1a1f28;
  --muted: #5a6575;
  --accent: #e8940a;
  --accent-text: #ffffff;
  --ok: #1a9e5c;
  --bad: #d63f3f;
  --info: #2a7fd6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

#app { min-height: 100vh; min-height: 100dvh; }

/* ---------- layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.topbar nav { display: flex; gap: 8px; align-items: center; }
.hello { color: var(--muted); font-size: 16px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}
.page.wide { max-width: 900px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

h1 { font-size: 30px; margin: 6px 0 12px; }
h2 { font-size: 24px; margin: 4px 0 10px; }
h3 { font-size: 20px; margin: 4px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 15px; }

/* ---------- buttons / inputs: BIG tap targets ---------- */
.btn {
  display: inline-block;
  min-height: 56px;
  padding: 14px 22px;
  font-size: 20px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  line-height: 1.3;
}
.btn:active { transform: scale(0.98); }
.btn.block { display: block; width: 100%; }
.btn.secondary {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--bad); color: #2b0d0d; }
.btn.okbtn { background: var(--ok); color: #06281a; }
.btn.sm { min-height: 48px; padding: 10px 16px; font-size: 17px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

label.field { display: block; margin: 14px 0 4px; font-size: 18px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  font-size: 20px;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
input:focus, select:focus, .btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.hint { font-size: 15px; color: var(--muted); margin-top: 4px; }

.err {
  background: #3a1d1d;
  border: 1px solid var(--bad);
  color: #ffd7d7;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 17px;
}
.okmsg {
  background: #123626;
  border: 1px solid var(--ok);
  color: #c9f5de;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 17px;
}

.linkrow { margin-top: 16px; text-align: center; }
.linkrow a { color: var(--info); font-size: 18px; }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
}
.badge.pending { background: #4a3a12; color: #ffd97a; }
.badge.active { background: #123626; color: #7fe6ab; }
.badge.disabled { background: #3a1d1d; color: #ff9d9d; }
.badge.owneronly { background: #2a2340; color: #c9b8ff; }
.badge.on { background: #123626; color: #7fe6ab; }
.badge.off { background: #2b3340; color: var(--muted); }

/* ---------- admin ---------- */
.bigcount { font-size: 56px; font-weight: 800; line-height: 1; margin: 4px 0; }

table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 16px;
}
table.users th { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.user-email { color: var(--muted); font-size: 14px; word-break: break-all; }
.user-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.rowbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tablewrap { overflow-x: auto; }

.flagrow {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.flagrow:last-child { border-bottom: none; }
.flagname { font-weight: 700; font-size: 18px; }
.flagdesc { color: var(--muted); font-size: 15px; margin-top: 2px; }
.flagbadges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.switchrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.switchrow .btn { flex: 1 1 auto; min-width: 120px; }

.override-panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 10px;
}
.override-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.override-row:last-child { border-bottom: none; }
.override-row select { width: auto; min-height: 48px; font-size: 16px; }

/* ---------- legal ---------- */
.legalpane {
  max-height: 38vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 16px;
}
.legalpane h4 { font-size: 18px; margin: 14px 0 6px; }
.legalpane h4:first-child { margin-top: 0; }
.legalpane p, .legalpane li { font-size: 16px; }
.legalpane ul { padding-left: 20px; }
.acceptrow { margin-top: 10px; }
.scrollhint { font-size: 15px; color: var(--muted); }

/* ---------- flags list (home) ---------- */
.flaglist { list-style: none; padding: 0; margin: 0; }
.flaglist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}
.flaglist li:last-child { border-bottom: none; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 24px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 18px;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

/* ================= Trim Planner (Gate 2) ================= */
.input, textarea.input {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  font-size: 20px;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
}
.input.big { font-size: 30px; min-height: 72px; font-weight: 700; }
.input:focus, textarea.input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
label { display: block; margin: 10px 0 4px; font-size: 17px; font-weight: 600; }
label .input, label select.input, label textarea.input { margin-top: 4px; font-weight: 400; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 8px 0; }
.row.space { justify-content: space-between; align-items: center; }
.grow { flex: 1 1 160px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.scrollx { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.sm { font-size: 15px; }
.big { font-size: 26px; }

.pill {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line);
  font-size: 16px; font-weight: 700; white-space: nowrap;
}
.pill.big { font-size: 20px; padding: 10px 20px; }
.pill.sm { font-size: 13px; padding: 3px 10px; }

/* TP nav frame */
.tpnav {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0 14px;
}
.tpnav-title { flex: 1; font-size: 22px; font-weight: 800; text-align: center; }
.tpwrap { max-width: 900px; margin: 0 auto; }

/* quick-switch job tabs (#21) */
.jobtabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 2px 2px 10px; margin: 0 -2px;
  -webkit-overflow-scrolling: touch;
}
.jobtab {
  flex: 1 0 auto; text-align: center; text-decoration: none;
  font-size: 15px; font-weight: 700; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; white-space: nowrap;
}
.jobtab.active { color: var(--text); border-color: var(--accent); background: var(--panel2); }

/* fraction keypad fields: readonly, tap to open (#16, #17) */
input.frackey { caret-color: transparent; }

/* setup: Use preset / New material switch (#9) */
.segrow { display: flex; gap: 8px; margin: 12px 0; }
.segrow .btn { flex: 1; }

/* job cards */
.jobcard-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.jobcard-name { font-size: 24px; font-weight: 800; color: var(--text); text-decoration: none; }
.jobcard-actions { display: flex; gap: 10px; margin-top: 10px; }
.tptabs { display: flex; gap: 10px; margin: 12px 0; }

/* menu */
.menulist { padding: 6px; }
.menuitem {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 14px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--text); min-height: 64px;
}
.menuitem:last-child { border-bottom: none; }
.menuitem-t { font-size: 21px; font-weight: 700; }
.menuitem-d { flex: 1; color: var(--muted); font-size: 15px; }
.menuitem-go { font-size: 28px; color: var(--muted); }

/* measurement field rows */
.fieldrow {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; text-align: left; background: var(--bg);
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 8px 0; min-height: 72px; cursor: pointer;
  color: var(--text); font-size: 18px; font-family: inherit;
}
.fieldrow-label { flex: 1; }
.fieldrow-val { font-size: 30px; font-weight: 800; white-space: nowrap; }
.fieldrow-val.big { font-size: 34px; }

/* fraction keypad */
.tpkeys { margin: 10px 0; }
.tpkeys-quick { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px; margin-bottom: 8px; padding-bottom: 2px; }
.tpkeys-quick .btn { flex: none; }
.tpkeys-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tpkeys-grid .equals-wide { grid-column: span 2; background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 24px; }
.btn.tpkey { min-height: 60px; font-size: 24px; padding: 10px 4px; }

/* bottom sheet editor */
.tpsheet {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
}
.tpsheet-card {
  width: 100%; max-width: 640px; background: var(--panel);
  border-radius: 20px 20px 0 0; padding: 20px 18px 30px;
  border-top: 2px solid var(--line);
}
.tpsheet-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.voicebig { font-size: 64px; font-weight: 800; text-align: center; margin: 18px 0; }

/* draw canvas */
.canvas-card { padding: 10px; }
#drawcv { width: 100%; height: auto; border-radius: 12px; touch-action: none; display: block; }
/* Round-4 #1: wall dropdown sits with the layer/room chips. */
select.wallselect {
  flex: none;
  width: auto;
  min-height: 48px;
  font-size: 17px;
  font-weight: 600;
  padding: 10px 12px;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-self: center;
}
.corneredit { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.corneredit-h { font-weight: 700; font-size: 18px; margin-bottom: 6px; }

/* cut list */
.cuthead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cutcard.done { opacity: 0.62; }
.cutcheck { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; width: 100%; }
.cutcheck input[type="checkbox"] { width: 40px; height: 40px; flex: none; margin-top: 6px; accent-color: var(--ok); }
.cutmain { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cuttag { font-size: 17px; font-weight: 600; }
.cutbig { font-size: 44px; font-weight: 800; line-height: 1.1; }
.cutsmall { font-size: 17px; color: var(--muted); }
.cutguide { font-size: 16px; color: var(--info, #7fd4ff); margin-top: 6px; line-height: 1.5; }
.stockplan { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.stockplan-h { font-weight: 700; margin-bottom: 8px; }
.stockplan-b { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 17px; }
.simplenav { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; }
.checkline { display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 600; margin: 10px 0; }
.checkline input[type="checkbox"] { width: 32px; height: 32px; accent-color: var(--accent); }

/* calculator */
.calctop { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.calcbody { display: flex; gap: 10px; height: 132px; margin-bottom: 8px; }
.calclines { flex: 1.2; height: 100%; overflow-y: auto; }
/* Round-4 #7: swipe-to-delete — the row slides left to reveal Delete. */
.calcline-wrap { position: relative; overflow: hidden; border-radius: var(--radius); margin-bottom: 8px; }
.calcline {
  display: flex; align-items: center; gap: 8px; padding: 10px;
  border: 2px solid var(--line); border-radius: var(--radius);
  cursor: pointer; background: var(--bg);
  transition: transform 0.18s ease;
  position: relative; z-index: 1;
}
.calcline.swiped { transform: translateX(-84px); }
.calcline-del {
  position: absolute; right: 0; top: 0; bottom: 0; width: 84px;
  background: #e5484d; color: #fff; border: none; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 16px; font-weight: 700; cursor: pointer; z-index: 0;
}
.calcline.sel { border-color: var(--accent); }
.calc-op { font-size: 26px; font-weight: 800; min-width: 30px; text-align: center; }
.calc-val { flex: 1; font-size: 24px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.calcanswer {
  flex: 1; background: var(--panel2); border: 2px solid var(--accent);
  border-radius: var(--radius); padding: 14px; text-align: center;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0;
}
.calcanswer-v { font-size: 44px; font-weight: 800; white-space: nowrap; }
.calckeys { display: flex; gap: 8px; margin: 8px 0; }
#app.calcapp .calckeys .btn.tpkey { min-height: 56px; font-size: 20px; }
.calc-ops { display: grid; grid-template-columns: 1fr; gap: 8px; flex: 0 0 76px; }
.calc-ops .btn.tpkey { min-height: 64px; }
.calckeys .tpkeys-grid { flex: 1; }
.convrow { display: flex; gap: 12px; align-items: flex-end; }
.conv-arrow { font-size: 34px; padding-bottom: 60px; }
.conv-out { font-size: 34px; font-weight: 800; min-height: 72px; display: flex; align-items: center; white-space: nowrap; }

/* calculator: stationary keypad (#4-7, reworked round-2 #2). The keypad +
   action buttons live in a sticky footer pinned to the viewport bottom.
   Everything above keeps natural fixed heights, so keys are never squeezed
   into clipped strips and nothing jumps while typing. */
.calc-sticky {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--bg);
  border-top: 1px solid var(--line);
  margin: 10px -16px 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.calc-sticky .calckeys { margin-top: 0; }
.calc-sticky .btnrow { margin-bottom: 0; }
/* conversion mode: keypad full-width below the card (#7) */
#conv-keys { display: flex; margin: 0 0 8px; }
#conv-keys .tpkeys { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; }

/* ============ Round-4 #2: calculator fits on one screen, zero scrolling ============
 * #app becomes a fixed-height flex column; the keypad flexes to fill whatever
 * space is left after the compact top. Keypad buttons shrink (min-height: 0)
 * instead of forcing the page to scroll. */
#app.calcapp { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#app.calcapp .topbar { flex: none; }
#app.calcapp main.page.calcpage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 12px 0;
}
#app.calcapp .page.calcpage .tpnav { flex: none; padding: 6px 0 8px; }
#app.calcapp .page.calcpage .tpwrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Compact top: tabs, entry + answer, quick fractions. */
#app.calcapp .calctop { flex: none; margin-bottom: 6px; }
/* Round-4 #5: tabs sit side-by-side, smaller; exit/gear shrink to match. */
#app.calcapp .calctop .btnrow { flex-wrap: nowrap; margin: 0; gap: 8px; }
#app.calcapp .calctop .btnrow .btn { min-height: 40px; padding: 8px 12px; font-size: 15px; white-space: nowrap; }
#app.calcapp .calctop > .btn.sm { min-height: 40px; padding: 8px 12px; font-size: 15px; }
#app.calcapp #gear-panel { flex: none; }
#app.calcapp #gear-panel .card { margin-bottom: 8px; padding: 12px; }
/* Round-4 #5: slimmer answer box gives the keypad more vertical room. */
#app.calcapp .calcbody { flex: none; height: 88px; margin-bottom: 6px; }
/* Round-4 #14: single expression bar — one line for the equation/answer. */
#app.calcapp .calcexpr {
  flex: none;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 12px 14px;
  margin-bottom: 6px;
  min-height: 88px;
  display: flex;
  align-items: center;
  overflow: hidden;
}
#app.calcapp .calcexpr-v {
  font-size: 52px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
}
#app.calcapp .calcanswer { padding: 6px 10px; }
#app.calcapp .calcanswer-v { font-size: 30px; }
#app.calcapp .calc-val { font-size: 20px; }
#app.calcapp .calcline { padding: 8px 10px; margin-bottom: 6px; }
#app.calcapp .tpkeys-quick { flex: none; margin-bottom: 6px; }
#app.calcapp .tpkeys-quick .btn { min-height: 44px; padding: 8px 14px; font-size: 16px; }
/* Keypad takes all remaining space; buttons shrink to fit. */
#app.calcapp .calc-sticky {
  position: static;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 6px -12px 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
#app.calcapp .calc-sticky .calckeys {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 0 8px;
  display: flex;
}
#app.calcapp .calc-sticky .btnrow { flex: none; margin-bottom: 0; }
#app.calcapp .calc-sticky .btnrow .btn { min-height: 52px; padding: 10px 16px; font-size: 18px; }
#app.calcapp .calc-ops {
  flex: 0 0 68px;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
}
#app.calcapp .calckeys .tpkeys-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
}
#app.calcapp .btn.tpkey {
  min-height: 0;
  height: 100%;
  padding: 6px 4px;
  font-size: 22px;
}
#app.calcapp .calc-ops .btn.tpkey { min-height: 0; }
/* Conversion mode keypad fills the same way. */
#app.calcapp #conv-keys { flex: 1 1 auto; min-height: 0; display: flex; margin: 0; }
#app.calcapp #conv-keys .tpkeys { flex: 1 1 auto; min-height: 0; }
#app.calcapp #conv-keys .tpkeys-grid {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: repeat(4, 1fr);
}
#app.calcapp .card { margin-bottom: 8px; padding: 14px; }
#app.calcapp .conv-out { font-size: 28px; min-height: 56px; }
#app.calcapp .conv-arrow { padding-bottom: 40px; }
/* Update-available banner (Round-4 #4). */
#update-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: var(--accent-text);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#update-banner .btn { min-height: 44px; padding: 8px 18px; font-size: 17px; }

/* Guide step numbers */
.stepnum {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 22px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin-right: 12px;
}
/* ============ Interactive tour ============ */
.tour-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
}
.tour-highlight {
  box-shadow: 0 0 0 4px var(--accent), 0 0 24px var(--accent) !important;
  border-radius: var(--radius);
  animation: tour-pulse 1.2s ease-in-out infinite;
}
@keyframes tour-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent), 0 0 12px var(--accent); }
  50% { box-shadow: 0 0 0 6px var(--accent), 0 0 28px var(--accent); }
}
.tour-tooltip {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 1003;
  background: #1a1f28;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.tour-tooltip h3 { margin: 0 0 8px; font-size: 20px; }
.tour-tooltip p { margin: 0 0 12px; font-size: 16px; line-height: 1.4; }
.tour-progress {
  font-size: 13px; font-weight: 700; color: var(--accent);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.tour-welcome-card {
  position: absolute;
  top: 50%; left: 16px; right: 16px;
  transform: translateY(-50%);
  background: #1a1f28;
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}
.tour-welcome-card h2 { margin: 0 0 12px; }
.tour-welcome-card p { margin: 0 0 16px; font-size: 16px; line-height: 1.4; }
.tour-welcome-card .btn { margin-bottom: 8px; }
/* Admin user cards (mobile-friendly) */
.usercards { display: flex; flex-direction: column; gap: 12px; }
.usercard {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.usercard-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.usercard-top strong { font-size: 18px; }
.user-email { font-size: 15px; color: var(--muted); word-break: break-all; margin-bottom: 4px; }
.user-sub { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.usercard-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.usercard-actions .btn { flex: 1 1 auto; min-width: 100px; }
/* Measurement minimap: wall outline with current piece highlighted */
.minimap {
  background: var(--panel2);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
}
.minimap svg { display: block; }

/* Swipe-to-delete on review rows */
.swiperow { position: relative; overflow: hidden; border-radius: 12px; }
.swipedelete {
  position: absolute; right: 0; top: 0; bottom: 0; width: 80px;
  background: #c0392b; color: #fff; border: none; font-size: 16px; font-weight: 700;
  border-radius: 0 12px 12px 0;
}
.swipefront { position: relative; z-index: 1; width: 100%; margin: 0; }

/* Keypad inside a .row label: take full width, don't get squeezed */
.row .tpkeys { flex: 1 1 100%; min-width: 100%; }
label .tpkeys { width: 100%; }

/* Landscape: draw pad fills the screen, 5 buttons pinned at bottom */
@media (orientation: landscape) {
  .page:has(#drawcv) { max-width: none; padding: 8px; }
  .page:has(#drawcv) .btnrow.scrollx { display: none; } /* hide layer/room chips */
  .page:has(#drawcv) .tpnav { display: none; } /* hide nav to maximize space */
  .page:has(#drawcv) .canvas-card { padding: 0; margin: 0; }
  .page:has(#drawcv) #drawcv { height: calc(100vh - 120px); width: 100%; object-fit: contain; }
  .page:has(#drawcv) .muted.sm { display: none; } /* hide hints */
}

/* Patch notes modal */
#patch-notes {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.patch-card {
  background: var(--card, #1c2330); color: var(--text, #fff);
  border-radius: 16px; padding: 20px; max-width: 400px; width: 100%;
  max-height: 80vh; overflow-y: auto;
}
.patch-card h2 { margin: 0 0 12px; }
.patch-card ul { margin: 0 0 16px; padding-left: 20px; }
.patch-card li { margin-bottom: 8px; line-height: 1.4; }
