/* SOR — Design system (derived from Closr DESIGN.md, simplified for site observation reports) */

:root {
  --bg: #f5f1ea;
  --paper: #fdfbf6;
  --line: #e2dccf;
  --ink: #1f2429;
  --muted: #6c747c;
  --hero: #2e353d;
  --hero-2: #3a424b;
  --accent: #c8612e;
  --accent-deep: #a84e22;
  --red: #c43a3a;   --red-bg: #f0d9d6;
  --amber: #d49b3e; --amber-bg: #f5e8c8;
  --green: #6a8c5a; --green-bg: #d8e3cf;
  --blue: #5b7ea0;  --blue-bg: #d3def0;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --serif: "Iowan Old Style", Charter, Georgia, serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* , *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Top bar */
.topbar {
  background: var(--hero);
  color: #f5f1ea;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .brand .mark { width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: white; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.topbar .brand .name { font-weight: 700; letter-spacing: 1.4px; font-size: 13px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: nowrap; }
.topbar .crumb {
  font: 600 11px/1 var(--sans); letter-spacing: 1.5px; text-transform: uppercase;
  color: rgba(245,241,234,0.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}

/* Buttons */
.btn {
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font: 600 13px/1 var(--sans);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:hover { background: #f6efe1; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost-dark { background: transparent; color: #f5f1ea; border-color: rgba(255,255,255,0.18); }
.btn.ghost-dark:hover { background: rgba(255,255,255,0.06); }
.btn.danger { color: var(--red); border-color: rgba(196,58,58,0.4); }
.btn.danger:hover { background: var(--red-bg); }
.btn svg { width: 14px; height: 14px; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.icon { padding: 8px; }

/* Layout shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.main { padding: 22px 20px 80px; max-width: 1280px; margin: 0 auto; width: 100%; }
.main.narrow { max-width: 880px; }

/* Headings & meta */
.title { font: 600 30px/1.05 var(--serif); letter-spacing: -0.3px; }
.title.lg { font-size: 38px; }
.subtitle { font: 500 13px/1.5 var(--sans); color: var(--muted); margin-top: 6px; }
.eyebrow { font: 700 11px/1 var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.section-h { font: 700 11px/1 var(--sans); letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }

/* Cards / panels */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.panel + .panel { margin-top: 14px; }

.row-list { display: flex; flex-direction: column; gap: 10px; }

/* Project cards (home) */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
  text-align: left; transition: transform 120ms ease, border-color 120ms ease;
}
.project-card:hover { border-color: #cfc6b1; }
.project-card .name { font: 600 18px/1.2 var(--serif); }
.project-card .meta { font: 500 12px/1.4 var(--sans); color: var(--muted); }
.project-card.add {
  border-style: dashed; align-items: center; justify-content: center; color: var(--muted);
  background: transparent; min-height: 130px; cursor: pointer;
}
.project-card.add svg { width: 22px; height: 22px; margin-bottom: 6px; }

/* Forms */
.field { margin-bottom: 12px; }
.field label, label.field-label { display: block; font: 700 10px/1 var(--sans); letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; font: 500 14px/1.4 var(--sans);
  padding: 10px 12px; background: white;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  color: var(--ink); outline: none; font-family: var(--sans);
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,97,46,0.12); }
.field textarea { resize: vertical; min-height: 80px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 11px/1 var(--sans); padding: 5px 9px;
  border-radius: 999px; border: 1px solid transparent;
  white-space: nowrap;
}
.pill.open    { background: var(--red-bg);   color: var(--red);   border-color: rgba(196,58,58,0.33); }
.pill.prog    { background: var(--amber-bg); color: #8b6a1e;       border-color: rgba(212,155,62,0.33); }
.pill.closed  { background: var(--green-bg); color: var(--green); border-color: rgba(106,140,90,0.33); }
.pill.muted   { background: transparent; color: var(--muted); border-color: var(--line); }

/* Switch */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line);
  margin: 8px 0 14px;
}
.switch-row .t { font: 600 13px/1.2 var(--sans); }
.switch-row .s { font: 500 11px/1.4 var(--sans); color: var(--muted); margin-top: 2px; }
.toggle {
  width: 44px; height: 26px; background: #cdc6b8; border-radius: 999px; position: relative;
  border: 0; padding: 0; cursor: pointer; flex-shrink: 0; transition: background 140ms ease;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: white; border-radius: 50%; transition: transform 140ms ease;
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(18px); }

/* Observation row */
.obs-row {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 10px; align-items: center;
}
.obs-row .ph {
  aspect-ratio: 4/3; border-radius: 6px;
  background: #d6cdb6 center/cover no-repeat;
  position: relative; overflow: hidden;
}
.obs-row .ph .num { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,0.55); color: white; font: 600 10px/1 var(--sans); padding: 4px 6px; border-radius: 3px; }
.obs-row .info .cap { font: 500 14px/1.45 var(--sans); color: var(--ink); }
.obs-row .info .meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
.obs-row.selected { border-color: var(--accent); }
.obs-row .tools { display: flex; flex-direction: column; gap: 4px; }
.obs-row .tools button { background: transparent; border: 1px solid var(--line); width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); transition: color 100ms ease, background 100ms ease, border-color 100ms ease; }
.obs-row .tools button:hover:not(:disabled) { color: var(--ink); background: var(--bg); border-color: #cfc6b1; }
.obs-row .tools button:disabled { opacity: 0.35; cursor: not-allowed; }
.obs-row .tools button.move:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.obs-row .tools button.del:hover { color: var(--red); border-color: rgba(196,58,58,0.4); }
.obs-row .tools button svg { width: 16px; height: 16px; }
.obs-row.dragging { opacity: 0.4; }

/* Empty state */
.empty {
  background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius-lg);
  padding: 36px 24px; text-align: center; color: var(--muted);
}
.empty h3 { font: 600 18px/1.2 var(--serif); color: var(--ink); margin-bottom: 6px; }
.empty p { font-size: 13px; margin-bottom: 14px; }

/* Segmented */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 7px 11px; font: 600 12px/1 var(--sans); color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--paper); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--hero); color: var(--paper); padding: 10px 16px;
  border-radius: 8px; font: 600 13px/1.2 var(--sans);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: toast-in 160ms ease-out;
  z-index: 100;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Modal */
.modal-wrap {
  position: fixed; inset: 0; background: rgba(31,36,41,0.45);
  display: grid; place-items: center; z-index: 50;
  padding: 16px;
}
.modal {
  background: var(--paper); border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px);
  overflow: auto; padding: 20px;
}
.modal h2 { font: 600 22px/1.1 var(--serif); margin-bottom: 14px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Sheet (mobile) — used for observation editor */
.sheet-wrap {
  position: fixed; inset: 0; background: rgba(31,36,41,0.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--paper);
  width: 100%; max-width: 560px;
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  padding: 16px 20px 24px;
  max-height: 92vh; overflow-y: auto;
}
.sheet .grip { width: 38px; height: 4px; background: #ddd5c5; border-radius: 2px; margin: 0 auto 12px; }
.sheet h3 { font: 600 22px/1.1 var(--serif); margin-bottom: 4px; }
.sheet .lead { font: 500 12px/1.5 var(--sans); color: var(--muted); margin-bottom: 14px; }

/* FAB */
.fab {
  position: fixed; right: 22px; bottom: 22px;
  width: 60px; height: 60px; border: 0; border-radius: 50%; background: var(--accent);
  color: white; display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(200,97,46,0.45);
  animation: fab-pulse 1.6s ease-out infinite;
  z-index: 20;
}
.fab svg { width: 24px; height: 24px; }
@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(200,97,46,0.45), 0 0 0 0 rgba(200,97,46,0.45); }
  50% { box-shadow: 0 10px 30px rgba(200,97,46,0.45), 0 0 0 14px rgba(200,97,46,0); }
}

/* Capture preview */
.capture-preview {
  aspect-ratio: 4/3; border-radius: var(--radius-md);
  background: #d6cdb6 center/cover no-repeat;
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
}
.capture-preview .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted);
  font-size: 13px; font-weight: 500;
}
.capture-preview .retake {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(0,0,0,0.5); color: white;
  font: 600 12px/1 var(--sans); padding: 7px 11px; border-radius: 999px;
  border: 0;
}
.capture-preview input[type=file] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}

/* Two-column layout for builder on desktop */
.builder {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px;
}
@media (max-width: 900px) {
  .builder { grid-template-columns: 1fr; }
  .builder .detail-col { order: -1; }
  .obs-row { grid-template-columns: 80px 1fr auto; }
}

.detail-col .preview { aspect-ratio: 4/3; border-radius: 10px; background: #d6cdb6 center/cover no-repeat; margin-bottom: 14px; border: 1px solid var(--line); }
.detail-col .preview.empty-state { background: var(--bg); display: grid; place-items: center; color: var(--muted); font-size: 12px; }

/* Print — used by the "Print / Save PDF" export */
@media print {
  @page { size: A4; margin: 12mm 12mm 14mm; }
  body { background: white; }
  .no-print, .topbar, .fab { display: none !important; }
}

/* Small utilities */
.row-flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.hidden { display: none !important; }
