* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #525252;
  --ink-3: #a3a3a3;
  --line: #e5e5e0;
  --line-strong: #1a1a1a;
  --accent: #ff5722;
  --accent-dark: #e64a19;
  --warn: #ffc107;
  --safe: #2e7d32;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
}
html, body {
  height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* === HEADER === */
.topbar {
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--accent);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-size: 16px;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.topbar-right {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-home-link {
  color: white;
  text-decoration: none;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 2px;
  transition: background 0.12s, border-color 0.12s;
}
.topbar-home-link:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.topbar-right .live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--safe);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.4 } }

/* === MAIN === */
main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 100px;
}

/* === JOB CARD === */
.job-meta {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.job-meta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.job-meta-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.job-meta-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink);
  background: #f5f5f0;
  padding: 4px 8px;
  border-radius: 2px;
}
.job-id-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.job-id-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink);
  background: #f5f5f0;
  padding: 4px 8px;
  border-radius: 2px;
  border: 1px solid transparent;
  width: 140px;
  text-align: center;
  transition: border 0.15s, background 0.15s;
}
.job-id-input:hover { border-color: var(--line); }
.job-id-input:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}
.job-id-regen {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  width: 28px;
  height: 28px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.1s, color 0.1s, border 0.1s;
}
.job-id-regen:hover {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.meta-grid .full { grid-column: 1 / -1; }
.meta-section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.meta-section-label:first-of-type { margin-top: 0; }
.meta-section-hint {
  font-family: 'Manrope', sans-serif;
  font-size: 10px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  font-style: italic;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.field input, .field select, .field textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
  transition: border 0.15s, background 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}

/* === PHOTO GRID === */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}
.section-header h2 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.photo-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-2);
}
/* === PHOTO LIST (row-based, image + text side by side) === */
.photo-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}
.photo-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: border 0.15s, box-shadow 0.15s;
  position: relative;
}
.photo-row:hover { border-color: var(--ink); box-shadow: var(--shadow); }
.photo-row:active { transform: scale(0.998); }

/* Header strip — light, mirrors the PDF photo page header row layout */
.photo-row .row-header {
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.photo-row .row-num {
  background: var(--accent);
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.photo-row .row-room-header {
  font-family: 'helvetica', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}
.photo-row .row-room-header.empty {
  color: var(--ink-3);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

/* Pulsing red dot — appears in the row header when a photo is missing
   one or more report-critical fields. Click it to see what's missing.
   Uses high-specificity selector + !important on size/shape so generic
   button resets don't shrink it to a tiny square. */
.photo-row .row-header .row-missing-dot {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px;
  min-height: 20px;
  max-width: 20px;
  max-height: 20px;
  border-radius: 50% !important;
  background: #e53935 !important;
  border: 2px solid #fff !important;
  padding: 0 !important;
  margin: 0 6px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
  box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.9), 0 2px 6px rgba(0,0,0,0.25);
  animation: missingDotPulse 1.1s ease-in-out infinite;
}
.photo-row .row-header .row-missing-dot:hover {
  background: #c62828 !important;
}
@keyframes missingDotPulse {
  0%   { box-shadow: 0 0 0 0    rgba(229, 57, 53, 0.9), 0 1px 4px rgba(0,0,0,0.25); transform: scale(1); }
  50%  { box-shadow: 0 0 0 10px rgba(229, 57, 53, 0),   0 1px 4px rgba(0,0,0,0.25); transform: scale(1.15); }
  100% { box-shadow: 0 0 0 0    rgba(229, 57, 53, 0),   0 1px 4px rgba(0,0,0,0.25); transform: scale(1); }
}

/* Body — image + content */
.photo-row .row-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}
.photo-row .row-img-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.photo-row .row-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.photo-row .row-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.photo-row .row-room {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.photo-row .row-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.photo-row .row-title-empty {
  color: var(--ink-3);
  font-style: italic;
  font-weight: 500;
}
.photo-row .row-dims {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #5d4037;
  background: #fff3cd;
  border: 1px solid #ffe082;
  padding: 3px 9px;
  border-radius: 3px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.photo-row .row-sev {
  display: inline-block;
  font-family: 'helvetica', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 3px;
  color: white;
  white-space: nowrap;
  flex-shrink: 0;
}
.photo-row .row-sev-low    { background: #2e7d32; }
.photo-row .row-sev-medium { background: #ffc107; color: #0a0a0a; }
.photo-row .row-sev-high   { background: #ff5722; }
.photo-row .row-sev-total  { background: #d32f2f; }

/* Severity buttons in markup modal (dark theme) */
.severity-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.sev-btn {
  flex: 1;
  min-width: 60px;
  padding: 9px 6px;
  border: 2px solid transparent;
  background: #2a2a2a;
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.sev-btn::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}
.sev-btn[data-sev="low"]::before    { background: #2e7d32; }
.sev-btn[data-sev="medium"]::before { background: #ffc107; }
.sev-btn[data-sev="high"]::before   { background: #ff5722; }
.sev-btn[data-sev="total"]::before  { background: #d32f2f; }
.sev-btn:hover { background: #3a3a3a; }
.sev-btn.active { border-color: white; background: #1a1a1a; }
.sev-btn.active[data-sev="low"]    { background: #2e7d32; border-color: #2e7d32; }
.sev-btn.active[data-sev="medium"] { background: #ffc107; color: #0a0a0a; border-color: #ffc107; }
.sev-btn.active[data-sev="medium"]::before { background: #0a0a0a; }
.sev-btn.active[data-sev="high"]   { background: #ff5722; border-color: #ff5722; }
.sev-btn.active[data-sev="total"]  { background: #d32f2f; border-color: #d32f2f; }
.photo-row .row-desc {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.photo-row .row-desc.empty {
  color: var(--ink-3);
  font-style: italic;
}
.photo-row .row-edit-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-3);
  margin-top: auto;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Per-row action buttons live in the light header strip, right-aligned */
.photo-row .row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;  /* push to right end of header */
}
.row-action-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  width: 30px;
  height: 30px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.row-action-btn:hover { background: var(--ink); color: white; border-color: var(--ink); }
.row-action-btn.delete:hover { background: #d32f2f; border-color: #d32f2f; color: white; }
.row-action-btn.edit:hover { background: var(--accent); border-color: var(--accent); color: white; }
.row-action-btn.move:hover { background: var(--ink); color: white; border-color: var(--ink); }
.row-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* On desktop, allow horizontal row layout to still fit action buttons cleanly */
@media (min-width: 768px) {
  .photo-row .row-actions { top: 14px; right: 14px; }
}
.add-photo-btn {
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: 4px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}
.add-photo-btn:hover { border-color: var(--accent); color: var(--accent); }
.add-photo-btn .plus {
  font-size: 36px;
  line-height: 1;
  color: var(--accent);
  font-weight: 300;
}
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-3);
  font-size: 14px;
}

/* === STICKY FOOTER ACTION === */
.footer-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--ink);
  padding: 14px 20px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 50;
}
.footer-bar-inner {
  display: flex;
  gap: 10px;
}
.btn {
  flex: 1;
  padding: 16px 20px;
  border: none;
  border-radius: 3px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: white; border: 1px solid #444; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === MARKUP MODAL === */
.modal {
  position: fixed;
  inset: 0;
  background: var(--ink);
  z-index: 100;
  display: none;
  flex-direction: column;
}
.modal.open { display: flex; }
.modal-header {
  padding: 12px 16px;
  background: #1a1a1a;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #333;
}
.modal-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.modal-close {
  background: none;
  border: 1px solid #444;
  color: white;
  width: 36px; height: 36px;
  border-radius: 3px;
  font-size: 20px;
  cursor: pointer;
}

/* === MARKUP MODAL TWO-PHASE LAYOUT === */
.markup-phase {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;  /* anchor for overlay children in image phase */
}

/* ===== PHASE 1: IMAGE — fullscreen image with floating overlay controls ===== */
#markupPhaseImage {
  display: block;       /* override flex; children use absolute positioning */
  position: relative;
}
#markupPhaseImage .canvas-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
}
#markupPhaseImage .toolbar {
  position: absolute;
  z-index: 10;
  top: 10px;
  left: 10px;
  right: 10px;
  background: rgba(20, 20, 20, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 6px 8px;
}
#markupPhaseImage .phase-actions {
  position: absolute;
  z-index: 10;
  bottom: 12px;
  left: 12px;
  right: 12px;
  background: rgba(20, 20, 20, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-top: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 10px 12px;
}

.phase-actions {
  display: flex;
  gap: 10px;
}
.phase-actions .btn {
  flex: 1;
  padding: 14px 20px;
  font-size: 14px;
}

/* ===== BOTTOM SHEET (DETAILS FORM) ===== */
.details-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 80%;
  height: 80%;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -12px 30px rgba(0,0,0,0.45);
  transform: translateY(105%);   /* hidden below bottom */
  transition: transform 0.3s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.details-sheet.open {
  transform: translateY(0);
}

.sheet-header {
  background: var(--ink);
  color: white;
  padding: 18px 16px 10px;
  border-radius: 16px 16px 0 0;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.sheet-handle {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}
.sheet-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.sheet-close {
  background: var(--accent);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.sheet-close:hover { background: var(--accent-dark); }
.sheet-close:active { transform: scale(0.93); }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
}
.sheet-body .details-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: transparent;
  border: none;
  padding: 0;
}

.sheet-footer {
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.sheet-footer .btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 14px;
}

/* Landscape: sheet doesn't need to be quite as tall — half the screen leaves more image space */
.modal.landscape-mode .details-sheet {
  height: 90%;
  max-height: 90%;
}

/* Details phase: scrollable body + sticky action bar */
.details-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.details-thumb-wrap {
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  text-align: center;
  max-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.details-thumb-wrap img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
}
.details-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
}
.details-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.details-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.details-field select,
.details-field input[type="text"],
.details-field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink);
}
.details-field select:focus,
.details-field input:focus,
.details-field textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}
.details-field textarea {
  resize: vertical;
  min-height: 70px;
  max-height: 200px;
  line-height: 1.4;
}
.details-input-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.details-input-row input[type="text"],
.details-input-row textarea {
  flex: 1;
  min-width: 0;
}
.details-input-row .mic-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  padding: 0 16px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 18px;
  min-width: 48px;
}
.details-input-row .mic-btn.recording {
  background: #d32f2f;
  border-color: #d32f2f;
  color: white;
  animation: pulse 1.2s infinite;
}

/* Severity buttons inside details (light theme variant) */
.details-field .severity-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.details-field .sev-btn {
  flex: 1;
  min-width: 60px;
  padding: 10px 6px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.details-field .sev-btn::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #aaa;
  flex-shrink: 0;
}
.details-field .sev-btn[data-sev="low"]::before    { background: #2e7d32; }
.details-field .sev-btn[data-sev="medium"]::before { background: #ffc107; }
.details-field .sev-btn[data-sev="high"]::before   { background: #ff5722; }
.details-field .sev-btn[data-sev="total"]::before  { background: #d32f2f; }
.details-field .sev-btn:hover { background: var(--bg); }
.details-field .sev-btn.active { color: white; border-color: var(--ink); background: var(--ink); }
.details-field .sev-btn.active[data-sev="low"]    { background: #2e7d32; border-color: #2e7d32; }
.details-field .sev-btn.active[data-sev="medium"] { background: #ffc107; border-color: #ffc107; color: #0a0a0a; }
.details-field .sev-btn.active[data-sev="medium"]::before { background: #0a0a0a; }
.details-field .sev-btn.active[data-sev="high"]   { background: #ff5722; border-color: #ff5722; }
.details-field .sev-btn.active[data-sev="total"]  { background: #d32f2f; border-color: #d32f2f; }

/* Modal header right-side action buttons (rotate + close) */
.modal-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.modal-rotate {
  background: none;
  border: 1px solid #444;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 3px;
  font-size: 18px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  display: grid;
  place-items: center;
  transition: background 0.1s, border-color 0.1s;
}
.modal-rotate:hover { background: #2a2a2a; }
.modal-rotate.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* === LANDSCAPE LAYOUT (auto OR manually toggled) ===
   Applies whenever the .modal carries .landscape-mode class.
   JS adds this class automatically on phone landscape OR when user taps
   the rotate button. */
.modal.landscape-mode .modal-header {
  padding: 6px 12px;
}
.modal.landscape-mode .modal-title {
  font-size: 11px;
}
.modal.landscape-mode .modal-close,
.modal.landscape-mode .modal-rotate {
  width: 30px;
  height: 30px;
  font-size: 16px;
}

/* PHASE: IMAGE in landscape — toolbar floats vertical on LEFT, canvas-wrap still fills */
/* (canvas-wrap stays absolute inset:0, only the toolbar repositions) */
.modal.landscape-mode #markupPhaseImage .toolbar {
  top: 10px;
  bottom: 78px;        /* leave space for floating phase-actions */
  left: 10px;
  right: auto;
  width: 64px;
  flex-direction: column;
  flex-wrap: nowrap;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px;
  gap: 4px;
}
.modal.landscape-mode #markupPhaseImage .tool-btn {
  width: 100%;
  min-width: 0;
  padding: 8px 4px;
  font-size: 10px;
  flex-shrink: 0;
}
.modal.landscape-mode #markupPhaseImage .tool-btn .icon {
  font-size: 14px;
}
.modal.landscape-mode #markupPhaseImage .color-swatches {
  flex-direction: column;
  border-left: none;
  border-top: 1px solid #333;
  padding: 8px 0 0 0;
  margin-left: 0;
  margin-top: 4px;
  width: 100%;
  align-items: center;
}
.modal.landscape-mode #markupPhaseImage .swatch {
  width: 22px;
  height: 22px;
}
.modal.landscape-mode #markupPhaseImage .phase-actions {
  left: 84px;          /* clear the side toolbar */
  right: 12px;
  bottom: 12px;
  padding: 8px 12px;
}

/* PHASE: DETAILS — thumbnail on LEFT, form on RIGHT */
.modal.landscape-mode #markupPhaseDetails .details-body {
  flex-direction: row;
  gap: 12px;
  padding: 12px;
}
.modal.landscape-mode #markupPhaseDetails .details-thumb-wrap {
  width: 200px;
  max-height: none;
  flex-shrink: 0;
  align-self: flex-start;
}
.modal.landscape-mode #markupPhaseDetails .details-thumb-wrap img {
  max-height: 100%;
}
.modal.landscape-mode #markupPhaseDetails .details-form {
  flex: 1;
  min-width: 0;
}
.modal.landscape-mode #markupPhaseDetails .phase-actions {
  padding: 8px 12px;
}

/* Action button sizing in landscape */
.modal.landscape-mode .phase-actions .btn {
  padding: 10px 14px;
  font-size: 12px;
}

/* Zoom controls in landscape — toolbar moved to left, so zoom can stay top-right */
.modal.landscape-mode .zoom-controls {
  top: 10px;
  right: 10px;
}
.modal.landscape-mode .zoom-btn {
  width: 28px;
  height: 28px;
  font-size: 15px;
}
.canvas-wrap {
  flex: 1;
  position: relative;
  background: #1a1a1a;   /* softer than pure black — blends with UI when image is letterboxed */
  display: flex;
  align-items: center;   /* center image vertically when smaller than wrap */
  justify-content: center;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}
.canvas-wrap.zoomed {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
}
.canvas-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  transform-origin: top left;
}
#markupCanvas {
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  cursor: crosshair;
}
/* When pan tool is active, canvas cursor becomes a grab hand */
body:has(.tool-btn[data-tool="pan"].active) #markupCanvas {
  cursor: grab;
}
body:has(.tool-btn[data-tool="pan"].active) #markupCanvas:active {
  cursor: grabbing;
}
.canvas-wrap.zoomed #markupCanvas {
  max-width: none;
  max-height: none;
}

/* === ZOOM CONTROLS (floating over canvas) ===
   Positioned BELOW the floating toolbar so they don't overlap. */
.zoom-controls {
  position: absolute;
  top: 78px;       /* below the floating toolbar (toolbar ~60px tall + 10px margin + 8px gap) */
  right: 10px;
  display: flex;
  gap: 4px;
  z-index: 11;
  background: rgba(10,10,10,0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 3px;
  border: 1px solid #333;
  padding: 3px;
}
.zoom-btn {
  background: transparent;
  border: none;
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.1s;
}
.zoom-btn:hover { background: #333; }
.zoom-btn:active { background: var(--accent); }
.zoom-level-btn {
  background: transparent;
  border: none;
  color: white;
  padding: 0 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  min-width: 52px;
  text-align: center;
  border-radius: 2px;
  transition: background 0.1s;
}
.zoom-level-btn:hover { background: #333; }

/* Floating text overlay — default state is "placed" (no chrome).
   When .selected (newly added OR re-tapped), shows dashed border + controls. */
.floating-text {
  position: absolute;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 24px;
  color: #ff3030;
  text-shadow:
    -2px -2px 0 #000, 2px -2px 0 #000,
    -2px 2px 0 #000, 2px 2px 0 #000,
    0 0 4px rgba(0,0,0,0.6);
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  border: 2px solid transparent;
  background: transparent;
  border-radius: 3px;
  white-space: nowrap;
  z-index: 10;
  transition: border-color 0.1s, background 0.1s;
}
.floating-text.selected {
  cursor: move;
  border-color: rgba(255,255,255,0.8);
  border-style: dashed;
  background: rgba(0,0,0,0.15);
}
.floating-text.dragging {
  border-color: #ff5722;
  background: rgba(255,87,34,0.15);
}
.floating-text-controls {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 4px;
  background: #1a1a1a;
  padding: 4px;
  border-radius: 3px;
  border: 1px solid #333;
  white-space: nowrap;
}
.floating-text.selected .floating-text-controls {
  display: flex;
}
.ftc-btn {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: white;
  padding: 4px 10px;
  border-radius: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
}
.ftc-btn.confirm { background: #2e7d32; border-color: #2e7d32; }
.ftc-btn.delete { background: #d32f2f; border-color: #d32f2f; }

.toolbar {
  background: #1a1a1a;
  padding: 10px 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-top: 1px solid #333;
  flex-wrap: nowrap;
}
.tool-btn {
  flex-shrink: 0;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: white;
  padding: 10px 12px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tool-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}
.tool-btn .icon { font-size: 16px; }

/* Delete-shape button: disabled (gray) by default, turns red + pulses when a
   shape is selected so the user immediately sees they can delete it. */
.tool-btn.delete-btn:disabled {
  background: #2a2a2a;
  border-color: #3a3a3a;
  color: #6a6a6a;
  cursor: not-allowed;
  opacity: 0.55;
}
.tool-btn.delete-btn.ready {
  background: #d32f2f;
  border-color: #d32f2f;
  color: white;
  animation: deleteBtnPulse 1.4s ease-in-out infinite;
}
.tool-btn.delete-btn.ready:hover {
  background: #b71c1c;
  border-color: #b71c1c;
}
@keyframes deleteBtnPulse {
  0%   { box-shadow: 0 0 0 0    rgba(211, 47, 47, 0.7); }
  70%  { box-shadow: 0 0 0 6px  rgba(211, 47, 47, 0); }
  100% { box-shadow: 0 0 0 0    rgba(211, 47, 47, 0); }
}
.color-swatches {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0 8px;
  border-left: 1px solid #333;
  margin-left: 4px;
}
.swatch {
  width: 28px; height: 28px;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.swatch.active { border-color: white; }
.desc-bar {
  background: #1a1a1a;
  padding: 12px;
  border-top: 1px solid #333;
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.desc-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.desc-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.desc-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #999;
}
.desc-input-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.desc-bar input[type="text"], .desc-bar textarea {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: white;
  padding: 10px 12px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 14px;
  min-width: 0;
}
.desc-bar input[type="text"]:focus, .desc-bar textarea:focus { outline: none; border-color: var(--accent); }
.desc-bar textarea {
  resize: vertical;
  min-height: 56px;
  max-height: 160px;
  line-height: 1.4;
}
.mic-btn, .save-btn {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: white;
  padding: 0 16px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 18px;
  min-width: 48px;
}
.mic-btn.recording { background: #d32f2f; border-color: #d32f2f; animation: pulse 1.2s infinite; }
.save-btn {
  background: var(--accent);
  border-color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 20px;
}
.room-select-wrap {
  background: #1a1a1a;
  padding: 10px 12px;
  border-top: 1px solid #333;
  display: flex;
  gap: 8px;
  align-items: center;
}
.room-select-wrap label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.room-select-wrap select {
  flex: 1;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: white;
  padding: 10px 12px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 14px;
}

/* Custom "Other..." input that appears under a dropdown when "Other" is picked */
.custom-other-input {
  margin-top: 8px;
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink);
  transition: border-color 0.15s;
}
.custom-other-input:focus { outline: none; border-color: var(--ink); }

/* Dark variant inside markup modal's room-select-wrap */
.room-select-wrap .custom-other-input {
  background: #2a2a2a;
  border-color: var(--accent);
  color: white;
  margin-top: 8px;
  width: 100%;
  font-size: 14px;
  padding: 10px 12px;
}
.room-select-wrap.has-custom {
  flex-wrap: wrap;
}

/* === DESKTOP === */
@media (min-width: 768px) {
  main { padding: 40px 32px 140px; }
  .meta-grid { grid-template-columns: repeat(3, 1fr); }
  .meta-grid .full { grid-column: 1 / -1; }
  .photo-row .row-header { padding: 12px 16px; }
  .photo-row .row-body {
    flex-direction: row;
    padding: 18px;
    gap: 20px;
    align-items: flex-start;
  }
  .photo-row .row-img-wrap {
    width: 280px;
    aspect-ratio: 4/3;
    flex-shrink: 0;
  }
  .photo-row .row-content { gap: 10px; }
  .footer-bar {
    padding: 16px 32px;
  }
  .footer-bar-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
  }
  .btn { font-size: 13px; }
}

/* hide file input */
.hidden-input { display: none; }

.toast {
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%);
  background: var(--safe);
  color: white;
  padding: 12px 20px;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* === PROJECTS NAV (above job-meta) === */
.projects-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  gap: 12px;
  flex-wrap: wrap;
}
.projects-nav-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  text-transform: uppercase;
}
.projects-nav-info b {
  color: var(--ink);
  font-weight: 700;
}
.projects-nav-actions {
  display: flex;
  gap: 8px;
}
.nav-btn {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.nav-btn:hover { background: var(--ink); color: white; }
.nav-btn.primary { background: var(--ink); color: white; }
.nav-btn.primary:hover { background: var(--accent); border-color: var(--accent); }

/* === DIALOG (small centered modal for Save) === */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.75);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dialog-backdrop.open { display: flex; }
.dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  max-width: 440px;
  width: 100%;
  padding: 24px;
}
.dialog-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
}
.dialog-body {
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.5;
}
.dialog-body input {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink);
  margin-top: 8px;
}
.dialog-body input:focus { outline: none; border-color: var(--ink); }
.dialog-body .save-backup-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}
.dialog-body .save-backup-row input[type="checkbox"] {
  width: auto;
  margin: 3px 0 0 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.dialog-body .save-backup-row b { display: block; margin-bottom: 4px; }
.dialog-body .save-backup-row small {
  font-size: 11px;
  color: var(--ink-2);
}
.dialog-body .save-backup-row code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: #f5f5f0;
  padding: 1px 4px;
  border-radius: 2px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.dialog-btn {
  padding: 10px 16px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.dialog-btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.dialog-btn.danger { background: #d32f2f; border-color: #d32f2f; color: white; }
.dialog-btn.success { background: #1f7a3f; border-color: #1f7a3f; color: white; }
.dialog-btn.success:hover { background: #155a2c; border-color: #155a2c; }

/* Dark dialog variant (appears over markup modal) */
.dialog.dark { background: #1a1a1a; border-color: #333; }
.dialog.dark .dialog-title { color: white; border-bottom-color: #444; }
.dialog.dark .dialog-body { color: #ccc; }
.dialog.dark textarea {
  width: 100%;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: white;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 3px;
  margin-top: 8px;
  resize: vertical;
  min-height: 70px;
  line-height: 1.4;
}
.dialog.dark textarea:focus { outline: none; border-color: var(--accent); }
.dialog.dark .dialog-btn {
  background: #2a2a2a;
  border-color: #3a3a3a;
  color: white;
}
.dialog.dark .dialog-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
}

/* Text size selector inside text annotation dialog */
.text-size-selector {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.text-size-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #999;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-right: 6px;
}
.size-btn {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: white;
  padding: 7px 12px;
  border-radius: 2px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.size-btn:hover { background: #3a3a3a; }
.size-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* === PROJECTS MODAL (full-screen list) === */
.projects-modal {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 110;
  display: none;
  flex-direction: column;
}
.projects-modal.open { display: flex; }
.projects-modal-header {
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--accent);
}
.projects-modal-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.modal-back {
  background: var(--accent);
  border: none;
  color: white;
  padding: 9px 16px;
  border-radius: 3px;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.1s;
}
.modal-back:hover { background: var(--accent-dark); }
.modal-back:active { transform: scale(0.97); }

/* === PREVIEW MODAL (PDF preview before download/share) === */
.preview-modal {
  position: fixed;
  inset: 0;
  background: #2a2a2a;
  z-index: 120;
  display: none;
  flex-direction: column;
}
.preview-modal.open { display: flex; }
.preview-modal-header {
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--accent);
  gap: 12px;
  flex-wrap: wrap;
}
.preview-modal-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.preview-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  background: #2a2a2a;
  padding: 0;
}
.preview-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}
.preview-fallback {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: #ccc;
  font-size: 14px;
  line-height: 1.5;
}
.preview-fallback b { color: white; font-size: 16px; }
.preview-fallback .btn {
  flex: 0 0 auto;
  width: auto;
  max-width: 280px;
  padding: 16px 28px;
}
.preview-modal-footer {
  background: var(--ink);
  border-top: 1px solid #333;
  padding: 12px 20px;
  display: flex;
  gap: 8px;
  justify-content: stretch;
}
.preview-modal-footer .btn {
  flex: 1;
  padding: 14px 12px;
  font-size: 13px;
}

/* Floating Close button — sits ON TOP of the iframe so mobile PDF viewer
   can never trap the user. Always visible, always tappable, large target. */
.preview-floating-close {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: 3px solid white;
  font-family: 'Manrope', sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  display: none;
  place-items: center;
  padding: 0;
}
.preview-modal.open .preview-floating-close { display: grid; }
.preview-floating-close:hover { background: var(--accent-dark); }
.preview-floating-close:active { transform: scale(0.93); }

@media (min-width: 768px) {
  .preview-modal-footer {
    padding: 14px 20px;
  }
  .preview-modal-footer .btn { font-size: 13px; padding: 14px 18px; }
}

/* === MOBILE RESPONSIVENESS PASS === */
@media (max-width: 480px) {
  /* Footer buttons get tighter on small phones */
  .btn { font-size: 11px; padding: 14px 8px; letter-spacing: 0.03em; }
  .footer-bar { padding: 10px 12px; }
  .footer-bar-inner { gap: 6px; }

  /* Top nav buttons wrap better on narrow screens */
  .projects-nav { padding: 10px 12px; }
  .projects-nav-actions { width: 100%; justify-content: stretch; }
  .projects-nav-actions .nav-btn { flex: 1; padding: 9px 6px; font-size: 10px; }

  /* Back button on modal headers */
  .modal-back { padding: 8px 12px; font-size: 11px; }
  .projects-modal-title { font-size: 11px; }

  /* Row action buttons (delete + drag) smaller on tiny phones */
  .row-action-btn { width: 30px; height: 30px; font-size: 14px; }

  /* Zoom controls compact */
  .zoom-controls { top: 6px; right: 6px; }
  .zoom-btn { width: 30px; height: 30px; font-size: 16px; }
  .zoom-level-btn { min-width: 44px; font-size: 11px; padding: 0 6px; }
}
.projects-save-banner {
  max-width: 900px;
  width: 100%;
  margin: 16px auto 0;
  padding: 14px 18px;
  background: #fff4eb;
  border: 1.5px solid var(--accent);
  border-left-width: 4px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
  border-radius: 2px;
}
.projects-save-banner strong { color: var(--ink); font-weight: 700; }
.projects-save-banner code {
  background: var(--cream-3);
  padding: 1px 5px;
  border-radius: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.projects-modal-body {
  flex: 1;
  overflow-y: auto;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 24px 20px 40px;
}
.projects-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.6;
}
.projects-empty b { color: var(--ink); display: block; margin-bottom: 8px; font-size: 16px; }
.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border 0.15s;
}
.project-card:hover { border-color: var(--ink); }
.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.project-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.project-card-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}
.project-card-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.project-card-meta span {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
}
.project-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.project-card-actions .nav-btn { padding: 7px 12px; font-size: 10px; }
.project-card-actions .nav-btn.danger {
  border-color: #d32f2f;
  color: #d32f2f;
}
.project-card-actions .nav-btn.danger:hover { background: #d32f2f; color: white; }
.projects-import {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 4px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--ink-2);
}

/* === SETTINGS MODAL (reuses .projects-modal styling for shell) === */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 18px;
}
.settings-help {
  font-size: 12px;
  color: var(--ink-2);
  margin: 8px 0 16px;
  line-height: 1.5;
}
.logo-upload-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.logo-preview {
  width: 100px;
  height: 100px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.logo-preview-empty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}
.logo-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 16px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 0 -20px -40px;
}
