:root {
  --olive: #4b5534;
  --olive-dark: #3a4228;
  --olive-soft: #e4e6d6;
  --cream: #f5efe4;
  --paper: #fbf8f2;
  --sand: #e8dcc6;
  --gold: #c9a24a;
  --ink: #2f3322;
  --muted: #6f6e5e;
  --line: #e6dccb;
  --danger: #a2483c;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(58, 66, 40, .08);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  position: relative;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  box-shadow: 0 0 0 1px var(--line);
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px;
  background: rgba(251, 248, 242, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1; text-decoration: none; color: inherit; }
.brand-word { font-weight: 900; font-size: 28px; letter-spacing: .02em; color: var(--olive); position: relative; }
.star { width: 14px; height: 14px; fill: var(--gold); position: relative; top: -14px; margin-left: 1px; }
.brand-sub { font-size: 10px; font-weight: 800; letter-spacing: .32em; color: var(--ink); margin-top: 3px; }
.pill {
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: var(--sand); color: var(--muted); white-space: nowrap;
}
.pill.ok { background: var(--olive-soft); color: var(--olive-dark); }
.pill.ok::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #5d8a3a; margin-right: 6px; vertical-align: 1px; }

.banner {
  margin: 12px 16px 0; padding: 12px 14px; border-radius: 14px;
  background: #fbf1d9; border: 1px solid #edd9a6; font-size: 14px;
}
.banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; font-size: 13px; }

main { padding: 0 16px; }
.view { display: none; padding-top: 16px; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero {
  position: relative; overflow: hidden;
  border-radius: 24px; padding: 28px 22px 26px;
  background:
    radial-gradient(circle at 92% 18%, rgba(201,162,74,.28) 0 42px, transparent 43px),
    radial-gradient(circle at 104% 110%, rgba(75,85,52,.14) 0 120px, transparent 121px),
    linear-gradient(160deg, #f3ead9, #ece2cf);
}
.hero:has(.hero-photo)::after { display: none; }
.hero-photo { margin: 18px -22px -26px; width: calc(100% + 44px); aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.hero::after {
  content: ""; position: absolute; right: 26px; bottom: 34px; width: 70px; height: 36px;
  border: 7px solid #d9a69a; border-bottom: 0; border-radius: 70px 70px 0 0;
  box-shadow: inset 0 0 0 7px #e8dcc6, inset 0 0 0 14px #9aab8a; opacity: .8;
}
.badge {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: var(--olive); color: var(--cream); padding: 5px 10px; border-radius: 999px;
}
.hero h1 {
  font-family: var(--serif); font-weight: 600; color: var(--olive-dark);
  font-size: clamp(30px, 8vw, 40px); line-height: 1.08; margin: 14px 0 8px; max-width: 12ch;
}
.hero p { margin: 0 0 18px; color: var(--muted); }

/* Buttons */
.btn {
  border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .12s ease, background .2s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.primary { background: var(--olive); color: var(--cream); }
.btn.primary:hover { background: var(--olive-dark); }
.btn.ghost { background: transparent; color: var(--olive-dark); box-shadow: inset 0 0 0 2px var(--olive); }
.btn.ghost:hover { background: var(--olive-soft); }
.link { background: none; border: 0; color: var(--olive); font-weight: 800; text-decoration: underline; cursor: pointer; padding: 4px; }
.link.center { display: block; margin: 10px auto 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }
.actions { margin-top: 18px; }

/* Features */
.features { list-style: none; padding: 0; margin: 18px 0 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.features li { display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: #fff; border-radius: 14px; border: 1px solid var(--line); }
.features strong { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.features small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; }
.ico { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--sand); display: grid; place-items: center; }
.ico svg, .tabbar svg { width: 18px; height: 18px; fill: none; stroke: var(--olive-dark); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.section-title { font-family: var(--serif); font-weight: 600; font-size: 22px; color: var(--olive-dark); margin: 22px 0 12px; }

/* Themes */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.theme-card {
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: var(--radius);
  padding: 0 0 12px; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; gap: 4px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.theme-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.theme-card .swatches { display: flex; height: 64px; margin-bottom: 8px; }
.theme-photo { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.theme-photo + .swatches { height: 8px; }
.theme-card .swatches i { flex: 1; }
.theme-card strong { padding: 0 12px; font-size: 15px; }
.theme-card span:last-child { padding: 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* Cards & form */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.slim { padding: 14px 18px; }
.card-title { font-family: var(--serif); font-weight: 600; font-size: 22px; color: var(--olive-dark); margin: 0 0 12px; }
.muted { color: var(--muted); margin: 0; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
label small { font-weight: 600; }
.grid2 label { margin-bottom: 0; }
.grid2 + label { margin-top: 12px; }
input, select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--paper); border-radius: 12px; padding: 11px 12px;
  font-size: 16px; font-weight: 600; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--olive); background: #fff; }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; flex-direction: row; }
.chips input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.chips span {
  display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--ink); cursor: pointer; background: var(--paper);
}
.chips input:checked + span { background: var(--olive); border-color: var(--olive); color: var(--cream); }
.chips input:focus-visible + span { outline: 2px solid var(--gold); }

.photo-drop {
  border: 2px dashed var(--sand); border-radius: 16px; padding: 14px; flex-direction: row; align-items: center; gap: 12px;
  cursor: pointer; background: var(--paper); margin: 0;
}
.photo-drop:hover { border-color: var(--olive); }
.photo-drop img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.photo-drop strong { display: block; color: var(--ink); font-size: 14px; }
.photo-drop small { color: var(--muted); }

/* Busy */
.busy { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 18px; font-weight: 700; color: var(--olive-dark); }
.busy[hidden] { display: none; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--sand); border-top-color: var(--olive); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 0 0 4px; }
.plan-title { font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.15; color: var(--olive-dark); margin: 0 0 8px; }
.result h3 { margin-top: 0; }
.result h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.render { border-radius: 14px; margin-bottom: 12px; width: 100%; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 12px; }
.palette div { display: flex; flex-direction: column; font-size: 12px; font-weight: 700; }
.palette i { height: 44px; border-radius: 10px; border: 1px solid rgba(0,0,0,.06); margin-bottom: 4px; }
.palette small { color: var(--muted); font-weight: 600; }
.items { list-style: none; padding: 0; margin: 0; }
.items li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.items li > i { width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; border: 1px solid rgba(0,0,0,.1); }
.items strong { display: block; font-size: 15px; }
.items small { color: var(--muted); font-size: 12.5px; line-height: 1.35; display: block; }
.items li > span { font-weight: 800; white-space: nowrap; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0 4px; font-weight: 800; }
.total strong { font-size: 20px; color: var(--olive-dark); }
.budget-note { font-size: 13px; font-weight: 700; margin: 0 0 6px; }
.budget-note.ok { color: #4f7a35; }
.budget-note.over { color: var(--danger); }
details { border-top: 1px solid var(--line); padding: 10px 0; }
details summary { cursor: pointer; font-weight: 800; color: var(--olive-dark); list-style: none; display: flex; justify-content: space-between; }
details summary::after { content: "+"; font-size: 18px; line-height: 1; }
details[open] summary::after { content: "–"; }
details ul, details ol { margin: 8px 0 0; padding-left: 20px; font-size: 14.5px; }
details li { margin-bottom: 5px; }
.result .row { margin-top: 16px; }

.privacy-note { text-align: center; font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.privacy-note a { color: var(--olive); font-weight: 800; }

/* Book CTA */
.book-cta { margin-top: 18px; padding: 16px; border-radius: 16px; background: var(--olive-soft); }
.book-cta p { margin: 0 0 12px; font-size: 14.5px; }
.btn.wa { background: #25d366; color: #fff; width: 100%; }
.btn.wa:hover { background: #1ebe5b; }

/* Sleep score */
.sleep { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: start; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 14px 0 4px; }
.sleep-ring {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, var(--paper) 78%, transparent 79%), conic-gradient(var(--olive) calc(var(--p) * 1%), var(--sand) 0);
}
.sleep-ring strong { font-size: 30px; line-height: 1; color: var(--olive-dark); font-weight: 900; }
.sleep-ring small { font-size: 11px; color: var(--muted); font-weight: 700; }
.sleep-label { margin: 0 0 8px; font-weight: 800; font-size: 17px; }
.sleep-bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.sleep-bars li { display: grid; grid-template-columns: 96px 1fr 38px; gap: 8px; align-items: center; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.sleep-bars b { height: 7px; background: var(--sand); border-radius: 9px; overflow: hidden; }
.sleep-bars i { display: block; height: 100%; background: var(--olive); border-radius: 9px; }
.sleep-bars em { font-style: normal; text-align: right; }
.sleep-tip { font-size: 13px; margin: 10px 0 0; color: var(--ink); }
@media (max-width: 420px) { .sleep { grid-template-columns: 1fr; justify-items: start; } }

/* 3D */
.stage-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #efe7d8; }
.stage { width: 100%; height: min(62vh, 480px); touch-action: none; }
.stage canvas { width: 100%; height: 100%; display: block; }
.stage-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.chip-btn { border: 0; background: rgba(255,255,255,.9); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 800; cursor: pointer; color: var(--olive-dark); box-shadow: var(--shadow); }
.chip-btn[aria-pressed="false"] { opacity: .6; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; background: var(--cream); }
.stage-empty[hidden] { display: none; }
.legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; font-weight: 700; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; border: 1px solid rgba(0,0,0,.1); }

/* Saved */
.saved-list { display: grid; gap: 12px; }
.saved-item { display: grid; grid-template-columns: 84px 1fr; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px; align-items: center; }
.saved-thumb { width: 84px; height: 84px; border-radius: 12px; overflow: hidden; display: flex; }
.saved-thumb img { width: 100%; height: 100%; object-fit: cover; }
.saved-thumb i { flex: 1; }
.saved-item strong { display: block; line-height: 1.25; }
.saved-item small { color: var(--muted); }
.saved-item .row { margin-top: 8px; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
}
.tabbar button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 800; color: var(--muted); padding: 6px 0; cursor: pointer; border-radius: 12px;
}
.tabbar button svg { width: 22px; height: 22px; stroke: var(--muted); }
.tabbar button.active { color: var(--olive-dark); background: var(--olive-soft); }
.tabbar button.active svg { stroke: var(--olive-dark); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--olive-dark); color: var(--cream); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s ease; max-width: calc(100% - 32px); z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.items li > span { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.shop { font-size: 12px; font-weight: 800; color: var(--olive); text-decoration: none; border-bottom: 1.5px solid var(--gold); }
.print-only { display: none; }

@media print {
  @page { margin: 14mm; }
  body, .app { background: #fff; box-shadow: none; }
  .app { max-width: none; padding: 0; }
  .topbar { position: static; border: 0; backdrop-filter: none; }
  .topbar .pill, .banner, .tabbar, .toast, #designForm, #busy, .no-print, .shop,
  #view-inspire, #view-3d, #view-saved { display: none !important; }
  #view-design { display: block !important; padding: 0; animation: none; }
  .card { box-shadow: none; border: 0; padding: 0; break-inside: auto; }
  .result + .result { margin-top: 18px; }
  .render { max-height: 120mm; width: auto; margin: 0 auto 12px; }
  details { break-inside: avoid; }
  details summary::after { content: ""; }
  .items li, .sleep { break-inside: avoid; }
  .print-only { display: block; }
  .print-foot { margin-top: 18px; font-size: 11px; color: var(--muted); text-align: center; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 380px) {
  .features, .theme-grid { grid-template-columns: 1fr; }
}
