/* Self-hosted Google Fonts (latin subset, variable weight): no render-blocking third-party CSS. */
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 500 700; font-display: swap; src: url("/fonts/cormorant-garamond-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("/fonts/inter-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #1f1f1f;
  --bg-2: #272726;
  --bg-3: #302f2d;
  --line: #3d3b37;
  --text: #ede7dc;
  --muted: #aaa398;
  --gold: #b8935a;
  --gold-2: #d4b47e;
  --gold-3: #96753f;
  --green: #25d366;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font-head: "Cormorant Garamond", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: clamp(2.3rem, 9vw, 3.4rem); line-height: 1.02; margin: 10px 0 14px; }
h2 { font-size: 2rem; line-height: 1.05; margin: 6px 0 8px; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 12px; line-height: 1.5; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: calc(16px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }
.screen { display: none; animation: fade 0.25s ease-out; }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero { text-align: center; padding: 14px 0 10px; }
.hero-logo { width: 150px; margin: 0 auto 6px; filter: drop-shadow(0 6px 16px rgba(184, 147, 90, 0.25)); }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.68rem; font-weight: 600; margin: 0; }
.lead { color: var(--muted); font-size: 1rem; max-width: 34ch; margin: 0 auto 20px; }
.ios-hint { color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
.share-glyph { display: inline-block; border: 1px solid var(--muted); border-radius: 4px; padding: 0 4px; font-size: 0.8rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 600; font-size: 0.98rem; text-decoration: none; transition: transform 0.08s ease, filter 0.15s ease; }
.btn:active { transform: scale(0.98); }
.btn-xl { width: 100%; padding: 17px 24px; font-size: 1.05rem; }
.btn-gold { background: linear-gradient(135deg, var(--gold-2) 0%, var(--gold) 45%, var(--gold-3) 100%); color: #1a1407; box-shadow: 0 8px 24px rgba(184, 147, 90, 0.28); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold-3); margin-top: 10px; }
.btn-dark { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); }
.btn-wa { background: var(--green); color: #06230f; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.link { background: none; border: 0; color: var(--gold); text-decoration: underline; text-underline-offset: 3px; padding: 6px 0; font-size: 0.9rem; }

/* Trust list */
.trust { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 10px; }
.trust li { display: flex; gap: 12px; align-items: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.trust-ico { font-size: 1.3rem; width: 36px; height: 36px; display: grid; place-items: center; background: rgba(184, 147, 90, 0.12); border-radius: 10px; flex: none; }
.trust strong { display: block; font-size: 0.95rem; }
.trust span:not(.trust-ico) { color: var(--muted); font-size: 0.82rem; }
.foot { color: var(--muted); font-size: 0.75rem; text-align: center; margin-top: 26px; letter-spacing: 0.04em; }

.recent { margin-top: 22px; }
.recent h3 { margin-bottom: 8px; }
.recent ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.recent li { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; }
.recent li button { background: none; border: 0; color: var(--gold); text-align: left; padding: 0; flex: 1; }
.recent li span { color: var(--muted); font-size: 0.8rem; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.back { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); width: 40px; height: 40px; border-radius: 12px; font-size: 1.1rem; }
.topbar-logo { height: 34px; width: auto; }
.step { margin-left: auto; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.sub { color: var(--muted); font-size: 0.95rem; }

/* Mic */
.mic-wrap { text-align: center; margin: 18px 0 6px; }
.mic { position: relative; width: 108px; height: 108px; border-radius: 50%; border: 0; background: radial-gradient(circle at 30% 30%, var(--gold-2), var(--gold) 55%, var(--gold-3)); color: #1a1407; box-shadow: 0 12px 34px rgba(184, 147, 90, 0.35); display: inline-grid; place-items: center; }
.mic-ring { position: absolute; inset: -8px; border-radius: 50%; border: 2px solid rgba(184, 147, 90, 0.45); opacity: 0; }
.mic.is-live { background: radial-gradient(circle at 30% 30%, #ff8a80, #e5484d 55%, #a3262a); color: #fff; box-shadow: 0 12px 34px rgba(229, 72, 77, 0.4); }
.mic.is-live .mic-ring { opacity: 1; animation: pulse 1.4s ease-out infinite; border-color: rgba(229, 72, 77, 0.6); }
.mic .stop-icon { display: none; }
.mic.is-live .mic-icon { display: none; }
.mic.is-live .stop-icon { display: block; }
.mic[disabled] { opacity: 0.6; }
.topbar-logo-lg { height: 56px; }
.install-row { text-align: center; margin-top: 18px; }
@keyframes pulse { 0% { transform: scale(0.92); opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0; } }
.mic-label { margin-top: 12px; color: var(--muted); font-size: 0.9rem; }
.mic-unsupported { color: #e5a84d; font-size: 0.85rem; }

/* Fields */
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field em { font-style: normal; color: var(--gold); text-transform: none; letter-spacing: 0; }
.field input, .field textarea, .field select { width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; color: var(--text); outline: none; font-size: 1rem; }
.field textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--gold-3); box-shadow: 0 0 0 3px rgba(184, 147, 90, 0.15); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .grid-2 { grid-template-columns: 1fr; } }
.tiny { color: var(--muted); font-size: 0.78rem; text-align: center; margin-top: 10px; }
#btn-build { margin-top: 14px; }

/* Working */
.working { min-height: 70dvh; display: grid; place-items: center; align-content: center; gap: 16px; text-align: center; }
.working-logo { width: 170px; opacity: 0.95; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.working p { color: var(--muted); }

/* Estimate */
.visual { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); aspect-ratio: 3 / 2; background: var(--bg-2); }
.visual img { width: 100%; height: 100%; object-fit: cover; }
.visual-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 14px 12px; background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent); display: flex; flex-direction: column; }
.visual-cap span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold-2); }
.visual-cap strong { font-family: var(--font-head); font-size: 1.3rem; font-weight: 600; }

.total-card { margin: 14px 0; background: linear-gradient(160deg, #2b2620, #222221 60%); border: 1px solid rgba(184, 147, 90, 0.35); border-radius: var(--radius); padding: 18px 18px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.total-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; }
.total-amount { font-family: var(--font-head); font-size: 3rem; font-weight: 700; color: var(--gold-2); line-height: 1.1; margin: 4px 0; }
.total-sub { color: var(--muted); font-size: 0.82rem; }

.scope { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; margin-bottom: 14px; }
.scope summary { list-style: none; cursor: pointer; padding: 14px 0; display: flex; align-items: baseline; gap: 10px; }
.scope summary::-webkit-details-marker { display: none; }
.scope summary span { font-family: var(--font-head); font-size: 1.3rem; font-weight: 600; }
.scope summary em { color: var(--muted); font-style: normal; font-size: 0.78rem; margin-left: auto; }
.scope[open] summary em { opacity: 0.5; }
.scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 12px; }
.scope-grid .field { margin: 0; }
.scope-grid .field.wide { grid-column: 1 / -1; }
.scope-grid select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--bg-3); color: var(--muted); border-radius: 999px; padding: 7px 12px; font-size: 0.82rem; }
.chip.is-on { background: rgba(184, 147, 90, 0.16); border-color: var(--gold-3); color: var(--gold-2); }
.assumptions { padding: 0 0 14px; color: var(--muted); font-size: 0.8rem; line-height: 1.5; }
.assumptions strong { color: #e5a84d; font-weight: 600; }

.lines { display: grid; gap: 12px; }
.group { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.group h3 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.group h3 b { font-family: var(--font-body); font-size: 0.95rem; font-weight: 600; color: var(--gold-2); }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.line:first-of-type { border-top: 0; }
.line small { grid-column: 1; color: var(--muted); font-size: 0.78rem; }
.line .amt { text-align: right; font-variant-numeric: tabular-nums; }
.line .amt.inc { color: var(--gold); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.totals { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.totals .line { font-size: 0.95rem; }
.totals .line.grand { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; color: var(--gold-2); }
.actions { margin: 18px 0 8px; }

/* Share */
.pdf-preview { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #fff; aspect-ratio: 210 / 260; margin: 12px 0 14px; }
.pdf-preview iframe { width: 100%; height: 100%; border: 0; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-grid .btn { width: 100%; }
#btn-share { grid-column: 1 / -1; }
#btn-new { display: block; margin: 18px auto 0; }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #ede7dc; color: #1f1f1f; padding: 11px 16px; border-radius: 999px; font-size: 0.88rem; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; text-align: center; }

/* Lean first screen: everything fits one phone screen, no scroll */
body.lock { overflow: hidden; height: 100dvh; }
body.lock .app { height: 100dvh; padding-bottom: calc(14px + env(safe-area-inset-bottom)); overflow: hidden; }
#screen-describe.is-active { display: flex; flex-direction: column; height: 100%; gap: 8px; }
#screen-describe .topbar { justify-content: center; margin-bottom: 0; }
#screen-describe h2 { font-size: 1.7rem; text-align: center; margin: 0; }
#screen-describe .mic-wrap { margin: 2px 0 0; }
.mic-sm { width: 84px; height: 84px; }
#screen-describe .mic-label { margin-top: 6px; font-size: 0.82rem; }
#screen-describe .field { margin: 0; }
#screen-describe .field-grow { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
#screen-describe .field-grow textarea { flex: 1 1 auto; min-height: 70px; resize: none; }
#screen-describe .grid-2 { gap: 8px; }
#screen-describe .field input { padding: 11px 12px; }
#screen-describe #btn-build { margin-top: 2px; padding: 15px 20px; }
@media (max-height: 700px) {
  #screen-describe h2 { font-size: 1.45rem; }
  .mic-sm { width: 68px; height: 68px; }
  #screen-describe .mic-label { display: none; }
}

/* Draft stage: editable prices, add a line, line editor sheet */
.draft-hint { color: var(--muted); font-size: 0.82rem; margin: 0 2px 10px; }
.amt-edit { background: rgba(184, 147, 90, 0.1); border: 1px solid rgba(184, 147, 90, 0.35); border-radius: 10px; padding: 5px 9px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; min-height: 34px; align-self: start; }
.amt-edit svg { color: var(--gold); flex: none; }
.amt-edit:active { background: rgba(184, 147, 90, 0.22); }
.line.is-edited .amt-edit { border-color: var(--gold); color: var(--gold-2); font-weight: 600; }
.add-line { display: block; width: 100%; margin-top: 8px; padding: 11px; background: none; border: 1px dashed var(--line); border-radius: 12px; color: var(--gold); font-size: 0.88rem; }
#btn-reset-edits, #btn-back-edit { display: block; margin: 4px auto 0; }
#btn-back-edit { margin-top: 18px; }
#btn-new { margin-top: 6px; }
.sheet { width: min(520px, 100vw); max-width: 100vw; margin: auto auto 0; border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; background: var(--bg-2); color: var(--text); padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet h3 { font-size: 1.5rem; margin-bottom: 4px; }
.sheet .field input { background: var(--bg-3); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { width: 100%; }
.sheet-actions .btn[hidden] { display: none; }
.sheet-actions .btn[hidden] + .btn { grid-column: 1 / -1; }
.sheet #edit-cancel { display: block; margin: 12px auto 0; }
.sheet #edit-calc { text-align: left; margin: 0; min-height: 1em; }
