/* 7LOOP BOL themes
   Dark (DEFAULT): graphite + industrial yellow.
   Light: silver on blue (flat).
   Printable .bol-document stays formal black/white. */
:root,
html[data-theme="dark"] {
  --bg: #1a1c1e;
  --bg-elevated: #222528;
  --surface: #2a2d31;
  --surface-2: #32363b;
  --ink: #f4f5f6;
  --muted: #9aa0a6;
  --border: #3d4248;
  --border-light: #35393e;
  --accent: #f5c518;
  --accent-hover: #ffd54f;
  --accent-ink: #1a1c1e;
  --accent-dim: rgba(245, 197, 24, 0.16);
  --danger: #ff6b6b;
  --danger-bg: #3a1515;
  --warn: #f5a623;
  --warn-bg: #3a2a12;
  --ok: #8bc34a;
  --ok-bg: #1e2e14;
  --input-bg: #1e2124;
  --input-disabled: #26292d;
  --bubble-bg: #1e2124;
  --chrome-bg: #141618;
  --chrome-fg: #f4f5f6;
  --chrome-border: #2f3338;
  --radius: 4px;
  --glow-accent: 0 0 8px rgba(245, 197, 24, 0.28);
  --glow-accent-sm: 0 0 4px rgba(245, 197, 24, 0.22);
  --glow-text: none;
  --tap: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}
html[data-theme="light"] {
  /* Cool silver on blue (flat) */
  --bg: #c5d4e8;
  --bg-elevated: #d4e0f0;
  --surface: #e8eef6;
  --surface-2: #f3f6fb;
  --ink: #152033;
  --muted: #4a5d78;
  --border: #90b4c8;
  --border-light: #b8c7dc;
  --accent: #1e5eff;
  --accent-hover: #3d75ff;
  --accent-ink: #ffffff;
  --accent-dim: rgba(30, 94, 255, 0.16);
  --danger: #c62828;
  --danger-bg: #ffebee;
  --warn: #e67a00;
  --warn-bg: #fff3e0;
  --ok: #1b7a3d;
  --ok-bg: #e8f5e9;
  --input-bg: #f7f9fc;
  --input-disabled: #dfe6f0;
  --bubble-bg: #f0f4fa;
  --chrome-bg: #1a3a6e;
  --chrome-fg: #f3f6fb;
  --chrome-border: #0f274d;
  --radius: 4px;
  --glow-accent: 0 0 8px rgba(30, 94, 255, 0.25);
  --glow-accent-sm: 0 0 4px rgba(30, 94, 255, 0.2);
  --glow-text: none;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  background-color: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
}
.screen.active { display: flex; }

/* Sticky bottom action bar (thumb-friendly) */
.bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background-color: var(--chrome-bg);
  border-top: 2px solid var(--accent);
  margin-top: auto;
  flex-shrink: 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
}
.bottom-bar .btn {
  flex: 1;
  width: 100%;
  min-height: 52px;
  font-size: 1.1rem;
}
.bottom-bar .btn-generate {
  background: var(--accent) !important;
  color: var(--accent-ink) !important;
  border-color: var(--accent) !important;
}
.bottom-bar-stack {
  flex-direction: column;
}
.bottom-bar-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.bottom-bar-row .btn {
  flex: 1;
}
.bottom-bar-stack .btn-ocr {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bottom-bar-stack .btn-ocr:active {
  border-color: var(--accent);
  color: var(--accent);
}
.bottom-bar .btn-clear-stops-bar {
  background: transparent;
  color: #ff8a80;
  border: 2px solid #5a3030;
  min-height: 52px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: none !important;
  font-weight: 700;
}
.bottom-bar .btn-clear-stops-bar:active {
  background: rgba(255, 138, 128, 0.12);
  border-color: #ff8a80;
}
.main-content.has-bottom-bar {
  padding-bottom: calc(16px + var(--safe-bottom));
}


.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: calc(52px + var(--safe-top));
  padding: var(--safe-top) 12px 8px;
  background-color: var(--chrome-bg);
  color: var(--chrome-fg);
  border-bottom: 2px solid var(--accent);
}
.topbar-left {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.app-version {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--chrome-fg, var(--ink));
  opacity: 0.38;
  flex-shrink: 0;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.topbar-spacer { width: 40px; }
.app-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact Save in Settings topbar — avoids overlap with title/version */
#btn-settings-save,
.btn-topbar-save {
  min-height: 36px;
  height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 2px 0 #9a9a9a,
    0 2px 6px rgba(0, 0, 0, 0.25);
}
#btn-settings-save:active,
.btn-topbar-save:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 0 0 transparent;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: transparent;
  color: var(--chrome-fg);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:active { background: rgba(255,255,255,0.15); }

.main-content {
  flex: 1;
  padding: 10px 12px calc(20px + var(--safe-bottom));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.04) 40%,
    rgba(0, 0, 0, 0.12) 100%
  );
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28),
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 3px 8px rgba(0, 0, 0, 0.22);
  transition: box-shadow 0.12s, transform 0.12s, filter 0.12s;
}
.btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(0, 0, 0, 0.25),
    0 0 0 transparent;
  filter: brightness(0.96);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}
.btn-primary {
  background-color: #f2f2f2;
  background-image: linear-gradient(180deg, #ffffff 0%, #f0f0f0 45%, #d8d8d8 100%);
  color: #111;
  border-color: #c8c8c8;
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 2px 0 #9a9a9a,
    0 3px 8px rgba(0, 0, 0, 0.28);
}
.btn-primary:active {
  background-image: linear-gradient(180deg, #d0d0d0 0%, #e4e4e4 100%);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.35),
    0 0 0 transparent;
  transform: translateY(2px);
}
.btn-primary:disabled {
  background: #888;
  border-color: #888;
  color: #ddd;
  opacity: 1;
  box-shadow: none;
}

/* Industrial raised CTAs (yellow dark / blue light) */
.btn-bright {
  background-color: var(--accent) !important;
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.45) 0%,
    rgba(255, 255, 255, 0.12) 38%,
    rgba(0, 0, 0, 0.18) 100%
  ) !important;
  color: var(--accent-ink) !important;
  border: 1px solid rgba(0, 0, 0, 0.25) !important;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22),
    0 3px 0 #8a7008,
    0 5px 14px rgba(245, 197, 24, 0.28);
}
.btn-bright:active {
  background-image: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.12) 0%,
    rgba(255, 255, 255, 0.08) 100%
  ) !important;
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(0, 0, 0, 0.2),
    0 0 0 #8a7008 !important;
  transform: translateY(2px);
}
.bottom-bar .btn-bright,
.bottom-bar .btn-generate,
html[data-theme="dark"] .btn-bright,
html[data-theme="dark"] .bottom-bar .btn-bright {
  color: var(--accent-ink) !important;
  border-color: rgba(0, 0, 0, 0.28) !important;
}
html[data-theme="light"] .btn-bright,
html[data-theme="light"] .bottom-bar .btn-bright,
html[data-theme="light"] .bottom-bar .btn-generate {
  border-color: rgba(0, 0, 0, 0.28) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 3px 0 #0d3a9e,
    0 5px 14px rgba(30, 94, 255, 0.3) !important;
}
html[data-theme="light"] .btn-bright:active {
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.35),
    0 0 0 #0d3a9e !important;
  transform: translateY(2px);
}
html[data-theme="light"] .home-bol-item {
  border-left-color: var(--accent);
}
html[data-theme="light"] .home-bol-date,
html[data-theme="light"] .section-title,
html[data-theme="light"] .equip-section-label {
  color: var(--accent);
}
html[data-theme="light"] .bottom-bar {
  border-top-color: var(--accent);
}
html[data-theme="light"] .topbar {
  border-bottom-color: var(--accent);
}

/* ========== Flat surfaces (no carbon/steel textures) ========== */
html[data-theme="dark"] body {
  background-color: var(--bg);
  background-image: none;
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .stop-card,
html[data-theme="dark"] .home-bol-item,
html[data-theme="dark"] .ticket-display,
html[data-theme="dark"] .fields-card {
  background-color: var(--surface);
  background-image: none;
}
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .bottom-bar {
  background-color: var(--chrome-bg);
  background-image: none;
  box-shadow: 0 0 10px rgba(245, 197, 24, 0.08);
}
html[data-theme="dark"] .btn-bright,
html[data-theme="dark"] .bottom-bar .btn-bright {
  /* keep raised bevel; soft accent glow only */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 3px 0 #8a7008,
    var(--glow-accent),
    0 5px 12px rgba(0, 0, 0, 0.35) !important;
}
html[data-theme="dark"] .bubble.selected {
  box-shadow: var(--glow-accent-sm);
}
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .equip-section-label,
html[data-theme="dark"] .home-bol-date {
  text-shadow: none;
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
  box-shadow: var(--glow-accent-sm);
}

html[data-theme="light"] body {
  background-color: var(--bg);
  background-image: none;
}
html[data-theme="light"] .card,
html[data-theme="light"] .stop-card,
html[data-theme="light"] .home-bol-item,
html[data-theme="light"] .ticket-display,
html[data-theme="light"] .fields-card {
  background-color: var(--surface);
  background-image: none;
  border-color: #a8bcd4;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 1px 2px rgba(21, 40, 70, 0.1);
}
html[data-theme="light"] .home-bol-item {
  border-left-color: var(--accent);
}
html[data-theme="light"] .topbar,
html[data-theme="light"] .bottom-bar {
  background-color: var(--chrome-bg);
  background-image: none;
  box-shadow: 0 0 10px rgba(30, 94, 255, 0.1);
}
html[data-theme="light"] .btn-bright,
html[data-theme="light"] .bottom-bar .btn-bright {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 3px 0 #0d3a9e,
    var(--glow-accent),
    0 5px 12px rgba(21, 40, 70, 0.22) !important;
}
html[data-theme="light"] .bubble.selected {
  box-shadow: var(--glow-accent-sm);
}
html[data-theme="light"] .section-title,
html[data-theme="light"] .equip-section-label,
html[data-theme="light"] .home-bol-date {
  text-shadow: none;
}
html[data-theme="light"] input:focus,
html[data-theme="light"] textarea:focus,
html[data-theme="light"] select:focus {
  box-shadow: var(--glow-accent-sm);
}

/* Printable receipt stays clean */
.bol-document,
.bol-document * {
  background-image: none !important;
  text-shadow: none;
}




#screen-home .main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.btn-home-generate {
  width: 100%;
  max-width: 420px;
  min-height: 56px;
  font-size: 1.15rem;
  margin-bottom: 18px;
}
.home-section-title {
  margin: 4px 0 10px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.home-bol-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  width: 100%;
  max-width: 420px;
}
#home-empty {
  max-width: 420px;
  text-align: center;
}
.home-bol-list > li,
.home-bol-item {
  margin: 0 0 10px;
  padding: 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
}
.home-bol-item .home-bol-row {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.home-bol-trash {
  flex-shrink: 0;
  align-self: center;
  width: 40px;
  height: 40px;
  margin: 0 6px 0 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.home-bol-trash:hover,
.home-bol-trash:focus-visible {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  outline: none;
}
.home-bol-trash:active {
  transform: scale(0.94);
  color: var(--danger);
}
.home-bol-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  text-align: center;
  padding: 12px 8px 12px 14px;
  min-height: 68px;
  border: none;
  background-color: transparent;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.home-bol-item:active .home-bol-row:active,
.home-bol-row:active {
  background-color: var(--surface-2);
}
.home-bol-date {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.home-bol-ticket {
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
.home-bol-place {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}
.preview-top-actions {
  margin: 0 0 10px;
}
.preview-top-actions .btn {
  width: 100%;
}

.btn-generate {
  width: 100%;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.btn-add-stop {
  width: 100%;
  margin-top: 8px;
  background: var(--bg-elevated);
  border-style: dashed;
  border-color: var(--border);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
}
.btn-secondary {
  width: 100%;
  background-color: var(--surface);
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.16) 0%,
    rgba(255, 255, 255, 0.04) 40%,
    rgba(0, 0, 0, 0.14) 100%
  );
}
.btn-danger-outline {
  width: 100%;
  border-color: var(--danger);
  color: var(--danger);
  margin-top: 8px;
}
.btn-sm {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.generate-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.ticket-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  text-align: center;
}
.ticket-display.hidden { display: none; }
.ticket-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.ticket-number {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.section-title {
  margin: 0 0 10px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85em;
}

.field-row {
  margin-bottom: 12px;
}
.field-row:last-child { margin-bottom: 0; }
.field-row label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
  color: var(--muted);
}
.field-row {
  margin-bottom: 10px;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 16px; /* prevent iOS zoom */
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.35;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
input:disabled, textarea:disabled {
  background: var(--input-disabled);
  color: var(--muted);
}

.input-with-confirm {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.input-with-confirm input { flex: 1; min-width: 0; }

.confirm-bang,
.stop-confirm-bang {
  flex-shrink: 0;
  width: var(--tap);
  min-height: var(--tap);
  border: 2px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.stop-confirm-bang {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.confirm-bang.hidden,
.stop-confirm-bang.hidden { display: none; }
.confirm-bang:active,
.stop-confirm-bang:active {
  background: color-mix(in srgb, var(--warn) 35%, var(--warn-bg));
  color: var(--warn);
}
.confirm-bang.confirmed {
  display: none;
}
/* Pending acknowledge: orange triangle + ? */
.confirm-warn-glyph {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}
.confirm-warn-glyph svg {
  display: block;
  width: 22px;
  height: 22px;
}
.confirm-q {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  color: currentColor;
  pointer-events: none;
}
.confirm-err-glyph {
  display: none;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}
.confirm-ok-glyph {
  display: none;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
}
.confirm-ok-glyph svg { display: block; width: 22px; height: 22px; }
/* Confirmed: green check in circle */
.confirm-bang.is-confirmed,
.stop-confirm-bang.is-confirmed {
  border-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
  animation: none;
}
.confirm-bang.is-confirmed .confirm-warn-glyph,
.stop-confirm-bang.is-confirmed .confirm-warn-glyph,
.confirm-bang.is-confirmed .confirm-err-glyph,
.stop-confirm-bang.is-confirmed .confirm-err-glyph {
  display: none !important;
}
.confirm-bang.is-confirmed .confirm-ok-glyph,
.stop-confirm-bang.is-confirmed .confirm-ok-glyph {
  display: inline-flex;
}
.confirm-bang.is-confirmed:active,
.stop-confirm-bang.is-confirmed:active {
  background: color-mix(in srgb, var(--ok) 35%, var(--ok-bg));
  color: var(--ok);
}
/* Error state wins over confirmed only when both — prefer error */
.confirm-bang.field-error.is-confirmed,
.stop-confirm-bang.field-error.is-confirmed {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}
.confirm-bang.field-error.is-confirmed .confirm-ok-glyph,
.stop-confirm-bang.field-error.is-confirmed .confirm-ok-glyph {
  display: none !important;
}

/* Failed Generate: red ! error state */
.confirm-bang.field-error,
.stop-confirm-bang.field-error {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  animation: bang-pulse 0.9s ease-in-out infinite;
}
.confirm-bang.field-error .confirm-warn-glyph,
.stop-confirm-bang.field-error .confirm-warn-glyph {
  display: none;
}
.confirm-bang.field-error .confirm-err-glyph,
.stop-confirm-bang.field-error .confirm-err-glyph {
  display: inline;
}
.confirm-bang.field-error:active,
.stop-confirm-bang.field-error:active {
  background: var(--danger);
  color: #fff;
}

/* Stop cards */
.stop-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.stop-card.needs-confirm {
  border-color: var(--warn);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warn) 55%, transparent);
}
.stop-card.needs-confirm.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}
.stop-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.stop-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  flex: 1;
}
.btn-remove-stop {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border-light);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

.type-bubbles, .load-bubbles {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.bubble {
  flex: 1;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bubble-bg);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}
.bubble.selected {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}
.bubble.bubble-disabled {
  opacity: 0.35;
  pointer-events: none;
}
.bubble input { display: none; }

.stop-details {
  display: none;
}
.stop-details.enabled { display: block; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  margin-bottom: 12px;
  padding: 4px 0;
}
/* Text label grows; switch label stays fixed oval (never width:100%) */
.toggle-row > label:not(.toggle) {
  font-size: 1rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  max-width: 44px;
  flex: 0 0 44px;
  flex-grow: 0;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  margin: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  width: 44px;
  height: 24px;
  max-width: 44px;
  background: var(--surface-2);
  border-radius: 999px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 1px;
  top: 1px;
  background: linear-gradient(180deg, #ffffff 0%, #e8e8e8 100%);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  transition: transform 0.15s;
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--glow-accent-sm, none);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  border-color: transparent;
}

.divider {
  height: 1px;
  background: var(--border-light);
  margin: 16px 0;
}

.stops-container { margin-top: 4px; }

/* Address book */
.address-book-list, .history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.address-book-list li, .history-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.address-book-list li span, .history-item-info {
  flex: 1;
  font-size: 0.9rem;
  word-break: break-word;
}
.history-item-info strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 2px;
}
.history-item-meta {
  font-size: 0.8rem;
  color: var(--muted);
}
.history-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hidden { display: none !important; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  text-align: center;
}
.toast.hidden { display: none; }

.preview-main { max-width: 720px; }
.preview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.save-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 12px 0 0;
  text-align: center;
}

/* ========== BOL DOCUMENT (print / capture) — always white/black ========== */
.bol-document {
  background: #fff !important;
  color: #000 !important;
  border: 1.5px solid #000;
  color-scheme: light;
  padding: 16px;
  font-family: "Times New Roman", Times, Georgia, serif;
  font-size: 11.5px;
  line-height: 1.25;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
  background-image: none !important;
  text-shadow: none;
}
.bol-document.bol-multipage {
  background: transparent !important;
  border: none;
  padding: 0;
  max-width: 680px;
}
.bol-page {
  background: #fff !important;
  color: #000 !important;
  border: 1.5px solid #000;
  box-sizing: border-box;
  padding: 14px 16px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto 18px;
  /* ~ US Letter aspect at preview width (680 × 11/8.5 ≈ 880) */
  min-height: 880px;
  position: relative;
  display: flex;
  flex-direction: column;
}
.bol-page:last-child {
  margin-bottom: 0;
}
.bol-page-num {
  margin-top: 4px;
  font-size: 9px;
  font-weight: 700;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #333;
}
.bol-cont-note {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  color: #444;
}
.bol-page-continued {
  margin-top: auto;
  padding-top: 10px;
  font-size: 10px;
  font-weight: 700;
  font-family: Arial, Helvetica, sans-serif;
  text-align: right;
  color: #555;
  border-top: 1px dashed #999;
}
.bol-header-compact {
  margin-bottom: 6px;
  padding-bottom: 6px;
}
.bol-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  border-bottom: 2px solid #000;
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.bol-company {
  flex: 1;
}
.bol-logo {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.15;
}
.bol-brand .bol-logo {
  font-size: 15px;
}
.bol-contact {
  font-size: 11px;
  line-height: 1.35;
}
.bol-title-block {
  text-align: right;
}
.bol-title {
  font-size: 18px;
  font-weight: 900;
  margin: 0 0 6px;
  letter-spacing: 0.04em;
  font-family: Arial, Helvetica, sans-serif;
}
.bol-comp-box,
.bol-alvys-box {
  display: inline-block;
  border: 1.5px solid #000;
  border-radius: 0;
  padding: 4px 10px;
  text-align: center;
  min-width: 120px;
}
.bol-alvys-box {
  display: block;
  margin: 0 0 6px auto;
  max-width: 200px;
}
.bol-alvys-box .bol-comp-label {
  color: #000;
}
.bol-stop-refs {
  font-size: 11px;
  margin: 0 0 4px;
  padding: 3px 0;
  border-bottom: 1px solid #000;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.bol-stop-refs strong {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bol-comp-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  display: block;
}
.bol-comp-no {
  font-size: 16px;
  font-weight: 800;
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0.03em;
}

.bol-header-meta {
  margin-top: 6px;
  text-align: right;
  font-size: 10px;
  line-height: 1.35;
  max-width: 220px;
  margin-left: auto;
}
.bol-meta-k {
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: Arial, Helvetica, sans-serif;
  margin-right: 4px;
}
.bol-header-driver {
  margin-top: 1px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
}
.bol-trailer-line {
  border: 1.5px solid #000;
  padding: 5px 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0.01em;
  word-break: break-word;
  line-height: 1.35;
}
.bol-addr-row {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
  border: 1.5px solid #000;
}
.bol-addr-row-tight .bol-addr-box {
  min-height: 0;
  padding: 4px 6px;
}
.bol-addr-row-tight .bol-addr-body {
  font-size: 11px;
}
.bol-addr-row .bol-addr-box {
  border: none;
  border-right: 1.5px solid #000;
}
.bol-addr-row .bol-addr-box:last-child {
  border-right: none;
}
.bol-addr-box {
  flex: 1;
  border: 1.5px solid #000;
  border-radius: 0;
  padding: 6px 8px;
  min-height: 48px;
}
.bol-addr-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  font-family: Arial, Helvetica, sans-serif;
}
.bol-addr-body {
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bol-stops-list {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bol-stop-item {
  border: 1.5px solid #000;
  border-radius: 0;
  padding: 6px 8px;
  margin: 0;
}
.bol-stop-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  font-size: 11px;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.bol-stop-badge {
  display: inline-block;
  border: 1px solid #000;
  border-radius: 0;
  padding: 1px 5px;
  font-size: 9px;
  margin-left: 6px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: #fff;
}
.bol-stop-meta {
  font-size: 11px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
}

.bol-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1.5px solid #000;
  margin-bottom: 8px;
}
.bol-truck-grid {
  grid-template-columns: repeat(3, 1fr);
}
.bol-truck-grid .bol-grid-cell {
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
}
.bol-truck-grid .bol-grid-cell:nth-child(3n) { border-right: none; }
.bol-truck-grid .bol-grid-cell:nth-last-child(-n+3) { border-bottom: none; }
.bol-grid-cell {
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  padding: 4px 6px;
  min-height: 36px;
}
.bol-grid-cell:nth-child(4n) { border-right: none; }
.bol-grid-label {
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: Arial, Helvetica, sans-serif;
  color: #333;
  display: block;
  margin-bottom: 2px;
}
.bol-grid-value {
  font-size: 12px;
  font-weight: 600;
  word-break: break-word;
}
.bol-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  margin-top: 2px;
}
.bol-check {
  white-space: nowrap;
}
.bol-check .box {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1px solid #000;
  border-radius: 0;
  margin-right: 3px;
  vertical-align: -1px;
  text-align: center;
  font-size: 8px;
  line-height: 9px;
  font-weight: 900;
}

.bol-table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid #000;
  margin-bottom: 10px;
}
.bol-table th, .bol-table td {
  border: 1px solid #000;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.bol-table th {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  font-family: Arial, Helvetica, sans-serif;
  background: #f0f0f0;
}
.bol-table td { font-size: 12px; min-height: 28px; }
.bol-table .col-pcs { width: 12%; }
.bol-table .col-desc { width: 48%; }
.bol-table .col-wt { width: 20%; }
.bol-table .col-dmg { width: 20%; }

.bol-footer {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px solid #000;
}
.bol-sig {
  flex: 2;
}
.bol-sig-line {
  border-bottom: 1.5px solid #000;
  min-height: 28px;
  margin-top: 4px;
  padding-bottom: 2px;
  font-size: 13px;
  font-weight: 600;
}
.bol-footer-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bol-footer-field .label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  font-family: Arial, Helvetica, sans-serif;
}
.bol-footer-field .value {
  border-bottom: 1.5px solid #000;
  min-height: 22px;
  font-size: 12px;
  padding-top: 2px;
}

@media (max-width: 400px) {
  .bol-addr-row { flex-direction: column; }
  .bol-grid { grid-template-columns: repeat(2, 1fr); }
  .bol-truck-grid { grid-template-columns: repeat(2, 1fr); }
  .bol-truck-grid .bol-grid-cell:nth-child(3n) { border-right: 1px solid #000; }
  .bol-truck-grid .bol-grid-cell:nth-child(2n) { border-right: none; }
  .bol-truck-grid .bol-grid-cell:nth-last-child(-n+3) { border-bottom: 1px solid #000; }
  .bol-truck-grid .bol-grid-cell:nth-last-child(-n+2) { border-bottom: none; }
  .bol-grid-cell:nth-child(2n) { border-right: none; }
  .bol-grid-cell:nth-child(4n) { border-right: 1px solid #000; }
  .bol-grid-cell:nth-child(2n) { border-right: none; }
  .bol-footer { flex-direction: column; }
  .bol-stop-meta { grid-template-columns: 1fr; }
}


/* ========== E-signature ========== */
.sig-settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.sig-preview {
  min-height: 72px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
}
.sig-preview.empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.sig-preview img {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
}

.bol-sig-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 8px;
  padding-top: 0;
  border-top: 1.5px solid #000;
}
.bol-sig-row .bol-sig-box {
  border-right: none;
  border-top: none;
}
.bol-sig-row .bol-sig-box:first-child {
  border-left: none;
}
.bol-sig-row .bol-sig-box:last-child {
  border-right: none;
}
.bol-sig-box {
  flex: 1 1 28%;
  min-width: calc(33% - 8px);
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid #000;
  border-radius: 0;
  padding: 4px 6px 6px;
  min-height: 80px;
  background: #fff;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.bol-sig-box:active {
  background: #f5f5f5;
}
.bol-sig-box .bol-sig-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: Arial, Helvetica, sans-serif;
  margin-bottom: 4px;
}
.bol-sig-box .bol-sig-pad {
  border-bottom: 1.5px solid #000;
  min-height: 56px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
}
.bol-sig-box .bol-sig-pad img {
  max-width: 100%;
  max-height: 54px;
  object-fit: contain;
  display: block;
}
.bol-sig-box .bol-sig-tap-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #888;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 600;
  pointer-events: none;
}
.bol-sig-box.has-ink .bol-sig-tap-hint { display: none; }

.bol-footer-meta-row {
  display: flex;
  gap: 0;
  margin-top: 6px;
  border: 1.5px solid #000;
  border-bottom: none;
  align-items: stretch;
}
.bol-footer-meta-compact {
  min-height: 0;
}
.bol-footer-meta-row .bol-footer-field {
  flex: 1;
  padding: 2px 6px 3px;
  border-right: 1px solid #000;
}
.bol-footer-meta-row .bol-footer-field:last-child {
  border-right: none;
}
.bol-footer-meta-compact .bol-footer-field .label {
  font-size: 8px;
  line-height: 1.1;
  margin: 0;
}
.bol-footer-meta-compact .bol-footer-field .value {
  border-bottom: none;
  min-height: 14px;
  font-size: 11px;
  line-height: 1.15;
  padding-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bol-footer-driver {
  flex: 1.4;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}
.bol-footer-date,
.bol-footer-miles {
  flex: 0.7;
  max-width: 28%;
}
.bol-sig-row-three {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
}
.bol-sig-row-three .bol-sig-box {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  min-height: 72px;
  padding: 3px 4px 4px;
}
.bol-sig-row-three .bol-sig-pad {
  min-height: 44px;
  height: 48px;
}
.bol-sig-row-three .bol-sig-pad img,
.bol-sig-row-three .bol-sig-pad img.bol-sig-ink {
  max-height: 46px;
}
.bol-sig-row-two .bol-sig-box {
  flex: 1 1 45%;
  min-width: calc(50% - 4px);
}

.bol-footer-meta-row .bol-footer-field .value {
  border-bottom: none;
  min-height: 14px;
}


/* Classic sign-here guide: large X + vertical line (portrait pad) */
.sig-canvas-wrap {
  position: relative;
}
.sig-guide {
  position: absolute;
  inset: 6px;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: 10px 0 10px 12px;
  box-sizing: border-box;
}
.sig-guide-x {
  flex: 0 0 auto;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(48px, 14vw, 84px);
  font-weight: 900;
  line-height: 0.85;
  color: #111;
  margin-right: 10px;
  margin-top: 4px;
  user-select: none;
}
.sig-guide-line {
  flex: 0 0 3px;
  width: 3px;
  align-self: stretch;
  background: #111;
  border-radius: 1px;
  margin-bottom: 12px;
  margin-top: 8px;
}
#sig-canvas {
  position: relative;
  z-index: 1;
}

/* Portrait-captured ink shown landscape on BOL / settings preview (−90°) */
.bol-sig-ink,
.sig-preview img.bol-sig-ink,
.bol-sig-pad img.bol-sig-ink {
  transform: rotate(-90deg);
  transform-origin: center center;
  max-width: 56px;
  max-height: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.bol-sig-pad {
  overflow: hidden;
}
.bol-sig-pad img.bol-sig-ink {
  max-width: 52px;
  max-height: 120%;
}
.bol-carrier-under-driver .bol-sig-pad img.bol-sig-ink {
  max-width: 36px;
  max-height: 100px;
}
.sig-preview {
  min-height: 96px;
}
.sig-preview img.bol-sig-ink {
  max-width: 72px;
  max-height: 160px;
}

/* Signature modal — full-screen, canvas fills remaining viewport */
.sig-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #111;
  display: flex;
  flex-direction: column;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  box-sizing: border-box;
  overflow: hidden;
}

.sig-modal.hidden { display: none; }


.sig-modal-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  border: none;
  max-width: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  box-sizing: border-box;
}
.sig-modal-header {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: #111;
  color: #fff;
}
.sig-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}
.sig-canvas-wrap {
  flex: 1 1 auto;
  min-height: 0;
  background: #e8e8e8;
  padding: 6px;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  position: relative;
  /* Prefer a wide signing surface (landscape proportions when possible) */
  width: 100%;
}
#sig-modal.sig-pad-wide .sig-canvas-wrap,
.sig-modal .sig-canvas-wrap {
  min-height: min(50dvh, 100%);
}
#sig-canvas {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  border: 2px solid #111;
  border-radius: 4px;
  touch-action: none;
  cursor: crosshair;
  display: block;
  box-sizing: border-box;
}
.sig-modal-hint {
  flex: 0 0 auto;
  margin: 0;
  padding: 4px 12px;
  text-align: center;
  font-size: 0.8rem;
  color: #555;
  font-weight: 600;
  background: #fff;
}
.sig-modal-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 8px;
  padding: 8px 10px 10px;
  background: #fff;
  border-top: 1px solid #ddd;
}
.sig-modal-actions .btn { width: 100%; min-height: 48px; }

/* Prefer wide / landscape pad layout */
@media (orientation: landscape), (min-aspect-ratio: 1/1) {
  .sig-modal-header { padding: 6px 12px; }
  .sig-modal-header h2 { font-size: 0.95rem; }
  .sig-modal-hint { padding: 2px 10px; font-size: 0.75rem; }
  .sig-modal-actions {
    gap: 6px;
    padding: 6px 8px 8px;
  }
  .sig-modal-actions .btn { min-height: 40px; font-size: 0.9rem; }
  .sig-canvas-wrap { padding: 4px; flex: 1 1 auto; }
  .sig-modal-panel {
    flex-direction: column;
  }
}

@media (orientation: landscape) and (max-height: 420px) {
  .sig-modal-hint { display: none; }
}

@media (max-width: 400px) {
  .bol-sig-row { flex-direction: column; }
}

@media print {
  .sig-modal { display: none !important; }
  .bol-sig-box { cursor: default; }
  .bol-sig-box .bol-sig-tap-hint { display: none !important; }
}


/* Three stop-type bubbles */
.type-bubbles-3 {
  flex-wrap: wrap;
}
.type-bubbles-3 .bubble {
  flex: 1 1 30%;
  min-width: 28%;
  font-size: 0.82rem;
  padding: 0 6px;
  text-align: center;
}

.equip-section-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 4px 0 8px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.trailer-dropped-section {
  margin-top: 8px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  margin-bottom: 10px;
}
.trailer-dropped-section.hidden { display: none; }

textarea.stop-address {
  min-height: 4.8em;
  line-height: 1.35;
  resize: vertical;
}

.bol-stop-checks {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px solid #000;
}
.bol-stop-equip-pair {
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}
.bol-stop-cargo {
  font-size: 11px;
  margin: 4px 0 2px;
  padding: 3px 5px;
  border: 1px solid #000;
  border-radius: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 1px;
}



/* Validation highlight */
.field-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.35);
  outline: none;
}
.stop-card.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.25);
}
.type-bubbles.field-error,
.load-bubbles.field-error {
  border-radius: 12px;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.4);
}
@keyframes bang-pulse {
  0%, 100% { transform: scale(1); background: var(--danger-bg); }
  50% { transform: scale(1.08); background: #ffcdd2; }
}

.container-row.bobtail-hidden,
.equip-fields.bobtail-hidden {
  display: none !important;
}
.bobtail-hint {
  margin: 0 0 8px;
}

/* Preview pinch-zoom / pan */
.zoom-hint {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}
.bol-zoom-viewport {
  width: 100%;
  max-height: min(70dvh, 900px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: #e8e8e8;
  overscroll-behavior: contain;
}
.bol-zoom-canvas {
  /* Letter page sized; user can pinch via browser + scroll to pan */
  width: max(100%, 8.5in);
  min-height: 11in;
  display: flex;
  justify-content: center;
  padding: 8px;
  box-sizing: border-box;
  transform-origin: top center;
}
.bol-zoom-canvas .bol-document {
  flex-shrink: 0;
}

/* Address autocomplete (custom — works on Android Chrome) */
.addr-suggest-wrap {
  position: relative;
}
.addr-suggest-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.addr-suggest-list.hidden { display: none; }
.addr-suggest-item {
  padding: 12px 14px;
  min-height: 48px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.95rem;
  line-height: 1.3;
  cursor: pointer;
  word-break: break-word;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  user-select: none;
}
.addr-suggest-item:last-child { border-bottom: none; }
.addr-suggest-item.addr-suggest-armed {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.addr-suggest-item:active,
.addr-suggest-item:hover {
  background: var(--ink);
  color: var(--bg);
}

.stops-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-clear-stops {
  width: 100%;
  border-color: var(--danger);
  color: var(--danger);
  background: #fff;
  font-weight: 700;
}
.btn-clear-stops:active {
  background: var(--danger-bg);
}

/* US Letter receipt page */
@page {
  size: letter;
  margin: 0.4in;
}

.preview-main {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.bol-document {
  width: 8.5in;
  max-width: 8.5in;
  min-height: 11in;
  padding: 0.45in;
  box-sizing: border-box;
  margin: 0 auto;
  background: #fff;
}

@media print {
  body { background: #fff; }
  .topbar, .bottom-bar, .preview-actions, .save-hint, .zoom-hint, .toast, .sig-modal { display: none !important; }
  .screen { display: none !important; }
  #screen-preview.screen.active { display: block !important; }
  .preview-main { overflow: visible; padding: 0; max-width: none; }
  .bol-document {
    border: none;
    width: 8.5in;
    max-width: 8.5in;
    min-height: 11in;
    padding: 0.4in;
    margin: 0;
    box-shadow: none;
  }
}

@media print {
  .bol-zoom-viewport {
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    background: transparent !important;
  }
  .bol-zoom-canvas {
    width: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }
}

/* OCR import */
.btn-ocr {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--ink);
  font-weight: 700;
  border-radius: var(--radius);
}
.ocr-progress {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
.ocr-progress.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
  html[data-theme="dark"] .btn-bright,
  html[data-theme="light"] .btn-bright,
  html[data-theme="dark"] .section-title,
  html[data-theme="light"] .section-title {
    box-shadow: none !important;
    text-shadow: none !important;
  }
}


/* Equipment camera OCR */
.equip-ocr-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: var(--tap);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-2);
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(0, 0, 0, 0.12) 100%
  );
  color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 1px 0 rgba(0, 0, 0, 0.35);
}
.equip-ocr-btn:active {
  transform: translateY(1px);
  filter: brightness(0.95);
}
.equip-ocr-btn svg { display: block; }
.equip-ocr-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.equip-ocr-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 12px calc(12px + var(--safe-bottom));
}
.equip-ocr-sheet.hidden { display: none; }
.equip-ocr-sheet-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
.equip-ocr-sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 16px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 8px 8px;
  border-top: 3px solid var(--accent);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.equip-ocr-sheet-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
}
.equip-ocr-sheet-hint {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}
.equip-ocr-choice { width: 100%; }


/* Settings company logo */
.logo-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.logo-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  max-width: 220px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.logo-preview-wrap.logo-preview-empty {
  border-style: dashed;
}
.logo-preview {
  max-width: 180px;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.logo-preview.hidden { display: none; }
.logo-preview-placeholder {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.logo-settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.logo-settings-actions .btn { width: 100%; }

/* BOL header logo + name */
.bol-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 0 0 4px;
}
.bol-logo-img {
  display: block;
  max-height: 48px;
  max-width: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.bol-logo-img.hidden { display: none; }

@media print {
  .bol-document.bol-multipage {
    max-width: none;
    width: auto;
  }
  .bol-page {
    width: 8.5in;
    min-height: 11in;
    max-width: none;
    margin: 0;
    padding: 0.4in;
    border: none;
    page-break-after: always;
    break-after: page;
  }
  .bol-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  .bol-page-continued {
    display: none;
  }
}


/* Preview save bar */
#screen-preview .bottom-bar-stack {
  flex-direction: column;
}
#screen-preview .bottom-bar-row .btn {
  font-size: 0.85rem;
}
#screen-preview .btn-save-tall {
  opacity: 0.85;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
}


/* ---------- First-run tutorial coach ---------- */
.tutorial-coach {
  position: fixed;
  z-index: 180;
  display: flex;
  justify-content: center;
}
.tutorial-coach.hidden,
.tutorial-coach[hidden] {
  display: none !important;
}
.tutorial-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tutorial-coach-welcome {
  inset: 0;
  align-items: center;
  padding: 24px 16px;
  pointer-events: auto;
}
.tutorial-coach-welcome .tutorial-backdrop {
  display: block;
  background: rgba(10, 12, 16, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
}
.tutorial-coach-welcome .tutorial-coach-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  padding: 22px 18px 16px;
  text-align: center;
}
.tutorial-coach-welcome .tutorial-title { font-size: 1.35rem; }
.tutorial-coach-welcome .tutorial-body {
  font-size: 1rem;
  color: var(--ink);
}
.tutorial-coach-welcome .tutorial-coach-actions { justify-content: center; }

/* Install / A2HS tutorial step (same centered card as welcome) */
.tutorial-coach-install .tutorial-body {
  white-space: pre-line;
  text-align: left;
  max-width: 28em;
  margin-left: auto;
  margin-right: auto;
}
.tutorial-coach-install .tutorial-coach-actions {
  flex-wrap: wrap;
  justify-content: center;
}
.tutorial-coach-install #tutorial-a2hs {
  flex: 1 1 100%;
  order: -1;
  margin-bottom: 4px;
}
.tutorial-a2hs-btn.hidden,
.tutorial-a2hs-btn[hidden] {
  display: none !important;
}
.tutorial-a2hs-btn.is-installed {
  opacity: 0.85;
  filter: none;
}

/* Compact non-blocking coach (bottom or top) */
.tutorial-coach-bar,
.tutorial-coach-top {
  left: 0;
  right: 0;
  align-items: flex-end;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  pointer-events: none;
}
.tutorial-coach-bar { bottom: 0; top: auto; }
.tutorial-coach-top {
  top: calc(8px + var(--safe-top, 0px));
  bottom: auto;
  align-items: flex-start;
  padding-top: calc(8px + var(--safe-top, 0px));
}
.tutorial-coach-bar .tutorial-backdrop,
.tutorial-coach-top .tutorial-backdrop { display: none; }

.tutorial-coach-card {
  pointer-events: auto;
  width: min(420px, 100%);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  padding: 10px 12px 10px;
}
.tutorial-coach-bar .tutorial-coach-card,
.tutorial-coach-top .tutorial-coach-card {
  padding: 8px 10px 8px;
}
.tutorial-step-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.tutorial-title {
  margin: 2px 0 4px;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.25;
}
.tutorial-coach-bar .tutorial-title,
.tutorial-coach-top .tutorial-title { font-size: 0.92rem; }
.tutorial-body {
  margin: 0 0 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
}
.tutorial-coach-bar .tutorial-body,
.tutorial-coach-top .tutorial-body {
  font-size: 0.78rem;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tutorial-gate-hint {
  margin: -2px 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--danger);
}
.tutorial-gate-hint.hidden { display: none !important; }
.tutorial-coach-actions { display: flex; gap: 8px; }
.tutorial-coach-actions .btn {
  flex: 1;
  min-height: 40px;
  width: auto;
  font-size: 0.85rem;
}
#tutorial-next:disabled,
#tutorial-next.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.2);
}
.tutorial-highlight {
  outline: 3px solid var(--accent) !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent) !important;
  position: relative;
  z-index: 5;
  scroll-margin: 140px;
}
.addr-suggest-item.addr-suggest-sample {
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
  font-weight: 600;
}

/* Keep scroll targets above coach + bottom bar while tutorial runs */
body.tutorial-active #screen-home .main-content,
body.tutorial-active #screen-settings .main-content {
  padding-bottom: calc(190px + var(--safe-bottom)) !important;
}
body.tutorial-active #screen-generate .main-content.has-bottom-bar,
body.tutorial-active #screen-preview .main-content.has-bottom-bar {
  padding-bottom: calc(var(--bottom-bar-h, 96px) + 200px + var(--safe-bottom)) !important;
}
body.tutorial-active #screen-generate .stops-actions {
  scroll-margin-bottom: 220px;
}

/* Settings danger zone */
.card-danger-zone {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.section-title-danger {
  color: var(--danger);
}
.hint-danger {
  color: var(--muted);
}
#btn-clear-cache-data {
  width: 100%;
  margin-top: 4px;
}

/* ---------- Misty Maxwell-style easter egg (Home only) ---------- */
#screen-home {
  position: relative;
}
.misty-easter {
  position: absolute;
  left: max(6px, env(safe-area-inset-left, 0px));
  bottom: max(4px, env(safe-area-inset-bottom, 0px));
  z-index: 12;
  width: 48px;
  height: 48px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.42;
  transition: opacity 0.2s ease, width 0.35s ease, height 0.35s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  line-height: 0;
}
.misty-easter:hover,
.misty-easter:focus-visible {
  opacity: 0.72;
  outline: none;
}
.misty-easter-sprite {
  display: block;
  width: 48px;
  height: 48px;
  /* 24-frame turntable sheet (2712×128 → fw 113) */
  background-image: url('./assets/misty-turntable.png');
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: auto 100%;
  pointer-events: none;
  user-select: none;
  image-rendering: auto;
}
/* Tap spins: cycle turntable sprites (not CSS rotateY) */
.misty-easter.is-spin-once .misty-easter-sprite {
  animation: misty-tt-once 0.95s steps(24) 1;
}
.misty-easter.is-wiggle .misty-easter-sprite {
  animation: misty-tt-wiggle 0.85s steps(24) 1;
}
.misty-easter.is-spinning .misty-easter-sprite {
  animation: misty-tt-spin 0.7s steps(24) infinite;
}
/* Soft phase (0–7s): turntable ~1.7s/rev */
.misty-easter.is-spinning-soft .misty-easter-sprite {
  animation: misty-tt-spin 1.7s steps(24) infinite;
}
/* Drop/blast phase: faster turntable ~0.85s/rev */
.misty-easter.is-spinning-fast .misty-easter-sprite {
  animation: misty-tt-spin 0.85s steps(24) infinite;
}
/* Bounce around viewport (JS sets left/top) */
.misty-easter.is-bouncing {
  position: fixed;
  bottom: auto;
  right: auto;
  opacity: 1;
  z-index: 40;
  will-change: left, top;
}
/* Modest enlarge ~1.33× peek — not a center takeover */
.misty-easter.is-bouncing.is-enlarged {
  width: min(13vw, 64px);
  height: min(13vw, 64px);
}
.misty-easter.is-bouncing.is-enlarged .misty-easter-sprite {
  width: 100%;
  height: 100%;
}
/* Sprite sheet: 24 frames × 113px = 2712px. steps(24) from 0 → -2712 lands each frame. */
@keyframes misty-tt-spin {
  from { background-position: 0 0; }
  to { background-position: -2712px 0; }
}
@keyframes misty-tt-once {
  from { background-position: 0 0; }
  to { background-position: -2712px 0; }
}
@keyframes misty-tt-wiggle {
  0% { background-position: 0 0; }
  35% { background-position: -1130px 0; } /* ~10 frames */
  70% { background-position: -2034px 0; } /* ~18 frames */
  100% { background-position: -2712px 0; }
}

/* Viewport trail layer — never blocks Home UI */
.misty-trail-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 39;
  pointer-events: none;
  display: none;
}
.misty-trail-canvas.is-active {
  display: block;
}
/* Flash overlay at drop */
.misty-rainbow {
  position: fixed;
  inset: 0;
  z-index: 38;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: soft-light;
}
.misty-rainbow.is-active {
  opacity: 0.62;
  animation: misty-strobe 0.38s steps(1) infinite;
}
@keyframes misty-strobe {
  0%   { background: #ff3b5c; }
  14%  { background: #ff9f1c; }
  28%  { background: #ffd60a; }
  42%  { background: #2ec4b6; }
  57%  { background: #3a86ff; }
  71%  { background: #8338ec; }
  85%  { background: #ff006e; }
  100% { background: #ff3b5c; }
}
/* Keep out of the way during tutorial coach */
body.tutorial-active .misty-easter,
body.tutorial-active .misty-rainbow,
body.tutorial-active .misty-trail-canvas,
body.tutorial-active .misty-paddle,
body.tutorial-active .misty-pong-hud,
body.tutorial-active .misty-level-banner,
body.tutorial-active .misty-gameover,
body.tutorial-active .misty-panic {
  display: none !important;
}

/* ---------- Misty approved panic shutoff (baked GIF/webp + still) ---------- */
.misty-panic {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 44;
  display: none;
  align-items: center;
  justify-content: center;
  width: min(42vw, 148px);
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  line-height: 0;
}
.misty-panic.is-active {
  display: flex;
}
.misty-panic:active {
  transform: translateX(-50%) scale(0.94);
}
.misty-panic-img,
.misty-panic picture {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
@media (prefers-reduced-motion: reduce) {
  .misty-panic:active {
    transform: translateX(-50%);
  }
}

/* ---------- Misty mini-Pong (5th-tap full effect) ---------- */
.misty-paddle {
  position: fixed;
  left: 0;
  bottom: max(56px, calc(env(safe-area-inset-bottom, 0px) + 48px));
  z-index: 42;
  width: min(34vw, 140px);
  height: 18px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: linear-gradient(180deg, #ff9f1c 0%, #ff006e 55%, #8338ec 100%);
  box-shadow: 0 0 14px rgba(255, 0, 110, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  touch-action: none;
  cursor: grab;
  display: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.misty-paddle.is-active {
  display: block;
}
.misty-paddle.is-dragging {
  cursor: grabbing;
  transform: scaleY(1.08);
}
.misty-pong-hud {
  position: fixed;
  left: 50%;
  bottom: max(82px, calc(env(safe-area-inset-bottom, 0px) + 74px));
  transform: translateX(-50%);
  z-index: 43;
  display: none;
  gap: 14px;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(8, 10, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
}
.misty-pong-hud.is-active {
  display: flex;
}
.misty-pong-hud b {
  font-variant-numeric: tabular-nums;
  color: #ffd60a;
}
.misty-pong-best b {
  color: #2ec4b6;
}
.misty-pong-level b {
  color: #a78bfa;
}
.misty-level-banner {
  position: fixed;
  inset: 0;
  z-index: 49;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: transparent;
}
.misty-level-banner.is-active {
  display: flex;
}
.misty-level-banner-text {
  font-size: clamp(42px, 14vw, 72px);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow:
    0 0 22px rgba(167, 139, 250, 0.85),
    0 0 40px rgba(255, 0, 110, 0.45),
    0 4px 0 rgba(0, 0, 0, 0.55);
  animation: misty-level-pop 0.45s ease-out;
  padding: 12px 28px;
  border-radius: 16px;
  background: rgba(8, 10, 22, 0.55);
  border: 2px solid rgba(167, 139, 250, 0.55);
  image-rendering: pixelated;
}
@keyframes misty-level-pop {
  0% { transform: scale(0.55); opacity: 0; }
  55% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .misty-level-banner-text {
    animation: none;
  }
}
.misty-gameover {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.misty-gameover.is-active {
  display: flex;
}
.misty-gameover-card {
  text-align: center;
  padding: 28px 32px 22px;
  border-radius: 18px;
  background: linear-gradient(160deg, #1a1030 0%, #0d1528 100%);
  border: 2px solid rgba(255, 214, 10, 0.55);
  box-shadow: 0 0 40px rgba(255, 0, 110, 0.35), 0 12px 32px rgba(0, 0, 0, 0.45);
  color: #fff;
  min-width: min(78vw, 280px);
  animation: misty-gameover-pop 0.35s ease-out;
}
.misty-gameover-title {
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ff3b5c;
  text-shadow: 0 0 18px rgba(255, 59, 92, 0.65);
  margin-bottom: 12px;
}
.misty-gameover-score,
.misty-gameover-best {
  font-size: 16px;
  margin: 4px 0;
  opacity: 0.95;
}
.misty-gameover-score b {
  color: #ffd60a;
  font-variant-numeric: tabular-nums;
}
.misty-gameover-best b {
  color: #2ec4b6;
  font-variant-numeric: tabular-nums;
}
.misty-gameover-hint {
  margin-top: 14px;
  font-size: 12px;
  opacity: 0.55;
}
@keyframes misty-gameover-pop {
  from { transform: scale(0.82); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .misty-gameover-card {
    animation: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .misty-easter.is-spinning-soft .misty-easter-sprite {
    animation: misty-spin-soft 2.4s linear infinite;
  }
  .misty-easter.is-spinning-fast .misty-easter-sprite {
    animation: misty-spin-fast 1.2s linear infinite;
  }
  .misty-easter.is-spin-once .misty-easter-sprite {
    animation-duration: 1.1s;
  }
  .misty-easter.is-wiggle .misty-easter-sprite {
    animation-duration: 1.0s;
  }
  .misty-rainbow.is-active {
    animation-duration: 0.9s;
    opacity: 0.35;
  }
}
