:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1f1c18;
  --muted: #6f675d;
  --line: #e4ded4;
  --accent: #5c4632;        /* marrón tierra (alfombras de fibra natural); blanco encima: 9,6:1 */
  --accent-ink: #ffffff;
  --accent-soft: #efe6da;
  --danger: #a3382c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31,28,24,.06), 0 4px 16px rgba(31,28,24,.06);
  --bar-h: 76px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --surface: #201e1b; --ink: #f1ede6; --muted: #a59d92; --line: #34302b;
    --accent: #d8c3a0; --accent-ink: #1c1712; --accent-soft: #33291f; --danger: #e0806f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- Estructura ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 20px; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 8px; }
.brand small { font-weight: 400; font-size: 13px; color: var(--muted); }
@media (max-width: 480px) { .topbar .top-actions ~ * , .topbar:has(.top-actions:not(.hidden)) .brand small { display: none; } }
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px 16px calc(var(--bar-h) + 32px); }
.step { margin-bottom: 28px; }
.step h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.step h2 .num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 14px; flex: none;
}
.step h2 .hint { font-weight: 400; font-size: 14px; color: var(--muted); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- Paso 1: foto ---------- */
.capture {
  display: grid; gap: 12px; padding: 28px 16px; text-align: center;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface);
}
.capture p { margin: 0; color: var(--muted); }
.capture .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.capture .btn.primary { min-height: 52px; font-size: 17px; padding: 12px 24px; }
.photo-preview { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; box-shadow: var(--shadow); }
.photo-preview img { width: 100%; max-height: 52vh; object-fit: contain; margin: 0 auto; }
.photo-preview .btn { position: absolute; right: 10px; bottom: 10px; }
.note { margin-top: 12px; }
.note label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
textarea, input[type=text], input[type=search], input[type=number], input[type=password], select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
textarea { resize: vertical; min-height: 64px; }

/* ---------- Paso 2: catálogo ---------- */
.search { margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips.sub .chip { font-size: 13px; padding: 5px 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 6px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 920px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card {
  position: relative; text-align: left; padding: 0; cursor: pointer; overflow: hidden;
  border: 2px solid transparent; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.card.on { border-color: var(--accent); }
.card .ph { aspect-ratio: 1; background: #f1eee9; display: grid; place-items: center; }
.card .ph img { width: 100%; height: 100%; object-fit: contain; }
.card .info { padding: 8px 10px 10px; }
.card .name { font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .price { font-size: 14px; color: var(--muted); margin-top: 2px; }
.card .tick {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); font-weight: 700;
}
.card.on .tick { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ---------- Barra inferior ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(0,0,0,.06);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bar-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 12px; min-height: 52px; }
.picked { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.picked img { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: #f1eee9; border: 1px solid var(--line); flex: none; cursor: pointer; }
.picked .msg { color: var(--muted); font-size: 14px; align-self: center; }
.total { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.total b { display: block; font-size: 16px; color: var(--ink); }

/* ---------- Resultado ---------- */
.compare {
  position: relative; border-radius: var(--radius); overflow: hidden; background: #000;
  box-shadow: var(--shadow); user-select: none; touch-action: pan-y;
}
.compare img { width: 100%; height: auto; }
.compare .before { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
.compare .handle { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; background: #fff; transform: translateX(-1px); pointer-events: none; }
.compare .handle::after {
  content: '⇆'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 38px; height: 38px; border-radius: 50%; background: #fff; color: #1f1c18; display: grid; place-items: center; font-size: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.compare input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.compare .tag { position: absolute; top: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; pointer-events: none; }
.compare .tag.l { left: 10px; } .compare .tag.r { right: 10px; }
.disclaimer { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }
.quote { margin-top: 20px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.quote h3 { margin: 0; padding: 14px 16px; font-size: 16px; border-bottom: 1px solid var(--line); }
.quote .row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.quote .row img { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: #f1eee9; flex: none; }
.quote .row .t { flex: 1; min-width: 0; }
.quote .row .t small { display: block; color: var(--muted); font-size: 12px; }
.quote .row .p { font-weight: 600; white-space: nowrap; }
.quote .sum { display: flex; justify-content: space-between; padding: 14px 16px; font-weight: 700; font-size: 18px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.result-actions .btn { flex: 1 1 140px; }

/* ---------- Carga ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); text-align: center;
}
.overlay .box { max-width: 340px; }
.spinner { width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.overlay .secs { color: var(--muted); font-size: 14px; margin-top: 6px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 24px); transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow); font-size: 15px;
}
.toast.err { background: var(--danger); color: #fff; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- Visualizador Troccoli ---------- */
.brand { text-decoration: none; color: var(--ink); text-transform: uppercase; letter-spacing: .12em; font-size: 17px; }
.brand small { text-transform: none; letter-spacing: 0; }
.wrap.narrow { max-width: 460px; }
.hero h1 { font-size: 26px; line-height: 1.15; letter-spacing: -.02em; margin: 8px 0 8px; }
.hero p { color: var(--muted); margin: 0 0 18px; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 14px; }
.fld { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.fld input, .fld select, .fld textarea { color: var(--ink); font-size: 16px; }
input[type=email], input[type=tel], input:not([type]) { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.known { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }
.help { font-size: 13px; color: var(--muted); margin: 0; }
.greet { font-size: 22px; margin: 4px 0 14px; }
.newproj { display: flex; gap: 8px; margin-bottom: 18px; }
.newproj input { flex: 1; min-width: 0; }
.projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .projects { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pcard { position: relative; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); align-self: start; }
/* Siempre apaisada (4:3), aunque la foto sea vertical: se recorta para llenar. */
.pcard .ph { position: relative; display: block; aspect-ratio: 4/3; background: #ece6dd; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; color: var(--muted); font-size: 13px; }
.pcard .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pcard .ph span { position: absolute; inset: 0; display: grid; place-items: center; }
.pcard .info { display: flex; align-items: center; gap: 6px; padding: 8px 6px 10px 12px; }
.pcard .info a { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.pcard .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard small { display: block; color: var(--muted); font-size: 13px; }
.back { display: inline-block; margin: 2px 0 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.ptitle { font-size: 22px; margin: 0 0 16px; letter-spacing: -.01em; }
.photos { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 10px; scrollbar-width: none; }
.photos:empty { display: none; }
.photo { flex: none; width: 120px; aspect-ratio: 4/3; padding: 0; border: 3px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; background: #000; }
.photo.on { border-color: var(--accent); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.capture.compact { padding: 12px; border-width: 1px; }
.capture.compact p { display: none; }
.card .ph.cover img { object-fit: cover; }
.card .more { position: absolute; top: 8px; left: 8px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font: italic 600 14px Georgia, serif; cursor: pointer; }
.tries { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .tries { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.try { padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.try img { aspect-ratio: 4/3; width: 100%; object-fit: cover; }
.try span { display: block; padding: 6px 10px 8px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picked img.room { border-color: var(--accent); object-fit: cover; }
.res-items { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.res-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 6px 12px 6px 6px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }
.res-item img { width: 44px; height: 44px; border-radius: 8px; object-fit: contain; background: #f1eee9; }
.res-item small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
dl.tech { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; margin: 8px 0; }
dl.tech dt { color: var(--muted); } dl.tech dd { margin: 0; }
dl.tech:empty { display: none; }
.pad { padding: 0 16px; }
.quote .help.pad, .quote .pad:last-child { padding-bottom: 14px; }
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88dvh; border-radius: 18px 18px 0 0; background: var(--surface); color: var(--ink); }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 18px; } }
dialog.sheet::backdrop { background: rgba(20,18,16,.45); }
.sheet-in { padding: 0 0 16px; overflow-y: auto; max-height: 88dvh; }
.sheet-in > :not(img) { margin-left: 16px; margin-right: 16px; }
.sheet-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.sheet-in h3 { font-size: 20px; margin-top: 14px; margin-bottom: 6px; }
.sheet-in p { color: var(--muted); }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.phead .ptitle { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pacts { position: relative; flex: none; }
/* Menú de tres puntos (proyecto) */
.dots { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; flex: none; }
.dots:hover, .dots[aria-expanded=true] { background: var(--accent-soft); }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 170px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 6px; }
.menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 15px; }
.menu button:hover { background: var(--accent-soft); }
.menu button.danger { color: var(--danger); }
.pcard .menu { top: auto; bottom: 48px; right: 8px; }
.photo { position: relative; }
.photo .del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; cursor: pointer; }
