:root {
  --cream: #e2e0d9;
  --cream-2: #d6d3ca;
  --paper: #f1efe9;
  --ink: #2a2829;
  --ink-2: #5e5a56;
  --line: #bdb8ad;
  --accent: #8a5a2b;
  --ok: #3f6b3a;
  --warn: #9a3b2e;
  --radius: 12px;
  --pad: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); color: var(--ink); }
body {
  font-family: "Archivo", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px; line-height: 1.4; -webkit-text-size-adjust: 100%;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) var(--pad) 10px;
  background: var(--ink); color: var(--cream);
}
.brand {
  color: var(--cream); text-decoration: none; text-transform: uppercase;
  font-weight: 800; font-stretch: 125%; letter-spacing: 0.02em; font-size: 15px;
}
.save-status { font-size: 13px; opacity: 0.85; }
.save-status.err { color: #ffb4a6; opacity: 1; }

.app { max-width: 720px; margin: 0 auto; padding: var(--pad); }

h1, h2, h3 {
  font-weight: 800; font-stretch: 125%; text-transform: uppercase; letter-spacing: 0.01em;
  line-height: 1.1; margin: 0 0 10px;
}
h1 { font-size: 26px; margin-top: 6px; }
h2 { font-size: 18px; margin-top: 26px; }
h3 { font-size: 15px; margin-top: 18px; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-2); font-size: 14px; }
.small { font-size: 13px; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px var(--pad); margin: 10px 0;
}
.card.disabled { opacity: 0.55; }

.list { list-style: none; margin: 0; padding: 0; }
.list li a, .list li button.row {
  display: block; width: 100%; text-align: left; color: inherit; text-decoration: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin: 8px 0; font: inherit;
}
.row-title { font-weight: 600; }
.row-sub { font-size: 14px; color: var(--ink-2); }
.tags { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--cream-2); }
.tag.done { background: #cfdfc9; }

button, .btn {
  font: inherit; font-weight: 600; border-radius: var(--radius); border: 1px solid var(--ink);
  padding: 13px 16px; background: var(--paper); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
button.primary, .btn.primary { background: var(--ink); color: var(--cream); }
button.block, .btn.block { width: 100%; margin: 8px 0; }
button.link { border: none; background: none; padding: 6px 0; text-decoration: underline; font-weight: 400; color: var(--ink-2); }
button.danger { border-color: var(--warn); color: var(--warn); }
button:disabled { opacity: 0.45; cursor: default; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input, textarea, select {
  font: inherit; font-size: 17px; width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.search-box { position: relative; }
.suggest { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.suggest li button { width: 100%; text-align: left; border: none; border-radius: 0; background: #fff; padding: 10px 12px; font-weight: 400; display: block; }
.suggest li + li button { border-top: 1px solid var(--cream-2); }

.steps { display: flex; gap: 6px; margin: 4px 0 14px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--cream-2); }
.steps span.on { background: var(--ink); }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.photo-slot {
  position: relative; border: 1px dashed var(--ink-2); border-radius: var(--radius); background: var(--paper);
  aspect-ratio: 3 / 4; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 8px; font-size: 14px; font-weight: 600;
}
.photo-slot.filled { border-style: solid; padding: 0; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-slot .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 12px;
  background: rgba(42, 40, 41, 0.75); color: var(--cream); text-align: left;
}
.photo-slot .optional { font-weight: 400; font-size: 12px; color: var(--ink-2); }
.photo-slot input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-slot.busy::after { content: 'Uploading…'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(241,239,233,.85); }
.photo-extra { display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center; margin: 8px 0; }
.photo-extra img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.photo-extra input { font-size: 15px; padding: 8px 10px; }

/* Measurement table */
.meas { width: 100%; border-collapse: collapse; font-size: 15px; }
.meas th, .meas td { padding: 6px 4px; border-bottom: 1px solid var(--cream-2); text-align: left; }
.meas th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-2); font-weight: 600; }
.meas td.name { white-space: nowrap; font-weight: 600; }
.meas td.name .note { font-weight: 400; color: var(--ink-2); font-size: 13px; }
.meas input { text-align: center; padding: 9px 4px; font-variant-numeric: tabular-nums; }
.meas input::placeholder { color: #b2aca1; }
.meas .relief td { border-bottom: none; }
.unit { font-size: 13px; color: var(--ink-2); margin-top: 6px; }

.notice { background: var(--cream-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }
.notice.warn { background: #efd6cf; }
.notice.ok { background: #d5e3cf; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 99px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer-links { margin-top: 30px; display: flex; justify-content: space-between; }
.sheet-head .meta { font-size: 14px; color: var(--ink-2); }
fieldset { border: none; padding: 0; margin: 0; }
fieldset:disabled input, fieldset:disabled textarea { background: var(--paper); }

/* PDF viewer */
.viewer-bar { position: sticky; top: calc(48px + var(--safe-top)); z-index: 5; display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; background: var(--cream); }
.viewer-bar .btn, .viewer-bar button { padding: 10px 14px; }
.pdf-pages canvas { width: 100%; height: auto; display: block; margin: 0 0 12px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); border-radius: 4px; }

/* Intake questions */
.question { margin: 14px 0; }
.question .q-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.question .q-head label { margin: 0 0 2px; }
.question textarea { min-height: 76px; margin-top: 6px; }
.question.skipped label { color: var(--ink-2); }

/* Acoustic / Electric picker */
.type-pick { display: flex; gap: 8px; }
.type-pick button { flex: 1; padding: 11px 10px; background: var(--paper); }
.type-pick button.on { background: var(--ink); color: var(--cream); }
#sheet-type label { margin-top: 10px; }

/* Checklist */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { border-bottom: 1px solid var(--cream-2); }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; font-size: 16px; margin: 0; padding: 10px 2px; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--ink); }
