:root,
html[data-theme="light"] {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --card: #eef2f6;
  --text: #0f172a;
  --muted: #64748b;
  --teal: #0d9488;
  --teal-dim: #0f766e;
  --danger: #dc2626;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* Visual Home Indicator only: 5pt pill + 8pt from bottom = 13pt. Paint, no controls. */
  --home-slot: #020617;
  --home-slot-h: 0px;
  --home-slot-h: min(13px, env(safe-area-inset-bottom, 0px));
  --safe-b-nav: var(--home-slot-h);
  --nav-icons: 56px;
  --nav: 56px;
  --tap: 44px;
  --border: #d0d9e4;
  --input-bg: #ffffff;
  --topbar-bg: rgba(244, 246, 248, 0.96);
  --list-active: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --chip-active-bg: #ccfbf1;
  --chip-active-border: #0d9488;
  --chip-active-text: #0f766e;
}
/* Pure white — closest to Fieldwire web */
html[data-theme="cloud"] {
  --bg: #ffffff;
  --panel: #ffffff;
  --card: #f3f4f6;
  --text: #111827;
  --muted: #6b7280;
  --teal: #2563eb;
  --teal-dim: #1d4ed8;
  --danger: #dc2626;
  --border: #e5e7eb;
  --input-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.98);
  --list-active: #f3f4f6;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
  --chip-active-bg: #dbeafe;
  --chip-active-border: #2563eb;
  --chip-active-text: #1d4ed8;
}
html[data-theme="paper"] {
  --bg: #f7f3eb;
  --panel: #fffdf8;
  --card: #f0e9dc;
  --text: #1c1917;
  --muted: #78716c;
  --teal: #0f766e;
  --teal-dim: #115e59;
  --danger: #b91c1c;
  --border: #e7e0d3;
  --input-bg: #fffdf8;
  --topbar-bg: rgba(247, 243, 235, 0.96);
  --list-active: #ebe4d6;
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.06);
  --chip-active-bg: #ccfbf1;
  --chip-active-border: #0f766e;
  --chip-active-text: #115e59;
}
html[data-theme="soft"] {
  --bg: #f5f3ff;
  --panel: #faf8ff;
  --card: #ebe6fa;
  --text: #1e1b4b;
  --muted: #6b7280;
  --teal: #7c3aed;
  --teal-dim: #6d28d9;
  --danger: #dc2626;
  --border: #ddd6fe;
  --input-bg: #faf8ff;
  --topbar-bg: rgba(245, 243, 255, 0.96);
  --list-active: #e9e4f8;
  --shadow: 0 1px 3px rgba(30, 27, 75, 0.06);
  --chip-active-bg: #ede9fe;
  --chip-active-border: #7c3aed;
  --chip-active-text: #5b21b6;
}
html[data-theme="slate"] {
  --bg: #e8eef4;
  --panel: #f1f5f9;
  --card: #dde5ee;
  --text: #0f172a;
  --muted: #64748b;
  --teal: #0d9488;
  --teal-dim: #0f766e;
  --danger: #dc2626;
  --border: #c5d0dc;
  --input-bg: #f8fafc;
  --topbar-bg: rgba(232, 238, 244, 0.96);
  --list-active: #d4dde8;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --chip-active-bg: #ccfbf1;
  --chip-active-border: #0d9488;
  --chip-active-text: #0f766e;
}
html[data-theme="ocean"] {
  --bg: #e6eef6;
  --panel: #f0f7fc;
  --card: #d9e8f4;
  --text: #0c4a6e;
  --muted: #64748b;
  --teal: #0284c7;
  --teal-dim: #0369a1;
  --danger: #dc2626;
  --border: #b8d0e4;
  --input-bg: #f8fcff;
  --topbar-bg: rgba(230, 238, 246, 0.96);
  --list-active: #cfe0ef;
  --shadow: 0 1px 3px rgba(12, 74, 110, 0.07);
  --chip-active-bg: #e0f2fe;
  --chip-active-border: #0284c7;
  --chip-active-text: #0369a1;
}
html[data-theme="dark"] {
  --bg: #152238;
  --panel: #243447;
  --card: #2f4258;
  --text: #f8fafc;
  --muted: #a8b9cc;
  --teal: #2dd4bf;
  --teal-dim: #0d9488;
  --danger: #fca5a5;
  --border: #3d556e;
  --input-bg: #1a2b40;
  --topbar-bg: rgba(21, 34, 56, 0.96);
  --list-active: #2c4058;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  --chip-active-bg: #134e4a;
  --chip-active-border: #2dd4bf;
  --chip-active-text: #5eead4;
}
html[data-theme="midnight"] {
  --bg: #0a0a0b;
  --panel: #17171a;
  --card: #222226;
  --text: #fafafa;
  --muted: #a1a1aa;
  --teal: #5eead4;
  --teal-dim: #0f766e;
  --danger: #f87171;
  --border: #3f3f46;
  --input-bg: #111114;
  --topbar-bg: rgba(10, 10, 11, 0.96);
  --list-active: #27272a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --chip-active-bg: #134e4a;
  --chip-active-border: #5eead4;
  --chip-active-text: #99f6e4;
}
* { box-sizing: border-box; }
/*
 * Full-bleed shell. Do NOT lock height to window.innerHeight / --app-h:
 * on iOS A2HS that value is often short of the layout viewport and leaves a
 * dead band under the tab bar (icons look “high”). inset:0 fills the webview.
 */
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: -webkit-fill-available;
}
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  overflow: hidden;
  background: var(--bg, #f4f6f8);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  transition: background 0.15s, color 0.15s;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
#app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: auto; /* top+bottom pin — never a short --app-h */
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 0.45rem;
  /* Clear iPhone status bar / Dynamic Island (viewport-fit=cover + black-translucent) */
  padding: calc(0.5rem + var(--safe-t, env(safe-area-inset-top, 0px))) 0.65rem 0.5rem;
  background: var(--topbar-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 0.95rem; margin: 0; font-weight: 700; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 0.55rem; padding: 0.45rem;
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
}
.icon-btn i { font-size: 1.1rem; line-height: 1; }
.icon-btn.primary { background: var(--teal-dim); border-color: var(--teal); }
.icon-btn.danger { border-color: #7f1d1d; color: var(--danger); }

/* Fixed bottom-nav — reserve its height so list content is not covered */
.main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.75rem;
  padding-bottom: calc(var(--nav) + var(--safe-b-nav, 0px) + 0.75rem);
}
.main.plan-mode {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 0.85rem;
  padding: 0.85rem; margin-bottom: 0.55rem;
}
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.85rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: 0.85rem; margin-bottom: 0.45rem; width: 100%; text-align: left;
}
.list-row:active { background: var(--list-active); }
/* Defect browse */
.browse-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.35rem 0 0.45rem;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.browse-nav {
  min-width: 5.5rem;
  height: 2.6rem;
  padding: 0 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1;
  font-weight: 700;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.browse-nav:disabled {
  opacity: 0.3;
  pointer-events: none;
}
.browse-nav:not(:disabled):active {
  background: var(--list-active);
  transform: scale(0.96);
}
.browse-pos {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 3.5rem;
  text-align: center;
}
.topbar-save {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal);
  max-width: 6.5rem;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.35rem 0.45rem;
  line-height: 1.1;
}

/* Fieldwire-style: one low-profile horizontal filter strip */
.task-filters {
  margin: 0 0 0.45rem;
  margin-left: -0.75rem;
  margin-right: -0.75rem;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.fw-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.28rem 0;
  scrollbar-width: none;
  min-height: 2rem;
}
.fw-filter-bar::-webkit-scrollbar { display: none; }
.fw-filter-icon {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
  width: 1.1rem;
  text-align: center;
  opacity: 0.85;
}
.fw-filter {
  flex: 0 0 auto;
  max-width: 8.5rem;
  height: var(--tap);
  min-height: var(--tap);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0 1.35rem 0 0.65rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  background-size: 0.5rem;
  cursor: pointer;
}
.fw-filter:focus {
  outline: none;
  border-color: var(--teal);
}
/* Active filter chip (Fieldwire highlights applied filters) */
.fw-filter.is-active {
  background-color: var(--chip-active-bg);
  border-color: var(--chip-active-border);
  color: var(--chip-active-text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%230f766e' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
.fw-filter-count {
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 0.15rem 0 0.25rem;
  margin-left: auto;
}
.fw-filter-clear {
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--teal);
  padding: 0.2rem 0.35rem;
  white-space: nowrap;
}
.fw-filter-clear:active { opacity: 0.7; }
/* Plan multi-filter opens a sheet (not a native multi-select) */
button.fw-filter-btn {
  max-width: 8.5rem;
  padding-right: 0.55rem;
  background-image: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
button.fw-filter-btn.is-active {
  background-image: none;
}

/* Projects / Tasks + FABs / defect camera + − FABs (same corner language as plan view).
   z-index above QA (180) so Add stays tappable if the harness panel is on. */
.projects-add-fab,
.tasks-add-fab,
.defect-close-fab,
.defect-cam-fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--nav) + var(--safe-b-nav) + 1rem);
  z-index: 190;
}
.defect-cam-fab {
  bottom: calc(var(--nav) + var(--safe-b-nav) + 1rem + 3.85rem);
  background: var(--teal-dim, #0f766e);
  color: #ecfdf5;
  font-size: 1.15rem;
}
.defect-close-fab {
  /* Distinct from teal + : slate/muted so it reads as “close / leave” */
  background: #334155;
  color: #f8fafc;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.4);
  font-size: 2rem;
  font-weight: 600;
  line-height: 0.9;
}
html[data-theme="light"] .defect-close-fab,
html[data-theme="cloud"] .defect-close-fab,
html[data-theme="paper"] .defect-close-fab,
html[data-theme="soft"] .defect-close-fab {
  background: #475569;
  color: #fff;
}
.task-list-pad,
.defect-swipe-root {
  padding-bottom: 8.5rem; /* room for camera + close FABs */
}
/* Form at the top of the page — do not 100dvh-spacer it off-screen
   (Chrome app-scale made min-height:100dvh push the card below the fold). */
.defect-swipe-root {
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}
.defect-swipe-root > .back-banner,
.defect-swipe-root > .browse-bar,
.defect-swipe-root > .swipe-hint,
.defect-swipe-root > p.muted {
  flex-shrink: 0;
}
.defect-swipe-card {
  margin-top: 0.25rem;
  flex-shrink: 0;
}
.defect-swipe-root > .section-h,
.defect-swipe-root > .photo-grid {
  flex-shrink: 0;
}
/* Status + severity on one row (severity right) */
.field-row-sev-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  grid-column: 1 / -1;
}
.field-row-sev-status .field {
  margin: 0;
}
.field-status-soft label,
.status-select-soft {
  opacity: 0.55;
  color: var(--muted);
}
.status-select-soft {
  border-style: dashed;
}
.field-status-soft:focus-within label,
.field-status-soft:focus-within .status-select-soft {
  opacity: 0.9;
}
textarea.ta-autogrow,
textarea[data-live="defect"] {
  min-height: 4.5rem;
  resize: vertical;
  line-height: 1.4;
}
.types-row-master {
  align-items: center;
}
.types-row-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}
@media (min-width: 900px) and (pointer: fine) {
  .projects-add-fab,
  .tasks-add-fab,
  .defect-close-fab {
    bottom: 1.25rem;
  }
  .defect-cam-fab {
    bottom: calc(1.25rem + 3.85rem);
  }
}

/* Appearance picker — mini UI sample per theme */
.theme-grid {
  display: flex; flex-direction: column; gap: 0.5rem;
}
.theme-group-label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin: 0.35rem 0 0.1rem;
}
.theme-card {
  display: flex; align-items: stretch; gap: 0.7rem;
  width: 100%; text-align: left;
  border: 1px solid var(--border); background: var(--panel);
  border-radius: 0.75rem; padding: 0.5rem 0.6rem;
  position: relative;
  box-shadow: var(--shadow);
}
.theme-card.active { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.theme-preview {
  width: 4.6rem; height: 3.1rem; border-radius: 0.4rem; overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08); flex-shrink: 0;
  display: flex; flex-direction: column; pointer-events: none;
}
.theme-preview-bar {
  height: 0.55rem; flex-shrink: 0;
  display: flex; align-items: center; gap: 2px; padding: 0 3px;
}
.theme-preview-bar i {
  width: 4px; height: 4px; border-radius: 50%; display: block; opacity: 0.5;
}
.theme-preview-body {
  flex: 1; padding: 3px; display: flex; flex-direction: column; gap: 2px;
}
.theme-preview-row {
  height: 0.55rem; border-radius: 2px; flex: 1;
}
.theme-preview-chip {
  align-self: flex-start; height: 0.4rem; width: 1.4rem; border-radius: 999px;
}
.theme-card-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.theme-check {
  color: var(--teal); font-weight: 800; font-size: 0.95rem; align-self: center;
}
.photo-grid img {
  background: var(--card);
}
.muted { color: var(--muted); font-size: 0.75rem; }
.title { font-weight: 700; font-size: 0.95rem; }
.badge {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  padding: 0.15rem 0.4rem; border-radius: 9999px; background: #0f766e33; color: var(--teal);
}
/* Traffic-light severity: green / yellow / orange / red */
.sev-low, .pin-sev-low, .badge.sev-low {
  background: #22c55e !important; color: #052e16 !important;
}
.sev-medium, .pin-sev-medium, .badge.sev-medium {
  background: #eab308 !important; color: #1c1917 !important;
}
.sev-high, .pin-sev-high, .badge.sev-high {
  background: #f97316 !important; color: #1c1917 !important;
}
.sev-critical, .pin-sev-critical, .badge.sev-critical {
  background: #dc2626 !important; color: #fff !important;
}
/* Defect detail: severity colour on the select control only (not whole field) */
.field-severity {
  border-radius: 0.65rem;
  padding: 0;
  border: none;
  background: transparent;
}
.field-severity label {
  color: var(--muted);
  font-weight: 600;
}
.field-severity .sev-select,
.field-severity select {
  font-weight: 700;
  border-width: 2px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
/* Selected severity colours the option control itself */
.field-severity .sev-select.sev-low,
.field-severity select.sev-low {
  background: #bbf7d0 !important;
  border-color: #22c55e !important;
  color: #14532d !important;
}
.field-severity .sev-select.sev-medium,
.field-severity select.sev-medium {
  background: #fef08a !important;
  border-color: #eab308 !important;
  color: #713f12 !important;
}
.field-severity .sev-select.sev-high,
.field-severity select.sev-high {
  background: #fed7aa !important;
  border-color: #f97316 !important;
  color: #9a3412 !important;
}
.field-severity .sev-select.sev-critical,
.field-severity select.sev-critical {
  background: #fecaca !important;
  border-color: #dc2626 !important;
  color: #7f1d1d !important;
}
html[data-theme="dark"] .field-severity .sev-select:not(.sev-low):not(.sev-medium):not(.sev-high):not(.sev-critical),
html[data-theme="midnight"] .field-severity .sev-select:not(.sev-low):not(.sev-medium):not(.sev-high):not(.sev-critical),
html[data-theme="dark"] .field-severity select:not(.sev-low):not(.sev-medium):not(.sev-high):not(.sev-critical),
html[data-theme="midnight"] .field-severity select:not(.sev-low):not(.sev-medium):not(.sev-high):not(.sev-critical) {
  background: rgba(15, 23, 42, 0.85) !important;
  color: #f8fafc !important;
}

.field { margin-bottom: 0.65rem; }
.field label { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; }
#live-type-custom,
#df-type-custom,
.sc-pin-type {
  -webkit-user-select: text;
  user-select: text;
  pointer-events: auto;
  touch-action: manipulation;
}
.sc-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  appearance: none !important;
}
.field input, .field select, .field textarea {
  width: 100%; background: var(--input-bg); border: 1px solid var(--border); border-radius: 0.55rem;
  padding: 0.65rem 0.75rem;
  min-height: var(--tap);
  font-size: 16px;
  line-height: 1.3;
}
.field textarea { min-height: 4.5rem; resize: vertical; }
.field.live input:focus, .field.live select:focus, .field.live textarea:focus {
  border-color: var(--teal); box-shadow: 0 0 0 2px rgba(20,184,166,0.25);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 0.65rem; padding: 0.55rem 0.9rem; font-weight: 600; font-size: 1rem;
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--teal-dim); border-color: var(--teal); color: #ecfdf5; }
.btn.danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: 0.9rem; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav) + var(--safe-b-nav, 0px) + 0.5rem);
  transform: translateX(-50%) translateY(120%); background: #f8fafc; color: #0f172a;
  padding: 0.55rem 1rem; border-radius: 9999px; font-size: 0.8rem; font-weight: 600;
  /* Above sheets (260), menus, and camera chrome so Create/Save feedback is never hidden */
  z-index: 500; opacity: 0; transition: 0.2s; max-width: 90vw; pointer-events: none;
}
.toast.show { transform: translateX(-50%); opacity: 1; }

/*
 * 56px tab row sits on the 13px visual Home Indicator (pill + 8pt inset).
 * That slot is paint-only. The pill cannot be removed or used for controls.
 */
.bottom-nav {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  flex: none;
  z-index: 200;
  box-sizing: border-box !important;
  width: 100%;
  height: var(--nav) !important;
  min-height: var(--nav) !important;
  max-height: var(--nav) !important;
  padding: 0 !important;
  margin: 0 !important;
  bottom: var(--safe-b-nav, 0px) !important;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  pointer-events: auto;
  touch-action: manipulation;
  overflow: hidden;
}
.bottom-nav::before {
  display: none !important;
  content: none !important;
}
/* Apple Home Indicator: paint only. Not tappable. */
.sc-home-slot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--home-slot-h, 0px);
  background: var(--home-slot, #020617);
  z-index: 50;
  pointer-events: none;
}
body.sc-desktop .sc-home-slot,
html.sc-ipad .sc-home-slot {
  display: none;
}
.bottom-nav button {
  flex: 1 1 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--nav) !important;
  min-height: var(--nav) !important;
  max-height: var(--nav) !important;
  align-self: stretch;
  box-sizing: border-box;
  padding: 4px 2px 4px !important;
  margin: 0;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.bottom-nav button span {
  line-height: 1.15;
  pointer-events: none;
}
.bottom-nav button.active { color: var(--teal); font-weight: 700; }
.bottom-nav i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 22px;
  pointer-events: none;
  line-height: 1;
}

html,
html.sc-browser,
html.sc-standalone,
:root {
  --ios-bottom-gap: 0px;
  --ios-screen-gap: 0px;
}

/* iOS: chrome that used viewport-fixed must pin to #app (now screen-tall). */
html.sc-ios-fill .projects-add-fab,
html.sc-ios-fill .tasks-add-fab,
html.sc-ios-fill .defect-close-fab,
html.sc-ios-fill .defect-cam-fab,
html.sc-ios-fill .add-menu-close-fab,
html.sc-ios-fill .toast,
html.sc-ios-fill .sheet,
html.sc-ios-fill .backdrop,
html.sc-ios-fill .sc-qa-panel,
html.sc-ios-fill .menu-drawer,
html.sc-ios-fill .menu-backdrop,
html.sc-ios-fill .cam-overlay {
  position: absolute !important;
}

/* Sprint A — desktop: no bottom nav; top nav under topbar */
.desktop-top-nav {
  display: none;
  flex-shrink: 0;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.65rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.desktop-nav-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 0.88rem; font-weight: 600;
  padding: 0.55rem 0.85rem; border-radius: 0.5rem; cursor: pointer;
  white-space: nowrap;
  min-height: var(--tap);
}
.desktop-nav-btn i { font-size: 1.05rem; pointer-events: none; }
.desktop-nav-btn:hover { background: var(--card); color: var(--text); }
.desktop-nav-btn.active {
  background: var(--chip-active-bg);
  border-color: var(--chip-active-border);
  color: var(--chip-active-text);
}
.menu-section-label {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
  padding: 0.65rem 1rem 0.25rem;
}

/* Desktop + iPad (body.sc-desktop set in JS via isDesktopUi / isLikelyIpad) */
@media (min-width: 900px) and (pointer: fine) {
  .bottom-nav { display: none !important; }
  .desktop-top-nav { display: flex; }
  html.sc-desktop-nav,
  body.sc-desktop {
    --nav: 0px;
  }
  body.sc-desktop .toast {
    bottom: 1rem;
  }
  body.sc-desktop .main:not(.plan-mode) {
    padding-bottom: 1.25rem;
  }
  body.sc-desktop .plan-toolbar {
    bottom: 0;
    background: linear-gradient(transparent, rgba(15, 23, 42, 0.55) 40%);
  }
  body.sc-desktop .plan-toolbar .hint {
    display: none; /* mode chips replace long hint on PC */
  }
}

/* iPad / forced desktop: hide phone bottom nav even when pointer is coarse */
body.sc-desktop .bottom-nav,
html.sc-ipad .bottom-nav {
  display: none !important;
}
body.sc-desktop .desktop-top-nav,
html.sc-ipad .desktop-top-nav {
  display: flex !important;
}
body.sc-desktop,
html.sc-ipad body,
html.sc-ipad {
  --nav: 0px;
}
body.sc-desktop .toast,
html.sc-ipad .toast {
  bottom: 1rem;
}
body.sc-desktop .main:not(.plan-mode),
html.sc-ipad .main:not(.plan-mode) {
  padding-bottom: 1.25rem;
}
body.sc-desktop .plan-toolbar,
html.sc-ipad .plan-toolbar {
  bottom: 0;
}

/*
 * iPhone: tabs under the topbar, no bottom bar. Page content (lists, plan)
 * runs to the physical bottom including the Home Indicator.
 */
html.sc-phone-top-nav,
body.sc-phone-top-nav {
  --nav: 0px;
  /* Full 34px Home Indicator — FABs, QA, sheets stay above the frozen band.
     Lists still extend: .main padding-bottom is overridden below. */
  --safe-b-nav: var(--safe-b);
}
body.sc-phone-top-nav .bottom-nav {
  display: none !important;
}
body.sc-phone-top-nav .sc-home-slot {
  display: none !important;
}
body.sc-phone-top-nav .desktop-top-nav {
  display: flex !important;
  align-items: stretch;
  justify-content: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
body.sc-phone-top-nav .desktop-nav-btn {
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 7px;
  font-size: 10px;
  border-radius: 0;
  border: none;
  min-height: 52px;
  white-space: nowrap;
}
body.sc-phone-top-nav .desktop-nav-btn i {
  font-size: 18px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.sc-phone-top-nav .main:not(.plan-mode) {
  padding-bottom: 0.75rem;
}
/* Plan chrome fills Apple’s Home Indicator; + stays above the pill. */
body.sc-phone-top-nav.sc-plan-view .plan-layout,
body.sc-phone-top-nav.sc-plan-view .main.plan-mode,
body.sc-phone-top-nav.sc-plan-view .plan-stage-wrap {
  background: #020617;
}
body.sc-phone-top-nav.sc-plan-view .plan-toolbar {
  bottom: 0 !important;
  padding-bottom: calc(0.55rem + var(--safe-b, env(safe-area-inset-bottom, 0px)));
}
html.sc-field.sc-phone-top-nav .desktop-nav-btn {
  min-height: 52px !important;
  font-size: 10px !important;
  padding: 6px 2px 7px !important;
}

/* Plan view: toolbar above fixed bottom-nav */
@media (max-width: 899px), (pointer: coarse) {
  body.sc-plan-view .plan-toolbar {
    bottom: calc(var(--nav) + var(--safe-b-nav, 0px));
    padding-bottom: 0.55rem;
  }
  body.sc-plan-view .toast {
    bottom: calc(var(--nav) + var(--safe-b-nav, 0px) + 0.5rem);
  }
}

.back-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  background: linear-gradient(90deg, #0f766e, #0d9488);
  color: #fff; padding: 0.75rem 0.85rem; margin: -0.75rem -0.75rem 0.75rem;
  font-weight: 700; font-size: 0.9rem; border: none; width: calc(100% + 1.5rem);
  text-align: left; cursor: pointer;
}
.back-banner .sub { font-weight: 500; font-size: 0.72rem; opacity: 0.9; }
.back-banner i { font-size: 1.1rem; }

.main { overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
.main.plan-mode { overflow: hidden; }
.main.defect-sheet {
  padding-bottom: 1rem;
  /* pan-y = vertical scroll; horizontal is handled by JS swipe */
  touch-action: pan-y;
  overscroll-behavior-x: none;
  overflow-x: hidden;
}
/* While finger is dragging horizontally, kill browser scroll/gesture steal */
body.sc-dragging-h,
body.sc-dragging-h * {
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}
.defect-swipe-root {
  will-change: transform;
  transition: transform 0.18s ease-out, opacity 0.18s ease-out;
  touch-action: pan-y;
}
.defect-swipe-root.is-dragging {
  transition: none;
}
.defect-swipe-card {
  touch-action: pan-y;
}
/* Grab cursor only when mobile swipe mode is active */
body.sc-mobile-swipe .defect-swipe-card {
  cursor: grab;
}
body.sc-mobile-swipe.sc-dragging-h .defect-swipe-card {
  cursor: grabbing;
}
.swipe-hint {
  color: var(--teal);
  font-weight: 600;
}
.photo-swipe-item {
  touch-action: pan-y;
  border-radius: 0.5rem;
  overflow: hidden;
}
.photo-swipe-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none; /* drag starts on container, not image */
  -webkit-user-drag: none;
  user-select: none;
}

/* Hamburger drawer — above QA chip (180) so the list is tappable to the bottom */
.menu-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 320; }
.menu-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(18rem, 86vw); z-index: 330;
  background: var(--panel); border-right: 1px solid #475569;
  transform: translateX(-105%); transition: transform 0.2s; display: flex; flex-direction: column;
  padding-top: var(--safe-t, env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--safe-b, env(safe-area-inset-bottom, 0px)) + 2rem);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.menu-drawer.open { transform: translateX(0); }
.menu-item {
  display: flex; align-items: center; gap: 0.65rem; width: 100%;
  padding: 0.85rem 1rem; border: none; background: transparent; color: var(--text);
  text-align: left; text-decoration: none; font-size: 0.9rem;
  min-height: 48px;
  box-sizing: border-box;
}
.menu-item i { width: 1.15rem; color: var(--muted); text-align: center; font-size: 1.1rem; }
.menu-item:active { background: #273549; }
.menu-divider { height: 1px; background: #334155; margin: 0.3rem 0; }

/* Home project filter chips (Sprint C) */
.home-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.55rem;
}
.home-filter-chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 9999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.home-filter-chip.active {
  background: var(--chip-active-bg);
  border-color: var(--chip-active-border);
  color: var(--chip-active-text);
}
.home-filter-chip:hover { color: var(--text); }

/* Plan groups — each group is a full-width row under the last */
.plan-groups {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
/* PC: multiple groups per row when viewport has room */
@media (min-width: 900px) {
  .plan-groups-desktop {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    gap: 0.75rem;
    align-items: start;
  }
  .plan-groups-desktop .plan-group {
    min-width: 0;
  }
}
.plan-group {
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: var(--panel);
  padding: 0.45rem 0.5rem 0.55rem;
  box-shadow: var(--shadow);
}
.plan-group-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
  min-height: 2rem;
}
.plan-group-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 2rem;
  height: 2rem;
  border-radius: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.plan-group-toggle:active { background: var(--list-active); }
.plan-group-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.plan-group-title {
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.line-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  background: #0f766e;
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}
.job-chip {
  flex: 0 1 auto;
  max-width: 7.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  background: #0f766e;
  color: #fff;
}
.job-actions {
  display: flex;
  gap: 0.45rem;
  margin: 0 0 0.65rem;
}
.job-action {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.55rem 0.35rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  color: inherit;
  background: var(--panel, #fff);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 0.7rem;
}
.job-action i { color: var(--muted, #64748b); }
@media (max-width: 389px) {
  .job-actions { flex-direction: column; }
}
@media (max-width: 339px) {
  .job-chip { display: none; }
}
.plan-group-count {
  font-size: 0.72rem;
  font-weight: 700;
}
.plan-group-rename {
  font-size: 0.7rem !important;
  padding: 0.3rem 0.5rem !important;
  flex-shrink: 0;
}
.plan-group-collapsed-hint {
  margin: 0 0.35rem 0.25rem 2.2rem;
  font-size: 0.72rem;
}
.plan-group-empty {
  grid-column: 1 / -1;
  margin: 0.35rem;
  font-size: 0.78rem;
}

/* Plan thumbnails grid — density scales with group size (2 → normal, 3+ → denser) */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
  margin-bottom: 0;
}
.plan-grid.dens-2 { grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
.plan-grid.dens-3 { grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.plan-grid.dens-4 { grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.plan-grid.dens-6 { grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
@media (min-width: 640px) {
  .plan-grid.dens-2 { grid-template-columns: repeat(3, 1fr); }
  .plan-grid.dens-3 { grid-template-columns: repeat(4, 1fr); }
  .plan-grid.dens-4 { grid-template-columns: repeat(4, 1fr); }
  .plan-grid.dens-6 { grid-template-columns: repeat(5, 1fr); }
}
/* PC denser tiles — smaller thumbs, more columns */
@media (min-width: 900px) {
  .plan-grid.dens-pc.dens-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
  .plan-grid.dens-pc.dens-3 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.32rem; }
  .plan-grid.dens-pc.dens-4 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.28rem; }
  .plan-grid.dens-pc.dens-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.25rem; }
  .plan-grid.dens-pc .plan-thumb { border-radius: 0.55rem; }
  .plan-grid.dens-pc .plan-thumb-img { aspect-ratio: 1 / 1; }
  .plan-grid.dens-pc .plan-thumb-meta { padding: 0.22rem 0.3rem 0.3rem; }
  .plan-grid.dens-pc .plan-thumb-meta .title { font-size: 0.62rem; line-height: 1.25; }
  .plan-grid.dens-pc .plan-thumb-meta .muted { display: none; }
  .plan-grid.dens-pc .plan-thumb-more {
    width: 1.35rem; height: 1.35rem; font-size: 0.75rem;
    top: 0.18rem; right: 0.18rem;
  }
  .plan-grid.dens-pc.dens-6 .plan-thumb-meta .title {
    font-size: 0.58rem;
  }
}
.plan-grid-add { margin-top: 0.35rem; margin-bottom: 0.75rem; }

.plan-thumb-wrap {
  position: relative;
  min-width: 0;
}
.plan-thumb {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--card);
  padding: 0;
  text-align: left;
  width: 100%;
  color: inherit;
  display: block;
}
.plan-thumb:active { border-color: var(--teal); }
.plan-thumb-img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--bg);
}
.plan-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.7rem;
}
.plan-thumb-meta { padding: 0.45rem 0.5rem 0.55rem; }
.plan-thumb-meta .title {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Dense groups: smaller meta + shorter image */
.plan-grid.dens-3 .plan-thumb-img { aspect-ratio: 1 / 1; }
.plan-grid.dens-3 .plan-thumb-meta { padding: 0.3rem 0.35rem 0.4rem; }
.plan-grid.dens-3 .plan-thumb-meta .title { font-size: 0.7rem; }
.plan-grid.dens-3 .plan-thumb-meta .muted { font-size: 0.62rem; }
.plan-grid.dens-4 .plan-thumb-img { aspect-ratio: 1 / 1; }
.plan-grid.dens-4 .plan-thumb-meta { padding: 0.25rem 0.3rem 0.35rem; }
.plan-grid.dens-4 .plan-thumb-meta .title { font-size: 0.65rem; }
.plan-grid.dens-4 .plan-thumb-meta .muted { font-size: 0.58rem; display: none; }
.plan-grid.dens-6 .plan-thumb-img { aspect-ratio: 1 / 1; }
.plan-grid.dens-6 .plan-thumb-meta { padding: 0.2rem 0.25rem 0.28rem; }
.plan-grid.dens-6 .plan-thumb-meta .title { font-size: 0.6rem; }
.plan-grid.dens-6 .plan-thumb-meta .muted { display: none; }

.plan-thumb-more {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  z-index: 2;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  padding: 0;
  opacity: 0.92;
}
.plan-thumb-more:active { background: var(--list-active); }
.plan-grid.dens-4 .plan-thumb-more,
.plan-grid.dens-6 .plan-thumb-more {
  width: 1.45rem;
  height: 1.45rem;
  font-size: 0.8rem;
}

.plan-add-tile {
  border: 1px dashed var(--border); border-radius: 0.75rem; background: transparent;
  min-height: 7rem; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.35rem; color: var(--muted); font-size: 0.8rem; font-weight: 600;
  width: 100%;
}
.plan-add-tile:active { border-color: var(--teal); color: var(--teal); }

.list-active { border-color: var(--teal) !important; box-shadow: 0 0 0 1px var(--teal); }

/* Plan stage + desktop side panel */
.plan-layout {
  flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative;
}
.plan-layout-desktop {
  flex-direction: row;
  align-items: stretch;
}
.plan-stage-wrap {
  flex: 1; min-height: 0; position: relative; background: #020617; touch-action: none; overflow: hidden;
}
/* iOS PWA: 47px of screen is outside innerHeight. Paint it like the plan so
   it doesn’t read as a second blank menu under the tabs. */
html:has(body.sc-plan-view),
body.sc-plan-view,
body.sc-plan-view #app {
  background: #020617;
}
.plan-layout-desktop .plan-stage-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.plan-side-panel {
  position: relative;
  width: min(26rem, 40vw);
  flex: 0 0 min(26rem, 40vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  color: var(--text);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: visible; /* allow resize grip to sit on the seam */
  z-index: 12;
  box-shadow: -4px 0 16px rgba(15, 23, 42, 0.06);
}
.plan-side-panel .panel-empty {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.plan-side-panel .panel-body {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--panel);
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;
  padding: 0.75rem 0.85rem; border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.panel-head .title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.panel-carousel {
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.panel-photo {
  display: block; width: 100%; max-height: 36vh; object-fit: contain; background: #0f172a;
}
.panel-photo-empty {
  min-height: 8rem; display: flex; align-items: center; justify-content: center;
  color: var(--muted); background: var(--card);
}
/* PC multi-photo drag-drop onto defect panel */
.panel-photo-drop {
  position: relative;
  cursor: copy;
  transition: outline-color 0.12s, background 0.12s;
}
.panel-photo-drop.drag-over {
  outline: 2px dashed var(--teal);
  outline-offset: -3px;
  background: var(--chip-active-bg);
}
.panel-photo-drop.drag-over .panel-photo {
  opacity: 0.5;
}
.panel-photo-drop.drag-over .panel-photo-empty {
  color: var(--chip-active-text);
  background: transparent;
}
.panel-carousel-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.4rem 0.65rem;
}
.panel-thumbs {
  display: flex; gap: 0.3rem; overflow-x: auto; padding: 0.35rem 0.65rem 0.55rem;
}
.panel-thumb {
  flex: 0 0 auto; width: 48px; height: 48px; padding: 0; border: 2px solid var(--border);
  border-radius: 0.35rem; overflow: hidden; background: var(--card);
}
.panel-thumb.active { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.panel-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.panel-fields { padding: 0.75rem 0.85rem 1rem; }

/* Panel pin list (empty / browse state) */
.panel-list-head {
  padding: 0.85rem 0.85rem 0.45rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-list-head .title { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.panel-list-filter {
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.panel-list-filter input {
  width: 100%; box-sizing: border-box; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); border-radius: 0.5rem;
  padding: 0.45rem 0.65rem; font-size: 0.8rem;
}
.panel-pin-list {
  flex: 1; min-height: 0; overflow-y: auto; padding: 0.35rem 0;
}
.panel-pin-row {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  text-align: left; border: none; background: transparent;
  padding: 0.55rem 0.75rem; cursor: pointer; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.panel-pin-row:hover { background: var(--card); }
.panel-pin-num {
  flex: 0 0 auto; min-width: 2.1rem; height: 2.1rem; border-radius: 0.45rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: #fff; background: var(--teal);
}
.panel-pin-num.sev-low { background: #22c55e; }
.panel-pin-num.sev-medium { background: #eab308; color: #1c1917; }
.panel-pin-num.sev-high { background: #f97316; }
.panel-pin-num.sev-critical { background: #dc2626; }
.panel-pin-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.panel-pin-meta .title {
  font-size: 0.85rem; font-weight: 650; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.panel-pin-meta .muted { font-size: 0.7rem; }

/* Floating plan chrome — mode chips + Fit */
.plan-float-chrome {
  position: absolute; top: 0.55rem; left: 0.55rem; right: 0.55rem; z-index: 16;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;
  pointer-events: none;
}
.plan-float-chrome > * { pointer-events: auto; }
.plan-mode-chips {
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.28rem;
  box-shadow: var(--shadow);
  max-width: min(100%, 22rem);
}
.mode-chip {
  border: none; background: transparent; color: var(--muted);
  font-size: 15px; font-weight: 700; padding: 8px 14px;
  min-height: var(--tap);
  border-radius: 999px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
}
.mode-chip:hover { color: var(--text); background: var(--card); }
.mode-chip.active {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  box-shadow: 0 0 0 1px var(--chip-active-border);
}
.plan-float-actions { display: flex; flex-direction: column; gap: 0.35rem; }
.plan-fit-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-size: 15px; font-weight: 700; padding: 8px 14px;
  min-height: var(--tap);
  border-radius: 0.65rem; cursor: pointer; box-shadow: var(--shadow);
}
.plan-fit-btn:hover { border-color: var(--teal); color: var(--teal); }
.plan-fit-btn.hidden { display: none !important; }
.plan-fit-btn i { font-size: 1.05rem; }
.panel-fields .field { margin-bottom: 0.55rem; }
.panel-fields .field label {
  display: block; font-size: 0.72rem; font-weight: 600; color: var(--muted); margin-bottom: 0.2rem;
}
.panel-fields .field input,
.panel-fields .field select,
.panel-fields .field textarea {
  width: 100%; box-sizing: border-box;
}

/* Defect types browser */
.types-tabs {
  display: flex; gap: 0.35rem; margin: 0 0 0.75rem; flex-wrap: wrap;
}
.types-tab {
  flex: 1 1 auto;
  min-width: 5.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.types-tab.active {
  background: var(--chip-active-bg, #ccfbf1);
  border-color: var(--chip-active-border, var(--teal));
  color: var(--chip-active-text, var(--teal-dim));
}
.types-row {
  align-items: center;
  gap: 0.5rem;
}
.plan-stage {
  position: absolute; inset: 0; overflow: hidden; touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.plan-layer {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform;
  /* Inverse of layer scale so pins stay a constant screen size at any zoom */
  --plan-inv-scale: 1;
}
.plan-layer img { display: block; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
/* Tip sits at left/top; counter-scale from that point so zoom doesn't shrink icons */
.plan-pin-anchor {
  position: absolute;
  width: 0;
  height: 0;
  transform: scale(var(--plan-inv-scale, 1));
  transform-origin: 0 0;
  pointer-events: none;
}
.plan-pin {
  position: absolute; left: 0; top: 0; width: 32px; height: 32px; margin: -28px 0 0 -16px;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 2px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; z-index: 2; background: #0d9488;
  touch-action: none; cursor: grab;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.plan-pin span, .plan-pin .plan-pin-num { transform: rotate(45deg); }
.plan-pin.active { outline: 3px solid #38bdf8; z-index: 3; }
.plan-pin.holding { transform: rotate(-45deg) scale(1.15); box-shadow: 0 0 0 4px rgba(56,189,248,0.45); }
/* Per-plan pin size (from + menu); tip stays on plan point */
.plan-pin.pin-sz-sm {
  width: 22px; height: 22px; margin: -19px 0 0 -11px;
  font-size: 8px; border-width: 1.5px;
}
.plan-pin.pin-sz-md {
  width: 32px; height: 32px; margin: -28px 0 0 -16px;
  font-size: 11px;
}
.plan-pin.pin-sz-lg {
  width: 44px; height: 44px; margin: -39px 0 0 -22px;
  font-size: 14px;
}
/* Large drag pin: tip sits on exact plan point; body above so finger doesn't cover tip */
.plan-pin.plan-pin-drag, .plan-pin.dragging {
  width: 52px; height: 52px; margin: -48px 0 0 -26px;
  z-index: 20; cursor: grabbing;
  box-shadow: 0 8px 24px rgba(0,0,0,0.55), 0 0 0 3px #38bdf8;
  font-size: 14px;
  pointer-events: none;
}
.plan-pin.plan-pin-drag.pin-sz-sm, .plan-pin.dragging.pin-sz-sm {
  width: 40px; height: 40px; margin: -36px 0 0 -20px; font-size: 11px;
}
.plan-pin.plan-pin-drag.pin-sz-lg, .plan-pin.dragging.pin-sz-lg {
  width: 64px; height: 64px; margin: -58px 0 0 -32px; font-size: 16px;
}
.plan-pin-tip {
  position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px;
  margin-left: -5px; background: #fff; border-radius: 50%;
  transform: rotate(45deg); box-shadow: 0 0 0 2px #0f172a;
}
.plan-pin-label {
  position: absolute; transform: none;
  background: rgba(15,23,42,0.92); color: #f1f5f9; border: 1px solid #475569;
  font-size: 9px; font-weight: 600; padding: 0.1rem 0.3rem; border-radius: 0.25rem;
  white-space: nowrap; max-width: 7rem; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; z-index: 2;
}
.plan-pin-label.pin-sz-sm { font-size: 8px; max-width: 5.5rem; padding: 0.05rem 0.22rem; }
.plan-pin-label.pin-sz-md { font-size: 9px; }
.plan-pin-label.pin-sz-lg { font-size: 11px; max-width: 9rem; padding: 0.12rem 0.35rem; }
/* Pin size S/M/L left · markup tools right (same row under Markup) */
.add-menu-markup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 0 0 0.25rem;
}
.add-menu-pin-sizes {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.28rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
  margin: 0;
}
.add-menu-markup-row .add-menu-tools {
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}
.add-menu-size-btn {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card, var(--panel));
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}
.add-menu-size-btn.active {
  border-color: var(--teal, #0d9488);
  background: rgba(13, 148, 136, 0.18);
  color: var(--teal, #0d9488);
  box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.25);
}
.add-menu-size-hint {
  font-size: 0.62rem;
  text-align: left;
}

/* Address typeahead dropdown */
.geo-field { position: relative; }
.geo-suggest {
  display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  max-height: 14rem; overflow-y: auto; margin-top: 0.25rem;
  background: #0f172a; border: 1px solid #475569; border-radius: 0.65rem;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.geo-suggest.open { display: block; }
.geo-item {
  display: block; width: 100%; text-align: left; border: none; border-bottom: 1px solid #1e293b;
  background: transparent; color: var(--text); padding: 0.7rem 0.75rem; cursor: pointer;
}
.geo-item:last-child { border-bottom: none; }
.geo-item:active, .geo-item:hover { background: #1e293b; }
.geo-main { display: block; font-weight: 700; font-size: 0.88rem; }
.geo-sub { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; line-height: 1.3; }

.map-crop {
  position: relative; width: 100%; max-height: 280px; background: #020617;
  border: 1px solid #475569; border-radius: 0.65rem; overflow: hidden;
  touch-action: none; user-select: none;
}
.map-crop img { display: block; width: 100%; height: auto; max-height: 280px; object-fit: contain; pointer-events: none; }
.map-corner {
  position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  background: #38bdf8; border: 3px solid #fff; border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5); z-index: 5; touch-action: none;
  cursor: nwse-resize;
}
.map-corner.nw { cursor: nwse-resize; }
.map-corner.se { cursor: nwse-resize; }
.map-corner::after {
  content: ''; position: absolute; inset: -12px; /* larger hit target */
}

.sync-badge {
  border: 1px solid #475569; background: #1e293b; color: #94a3b8;
  border-radius: 9999px; padding: 0.25rem 0.55rem; font-size: 0.65rem; font-weight: 700;
  max-width: 5.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sync-badge.ok { color: #6ee7b7; border-color: #065f46; }
.sync-badge.pending { color: #fcd34d; border-color: #92400e; }
.sync-badge.offline { color: #fca5a5; border-color: #7f1d1d; }

.plan-toolbar-compact { max-height: 42%; overflow-y: auto; }
.tool-row { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; width: 100%; }
/* Big + is rightmost; Done appears when a place tool is armed */
.tool-row-main {
  justify-content: flex-end;
  align-items: center;
  margin-left: auto;
  width: 100%;
  gap: 0.45rem;
}
.btn-add-fab {
  width: 3.35rem;
  height: 3.35rem;
  min-width: 3.35rem;
  border-radius: 9999px;
  border: none;
  background: var(--teal-dim);
  color: #ecfdf5;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.45);
  padding: 0;
  flex-shrink: 0;
}
.btn-add-fab:active { transform: scale(0.96); }
.btn-add-fab.armed {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--teal), 0 4px 14px rgba(13, 148, 136, 0.45);
}
#btn-cancel-add {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
}
.tool-row-main .tool-btn { font-size: 0.88rem; padding: 0.55rem 0.75rem; min-height: var(--tap); }
.tool-row-draw {
  display: none !important; /* markup tools live under + sheet only */
}
.tool-btn { min-width: 2.2rem; }
.add-menu-tools {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  justify-content: flex-end;
}
.add-menu-tools .btn { font-size: 0.88rem; padding: 0.55rem 0.75rem; min-height: var(--tap); }
.add-menu-tools-tight {
  gap: 0.28rem;
}
.add-menu-tools-tight .btn {
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
  min-height: var(--tap);
}
.add-menu-colors {
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  justify-content: flex-end;
  margin: 0.35rem 0 0.5rem;
}
.color-dot {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid #475569;
  padding: 0; cursor: pointer; flex-shrink: 0;
}
.color-dot.active { border-color: #fff; box-shadow: 0 0 0 2px #38bdf8; }

/* Compact + sheet: two-up tiles, right-biased primary (defect pin).
   Use % of #app (not vh) — Chrome app-scale makes 88vh taller than the app,
   so the form fields sat above the clip and you had to swipe to see them. */
.sheet-add-menu {
  max-height: 78%;
}
.sheet-pin-placed {
  max-height: 56%;
}
.sheet-pin-placed.sheet-pin-full {
  max-height: 86%;
}
.backdrop-pin-placed {
  background: rgba(15, 23, 42, 0.28);
}
.add-menu-title {
  margin: 0 0 0.15rem;
  font-size: 1rem;
  font-weight: 700;
}
/* − fixed bottom-right — same corner as + / defect − on other pages */
.add-menu-close-fab {
  position: fixed !important;
  right: 1rem;
  bottom: calc(var(--nav) + var(--safe-b-nav) + 1rem);
  z-index: 280; /* above sheet */
  width: 3.35rem !important;
  height: 3.35rem !important;
  min-width: 3.35rem !important;
  font-size: 2rem !important;
}
@media (min-width: 900px) and (pointer: fine) {
  .add-menu-close-fab {
    bottom: 1.25rem;
  }
}
.add-menu-body {
  /* room so Place tiles aren't hidden under the fixed − */
  padding-bottom: 4.75rem !important;
}
.add-menu-sec {
  margin: 0.45rem 0 0.3rem !important;
  font-size: 0.65rem !important;
}
.add-menu-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin: 0 0 0.15rem;
}
.add-menu-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.12rem;
  text-align: left;
  min-height: 3.6rem;
  padding: 0.5rem 0.55rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: var(--card, var(--panel));
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.add-menu-tile:active {
  transform: scale(0.98);
  background: var(--list-active, rgba(13, 148, 136, 0.12));
}
.add-menu-tile i {
  font-size: 0.95rem;
  margin-bottom: 0.05rem;
}
.add-menu-tile-title {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
}
.add-menu-tile-sub {
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.2;
}
/* Right tile = primary (defect pin) — slightly stronger for right-thumb reach */
.add-menu-tile-primary {
  border-color: var(--teal, #0d9488);
  background: rgba(13, 148, 136, 0.12);
  box-shadow: 0 1px 0 rgba(13, 148, 136, 0.15);
}
.add-menu-tile-sm {
  min-height: 3.15rem;
  padding: 0.4rem 0.5rem;
}
.add-menu-tile-sm .badge {
  font-size: 0.58rem;
  padding: 0.1rem 0.35rem;
  margin-bottom: 0.05rem;
}
.add-menu-done {
  margin-top: 0.55rem;
  font-size: 0.85rem;
  min-height: 2.4rem;
}

.plan-draw-svg {
  position: absolute; left: 0; top: 0; overflow: visible;
  pointer-events: none;
  /* Below pins / establish (z≥2) so markups never steal pin taps */
  z-index: 1;
}
#plan-pins {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  z-index: 6; /* above markup layer */
  pointer-events: none; /* only pins themselves receive events */
}
#plan-pins .plan-pin,
#plan-pins .plan-pin-label {
  pointer-events: auto;
}
.plan-draw-svg .draw-shape { pointer-events: none; touch-action: none; }
/* Only fat stroke hit-paths grab; centre grips removed */
.plan-draw-svg .draw-hit-path,
.plan-draw-svg .draw-resize-handle,
.plan-draw-svg .draw-resize-hit,
.plan-draw-svg .draw-resize-box {
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.plan-draw-svg .draw-sel-ring {
  pointer-events: none;
}
.plan-draw-svg .draw-note-badge {
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 2px;
}
.plan-toolbar {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--nav) + var(--safe-b-nav, 0px));
  z-index: 15;
  padding: 0.55rem 0.75rem 0.65rem;
  background: linear-gradient(transparent, rgba(15,23,42,0.95) 28%);
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  justify-content: flex-end;
  pointer-events: none; /* let stage receive gestures except on buttons */
}
.plan-toolbar .btn-add-fab,
.plan-toolbar .tool-row,
.plan-toolbar button {
  pointer-events: auto;
}
.plan-toolbar .hint {
  flex: 1 1 100%; font-size: 0.7rem; color: var(--muted);
  text-align: right;
}
.pin-mode-on { box-shadow: 0 0 0 2px var(--teal); }

/* Camera above bottom-nav (200) and QA panel (500) so shutter is tappable on iPhone */
.cam-overlay {
  position: fixed; inset: 0; z-index: 600; background: #000;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.cam-open .bottom-nav,
.bottom-nav.hidden-for-cam { display: none !important; visibility: hidden !important; pointer-events: none !important; }
body.cam-open .sc-qa-panel { display: none !important; }
.cam-topbar {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  padding-top: var(--safe-t, env(safe-area-inset-top, 0px));
}
/* Defect type: remember toggle + always-visible name field */
.type-remember-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.5rem;
  background: var(--surface-2, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text, #0f172a);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.type-remember-row input {
  margin: 0.15rem 0 0;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  accent-color: var(--teal, #0d9488);
}
.type-remember-row span {
  line-height: 1.3;
}

/* Top-bar: pending device local saves (iOS — photos in app/cloud only) */
.topbar-local-save {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 7.5rem;
  min-height: 2.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid #0f766e;
  background: #0d9488;
  color: #ecfdf5;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.topbar-local-save span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-local-save.hidden,
.topbar-local-save[hidden] {
  display: none !important;
}
.topbar-local-save.has-pending {
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.35);
  animation: sc-local-pulse 1.8s ease-in-out infinite;
}
.topbar-local-save.is-busy {
  opacity: 0.85;
  animation: none;
}
.topbar-local-save:disabled {
  opacity: 0.7;
  cursor: default;
}
.topbar-local-save:not(:disabled):active {
  background: #0f766e;
}
@keyframes sc-local-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.25); }
  50% { box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.45); }
}
/* Compact variant in multi-shot cam topbar */
.cam-topbar .topbar-local-save,
.cam-local-save {
  max-width: 5.75rem;
  font-size: 0.65rem;
  padding: 0.3rem 0.45rem;
  min-height: 2.1rem;
}
.cam-video-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #000;
  overflow: hidden;
  touch-action: none; /* pinch zoom lives here */
}
.cam-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  will-change: transform;
}
.cam-video-wrap video.cam-digital-zoom {
  /* digital zoom — capture crops the same center region */
}
.cam-zoom-badge {
  position: absolute;
  top: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.75);
  color: #ecfdf5;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.cam-zoom-badge.hidden { display: none !important; }
.cam-zoom-hint {
  position: absolute;
  bottom: 0.55rem;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 0.68rem;
  color: rgba(226, 232, 240, 0.75);
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 1px 2px #000;
}
.cam-thumbs { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0.4rem 0.75rem; background: #0f172a; flex-shrink: 0; }
.cam-thumbs img { width: 52px; height: 52px; object-fit: cover; border-radius: 0.4rem; border: 1px solid #475569; display: block; pointer-events: none; }
.cam-thumb {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0.4rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cam-thumb:active { opacity: 0.85; transform: scale(0.96); }

/* Multi-shot full-screen review + pinch zoom */
.cam-viewer {
  position: fixed;
  inset: 0;
  z-index: 650;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #e2e8f0;
}
.cam-viewer.hidden { display: none !important; }
.cam-viewer-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(0.45rem + var(--safe-t, env(safe-area-inset-top, 0px))) 0.65rem 0.45rem;
  background: #0f172a;
  flex-shrink: 0;
  z-index: 2;
}
.cam-viewer-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.cam-viewer-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.cam-viewer-stage img.zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}
.cam-viewer-hint {
  text-align: center;
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  background: #0f172a;
  flex-shrink: 0;
}
.cam-viewer-nav {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem calc(0.65rem + var(--safe-b-nav, env(safe-area-inset-bottom, 0px)));
  background: #0f172a;
  flex-shrink: 0;
}
.cam-viewer-nav .btn { flex: 1; min-height: 2.6rem; }
.cam-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem calc(0.75rem + var(--safe-b-nav));
  background: #0f172a;
  flex-shrink: 0; position: relative; z-index: 2;
}
.cam-bar-side {
  display: flex; align-items: center; gap: 0.35rem; min-width: 0;
}
.cam-bar-side-end {
  justify-content: flex-end;
}
.cam-bar .cam-shutter {
  justify-self: center;
  grid-column: 2;
}
.plan-pin.pin-establish { background: #0284c7; border-color: #e0f2fe; z-index: 4; }
/* Expanded hit target for mobile taps (~48px) */
.plan-pin.pin-establish .est-hit {
  position: absolute;
  left: 50%; top: 50%;
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: transparent;
  pointer-events: none;
}
.cam-done-bottom {
  min-width: 4.75rem;
  min-height: 2.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.cam-done-btn { font-weight: 700; }
.plan-draw-svg .draw-shape.selected { filter: drop-shadow(0 0 4px #38bdf8); }
.plan-draw-svg .draw-shape.is-resizing { filter: drop-shadow(0 0 5px #0ea5e9); }
.plan-draw-svg .draw-resize-handle {
  pointer-events: auto;
  touch-action: none;
  cursor: nwse-resize;
}
.plan-draw-svg .draw-resize-hit,
.plan-draw-svg .draw-resize-box {
  pointer-events: auto;
  touch-action: none;
}
.plan-draw-svg .draw-resize-box {
  filter: drop-shadow(0 1px 2px rgba(14, 165, 233, 0.45));
}

/* Floating bar while resizing a markup */
.draw-resize-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav) + var(--safe-b-nav) + 1rem);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem 0.45rem 0.85rem;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid #38bdf8;
  border-radius: 9999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: min(92vw, 28rem);
}
.draw-resize-bar.hidden { display: none !important; }
.draw-resize-tip {
  font-size: 0.75rem;
  font-weight: 600;
  color: #e0f2fe;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draw-resize-bar .btn {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
}
html[data-theme="light"] .draw-resize-bar,
html[data-theme="cloud"] .draw-resize-bar,
html[data-theme="paper"] .draw-resize-bar,
html[data-theme="soft"] .draw-resize-bar {
  background: rgba(255, 255, 255, 0.96);
  border-color: #0ea5e9;
}
html[data-theme="light"] .draw-resize-tip,
html[data-theme="cloud"] .draw-resize-tip,
html[data-theme="paper"] .draw-resize-tip,
html[data-theme="soft"] .draw-resize-tip {
  color: #0c4a6e;
}
@media (min-width: 900px) and (pointer: fine) {
  .draw-resize-bar {
    bottom: 1.25rem;
  }
}

/* Interactive sat map (map plan sheet) */
.sheet-tall { max-height: 92%; }
.sat-map {
  position: relative; width: 100%; height: min(52vh, 360px); background: #020617;
  border: 1px solid #475569; border-radius: 0.65rem; overflow: hidden;
  touch-action: none; user-select: none;
}
.sat-map-tiles { position: absolute; inset: 0; overflow: hidden; }
.sat-tile {
  position: absolute; width: 256px; height: 256px; max-width: none;
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}
.sat-crop-rect {
  position: absolute; border: 2px solid #38bdf8; background: rgba(56,189,248,0.12);
  pointer-events: none; box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
}
.sat-corner-dot {
  position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; background: #38bdf8; border: 3px solid #fff;
  color: #0f172a; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5); z-index: 6; touch-action: none;
  cursor: grab;
}
.map-preview-img {
  width: 100%; border-radius: 0.5rem; border: 1px solid #475569; display: block; max-height: 160px; object-fit: contain;
  background: #020617;
}
.map-proceed-row { margin-top: 0.65rem; flex-direction: column; }
.map-proceed-row .btn.primary { font-size: 1rem; padding: 0.85rem 1rem; }
.cam-shutter {
  width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff;
  background: var(--teal); box-shadow: 0 0 0 4px rgba(20,184,166,0.35);
  flex-shrink: 0;
}

/* Offline / pending banner */
.offline-banner {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  width: 100%; border: none; cursor: pointer;
  font-size: 0.78rem; font-weight: 650; padding: 0.45rem 0.75rem;
  text-align: center; flex-shrink: 0;
}
.offline-banner.hidden { display: none !important; }
/* Plan view: overlay the banner so showing “pending” does not shrink the
   stage and bounce the plan after you drop a pin. */
body.sc-plan-view .offline-banner:not(.hidden) {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 41;
}
.offline-banner.offline {
  background: #422006; color: #fde68a;
}
.offline-banner.pending {
  background: #134e4a; color: #99f6e4;
}
.offline-banner-err {
  opacity: 0.9;
  font-weight: 500;
  font-size: 0.72rem;
}
.offline-banner-link {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.pending-card { margin-bottom: 0.65rem; }
.pending-card code {
  word-break: break-all;
}
html[data-theme="light"] .offline-banner.offline,
html[data-theme="cloud"] .offline-banner.offline,
html[data-theme="paper"] .offline-banner.offline,
html[data-theme="soft"] .offline-banner.offline,
html[data-theme="slate"] .offline-banner.offline,
html[data-theme="ocean"] .offline-banner.offline {
  background: #fef3c7; color: #92400e;
}
html[data-theme="light"] .offline-banner.pending,
html[data-theme="cloud"] .offline-banner.pending,
html[data-theme="paper"] .offline-banner.pending,
html[data-theme="soft"] .offline-banner.pending,
html[data-theme="slate"] .offline-banner.pending,
html[data-theme="ocean"] .offline-banner.pending {
  background: #ccfbf1; color: #0f766e;
}

/* Form chunks + multi-column in wide panel */
.form-progress {
  font-size: 0.72rem; margin: 0 0 0.45rem; font-weight: 600;
}
.form-chunk { margin-bottom: 0.75rem; }
.form-chunk-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); margin: 0 0 0.4rem;
}
.form-chunk-details > summary {
  cursor: pointer; list-style: none; user-select: none;
}
.form-chunk-details > summary::-webkit-details-marker { display: none; }
.form-fields-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem 0.75rem;
}
.plan-side-panel.panel-wide .form-fields-grid,
.plan-side-panel.panel-xwide .form-fields-grid {
  grid-template-columns: 1fr 1fr;
}
.plan-side-panel.panel-wide .field-span-2,
.plan-side-panel.panel-xwide .field-span-2 {
  grid-column: 1 / -1;
}
.plan-side-panel.panel-xwide .panel-photo {
  max-height: 28vh;
}
.plan-side-panel.panel-xwide .panel-fields {
  /* Prefer fit attributes without nested scroll when very wide */
  flex: 1;
}

/* Panel resize handle — visible grip on the plan|panel seam */
.panel-resize-handle {
  position: absolute;
  left: -10px;
  top: 0;
  bottom: 0;
  width: 18px;
  z-index: 40;
  cursor: ew-resize;
  touch-action: none;
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-resize-handle::before {
  content: '';
  width: 4px;
  height: min(72px, 28%);
  border-radius: 999px;
  background: var(--border);
  box-shadow: 0 0 0 1px var(--panel), 0 1px 4px rgba(15, 23, 42, 0.15);
  transition: height 0.12s, background 0.12s;
}
.panel-resize-handle:hover::before,
.panel-resize-handle:active::before,
.panel-resize-handle.is-dragging::before {
  background: var(--teal);
  height: min(96px, 40%);
}
.panel-width-btns {
  display: flex; gap: 0.3rem; flex-shrink: 0; margin-left: auto;
}
.panel-width-btns .btn {
  font-size: 0.68rem; padding: 0.28rem 0.45rem; font-weight: 700;
}
.panel-list-head {
  display: flex; align-items: flex-start; gap: 0.5rem;
}
.cam-err { color: var(--danger); text-align: center; padding: 0.5rem; font-size: 0.8rem; }

.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; margin-top: 0.5rem;
}
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 0.45rem; border: 1px solid #475569;
}
/* Defect view: device upload tile (matches plan Upload tile language) */
.photo-upload-tile {
  aspect-ratio: 1;
  width: 100%;
  border: 1px dashed var(--border);
  border-radius: 0.45rem;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem;
  cursor: pointer;
  min-height: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.photo-upload-tile i {
  font-size: 1.25rem;
  line-height: 1;
  pointer-events: none;
}
.photo-upload-tile span { pointer-events: none; }
.photo-upload-tile:active,
.photo-upload-tile:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: color-mix(in srgb, var(--teal) 8%, transparent);
}
/* iOS: display:none file inputs often fail with <label for> / .click() */
.file-input-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none;
}

/* Voice dictation on notes / textareas */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}
.field-label-row label { margin: 0; flex: 1; min-width: 0; }
.field-with-dict textarea { margin-top: 0; }
.dict-btn {
  flex-shrink: 0;
  min-width: 2.75rem;
  height: 2.15rem;
  border-radius: 9999px;
  border: 1px solid var(--teal);
  background: var(--chip-active-bg, #ccfbf1);
  color: var(--chip-active-text, #0f766e);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  cursor: pointer;
  padding: 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 2;
}
.dict-btn-label { font-size: 0.68rem; letter-spacing: 0.02em; }
.dict-btn:hover { filter: brightness(0.98); }
.dict-btn.listening {
  color: #fff;
  background: #dc2626;
  border-color: #b91c1c;
  animation: dict-pulse 1.2s ease-in-out infinite;
}
.dict-btn.listening .dict-btn-label { content: '…'; }
.dict-btn-hint {
  border-color: var(--border);
  background: var(--card);
  color: var(--muted);
}
.dict-hint {
  margin: 0.25rem 0 0;
  font-size: 0.68rem;
  line-height: 1.3;
}
/* Mobile: keep mic easy to hit next to long labels */
@media (max-width: 640px) {
  .field-label-row { align-items: flex-start; }
  .dict-btn { min-width: 3.1rem; height: 2.35rem; font-size: 0.85rem; }
}
@keyframes dict-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

/* Sprint C coach marks */
.coach-mark {
  z-index: 80;
  pointer-events: auto;
}
.coach-mark.coach-banner {
  position: sticky;
  top: 0;
  margin: 0 0 0.55rem;
  order: -1;
}
.coach-mark.coach-plan {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  /* Sit above bottom tab bar + home indicator (was fixed 3.5rem → overlapped / crowded bottom chrome) */
  bottom: calc(var(--nav) + var(--safe-b-nav) + 0.65rem);
  max-width: 22rem;
  z-index: 20;
}
.coach-mark-inner {
  background: var(--panel);
  border: 1px solid var(--chip-active-border, var(--teal));
  border-radius: 0.75rem;
  box-shadow: var(--shadow), 0 0 0 1px rgba(13, 148, 136, 0.12);
  padding: 0.65rem 0.75rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.coach-mark-title {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--text);
}
.coach-mark-body {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
}
.coach-mark-body strong { color: var(--text); }
.coach-mark-dismiss {
  align-self: flex-end;
  margin-top: 0.15rem;
  border: none;
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  border-radius: 9999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}
.coach-mark-dismiss:hover { filter: brightness(0.97); }

/* First-run training tour */
.tour-root {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
.tour-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  pointer-events: auto;
}
.tour-card {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  width: min(26rem, 100%);
  max-height: min(88dvh, 36rem);
  overflow-y: auto;
  margin: 0;
  padding: 1.1rem 1.15rem calc(1.1rem + var(--safe-b-nav, 0px));
  background: var(--panel);
  color: var(--text);
  border-radius: 1.1rem 1.1rem 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}
@media (min-width: 560px) {
  .tour-root { align-items: center; padding: 1rem; }
  .tour-card {
    border-radius: 1rem;
    margin: 0 auto;
    max-height: min(80vh, 34rem);
  }
}
.tour-progress {
  display: flex; gap: 0.35rem; justify-content: center; margin-bottom: 0.75rem;
}
.tour-dot {
  width: 0.45rem; height: 0.45rem; border-radius: 999px;
  background: var(--border); display: inline-block;
}
.tour-dot.active { background: var(--teal); width: 1.1rem; }
.tour-dot.done { background: var(--teal); opacity: 0.45; }
.tour-icon {
  width: 2.75rem; height: 2.75rem; border-radius: 0.75rem;
  background: var(--chip-active-bg, #ccfbf1); color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; margin: 0 auto 0.65rem;
}
.tour-title {
  margin: 0 0 0.5rem; font-size: 1.15rem; text-align: center;
}
.tour-body {
  font-size: 0.88rem; line-height: 1.45; color: var(--text);
}
.tour-body ul { margin: 0.35rem 0 0; }
.tour-step-meta { text-align: center; margin: 0.75rem 0 0.5rem; font-size: 0.72rem; }
.tour-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.35rem;
}
.tour-actions-right { display: flex; gap: 0.4rem; }

.login-wrap { max-width: 22rem; margin: 2rem auto; padding: 0 1rem; }
.login-wrap h1 { text-align: center; font-size: 1.25rem; }
.login-wrap .auth-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  overflow: hidden;
  margin-bottom: 0.85rem;
}
.login-wrap .auth-tab {
  flex: 1;
  border: none;
  background: var(--card);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.65rem 0.4rem;
  min-height: var(--tap);
  cursor: pointer;
}
.login-wrap .auth-tab.active {
  background: var(--teal);
  color: #fff;
}
.app-logo-lg {
  display: block; width: 5.5rem; height: 5.5rem; margin: 0 auto 0.85rem;
  border-radius: 1.15rem; object-fit: cover;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35); border: 1px solid #334155;
}
.app-logo-sm {
  width: 1.75rem; height: 1.75rem; border-radius: 0.4rem; object-fit: cover;
  border: 1px solid #475569; flex-shrink: 0;
}
.sc-tab-logo {
  width: 1.5rem; height: 1.5rem; border-radius: 0.3rem; object-fit: cover;
  flex-shrink: 0;
}
.seg { display: flex; gap: 0.3rem; margin-bottom: 0.65rem; flex-wrap: wrap; }
.seg button {
  border: 1px solid #475569; background: transparent; color: var(--muted);
  border-radius: 9999px; padding: 0.55rem 0.9rem; font-size: 0.88rem;
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
}
.seg button.active { background: var(--teal-dim); color: #fff; border-color: var(--teal); }

/* Sheets must sit ABOVE bottom-nav (z 200) or Save/Confirm are blocked */
.sheet.sheet-page {
  top: 0;
  bottom: 0;
  max-height: none;
  border-radius: 0;
  border-bottom: 1px solid #475569;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: var(--safe-b-nav, 0px); z-index: 260;
  max-height: 86%;
  overflow: hidden;
  background: var(--panel); border-radius: 1rem 1rem 0 0;
  border: 1px solid #475569; border-bottom: none;
  padding: 0.85rem 0.85rem 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
  display: flex; flex-direction: column;
}
.sheet-body { flex: 1; overflow: auto; min-height: 0; padding-bottom: 0.25rem; overscroll-behavior: contain; position: relative; z-index: 1; }
.sheet-handle {
  /* Visible pill + large invisible hit area for mobile dismiss */
  position: relative;
  z-index: 0;
  width: 3rem;
  height: 0.32rem;
  background: #94a3b8;
  border-radius: 9999px;
  margin: 0.15rem auto 0.55rem;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.sheet-handle::before {
  /* Grab target around the pill only — a full-width hit box stole Type name taps. */
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4.5rem;
  height: 2.2rem;
}
.sheet-handle.is-dragging,
.sheet-handle:active {
  cursor: grabbing;
  background: var(--teal, #0d9488);
}
html[data-theme="light"] .sheet-handle,
:root:not([data-theme]) .sheet-handle {
  background: #94a3b8;
}
/* Sticky confirm/cancel. Sheet is already lifted by --safe-b-nav. */
.sheet-actions {
  position: sticky; bottom: 0; flex-shrink: 0;
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: stretch;
  padding: 0.75rem 0 0.85rem;
  margin-top: 0.35rem;
  background: linear-gradient(transparent, var(--panel) 18%);
  border-top: 1px solid #334155;
  z-index: 2;
}
.sheet-actions .btn { flex: 1; min-height: 2.75rem; font-size: 0.95rem; }
.sheet-actions .btn.primary { flex: 1.4; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 250; }

.type-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  border: 1px solid #475569; background: #0f172a; border-radius: 9999px;
  padding: 0.35rem 0.65rem; font-size: 0.75rem; margin: 0.2rem;
}
.type-chip.active { border-color: var(--teal); background: #0f766e44; color: var(--teal); }
.type-chip .n { font-size: 0.65rem; color: var(--muted); }

.live-save { font-size: 0.7rem; color: var(--teal); min-height: 1rem; } /* legacy; save status is topbar-save */
.section-h {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin: 0.85rem 0 0.4rem;
}

/* Feature request image previews (device upload + list thumbs) */
.fr-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0 0.15rem;
}
.fr-thumb-wrap {
  position: relative;
  width: 4.25rem;
  height: 4.25rem;
}
.fr-thumb {
  width: 4.25rem;
  height: 4.25rem;
  object-fit: cover;
  border-radius: 0.4rem;
  border: 1px solid var(--border, #334155);
  background: #0f172a;
  display: block;
}
.fr-thumb-rm {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  border: none;
  background: #b91c1c;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

/* ---------- multi-device QA harness panel ---------- */
/* Left-docked so it never covers the bottom-right + / − FABs. */
.sc-qa-panel {
  position: fixed;
  z-index: 180; /* below sheets (260), Add FAB (190), camera (600) */
  left: 0.75rem;
  right: auto;
  bottom: calc(var(--nav, 56px) + var(--safe-b-nav, 0px) + 12px);
  width: min(16rem, calc(100% - 5.75rem));
  max-width: min(16rem, calc(100% - 5.75rem));
  font-size: 1rem;
  pointer-events: none;
}
.sc-qa-panel .sc-qa-toggle,
.sc-qa-panel .sc-qa-body,
.sc-qa-panel button {
  pointer-events: auto;
}
.sc-qa-bar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: fit-content;
  max-width: 100%;
  pointer-events: none;
}
.sc-qa-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  min-width: 52px !important;
  min-height: 52px !important;
  box-sizing: border-box;
  border-radius: 9999px;
  border: none;
  background: #0f766e;
  color: #ecfdf5;
  font-weight: 800;
  font-size: 16px !important;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.35);
  cursor: pointer;
  float: none;
  padding: 0;
}
body.sc-menu-open .sc-qa-panel {
  visibility: hidden;
  pointer-events: none;
}
/* Pin/type sheets sit above the QA log so Type stays tappable. */
body:has(.sheet) .sc-qa-body {
  display: none !important;
}
.sc-qa-body {
  clear: both;
  margin-top: 0.45rem;
  padding: 0.9rem 1rem 1rem;
  border-radius: 0.9rem;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  max-height: min(58vh, 32rem);
  overflow: auto;
}
.sc-qa-body.hidden { display: none; }
.sc-qa-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}
.sc-qa-hint { margin: 0 0 0.55rem; font-size: 0.88rem; line-height: 1.4; color: #94a3b8; }
.sc-qa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
}
.sc-qa-actions .btn {
  font-size: 0.95rem;
  padding: 0.55rem 0.8rem;
  min-height: 44px;
}
.sc-qa-status { margin: 0.3rem 0 0.4rem; font-size: 0.9rem; }
.sc-qa-manual {
  margin: 0.4rem 0;
  padding: 0.55rem;
  border-radius: 0.5rem;
  background: #134e4a;
  border: 1px solid #2dd4bf;
}
.sc-qa-manual.hidden { display: none; }
.sc-qa-manual-text { margin: 0 0 0.5rem; line-height: 1.4; }
.sc-qa-manual .btn { margin-right: 0.35rem; margin-top: 0.2rem; }
.sc-qa-result-head {
  font-weight: 800;
  margin: 0.35rem 0;
  padding: 0.35rem 0.45rem;
  border-radius: 0.4rem;
}
.sc-qa-result-head.pass { background: #14532d; color: #bbf7d0; }
.sc-qa-result-head.fail { background: #7f1d1d; color: #fecaca; }
.sc-qa-step-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sc-qa-step {
  padding: 0.35rem 0;
  border-bottom: 1px solid #1e293b;
}
.sc-qa-step.ok strong { color: #86efac; }
.sc-qa-step.bad strong { color: #fca5a5; }
.sc-qa-step.active { background: rgba(45, 212, 191, 0.08); }
.sc-qa-detail { font-size: 0.82rem; word-break: break-word; margin-top: 0.15rem; white-space: pre-wrap; }
body.cam-open .sc-qa-panel { bottom: 0.75rem; }

/* Field device. Do not multiply individual chrome by --phone-boost (that
   blew up the menu while the 64px tab bar clipped). iPhone keeps this as-is;
   bloated Chrome layout is handled by scaling #app as a whole. */
html.sc-field { font-size: 16px; }
html.sc-field .menu-drawer { width: min(22rem, 92vw); }
html.sc-field .menu-item {
  min-height: var(--tap);
  font-size: 16px;
  padding: 12px 16px;
  gap: 12px;
}
html.sc-field .menu-item i { width: 1.35rem; font-size: 18px; }
html.sc-field .list-row {
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 16px;
}
html.sc-field .home-filter-chip,
html.sc-field .types-tab {
  min-height: var(--tap);
  font-size: 15px;
  padding: 8px 14px;
}
html.sc-field .mode-chip,
html.sc-field .plan-fit-btn,
html.sc-field .icon-btn,
html.sc-field .btn,
html.sc-field .seg button,
html.sc-field .add-menu-size-btn,
html.sc-field .desktop-nav-btn,
html.sc-field .login-wrap .auth-tab,
html.sc-field .fw-filter,
html.sc-field .topbar-save,
html.sc-field .field input,
html.sc-field .field select,
html.sc-field .field textarea,
html.sc-field .panel-fields .field input,
html.sc-field .panel-fields .field select,
html.sc-field .panel-fields .field textarea {
  min-height: var(--tap) !important;
  font-size: 16px !important;
}
html.sc-field .icon-btn {
  min-width: var(--tap) !important;
}
html.sc-field .sc-qa-toggle {
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
  min-height: 52px !important;
  font-size: 16px !important;
}
html.sc-field .icon-btn i,
html.sc-field .menu-item i { font-size: 18px !important; }
html.sc-field .bottom-nav button {
  min-height: var(--nav) !important;
  height: var(--nav) !important;
  font-size: 11px !important;
  padding: 4px 2px 4px !important;
}
html.sc-field .bottom-nav i { font-size: 22px !important; }
html.sc-field .mode-chip,
html.sc-field .plan-fit-btn {
  font-size: 15px !important;
  padding: 8px 14px !important;
}

/* Quick switch between Ascend and Site Capture (same control in both banners) */
.app-switch { display: inline-flex; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 0.6rem; overflow: hidden; background: var(--panel); }
.app-switch a { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.app-switch a.on { background: #0d9488; color: #fff; }
.menu-more > summary { list-style: none; cursor: pointer; }
.menu-more > summary::-webkit-details-marker { display: none; }
