:root {
  --bg: #f6f3ee; --card: #ffffff; --ink: #1f2328; --muted: #676b72;
  --line: #e4ded4; --accent: #1f4e46; --accent-2: #2d6a5f; --soft: #eaf1ef;
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.wrap { max-width: 1120px; margin: 0 auto; }

header { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 14px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); font: 600 26px/1 Fraunces, Georgia, "Times New Roman", serif; letter-spacing: -.01em; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.drop h1 { font-family: Fraunces, Georgia, "Times New Roman", serif; font-weight: 600; }
h1, h2 { letter-spacing: -.01em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 13px 22px; font-weight: 600; cursor: pointer; text-align: center;
}
.btn:hover:not(:disabled) { background: var(--accent-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.ghost:hover:not(:disabled) { background: #fff; }
.ghost:disabled { opacity: .4; cursor: default; }

/* Layout: photo + panel side by side on desktop; photo, panel, extras stacked on phones. */
.layout {
  display: grid; gap: 20px; align-items: start;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  grid-template-areas: "stage panel" "extras panel";
}
.stage { grid-area: stage; min-width: 0; }
.panel { grid-area: panel; }
.extras { grid-area: extras; min-width: 0; display: grid; gap: 18px; }
@media (max-width: 840px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "stage" "panel" "extras"; }
}

/* Empty state */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 420px; padding: 36px 22px; border: 2px dashed #d6cfc2; border-radius: var(--radius);
  background: var(--card); cursor: pointer; gap: 12px;
}
.drop.over { border-color: var(--accent); background: var(--soft); }
.drop svg { width: 54px; height: 54px; fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; }
.drop h1 { margin: 4px 0 0; font-size: clamp(22px, 4vw, 28px); }
.drop p { margin: 0; color: var(--muted); max-width: 380px; }
.drop small { color: var(--muted); font-size: 12.5px; }

/* Before/after viewer */
.viewer { position: relative; overflow: hidden; border-radius: var(--radius); background: #ddd; user-select: none; -webkit-user-select: none; }
.viewer img { display: block; width: 100%; height: auto; }
.viewer .before { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; clip-path: inset(0 50% 0 0); }
.viewer .handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.4); pointer-events: none; }
.viewer .handle::after {
  content: "‹ ›"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--ink);
  display: grid; place-items: center; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.viewer input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.tag { position: absolute; top: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; font-weight: 600; pointer-events: none; }
.tag.l { left: 10px; } .tag.r { right: 10px; }
.viewer.single .before, .viewer.single .handle, .viewer.single input, .viewer.single .tag { display: none; }

.busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(20,24,28,.55); color: #fff; font-weight: 600; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); text-align: center; padding: 16px; }
.spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy small { font-weight: 400; opacity: .85; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Section headings */
.panel h2, .history h2, .estimate h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }

/* History */
.steps { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.step { flex: 0 0 auto; width: 116px; border: 2px solid transparent; border-radius: 12px; background: var(--card); padding: 4px; cursor: pointer; text-align: left; }
.step.on { border-color: var(--accent); }
.step img { width: 100%; height: 74px; object-fit: cover; border-radius: 8px; display: block; }
.step span { display: block; font-size: 12px; line-height: 1.25; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Control panel */
.panel { padding: 18px; position: sticky; top: calc(env(safe-area-inset-top) + 16px); }
@media (max-width: 840px) { .panel { position: static; } }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.sw { border: 2px solid transparent; border-radius: 12px; padding: 0; background: none; cursor: pointer; text-align: left; }
.sw .chip { height: 58px; border-radius: 10px; border: 1px solid rgba(0,0,0,.08); }
.sw span { display: block; font-size: 12.5px; line-height: 1.25; padding: 5px 3px 0; }
.sw small { display: block; font-size: 11.5px; color: var(--muted); padding: 1px 3px 3px; }
.sw.on { border-color: var(--accent); }
.sw.on .chip { box-shadow: inset 0 0 0 3px #fff; }
.lbl { display: block; font-size: 13px; color: var(--muted); margin: 16px 0 6px; }
textarea, .text { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 16px; resize: vertical; background: #fff; color: var(--ink); }
textarea:focus, .text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Segmented control */
.seg { display: flex; gap: 4px; margin-top: 14px; background: var(--bg); padding: 4px; border-radius: 999px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 999px; font-size: 13.5px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
#scope { margin: 0 0 14px; }
.seg.small { margin: 0; }
.seg.small button { padding: 5px 10px; font-size: 12.5px; }

.apply { width: 100%; margin-top: 14px; padding: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; text-align: center; }

/* Estimate */
.estimate { padding: 18px; }
.est-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.est-head h2 { margin: 0 !important; }
.estimate ul { list-style: none; padding: 0; margin: 0; }
.estimate li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.estimate li span:last-child { white-space: nowrap; color: var(--muted); }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0 4px; }
.total strong { font-size: 22px; color: var(--accent); white-space: nowrap; }
.finance { width: 100%; margin-top: 12px; }
.fine { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

/* Lead modal */
.modal { position: fixed; inset: 0; background: rgba(20,24,28,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.sheet { position: relative; width: 100%; max-width: 420px; padding: 24px 22px 20px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.sheet h2 { margin: 0 32px 6px 0; font-size: 21px; }
.sheet p { margin: 0 0 4px; color: var(--muted); }
.sheet .seg { margin: 14px 0 8px; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.4; }
.consent input { margin-top: 2px; flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--accent); }
.err { color: #a12222; font-size: 13.5px; margin: 10px 0 0 !important; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); background: #8a1f1f; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14px; z-index: 20; }
.disclaimer { color: var(--muted); font-size: 12px; text-align: center; margin-top: 28px; }
