@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,500&family=Frank+Ruhl+Libre:wght@400;500;700&family=Source+Sans+3:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --color-bg: #f4ead8;
  --color-bg-deep: #ead9bc;
  --color-bg-elevated: #faf3e4;
  --color-surface: rgba(255, 250, 240, 0.92);
  --color-card: rgba(255, 248, 235, 0.88);
  --color-card-border: rgba(139, 94, 40, 0.22);
  --color-text: #2c1f14;
  --color-text-muted: rgba(44, 31, 20, 0.84);
  --color-muted: rgba(44, 31, 20, 0.72);
  --color-gold: #a67c1a;
  --color-gold-light: #6b4a12;
  --color-gold-soft: rgba(166, 124, 26, 0.16);
  --color-wine: #5c2038;
  --color-wine-deep: #3a1224;
  --color-azure: #3d6ea8;
  --color-accent: #b8860b;
  --color-accent-hover: #c99a22;
  --color-success: #2a8a52;
  --color-success-bright: #3a9a62;
  --color-warning: #c47a12;
  --color-danger: #c43c3c;
  --color-input-bg: rgba(255, 252, 245, 0.92);
  --color-input-border: rgba(139, 94, 40, 0.28);
  --color-chrome-bg: rgba(244, 234, 216, 0.9);
  --color-nav-hover: rgba(44, 31, 20, 0.06);
  --pattern-opacity: 0.04;
  --font-display: "Cormorant Garamond", "Frank Ruhl Libre", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-hebrew: "Frank Ruhl Libre", "David Libre", serif;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-card: 0 12px 32px rgba(80, 50, 20, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  --shadow-glow: 0 0 50px rgba(166, 124, 26, 0.08);
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --shell-height: 56px;
  --status-height: 34px;
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0f0f10;
  --color-bg-deep: #121214;
  --color-bg-elevated: #18181b;
  --color-surface: rgba(34, 34, 38, 0.88);
  --color-card: rgba(250, 242, 228, 0.04);
  --color-card-border: rgba(201, 162, 55, 0.2);
  --color-text: #f0f0f0;
  --color-text-muted: rgba(240, 240, 240, 0.68);
  --color-muted: #9ca3af;
  --color-gold: #c9a227;
  --color-gold-light: #e8d48b;
  --color-gold-soft: rgba(201, 162, 55, 0.18);
  --color-wine: #5c2038;
  --color-wine-deep: #3a1224;
  --color-azure: #4f8ef7;
  --color-accent: #b8860b;
  --color-accent-hover: #d4a82a;
  --color-success: #34c97a;
  --color-success-bright: #5cb87a;
  --color-warning: #f5a623;
  --color-danger: #f05050;
  --color-input-bg: rgba(12, 10, 14, 0.65);
  --color-input-border: rgba(201, 162, 55, 0.24);
  --color-chrome-bg: rgba(15, 15, 16, 0.92);
  --color-nav-hover: rgba(255, 255, 255, 0.06);
  --pattern-opacity: 0.012;
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(232, 212, 160, 0.05);
  --shadow-glow: 0 0 60px rgba(201, 162, 55, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse 100% 60% at 50% -10%, rgba(201, 162, 55, 0.08), transparent 50%),
    linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-deep) 100%);
  background-attachment: fixed;
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100dvh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--pattern-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath fill='%23c9a227' d='M40 4l4 12h12l-10 8 4 12-10-8-10 8 4-12-10-8h12z'/%3E%3C/svg%3E");
  background-size: 80px 80px;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--color-card);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}

.card::before {
  content: "";
  display: block;
  height: 3px;
  margin: -22px -22px 18px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--color-gold) 18%,
    var(--color-gold-light) 50%,
    var(--color-gold) 82%,
    transparent
  );
  opacity: 0.75;
}

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.grow {
  flex: 1;
  min-width: 260px;
}

h1,
h2,
h3,
.site-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-gold-light);
}

h1 {
  font-size: clamp(1.65rem, 4vw, 2.1rem);
  margin: 0 0 14px;
  line-height: 1.2;
}

h2 {
  font-size: 1.25rem;
  margin: 0 0 10px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-input-border);
  background: var(--color-input-bg);
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px var(--color-gold-soft);
}

:focus-visible {
  outline: 2px solid var(--color-gold-light);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

button {
  cursor: pointer;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 162, 55, 0.45);
  background: linear-gradient(180deg, #d4a82a 0%, var(--color-accent) 55%, #9a7010 100%);
  color: #1a1008;
  font-weight: 600;
  font-family: var(--font-body);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: filter 0.2s, transform 0.15s;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button.secondary {
  background: var(--color-surface);
  color: var(--color-gold-light);
  border-color: var(--color-card-border);
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.muted {
  color: var(--color-text-muted);
  font-size: 13px;
}

/* --- App landing & login --- */

.site-header {
  margin: 28px 0 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-card-border);
  text-align: center;
}

.site-header-inner {
  max-width: 640px;
  margin: 0 auto;
}

.site-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--color-gold);
  opacity: 0.85;
}

.site-ornament::before,
.site-ornament::after {
  content: "";
  flex: 1;
  max-width: 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
}

.site-ornament-symbol {
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(201, 162, 55, 0.35));
}

.site-ornament--start {
  justify-content: flex-start;
}

.site-ornament--start::before {
  max-width: 48px;
}

.site-ornament--start::after {
  flex: 1;
  max-width: none;
}

.site-title {
  margin: 0 0 6px;
}

.site-hebrew {
  margin: 0 0 12px;
  font-family: var(--font-hebrew);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--color-gold);
  letter-spacing: 0.04em;
}

.site-subtitle {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.site-header-actions {
  margin-top: 18px;
}

.app-landing-card h2 {
  color: var(--color-gold-light);
}

.app-landing-card .card::before {
  opacity: 0.55;
}

.login-page .container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 48px);
}

body.login-page.has-app-shell .container.app-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--shell-height) - var(--space-lg));
  max-width: 960px;
}

.login-card {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

.login-card h1 {
  margin-bottom: 8px;
}

.login-card .site-ornament {
  margin-bottom: 16px;
}

.viewfinder {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
}

.viewfinder video {
  position: relative;
  z-index: 0;
  width: 100%;
  height: auto;
  display: block;
  background: #000;
}

/* Static alignment frame: user fits the physical board inside this window. */
.viewfinder-guide {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.guide-cutout {
  position: relative;
  width: min(90%, 100%);
  max-height: min(76vh, 85%);
  aspect-ratio: 2008 / 1395;
  box-sizing: border-box;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 max(100vw, 100vh) rgba(0, 0, 0, 0.52);
}

.guide-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: rgba(255, 255, 255, 0.98);
  border-style: solid;
}

.guide-tl {
  top: -3px;
  left: -3px;
  border-width: 5px 0 0 5px;
  border-radius: 10px 0 0 0;
}

.guide-tr {
  top: -3px;
  right: -3px;
  border-width: 5px 5px 0 0;
  border-radius: 0 10px 0 0;
}

.guide-br {
  bottom: -3px;
  right: -3px;
  border-width: 0 5px 5px 0;
  border-radius: 0 0 10px 0;
}

.guide-bl {
  bottom: -3px;
  left: -3px;
  border-width: 0 0 5px 5px;
  border-radius: 0 0 0 10px;
}

.guide-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Live: white alignment frame. On lock we switch to crop preview (no green overlay). */
.viewfinder.is-frozen:not(.is-crop-preview) .guide-cutout {
  border-color: var(--color-success-bright);
  box-shadow:
    0 0 0 3px rgba(92, 184, 122, 0.4),
    0 0 0 max(100vw, 100vh) rgba(0, 0, 0, 0.52);
}

.viewfinder.is-frozen:not(.is-crop-preview) .guide-corner {
  border-color: #7dd99a;
}

/* Locked: show only the cropped JPEG (exact OCR input), hide live video + alignment UI. */
.viewfinder.is-crop-preview video {
  visibility: hidden;
  pointer-events: none;
}

.viewfinder.is-crop-preview .viewfinder-guide {
  display: none !important;
}

.frozen-crop-preview {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #0c0c0c;
  display: none;
}

.viewfinder.is-crop-preview .frozen-crop-preview {
  display: block;
}

.viewfinder.is-crop-preview .frozen-badge {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

.frozen-badge[hidden],
.frozen-badge.is-hidden {
  display: none !important;
}

.frozen-badge {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(61, 143, 92, 0.92);
  color: #0a2818;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 20px);
}

#retake {
  background: linear-gradient(180deg, #e0b04a 0%, var(--color-warning) 100%);
  color: #1a1008;
  border-color: rgba(0, 0, 0, 0.2);
}

#capture {
  background: linear-gradient(180deg, #6bc48a 0%, var(--color-success) 100%);
  color: #0a2818;
  border-color: rgba(0, 0, 0, 0.2);
}

#capture:disabled {
  background: rgba(61, 143, 92, 0.45);
  color: rgba(10, 40, 24, 0.7);
}

.result {
  line-height: 1.35;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px;
  min-height: 140px;
  overflow-x: visible;
  overflow-y: visible;
}

.capture-results {
  min-width: 0;
}

.pledge-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 8px;
}

.capture-results .capture-results-label {
  margin-bottom: 6px;
}

.pledge-table-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 650;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

table.pledge-table {
  width: 100%;
  border-collapse: collapse;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  margin-bottom: 4px;
}

.pledge-table th,
.pledge-table td {
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 8px;
  text-align: start;
  vertical-align: top;
}

.pledge-table th {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
  white-space: nowrap;
}

.pledge-table td:nth-child(4) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pledge-pipe-details {
  margin-top: 12px;
}

.pledge-pipe-details summary {
  cursor: pointer;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 13px;
}

.pledge-pipe-pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 11px;
  line-height: 1.35;
}

.capture-reject-banner {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.12);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.capture-reject-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.capture-reject-hint,
.capture-reject-action {
  margin: 0 0 6px;
}

.capture-reject-details {
  margin-top: 10px;
  font-size: 12px;
}

.pledge-layout-warning {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.1);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

.pledge-layout-warning strong {
  display: block;
  margin-bottom: 6px;
}

.pledge-layout-warning-body {
  margin: 0;
}

.pledge-table-empty {
  opacity: 0.95;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
}

.capture-build-badge {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(52, 211, 153, 0.55);
  background: rgba(16, 185, 129, 0.12);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(232, 238, 252, 0.95);
}

.capture-json-section {
  margin-bottom: 16px;
}

.capture-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.capture-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.capture-section-hint {
  margin: 0 0 10px;
  font-size: 12px;
}

button.capture-copy-json {
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 13px;
}

button.capture-download-report:not(:disabled) {
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 13px;
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
}

.capture-debug-overlay-section {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.capture-debug-overlay-img-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  border: 1px solid rgba(37, 99, 235, 0.45);
  background: rgba(15, 23, 42, 0.5);
}

.capture-debug-overlay-img {
  display: block;
  max-width: 100%;
  height: auto;
}

.capture-overlay-missing {
  margin: 0 0 12px;
}

.capture-debug-legend {
  margin: 0 0 10px;
  padding: 0 0 0 18px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(232, 238, 252, 0.85);
}

.capture-debug-legend li {
  margin: 4px 0;
  list-style: disc;
}

.capture-debug-swatch {
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-inline-end: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

.capture-debug-swatch--frame {
  border: 2px solid #2563eb;
  background: transparent;
}

.capture-debug-swatch--row {
  border: 2px solid #f97316;
  background: rgba(249, 115, 22, 0.2);
}

.capture-debug-swatch--corner {
  border: 2px dashed #d946ef;
  background: rgba(217, 70, 239, 0.15);
}

.capture-debug-swatch--grid {
  border-left: 2px dashed rgba(255, 255, 255, 0.7);
  background: transparent;
}

.capture-debug-swatch--content {
  border: 2px solid #06b6d4;
  background: rgba(6, 182, 212, 0.15);
}

.capture-debug-swatch--text {
  border: 1px solid rgba(250, 204, 21, 0.9);
  background: rgba(250, 204, 21, 0.2);
}

.capture-debug-swatch--ghost {
  border: 1px dashed rgba(148, 163, 184, 0.8);
  background: transparent;
}

.capture-geometry-badge {
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: rgba(232, 238, 252, 0.95);
}

.capture-overlay-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 12px;
  font-size: 13px;
}

.capture-overlay-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  opacity: 0.92;
}

.capture-alignment-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.capture-component-health-section {
  margin-top: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.38);
}

.capture-component-health-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.capture-component-health-badge.status-ok {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.5);
}

.capture-component-health-badge.status-warning {
  color: #fde68a;
  background: rgba(234, 179, 8, 0.2);
  border-color: rgba(234, 179, 8, 0.5);
}

.capture-component-health-badge.status-error {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.55);
}

.capture-component-health-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 6px 0 8px;
}

.capture-component-health-table th,
.capture-component-health-table td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.capture-component-health-table th {
  background: rgba(255, 255, 255, 0.06);
}

.capture-component-row.status-missing td:nth-child(2),
.capture-component-row.status-failed td:nth-child(2),
.capture-component-row.status-error td:nth-child(2) {
  color: #fca5a5;
}

.capture-component-row.status-ok td:nth-child(2) {
  color: #86efac;
}

.capture-component-row.status-degraded td:nth-child(2),
.capture-component-row.status-warning td:nth-child(2) {
  color: #fde68a;
}

.capture-component-issues {
  margin-top: 8px;
}

.capture-component-issues-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 650;
}

.capture-component-issues ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
}

.capture-component-issue {
  margin: 3px 0;
}

.capture-component-issue.status-error {
  color: #fecaca;
}

.capture-component-issue.status-warning {
  color: #fde68a;
}

.capture-alignment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}

.capture-alignment-table th,
.capture-alignment-table td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 8px;
  text-align: right;
}

.capture-alignment-table th {
  background: rgba(255, 255, 255, 0.06);
}

.capture-alignment-row--med td:first-child {
  border-inline-start: 3px solid #eab308;
}

.capture-alignment-row--high td:first-child {
  border-inline-start: 3px solid #ef4444;
}

.capture-warp-warn {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(217, 70, 239, 0.12);
  border: 1px solid rgba(217, 70, 239, 0.45);
  color: #f5d0fe;
  font-size: 13px;
  line-height: 1.45;
}

.capture-flatten-preview {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.capture-flatten-preview-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(217, 70, 239, 0.45);
  margin: 8px 0;
}

button.capture-download-debug-overlay:not(:disabled) {
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 13px;
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(37, 99, 235, 0.45);
}

button.capture-share-whatsapp:not(:disabled),
button.capture-share-debug-whatsapp:not(:disabled) {
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 13px;
  background: rgba(37, 211, 102, 0.15);
  border-color: rgba(37, 211, 102, 0.5);
  color: #bbf7d0;
}

button.capture-share-debug-whatsapp:not(:disabled) {
  font-weight: 600;
  background: rgba(37, 211, 102, 0.28);
  border-color: #22c55e;
}

.camera-trust-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.55);
  background: rgba(127, 29, 29, 0.35);
  font-size: 14px;
  line-height: 1.45;
}

.camera-trust-banner strong {
  display: block;
  margin-bottom: 6px;
}

.camera-trust-banner-text {
  margin: 0 0 8px;
  opacity: 0.95;
}

.camera-trust-steps {
  margin: 0;
  padding-left: 20px;
}

.camera-trust-steps a {
  color: var(--color-gold-light);
}

.camera-upload-card {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.55);
}

.camera-upload-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.camera-upload-hint {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.45;
}

.camera-upload-coach {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(201, 162, 55, 0.3);
  background: rgba(201, 162, 55, 0.08);
}

.camera-upload-coach[data-coach-state="selected"] {
  border-color: rgba(134, 239, 172, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.camera-upload-coach[data-coach-state="busy"] {
  border-color: rgba(201, 162, 55, 0.5);
  background: rgba(201, 162, 55, 0.12);
}

.camera-upload-coach-text {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.camera-upload-crop-compare {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.camera-upload-crop-example {
  margin: 0;
  flex: 1;
  max-width: 148px;
  text-align: center;
}

.camera-upload-crop-example figcaption {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
}

.camera-upload-crop-example--bad figcaption {
  color: #fca5a5;
}

.camera-upload-crop-example--good figcaption {
  color: #86efac;
}

.camera-upload-crop-frame {
  display: flex;
  align-items: stretch;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #475569;
}

.camera-upload-crop-margin {
  flex: 1 1 22%;
  min-width: 10px;
  background: #64748b;
}

.camera-upload-crop-board {
  flex: 2.4 1 56%;
  background: linear-gradient(180deg, #e8c547 0%, #c9a237 100%);
}

.camera-upload-crop-frame--fill .camera-upload-crop-board {
  flex: 1 1 100%;
}

.camera-upload-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.camera-upload-input {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 100%;
  font-size: 13px;
}

.camera-upload-filename {
  margin: 8px 0 0;
  font-size: 12px;
  word-break: break-all;
}

.camera-upload-preview {
  display: block;
  margin-top: 10px;
  max-width: 100%;
  max-height: min(42vh, 280px);
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  object-fit: contain;
  background: #0f172a;
}

.camera-upload-list {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 12px;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
}

.upload-batch-summary-list {
  margin: 0 0 14px;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.45;
}

.upload-batch-summary-list--error {
  color: #fecaca;
}

.upload-batch-progress {
  margin: 0 0 12px;
}

.capture-segment-section {
  margin-bottom: 18px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.capture-json-pre--primary {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: rgba(15, 23, 42, 0.85);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(42vh, 360px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 11px;
  line-height: 1.4;
}

.pledge-layout-section {
  margin-top: 16px;
}

.pledge-layout-pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  background: rgba(15, 23, 42, 0.85);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(38vh, 320px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 11px;
  line-height: 1.4;
}

.capture-json-details {
  margin-top: 14px;
}

.capture-json-details summary {
  cursor: pointer;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 13px;
}

.capture-json-pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(70vh, 520px);
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 11px;
  line-height: 1.35;
}

.error {
  color: #fecaca;
}

@media (max-width: 520px) {
  button {
    min-height: 44px;
    padding: 12px 16px;
  }

  input[type="text"],
  input[type="password"],
  input[type="file"] {
    min-height: 44px;
  }
}

/* --- Dedicated /camera page: wide viewfinder + frame size (keeps board aspect ratio) --- */

body.camera-page {
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  box-sizing: border-box;
}

.camera-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--color-card-border);
  background: linear-gradient(180deg, rgba(26, 12, 18, 0.96) 0%, rgba(20, 10, 14, 0.92) 100%);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.camera-back {
  color: var(--color-gold-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.camera-back:hover {
  text-decoration: underline;
  color: var(--color-gold);
}

.camera-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-gold-light);
}

.camera-topbar-spacer {
  width: 72px;
  flex-shrink: 0;
}

.camera-orient-hint {
  display: none;
}

.camera-dev-panel {
  flex-shrink: 0;
  margin: 0 0 6px;
  padding: 0;
  border: 1px solid rgba(42, 74, 110, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 12px;
}

.camera-dev-panel summary {
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-gold-light);
  user-select: none;
}

.camera-dev-body {
  margin: 0;
  padding: 8px 10px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--color-text);
  border-top: 1px solid rgba(42, 74, 110, 0.25);
  max-height: 28vh;
  overflow-y: auto;
}

.camera-main-hint {
  flex-shrink: 0;
}

/* Portrait: flex column; landscape: grid on live tab (see @media below). */
.camera-main {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-right));
  box-sizing: border-box;
}

body.camera-page.has-app-shell .camera-main .tabs {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.camera-page .tab-panel[data-tab-panel="live"]:not([hidden]) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.camera-live-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.camera-rail-tabs {
  display: none;
}

.camera-viewfinder-wrap {
  flex: 1;
  min-height: 200px;
  min-width: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding-top: 8px;
}

.camera-diag {
  margin: 0 0 6px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  word-break: break-word;
}

.camera-page .camera-viewfinder {
  width: 100%;
  max-width: 100%;
  flex: 1;
  min-height: min(42dvh, 420px);
  min-width: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.camera-page .camera-viewfinder video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: min(72dvh, 960px);
  object-fit: cover;
  background: #000;
}

.camera-page .guide-cutout {
  /* Pixel width/height from syncGuideFrameScale() (% of viewfinder). Avoid dvh — it shrinks on rotate/lock. */
  aspect-ratio: 2008 / 1395;
  box-sizing: border-box;
  width: 88%;
  max-width: 100%;
  max-height: 92%;
}

.camera-toolbar-card {
  margin-top: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.camera-actions button {
  touch-action: manipulation;
  min-height: 48px;
}

.camera-gallery-shortcut-short {
  display: none;
}

.camera-native-photo-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.camera-native-hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
}

.camera-take-photo-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 48px;
  background: linear-gradient(180deg, #4a7aab 0%, var(--color-azure) 100%);
  color: var(--color-text);
  border: 1px solid rgba(58, 106, 154, 0.55);
  user-select: none;
}

@media (orientation: landscape) {
  body.camera-page {
    min-height: 100dvh;
  }

  body.camera-page.has-app-shell .app-status-bar {
    display: none;
  }

  body.camera-page .camera-results {
    max-height: min(55dvh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Landscape side-rail scanner (class toggled by app.js) */
body.camera-page.is-landscape-scanner .camera-main {
  max-width: none;
  padding: 0;
  flex: 1;
  min-height: 0;
}

body.camera-page.is-landscape-scanner .tabs {
  flex: 1;
  min-height: 0;
  gap: 0;
}

body.camera-page.is-landscape-scanner .tabs-list {
  display: none;
}

body.camera-page.is-landscape-scanner .tabs[data-active-tab="upload"] .tabs-list,
body.camera-page.is-landscape-scanner .tabs[data-active-tab="results"] .tabs-list {
  display: flex;
  padding: 4px;
  flex-shrink: 0;
}

body.camera-page.is-landscape-scanner .tab-panel[data-tab-panel="live"]:not([hidden]) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.camera-page.is-landscape-scanner .camera-live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 112px);
  grid-template-rows: 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
  height: 100%;
}

body.camera-page.is-landscape-scanner .camera-viewfinder-wrap {
  grid-column: 1;
  grid-row: 1;
  padding: 0;
  margin: 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

body.camera-page.is-landscape-scanner .camera-viewfinder {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  border-radius: 0;
}

body.camera-page.is-landscape-scanner .camera-viewfinder video,
body.camera-page.is-landscape-scanner .camera-viewfinder .frozen-crop-preview {
  object-fit: cover;
  max-height: none;
  height: 100%;
  width: 100%;
}

body.camera-page.is-landscape-scanner .camera-rail.camera-toolbar-card {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  padding: 6px;
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--color-card-border);
  box-shadow: none;
  background: var(--color-chrome-bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 112px;
  max-width: 112px;
}

body.camera-page.is-landscape-scanner .camera-rail-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

body.camera-page.is-landscape-scanner .camera-rail-tab {
  padding: 5px 6px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  text-align: center;
}

body.camera-page.is-landscape-scanner .camera-rail-tab.is-active {
  background: var(--color-gold-soft);
  color: var(--color-gold-light);
  border-color: rgba(201, 162, 55, 0.35);
}

body.camera-page.is-landscape-scanner .camera-rail-tab[data-rail-tab="upload"] {
  min-height: 34px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-gold-light);
  border-color: rgba(201, 162, 55, 0.42);
}

body.camera-page.is-landscape-scanner .camera-gallery-shortcut-full {
  display: none;
}

body.camera-page.is-landscape-scanner .camera-gallery-shortcut-short {
  display: inline;
}

body.camera-page.is-landscape-scanner .camera-trust-banner {
  font-size: 10px;
  line-height: 1.35;
  padding: 4px;
  margin: 0;
}

body.camera-page.is-landscape-scanner .camera-trust-banner strong {
  font-size: 10px;
}

body.camera-page.is-landscape-scanner .camera-frame-row {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

body.camera-page.is-landscape-scanner .camera-frame-label {
  margin: 0;
  font-size: 10px;
}

body.camera-page.is-landscape-scanner .camera-frame-slider {
  width: 100%;
  min-width: 0;
}

body.camera-page.is-landscape-scanner .camera-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  margin: 0;
}

body.camera-page.is-landscape-scanner .camera-actions button,
body.camera-page.is-landscape-scanner .camera-take-photo-label {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  font-size: 11px;
  flex: none;
}

body.camera-page.is-landscape-scanner .camera-status {
  font-size: 10px;
  line-height: 1.35;
  max-height: 3.6em;
  overflow: hidden;
  flex-shrink: 0;
}

body.camera-page.is-landscape-scanner .camera-dev-panel {
  margin: 0;
  flex-shrink: 0;
  font-size: 10px;
}

body.camera-page.is-landscape-scanner .camera-dev-panel summary {
  padding: 4px 6px;
  font-size: 10px;
}

body.camera-page.is-landscape-scanner .camera-dev-body {
  max-height: 10vh;
  padding: 4px 6px;
  font-size: 9px;
}

body.camera-page.is-landscape-scanner #app-shell {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

body.camera-page.is-landscape-scanner #app-shell .app-shell-header--minimal,
body.camera-page.is-landscape-scanner #app-shell .app-drawer {
  pointer-events: auto;
}

body.camera-page.is-landscape-scanner .app-shell-header--minimal {
  position: absolute;
  inset: 0 auto auto 0;
  right: 112px;
  z-index: 31;
  min-height: 0;
  padding: max(4px, env(safe-area-inset-top)) 6px 4px max(6px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
  border: none;
  box-shadow: none;
  pointer-events: none;
}

body.camera-page.is-landscape-scanner .app-shell-header--minimal a,
body.camera-page.is-landscape-scanner .app-shell-header--minimal button {
  pointer-events: auto;
}

body.camera-page.is-landscape-scanner .camera-title {
  display: none;
}

body.camera-page.is-landscape-scanner.has-app-shell {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

body.camera-page.is-landscape-scanner.has-app-shell .camera-main {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* Browser Fullscreen API — hide in-app shell overlay while active */
body.camera-page.is-browser-fullscreen .app-shell-header--minimal {
  opacity: 0;
  pointer-events: none;
}

body.camera-page.is-browser-fullscreen.is-landscape-scanner.has-app-shell .camera-main {
  height: 100dvh;
}

body.camera-page.is-landscape-scanner .camera-fullscreen-btn {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  font-size: 11px;
}

.camera-fullscreen-btn {
  touch-action: manipulation;
}


.camera-frame-row {
  margin-bottom: 12px;
}

.camera-frame-label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.camera-frame-slider {
  width: 100%;
  accent-color: var(--color-gold);
}

.camera-actions {
  justify-content: flex-end;
}

.camera-status {
  margin-top: 10px;
}

.camera-results {
  margin-top: 18px;
  flex-shrink: 0;
}

.camera-results-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 650;
}

.app-landing-card .camera-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #d4a82a 0%, var(--color-accent) 55%, #9a7010 100%);
  color: #1a1008;
  font-weight: 700;
  font-family: var(--font-body);
  text-decoration: none;
  border: 1px solid rgba(201, 162, 55, 0.5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: filter 0.2s, transform 0.15s;
}

.app-landing-card .camera-open-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.app-landing-card .camera-open-btn--secondary {
  background: var(--color-surface);
  color: var(--color-gold-light);
  border-color: var(--color-card-border);
  box-shadow: none;
}

.app-landing-card .camera-open-btn--azure {
  background: linear-gradient(180deg, #3d6a9a 0%, var(--color-azure) 100%);
  color: var(--color-text);
  border-color: rgba(58, 106, 154, 0.55);
}

.app-landing-card .camera-open-btn--amber {
  background: linear-gradient(180deg, #e0b04a 0%, var(--color-warning) 100%);
  color: #1a1008;
  border-color: rgba(201, 137, 46, 0.5);
}

/* --- Manual pledge editor (/pledges/edit) --- */

.container.pledges-edit-page {
  max-width: 1100px;
}

.pledges-edit-header {
  margin-bottom: 20px;
}

.pledges-edit-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.pledges-edit-card {
  margin-bottom: 18px;
}

.pledges-edit-h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 650;
}

.pledges-edit-load-row {
  align-items: center;
  margin-bottom: 12px;
}

.pledges-edit-label {
  margin-top: 4px;
}

.pledges-edit-paste-hint {
  margin: 0 0 8px;
  font-size: 12px;
}

.pledges-edit-textarea {
  width: 100%;
  min-height: 100px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #e8eefc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  resize: vertical;
}

.pledges-edit-parasha-input {
  width: 100%;
  max-width: 420px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #e8eefc;
}

.pledges-edit-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.pledges-edit-summary {
  margin: 10px 0 12px;
  font-size: 13px;
}

.pledges-edit-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pledges-edit-mobile-only {
  display: none;
}

.pledges-edit-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

.pledges-edit-table th,
.pledges-edit-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: start;
  vertical-align: middle;
}

.pledges-edit-table th {
  background: rgba(0, 0, 0, 0.25);
  font-weight: 600;
  white-space: nowrap;
}

.pledges-edit-table .col-num {
  width: 4%;
  color: rgba(232, 238, 252, 0.65);
}

.pledges-edit-table .col-date {
  width: 14%;
}

.pledges-edit-table .col-name {
  width: 28%;
}

.pledges-edit-table .col-aliya {
  width: 28%;
}

.pledges-edit-table .col-amount {
  width: 12%;
}

.pledges-edit-table .col-actions {
  width: 10%;
  min-width: 100px;
  white-space: nowrap;
}

.pledges-edit-table .pledges-edit-field {
  min-width: 0;
}

.pledges-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pledges-edit-field label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(232, 238, 252, 0.7);
}

.pledges-edit-field--issue {
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.14);
  box-shadow: inset 3px 0 0 0 rgba(245, 158, 11, 0.75);
}

.pledges-edit-field--issue .pledges-edit-input {
  border-color: rgba(245, 158, 11, 0.65);
}

.pledges-edit-input {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.4);
  color: #e8eefc;
  font-size: 13px;
  box-sizing: border-box;
}

.pledges-edit-input:focus {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  border-color: rgba(59, 130, 246, 0.5);
}

.pledges-edit-table .pledges-edit-input--amount {
  max-width: none;
}

.pledges-edit-row-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.pledges-edit-table tr.pledge-row-needs-review,
.pledges-edit-row-card.pledge-row-needs-review {
  box-shadow: inset 3px 0 0 0 rgba(245, 158, 11, 0.65);
}

.pledges-edit-card-list {
  display: none;
  padding-bottom: calc(var(--status-height) + 72px);
}

.pledges-edit-row-card {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
}

.pledges-edit-row-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pledges-edit-row-card-num {
  font-size: 14px;
  font-weight: 650;
  color: rgba(232, 238, 252, 0.75);
}

.pledges-edit-row-card-body .pledges-edit-field {
  margin-bottom: 12px;
}

.pledges-edit-row-card-body .pledges-edit-field:last-child {
  margin-bottom: 0;
}

.pledges-edit-row-card-body .pledges-edit-input {
  font-size: 16px;
}

.pledges-edit-row-card .pledges-edit-field--issue {
  margin: 0 0 12px;
  padding: 10px 10px 10px 12px;
}

.pledges-edit-card-list-empty {
  margin: 8px 0 16px;
  text-align: center;
}

.pledges-edit-row-btn-short {
  display: none;
}

.camera-topbar-edit {
  font-size: 13px;
  flex-shrink: 0;
}

.capture-editor-hint a {
  color: var(--color-gold-light);
  font-weight: 600;
}

.capture-editor-hint a:hover {
  color: var(--color-gold);
}

.pledge-table th,
.pledge-table-title,
.capture-section-title,
.camera-results-title,
.camera-upload-title {
  font-family: var(--font-display);
  color: var(--color-gold-light);
}

.pledge-table td,
.pledge-table th {
  border-color: var(--color-card-border);
}

.pledge-table th {
  background: var(--color-gold-soft);
}

code {
  font-size: 0.92em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(201, 162, 55, 0.12);
  border: 1px solid rgba(201, 162, 55, 0.2);
  color: var(--color-gold-light);
}

/* --- Printed text lab (/tools/printed-board-test) --- */

.container.printed-test-page {
  max-width: 1100px;
}

.printed-test-header {
  justify-content: space-between;
  margin: 22px 0;
}

.printed-test-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
  background: var(--color-surface);
  color: var(--color-gold-light);
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
}

.printed-test-back:hover {
  filter: brightness(1.1);
  color: var(--color-gold);
}

.printed-test-card {
  margin-bottom: 18px;
}

.printed-test-card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.printed-test-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.printed-test-help {
  margin: 8px 0 0;
}

.printed-test-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.printed-test-check input {
  margin-top: 3px;
  accent-color: #f59e0b;
}

.printed-test-check span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 650;
}

.printed-test-check small {
  font-weight: 400;
  opacity: 0.78;
  line-height: 1.35;
}

.printed-test-controls {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.printed-test-controls label {
  margin-top: 10px;
}

.printed-test-controls input[type="range"] {
  width: 100%;
  accent-color: #f59e0b;
}

.printed-test-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.printed-test-status {
  margin: 12px 0 0;
}

.printed-test-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.printed-test-preview {
  display: block;
  width: 100%;
  max-height: 520px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #fff;
  object-fit: contain;
}

.printed-test-results {
  min-height: 100px;
}

.printed-test-results h3 {
  margin-top: 0;
}

.printed-segment-layout .printed-segment-cell {
  width: 120px;
  vertical-align: middle;
}

.printed-segment-thumb {
  display: block;
  max-width: 110px;
  max-height: 72px;
  width: auto;
  height: auto;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #fff;
}

.printed-segment-cell--empty {
  opacity: 0.55;
  font-size: 12px;
}

.printed-segment-text {
  min-width: 180px;
  font-size: 14px;
  line-height: 1.45;
}

.printed-segment-label {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.printed-segment-review {
  font-size: 11px;
  max-width: 200px;
  line-height: 1.35;
}

.printed-batch-section {
  margin-top: 18px;
}

.printed-batch-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 650;
}

button#downloadBtn:not(:disabled) {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
  color: #dcfce7;
}

@media (max-width: 720px) {
  .printed-test-actions {
    align-items: stretch;
  }

  .printed-test-actions button {
    width: 100%;
  }

  .printed-test-preview-head {
    flex-direction: column;
    gap: 4px;
  }
}

/* --- App shell (UI reform v50) --- */

body.has-app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

body.has-app-shell > #app-shell {
  flex-shrink: 0;
}

body.has-app-shell > .app-main,
body.has-app-shell > .container.app-main {
  flex: 1;
  width: 100%;
}

.app-shell-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  min-height: var(--shell-height);
  border-bottom: 1px solid var(--color-card-border);
  background: var(--color-chrome-bg);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-shell-header--login {
  justify-content: center;
  border-bottom: none;
  background: transparent;
  position: relative;
}

.app-shell-actions--login {
  position: absolute;
  inset-inline-end: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
}

.app-shell-logo--login {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.55rem;
}

.app-shell-login-nav {
  position: absolute;
  inset-inline-start: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: var(--space-md);
  font-family: var(--font-hebrew);
  font-size: var(--text-sm);
  font-weight: 700;
}

.app-shell-login-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.app-shell-login-nav a:hover {
  color: var(--color-gold-light);
  text-decoration: underline;
}

.app-shell-header--minimal {
  padding-left: max(var(--space-md), env(safe-area-inset-left));
  padding-right: max(var(--space-md), env(safe-area-inset-right));
}

.app-shell-brand {
  flex-shrink: 0;
}

.app-shell-brand--center {
  text-align: center;
}

.app-shell-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: inherit;
}

.app-shell-mark {
  color: var(--color-gold);
  font-size: 1.1rem;
}

.app-shell-name {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-shell-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-gold-light);
}

.app-shell-hebrew {
  font-family: var(--font-hebrew);
  font-size: var(--text-sm);
  color: var(--color-gold);
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  flex: 1;
  align-items: center;
}

.app-nav-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.app-nav-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-right: 4px;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.app-nav-link:hover {
  color: var(--color-text);
  background: var(--color-nav-hover);
}

.app-nav-link.is-active {
  color: var(--color-gold-light);
  background: var(--color-gold-soft);
}

.app-shell-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
  background: var(--color-surface);
  color: var(--color-gold-light);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle:hover {
  background: var(--color-gold-soft);
  border-color: var(--color-gold);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-gold-light);
  outline-offset: 2px;
}

.home-topnav .theme-toggle {
  font-family: var(--font-hebrew);
}

.privacy-theme-bar {
  display: flex;
  justify-content: flex-end;
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-sm) var(--space-md) 0;
}

.app-logout-form {
  margin: 0;
}

.app-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px var(--space-lg);
  min-height: var(--status-height);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-card-border);
  background: rgba(12, 12, 14, 0.95);
  flex-shrink: 0;
}

.app-status-bar--compact {
  padding-left: max(var(--space-md), env(safe-area-inset-left));
  padding-right: max(var(--space-md), env(safe-area-inset-right));
}

.app-status-item.status-ok {
  color: var(--color-success);
}

.app-status-item.status-warning {
  color: var(--color-warning);
}

.app-status-item.status-danger {
  color: var(--color-danger);
}

.app-status-sep {
  opacity: 0.35;
}

.app-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-text-muted);
  display: inline-block;
}

.app-status-dot.is-ok {
  background: var(--color-success);
}

.app-status-dot.is-bad {
  background: var(--color-danger);
}

.app-shell-minimal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

.app-shell-header--minimal .theme-toggle {
  min-height: 32px;
  padding: 4px 10px;
  font-size: var(--text-xs);
}

.app-menu-btn {
  padding: 6px 12px;
  font-size: var(--text-sm);
}

.app-drawer {
  position: fixed;
  top: var(--shell-height);
  right: 0;
  z-index: 99;
  width: min(280px, 92vw);
  padding: var(--space-md);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  box-shadow: var(--shadow-card);
}

.app-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-drawer-nav .app-nav-link {
  width: 100%;
}

.app-drawer-nav .app-logout-form button {
  width: 100%;
}

.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-lg);
  width: 100%;
}

.app-page-header {
  margin-bottom: var(--space-lg);
}

.app-page-header h1 {
  margin: 0 0 var(--space-xs);
}

.app-page-header p {
  margin: 0;
  max-width: 640px;
  line-height: 1.55;
}

/* Dashboard */

.dashboard-quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.dashboard-quick-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-card-border);
  background: var(--color-card);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.dashboard-quick-card:hover {
  border-color: rgba(201, 162, 55, 0.45);
  background: rgba(201, 162, 55, 0.06);
}

.dashboard-quick-card strong {
  font-size: var(--text-md);
  color: var(--color-gold-light);
}

.dashboard-quick-card span {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.dashboard-section {
  margin-bottom: var(--space-lg);
}

.dashboard-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.dashboard-scan-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  background: var(--color-wine);
  color: #fff8ee;
  font-weight: 600;
  font-size: var(--text-md);
  text-decoration: none;
  border: 1px solid transparent;
}

.dashboard-scan-cta:hover {
  background: var(--color-wine-deep);
  color: #fff8ee;
}

.dashboard-hero-secondary {
  color: var(--color-gold-light);
  font-weight: 600;
  text-decoration: none;
  padding: 8px 4px;
}

.dashboard-hero-secondary:hover {
  text-decoration: underline;
}

.camera-fallback {
  margin-top: var(--space-sm);
  padding: var(--space-sm) 0 0;
  border-top: 1px solid var(--color-card-border);
}

.camera-fallback summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-muted);
}

.camera-fallback-hint {
  margin: var(--space-xs) 0 var(--space-sm);
}

.camera-fallback-actions {
  gap: var(--space-sm);
}

.pledges-edit-success {
  text-align: center;
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  border-color: rgba(42, 138, 82, 0.35);
}

.pledges-edit-success-check {
  font-size: 2rem;
  margin: 0 0 var(--space-sm);
  color: var(--color-success);
}

.pledges-edit-success-title {
  margin: 0 0 var(--space-sm);
}

.pledges-edit-advanced,
.pledges-edit-export-more {
  margin-top: var(--space-md);
}

.pledges-edit-export-more summary,
.pledges-edit-advanced summary {
  cursor: pointer;
  font-weight: 600;
}

html[lang="he"] body.has-app-shell,
html[lang="he"] .login-page {
  font-family: var(--font-body);
}

html[lang="he"] .site-title,
html[lang="he"] .app-shell-hebrew {
  font-family: var(--font-hebrew);
}

.dashboard-section h2 {
  font-size: var(--text-md);
  margin: 0 0 var(--space-sm);
  color: var(--color-gold-light);
}

.org-orders-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-md);
}

.org-order-card {
  padding: var(--space-md);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: var(--color-card-bg, transparent);
}

.org-order-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.org-order-head strong {
  word-break: break-all;
  font-size: var(--text-sm);
}

.org-order-meta {
  margin: 0 0 var(--space-sm);
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text-muted);
}

.org-order-pdf {
  display: inline-flex;
}

.order-notice-dialog {
  max-width: 32rem;
  width: calc(100% - 2rem);
  padding: 0;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  background: var(--color-page-bg, #fff8ee);
  color: inherit;
}

.order-notice-dialog::backdrop {
  background: rgba(20, 8, 16, 0.45);
}

.order-notice-inner {
  padding: var(--space-lg);
}

.order-notice-inner h2 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-lg);
}

.order-notice-inner p {
  margin: 0 0 var(--space-md);
  line-height: 1.6;
}

.order-notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.dashboard-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
}

.tool-card {
  padding: var(--space-md);
}

.tool-card h3 {
  margin: 0 0 var(--space-xs);
  font-size: var(--text-md);
  color: var(--color-gold-light);
}

.tool-card p {
  margin: 0 0 var(--space-md);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.recent-session-block + .recent-session-block {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-card-border);
}

.recent-session-heading {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted, var(--color-text));
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.recent-session-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.recent-upload-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  max-height: 220px;
  overflow-y: auto;
}

.recent-upload-thumb-cell {
  flex: 0 0 auto;
  width: 88px;
  text-align: center;
}

.recent-upload-thumb {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--color-card-border);
  background: rgba(0, 0, 0, 0.2);
}

.recent-upload-thumb--placeholder {
  background: rgba(255, 255, 255, 0.06);
}

.recent-upload-thumb-label {
  display: block;
  margin-top: 4px;
  font-size: var(--text-xs);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-upload-ocr-badge {
  display: block;
  margin-top: 2px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-success);
}

.recent-session-ocr-read {
  margin-top: var(--space-md);
}

.recent-session-ocr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.recent-session-ocr-table th,
.recent-session-ocr-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--color-card-border);
  vertical-align: top;
}

.recent-session-ocr-table th {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted, var(--color-text));
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.recent-session-ocr-more,
.recent-session-ocr-empty {
  margin: var(--space-sm) 0 0;
  font-size: var(--text-sm);
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-card-border);
  color: var(--color-text);
}

.stat-chip--warning {
  border-color: rgba(245, 166, 35, 0.45);
  color: var(--color-warning);
  background: rgba(245, 166, 35, 0.1);
}

.stat-chip--success {
  border-color: rgba(52, 201, 122, 0.45);
  color: var(--color-success);
}

.stat-chip--muted {
  color: var(--color-text-muted);
  font-weight: 500;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.empty-state {
  padding: var(--space-lg);
  text-align: center;
  border: 1px dashed var(--color-card-border);
  border-radius: var(--radius-md);
}

.empty-state-title {
  margin: 0 0 var(--space-xs);
  font-weight: 600;
}

/* Tabs */

.tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.tabs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--color-card-border);
}

.tabs-list [role="tab"] {
  flex: 1 1 auto;
  min-width: 100px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: var(--text-sm);
  box-shadow: none;
  cursor: pointer;
}

.tabs-list [role="tab"].is-active,
.tabs-list [role="tab"][aria-selected="true"] {
  background: var(--color-gold-soft);
  color: var(--color-gold-light);
  border: 1px solid rgba(201, 162, 55, 0.35);
}

.tab-panel {
  min-height: 0;
}

.tab-panel[hidden] {
  display: none !important;
}

/* Toasts */

.toast-container {
  position: fixed;
  bottom: calc(var(--status-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  max-width: min(420px, 92vw);
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-card-border);
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  border-color: rgba(52, 201, 122, 0.45);
  color: var(--color-success);
}

.toast--error {
  border-color: rgba(240, 80, 80, 0.45);
  color: var(--color-danger);
}

.toast--warning {
  border-color: rgba(245, 166, 35, 0.45);
  color: var(--color-warning);
}

/* Setup panel */

.setup-panel {
  border: none;
  padding: 0;
  max-width: min(560px, 94vw);
  width: 100%;
  background: transparent;
}

.setup-panel::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.setup-panel-inner {
  margin: 0;
  padding: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-card-border);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.setup-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-card-border);
}

.setup-panel-header h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.setup-panel-content {
  padding: var(--space-lg);
  max-height: 70vh;
  overflow-y: auto;
}

.setup-panel-section {
  margin-bottom: var(--space-lg);
}

.setup-panel-section h3 {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-md);
}

.setup-url-list {
  margin: 0 0 var(--space-sm);
  padding-left: 1.2rem;
  font-size: var(--text-sm);
}

.setup-url-list a {
  color: var(--color-azure);
  word-break: break-all;
}

.setup-kv {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
}

.setup-kv li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.setup-note {
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  line-height: 1.45;
}

/* Debug workbench collapse */

.debug-workbench {
  margin: var(--space-md) 0;
  border: 1px solid rgba(79, 142, 247, 0.35);
  border-radius: var(--radius-md);
  background: rgba(79, 142, 247, 0.06);
}

.debug-workbench > summary {
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-azure);
  list-style: none;
}

.debug-workbench > summary::-webkit-details-marker {
  display: none;
}

.debug-workbench-body {
  padding: 0 var(--space-md) var(--space-md);
}

.debug-workbench-badge {
  display: inline-block;
  margin-left: var(--space-xs);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--text-xs);
  background: rgba(245, 166, 35, 0.15);
  color: var(--color-warning);
}

/* Pledge editor reform */

.pledges-edit-export-bar {
  position: sticky;
  bottom: calc(var(--status-height) + var(--space-xs));
  z-index: 20;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-card-border);
  background: var(--color-chrome-bg);
  backdrop-filter: blur(8px);
}

.pledges-edit-export-actions {
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.pledges-edit-export-provider-section {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-card-border);
}

.pledges-edit-export-heading {
  margin: 0 0 var(--space-sm);
  font-size: 1rem;
  font-weight: 600;
}

.pledges-edit-export-providers {
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.pledges-edit-export-provider-label {
  font-size: 0.9rem;
  color: var(--color-muted, #9ca3af);
}

.pledges-edit-export-provider-select {
  min-width: 12rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
  background: var(--color-input-bg, #1a1a1c);
  color: inherit;
}

.pledges-edit-export-hint {
  margin: var(--space-xs) 0 0;
  font-size: 0.85rem;
}

.pledges-edit-sumit-creds {
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
  background: rgba(255, 255, 255, 0.02);
}

.pledges-edit-sumit-heading {
  margin: 0 0 var(--space-xs);
  font-size: 0.95rem;
  font-weight: 600;
}

.pledges-edit-sumit-status {
  margin: 0 0 var(--space-sm);
  font-size: 0.85rem;
}

.pledges-edit-sumit-fields {
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.pledges-edit-sumit-label {
  font-size: 0.85rem;
  color: var(--color-muted, #9ca3af);
}

.pledges-edit-sumit-input {
  min-width: 10rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
  background: var(--color-input-bg, #1a1a1c);
  color: inherit;
}

.pledges-edit-sumit-actions {
  margin-bottom: var(--space-xs);
}

.pledges-edit-sumit-hint {
  margin: 0;
  font-size: 0.8rem;
}

.pledges-edit-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-bg-elevated);
}

.pledges-edit-table--compact .pledges-edit-input {
  padding: 4px 6px;
  font-size: var(--text-sm);
}

.pledges-edit-table--compact td,
.pledges-edit-table--compact th {
  padding: 4px 6px;
}

.pledges-edit-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.pledges-edit-view-debug {
  font-size: var(--text-sm);
  color: var(--color-azure);
}

.pledges-edit-toolbar {
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: flex-start;
}

@media (max-width: 720px) {
  .pledges-edit-desktop-only {
    display: none !important;
  }

  .pledges-edit-mobile-only.pledges-edit-card-list {
    display: block;
  }

  .pledges-edit-filter--compact-desktop {
    display: none;
  }

  .pledges-edit-page .app-page-header p {
    font-size: var(--text-sm);
  }

  .pledges-edit-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pledges-edit-toolbar-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .pledges-edit-filter {
    white-space: normal;
  }

  .pledges-edit-row-card .pledges-edit-row-btn {
    flex-shrink: 0;
    min-height: 40px;
    padding: 8px 14px;
  }

  .pledges-edit-row-card .pledges-edit-row-btn-long {
    display: inline;
  }

  .pledges-edit-row-card .pledges-edit-row-btn-short {
    display: none;
  }

  .pledges-edit-export-bar {
    flex-wrap: wrap;
  }

  .pledges-edit-export-bar .row {
    gap: var(--space-sm);
  }
}

/* Tool benchmark page (migrated from inline styles) */

.tool-benchmark-page .tool-benchmark-content {
  direction: rtl;
}

.tool-benchmark-page .tool-benchmark-content header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-card-border);
}

.tool-benchmark-page .tool-benchmark-content header h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.tool-benchmark-page .section {
  margin-bottom: var(--space-lg);
}

.tool-benchmark-page textarea {
  direction: rtl;
  resize: vertical;
  font-size: 20px;
  line-height: 1.5;
  min-height: 70px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-input-border);
  background: var(--color-input-bg);
  color: var(--color-text);
  font-family: var(--font-hebrew);
}

.tool-benchmark-page .range-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.tool-benchmark-page .range-val {
  font-size: var(--text-sm);
  font-weight: 600;
  min-width: 42px;
  text-align: left;
}

.tool-benchmark-page .fonts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.tool-benchmark-page .fonts-header .actions {
  display: flex;
  gap: var(--space-xs);
}

.tool-benchmark-page .btn-small {
  font-size: var(--text-xs);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}

.tool-benchmark-page .font-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.tool-benchmark-page .font-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 9px 12px;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  cursor: pointer;
}

.tool-benchmark-page .font-item.checked {
  border-color: rgba(79, 142, 247, 0.55);
  background: rgba(79, 142, 247, 0.1);
}

.tool-benchmark-page .font-name {
  flex: 1;
  font-size: var(--text-sm);
  direction: rtl;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-benchmark-page .badge-top {
  background: rgba(52, 201, 122, 0.15);
  color: var(--color-success);
}

.tool-benchmark-page .badge-system {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-muted);
}

.tool-benchmark-page .run-btn {
  width: 100%;
  padding: 13px;
  font-size: var(--text-md);
  font-weight: 600;
  background: var(--color-azure);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.tool-benchmark-page .progress-bar-wrap {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  height: 5px;
  margin-top: var(--space-md);
  overflow: hidden;
  display: none;
}

.tool-benchmark-page .progress-bar {
  height: 100%;
  background: var(--color-azure);
  width: 0%;
  transition: width 0.3s;
}

.tool-benchmark-page .preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.tool-benchmark-page .preview-card {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: min(100%, 420px);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.tool-benchmark-page .preview-card-h {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 8px 10px;
  background: var(--color-bg-elevated);
  direction: rtl;
}

.tool-benchmark-page .preview-card canvas {
  display: block;
  width: 100%;
  height: auto;
}

.tool-benchmark-page .results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.tool-benchmark-page .results-table th,
.tool-benchmark-page .results-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-card-border);
  text-align: right;
}

.tool-benchmark-page .score-green {
  color: var(--color-success);
}

.tool-benchmark-page .score-yellow {
  color: var(--color-warning);
}

.tool-benchmark-page .score-red {
  color: var(--color-danger);
}

.tool-benchmark-page .bar-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.tool-benchmark-page .bar-fill.fill-green {
  background: var(--color-success);
}

.tool-benchmark-page .bar-fill.fill-yellow {
  background: var(--color-warning);
}

.tool-benchmark-page .bar-fill.fill-red {
  background: var(--color-danger);
}

.tool-benchmark-page #offscreen {
  display: none;
}

.tool-benchmark-page .hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 5px;
}

.tool-benchmark-page .status-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
  display: none;
}

.tool-benchmark-page .results {
  margin-top: var(--space-xl);
}

.tool-benchmark-page .results-header {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
  padding: var(--space-md);
  background: var(--color-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
}

.tool-benchmark-page .original-text {
  font-family: var(--font-hebrew);
  font-size: 17px;
  direction: rtl;
  margin-top: 4px;
}

.tool-benchmark-page .meta-words {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
  direction: rtl;
}

.tool-benchmark-page .result-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: var(--color-card);
  margin-bottom: 6px;
}

.tool-benchmark-page .result-row.best {
  border-color: var(--color-success);
  background: rgba(52, 201, 122, 0.08);
}

.tool-benchmark-page .result-rank {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  min-width: 24px;
  text-align: center;
}

.tool-benchmark-page .result-info {
  flex: 1;
  min-width: 0;
}

.tool-benchmark-page .result-font-name {
  font-size: var(--text-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.tool-benchmark-page .result-detected {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  direction: rtl;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-benchmark-page .word-metrics {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  direction: rtl;
  margin-top: 6px;
  line-height: 1.55;
}

.tool-benchmark-page .bar-wrap {
  width: 120px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.tool-benchmark-page .bar-label {
  font-size: 9px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.tool-benchmark-page .score-num {
  font-size: var(--text-lg);
  font-weight: 700;
}

.tool-benchmark-page .badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.tool-benchmark-page .badge-exact {
  background: rgba(79, 142, 247, 0.15);
  color: var(--color-azure);
}

.tool-benchmark-page .badge-words-perfect {
  background: rgba(52, 201, 122, 0.15);
  color: var(--color-success);
}

.tool-benchmark-page .preview-empty {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-md);
  border: 1px dashed var(--color-card-border);
  border-radius: var(--radius-sm);
  direction: rtl;
}

.tool-benchmark-page .err-msg {
  font-size: var(--text-xs);
  color: var(--color-danger);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-azure);
  font-weight: 600;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  box-shadow: none;
}

.login-field {
  margin: 14px 0;
  text-align: start;
}

.login-page .login-field input {
  min-height: 44px;
}

.login-submit-row {
  justify-content: center;
  margin-top: 20px;
}

.login-card-lead {
  margin: 0 0 20px;
}

.login-setup-hint {
  margin-top: var(--space-md);
  text-align: center;
}

.login-auth0-section {
  margin-top: var(--space-md);
}

.login-auth0-btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.login-error {
  margin: 0 0 var(--space-md);
  color: #f0a8a8;
  text-align: center;
}

.auth-signed-in-card {
  text-align: center;
}

.auth-signed-in-check {
  width: 3rem;
  height: 3rem;
  margin: 0 auto var(--space-md);
  border-radius: 50%;
  background: var(--color-gold-soft);
  border: 2px solid var(--color-gold-light);
  color: var(--color-gold-light);
  font-size: 1.5rem;
  line-height: 2.8rem;
  font-weight: 700;
}

.auth-signed-in-continue {
  display: inline-block;
  text-decoration: none;
  box-sizing: border-box;
}

.auth-signed-in-user {
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
}

.auth-sumit-setup-card {
  text-align: left;
  max-width: 28rem;
  margin-inline: auto;
}

.auth-sumit-setup-form {
  margin-top: var(--space-md);
}

.auth-sumit-setup-hint {
  margin: var(--space-md) 0 0;
  font-size: var(--text-sm);
  text-align: center;
}

.auth-sumit-field-help {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.8rem;
}

.auth-sumit-setup-actions {
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.auth-sumit-diagnostic {
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(240, 168, 168, 0.45);
  background: rgba(240, 168, 168, 0.08);
  text-align: left;
  font-size: var(--text-sm);
}

.auth-sumit-diagnostic-title {
  margin: 0 0 var(--space-sm);
  font-weight: 600;
  color: #f0a8a8;
}

.auth-sumit-diagnostic-row {
  margin: 0 0 var(--space-xs);
}

.auth-sumit-diagnostic-label {
  color: var(--color-muted, #9ca3af);
  margin-inline-end: var(--space-xs);
}

.auth-sumit-diagnostic-tips {
  margin: var(--space-sm) 0 0;
  padding-inline-start: 1.25rem;
  color: var(--color-muted, #9ca3af);
}

.auth-sumit-diagnostic--ok {
  border-color: rgba(120, 200, 140, 0.45);
  background: rgba(120, 200, 140, 0.08);
}

.auth-sumit-diagnostic--ok .auth-sumit-diagnostic-title {
  color: #9fd4a8;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: 0 0 var(--space-md);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-transform: lowercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-card-border);
}

button.btn-secondary,
.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-card-border);
  color: var(--color-gold-light);
}

button.btn-secondary:hover,
.btn-secondary:hover {
  background: var(--color-gold-soft);
  border-color: var(--color-gold);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.camera-page.has-app-shell .camera-main {
  flex: 1;
  min-height: 0;
  max-width: none;
  padding: var(--space-md);
}

body.camera-page.has-app-shell {
  padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 860px) {
  .app-shell-header:not(.app-shell-header--minimal) {
    flex-wrap: wrap;
  }

  .app-nav {
    order: 3;
    width: 100%;
  }

  .app-shell-actions {
    margin-inline-start: auto;
  }
}

@media (max-width: 520px) {
  .app-main {
    padding: var(--space-md);
  }

  .tabs-list [role="tab"] {
    min-width: 0;
    font-size: var(--text-xs);
    padding: 8px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  button:hover:not(:disabled),
  button:active:not(:disabled) {
    transform: none;
  }

  .toast {
    transition: none;
  }
}

/* --- Home (public landing, Hebrew RTL) --- */

.home-page {
  --home-max: 1080px;
  --home-topbar-height: 64px;
  font-family: var(--font-hebrew);
}

.home-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 12px var(--space-md);
  border-bottom: 1px solid var(--color-card-border);
  background: var(--color-chrome-bg);
  backdrop-filter: blur(10px);
}

.home-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.home-brand-mark {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-gold);
  filter: drop-shadow(0 0 10px rgba(201, 162, 55, 0.35));
}

.home-brand-title {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-gold-light);
  letter-spacing: 0.02em;
}

.home-brand-sub {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.home-topnav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.home-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-card-border);
  background: var(--color-surface);
  color: var(--color-gold-light);
  font-family: var(--font-hebrew);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
}

.home-topnav-panel {
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
  position: fixed;
  top: var(--home-topbar-height);
  left: 0;
  right: 0;
  z-index: 25;
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-card-border);
  background: var(--color-chrome-bg);
}

.home-topnav.is-open .home-topnav-panel {
  display: flex;
}

.home-topnav-panel .home-btn {
  width: 100%;
  justify-content: center;
}

.home-topnav-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 4px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-md);
  transition: color 0.2s;
}

.home-page .theme-toggle {
  min-height: 44px;
}

.home-hero-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-md);
  font-weight: 600;
}

.home-hero-secondary:hover {
  color: var(--color-gold-light);
  text-decoration: underline;
}

.home-topnav-link:hover {
  color: var(--color-gold-light);
}

.home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: var(--font-hebrew);
  font-size: var(--text-md);
  font-weight: 700;
  text-decoration: none;
  transition: filter 0.2s, background 0.2s, border-color 0.2s;
}

.home-btn--primary {
  border: 1px solid rgba(201, 162, 55, 0.45);
  background: linear-gradient(180deg, #d4a82a 0%, var(--color-accent) 55%, #9a7010 100%);
  color: #1a1008;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.home-btn--primary:hover {
  filter: brightness(1.08);
}

.home-btn--ghost {
  border: 1px solid var(--color-card-border);
  background: transparent;
  color: var(--color-gold-light);
}

.home-btn--ghost:hover {
  background: var(--color-gold-soft);
  border-color: var(--color-gold);
}

.home-topnav-cta {
  padding: 9px 16px;
  font-size: var(--text-sm);
}

.home-main {
  max-width: var(--home-max);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) 0;
}

.home-hero {
  display: grid;
  gap: var(--space-xl);
  align-items: center;
  padding: var(--space-lg) 0 var(--space-xl);
}

.home-eyebrow {
  margin: 0 0 10px;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-gold);
}

.home-hero-title {
  margin: 0 0 16px;
  font-family: var(--font-hebrew);
  font-size: clamp(2.4rem, 9vw, 3.8rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-gold-light);
}

.home-hero-lead {
  margin: 0 0 var(--space-lg);
  max-width: 46ch;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  line-height: 1.75;
  color: var(--color-text);
}

.home-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.home-hero-points {
  margin: var(--space-lg) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: var(--text-md);
  color: var(--color-text);
  font-weight: 500;
}

.home-hero-points li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-hero-points li::before {
  content: "✓";
  color: var(--color-gold);
  font-weight: 700;
}

.home-hero-art {
  justify-self: center;
  width: 100%;
  max-width: 420px;
}

.home-hero-art svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 18px 46px rgba(0, 0, 0, 0.45));
}

.home-section {
  padding: var(--space-xl) 0;
  scroll-margin-top: calc(var(--home-topbar-height) + var(--space-md));
  border-top: 1px solid var(--color-card-border);
}

.home-section-head {
  max-width: 60ch;
  margin: 0 auto var(--space-xl);
  text-align: center;
}

.home-section-title {
  margin: 0 0 12px;
  font-family: var(--font-hebrew);
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
  font-weight: 700;
  color: var(--color-gold-light);
}

.home-section-title::after {
  content: "";
  display: block;
  width: 72px;
  height: 2px;
  margin: 12px auto 0;
  background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
}

.home-section-lead {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.7;
  color: var(--color-text);
}

.home-cards {
  display: grid;
  gap: var(--space-md);
}

.home-card {
  position: relative;
  padding: var(--space-lg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  background: var(--color-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.home-card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
  opacity: 0.7;
}

.home-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-hebrew);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-gold-light);
}

.home-card p {
  margin: 0;
  line-height: 1.7;
  color: var(--color-text);
}

.home-steps {
  counter-reset: home-step;
  display: grid;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-step {
  counter-increment: home-step;
  position: relative;
  padding: var(--space-md) var(--space-lg);
  padding-inline-start: 68px;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.home-step::before {
  content: counter(home-step);
  position: absolute;
  inset-inline-start: var(--space-md);
  top: var(--space-md);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 55, 0.45);
  background: var(--color-gold-soft);
  color: var(--color-gold-light);
  font-family: var(--font-body);
  font-weight: 700;
}

.home-step-title {
  margin: 0 0 6px;
  font-family: var(--font-hebrew);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-gold-light);
}

.home-step p {
  margin: 0;
  line-height: 1.7;
  color: var(--color-text);
}

.home-kit {
  display: grid;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-kit-item {
  display: grid;
  gap: 6px;
  padding: var(--space-lg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  text-align: center;
}

.home-kit-mark {
  font-size: 1.2rem;
  line-height: 1;
  color: var(--color-gold);
}

.home-kit-item strong {
  font-size: 1.1rem;
  color: var(--color-gold-light);
}

.home-kit-item span:last-child {
  color: var(--color-text);
  line-height: 1.6;
}

.home-note {
  margin: var(--space-lg) 0 0;
  padding: 12px var(--space-md);
  border-inline-start: 3px solid var(--color-gold);
  border-radius: var(--radius-sm);
  background: var(--color-gold-soft);
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.7;
  color: var(--color-text);
}

.home-cta {
  margin: var(--space-xl) 0;
  padding: var(--space-xl) var(--space-lg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse 80% 100% at 50% 0%, rgba(201, 162, 55, 0.12), transparent 70%),
    var(--color-card);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.home-cta h2 {
  margin: 0 0 12px;
  font-family: var(--font-hebrew);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 700;
}

.home-cta p {
  margin: 0 auto var(--space-lg);
  max-width: 52ch;
  line-height: 1.75;
  color: var(--color-text-muted);
}

.home-cta-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
}

.home-cta .home-contact {
  margin: var(--space-lg) auto 0;
  font-size: var(--text-md);
}

.home-contact-value {
  color: var(--color-gold-light);
  text-decoration: none;
}

.home-contact-value:hover {
  text-decoration: underline;
}

.home-footer {
  padding: var(--space-lg) var(--space-md) var(--space-xl);
  border-top: 1px solid var(--color-card-border);
  text-align: center;
  color: var(--color-text-muted);
}

.home-footer-brand {
  margin: 0 0 8px;
  font-size: var(--text-md);
  color: var(--color-gold-light);
}

.home-footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: var(--text-sm);
}

.home-footer-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.home-footer-nav a:hover {
  color: var(--color-gold-light);
  text-decoration: underline;
}

@media (min-width: 640px) {
  .home-cards,
  .home-kit {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 859px) {
  .home-hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .home-hero-actions .home-btn {
    width: 100%;
  }

  .home-cta-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .home-cta-actions .home-btn {
    width: 100%;
  }
}

@media (min-width: 860px) {
  .home-topbar {
    padding: 12px var(--space-lg);
  }

  .home-menu-btn {
    display: none;
  }

  .home-topnav-panel,
  .home-topnav.is-open .home-topnav-panel {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-md);
    position: static;
    padding: 0;
    border: none;
    background: transparent;
  }

  .home-topnav-panel .home-btn {
    width: auto;
  }

  .home-topnav-link {
    display: inline-flex;
    min-height: 0;
    padding: 0;
  }

  .home-main {
    padding: var(--space-xl) var(--space-lg) 0;
  }

  .home-hero {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }

  .home-cards,
  .home-kit {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-steps .home-step:last-child {
    grid-column: 1 / -1;
  }
}

/* --- Order form --- */

.order-main {
  padding-bottom: var(--space-xl);
}

.order-form {
  display: grid;
  gap: var(--space-lg);
}

.order-card {
  padding: var(--space-lg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  background: var(--color-card);
}

.order-card h2 {
  margin: 0 0 var(--space-md);
  font-family: var(--font-hebrew);
  font-size: 1.25rem;
  color: var(--color-gold-light);
}

.order-grid {
  display: grid;
  gap: var(--space-md);
}

.order-grid label,
.order-gabbai-users,
.order-row-text,
.order-row-copies,
.order-paste {
  display: grid;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.order-grid input,
.order-grid textarea,
.order-gabbai-users input,
.order-row input,
.order-paste textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-sm);
  background: var(--color-input-bg);
  color: var(--color-text);
  font-family: var(--font-hebrew);
  font-size: var(--text-md);
}

.order-row-text {
  width: fit-content;
  max-width: 100%;
}

.order-row-text input {
  width: calc(var(--order-text-chars, 15) * 1.1em + 24px);
  max-width: 100%;
}

.order-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 var(--space-sm);
  min-height: 44px;
  color: var(--color-text);
  line-height: 1.6;
}

.order-check input {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  flex-shrink: 0;
  margin: 0;
}

.order-help {
  margin: 0 0 var(--space-md);
  color: var(--color-text);
  font-weight: 500;
  line-height: 1.7;
}

.order-catalog {
  margin-top: var(--space-md);
  padding: 0;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.order-catalog-head {
  display: block;
  cursor: pointer;
  list-style: none;
  padding: 12px var(--space-md);
}

.order-catalog-head::-webkit-details-marker {
  display: none;
}

.order-catalog-head h3 {
  margin: 0 0 4px;
  color: var(--color-gold-light);
}

.order-catalog-head p {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.55;
}

.order-catalog-body {
  padding: 0 var(--space-md) var(--space-md);
  border-top: 1px solid var(--color-card-border);
}

.order-rows--grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.order-row {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-card-border);
}

.order-row--typed,
.order-row--name {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.order-row-line {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.order-row--typed .order-row-text,
.order-row--typed .order-row-copies,
.order-row--name .order-row-copies {
  display: block;
  gap: 0;
  width: auto;
  flex: 0 0 auto;
}

.order-row--typed .order-row-text input,
.order-row--typed .order-row-copies input,
.order-row--name .order-row-copies input,
.order-row--name .order-row-name {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-sm);
  background: var(--color-input-bg);
  color: var(--color-text);
  font-family: var(--font-hebrew);
  font-size: var(--text-md);
}

.order-row--typed .order-row-text input {
  width: calc(var(--order-text-chars, 15) * 0.85em + 16px);
  max-width: 9.25rem;
}

.order-row--typed .order-row-copies,
.order-row--name .order-row-copies {
  width: 3.25rem;
}

.order-row--typed .order-row-copies input,
.order-row--name .order-row-copies input {
  width: 100%;
  text-align: center;
}

.order-row--name .order-row-name {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  max-width: 9.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.order-row--typed .order-char,
.order-row--name .order-char {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  white-space: nowrap;
}

.order-row--typed .order-remove,
.order-row--name .order-remove {
  flex: 0 0 auto;
  justify-self: unset;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.order-row--typed .order-row-warn,
.order-row--name .order-row-warn {
  flex: none;
  grid-column: unset;
}

.order-row-name {
  margin: 0;
  color: var(--color-text);
  font-size: var(--text-md);
  word-break: break-word;
}

.order-import-msg {
  margin: 0 0 var(--space-sm);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(196, 60, 60, 0.4);
  background: rgba(196, 60, 60, 0.1);
  color: #8a1f1f;
  font-size: var(--text-sm);
  font-weight: 600;
}

html[data-theme="dark"] .order-import-msg {
  border-color: rgba(240, 80, 80, 0.45);
  background: rgba(240, 80, 80, 0.12);
  color: #ffd0d0;
}

.order-char {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.order-row.is-over-chars .order-char,
.order-row.is-over-copies .order-row-warn,
.order-row-warn {
  color: var(--color-warning);
}

.order-row-warn {
  margin: 0;
  font-size: var(--text-sm);
}

.order-remove {
  justify-self: start;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-hebrew);
  cursor: pointer;
}

.order-catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.order-paste {
  margin-top: var(--space-sm);
}

.order-grid input[readonly] {
  opacity: 0.9;
  background: var(--color-surface);
}

.order-quote-table-wrap {
  overflow-x: auto;
}

.order-quote-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.order-quote-table th,
.order-quote-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-card-border);
  text-align: right;
  vertical-align: top;
}

.order-quote-table th {
  color: var(--color-gold-light);
  font-weight: 600;
  white-space: nowrap;
}

.order-quote-table td span {
  display: block;
  margin-top: 4px;
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.5;
  opacity: 0.92;
}

.order-quote-totals {
  display: grid;
  gap: 8px;
  margin: var(--space-md) 0 0;
}

.order-quote-totals > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-text);
}

.order-quote-totals dt,
.order-quote-totals dd {
  margin: 0;
}

.order-quote-grand {
  padding-top: 8px;
  border-top: 1px solid var(--color-card-border);
  color: var(--color-text);
  font-size: var(--text-md);
  font-weight: 700;
}

.order-quote-grand dt,
.order-quote-grand dd {
  color: var(--color-gold-light);
}

.order-stats-grid article {
  padding: var(--space-md);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

html[data-theme="dark"] .order-stats-grid article {
  background: rgba(12, 10, 14, 0.35);
}

.order-stats-grid h3 {
  margin: 0 0 8px;
  color: var(--color-gold-light);
  font-size: var(--text-md);
}

.order-stats-grid ul {
  margin: 0;
  padding: 0 1.2em 0 0;
  color: var(--color-text);
  line-height: 1.7;
}

.order-actions {
  display: flex;
  justify-content: center;
}

@media (max-width: 859px) {
  .order-page .order-form {
    padding-bottom: 96px;
  }

  .order-page .order-actions {
    position: sticky;
    bottom: 0;
    z-index: 15;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    background: var(--color-chrome-bg);
    border-top: 1px solid var(--color-card-border);
  }

  .order-page .order-actions .home-btn {
    width: 100%;
    min-height: 48px;
  }
}

.order-error,
.order-banner {
  margin: 0 0 var(--space-md);
  padding: 12px var(--space-md);
  border-radius: var(--radius-sm);
}

.order-catalog.is-empty {
  border-color: rgba(240, 80, 80, 0.55);
}

.order-catalog-empty {
  margin: 0 0 8px;
  color: #c23b3b;
  font-size: var(--text-sm);
}

html[data-theme="dark"] .order-catalog-empty {
  color: #ffd0d0;
}

.order-stats-grid li.is-zero {
  color: #c23b3b;
}

html[data-theme="dark"] .order-stats-grid li.is-zero {
  color: #ffd0d0;
}

.order-error {
  border: 1px solid rgba(196, 60, 60, 0.45);
  background: rgba(196, 60, 60, 0.12);
  color: #8a1f1f;
  font-weight: 600;
}

html[data-theme="dark"] .order-error {
  border-color: rgba(240, 80, 80, 0.45);
  background: rgba(240, 80, 80, 0.12);
  color: #ffd0d0;
}

.order-banner {
  border: 1px solid rgba(201, 162, 55, 0.35);
  background: var(--color-gold-soft);
  color: var(--color-gold-light);
}

.order-id-line {
  font-size: var(--text-md);
}

.order-id-line strong {
  color: var(--color-gold-light);
  word-break: break-all;
}

@media (min-width: 640px) {
  .order-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-span-2 {
    grid-column: 1 / -1;
  }

  .order-rows--grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-row:not(.order-row--typed):not(.order-row--name) {
    grid-template-columns: max-content auto 120px auto;
    align-items: end;
  }

  .order-row--typed input,
  .order-row--name input,
  .order-row--name .order-row-name {
    min-height: 36px;
    padding: 6px 8px;
  }

  .order-row--typed .order-remove,
  .order-row--name .order-remove {
    min-width: 36px;
    min-height: 36px;
  }

  .order-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .order-rows--grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
