:root {
  --bg: #eef0e8; --panel: #fbfaf6; --card: #fff; --ink: #1f2a24; --muted: #6b7068; --line: #e3dfd4;
  /* H&H website colours and fonts (from Sally) */
  --green: #17392b; --green-hover: #1f4928; --oak: #c8955e; --oak-soft: #f6ecdf; --rust: #a8623a;
  --head: 'Gloock', Georgia, serif;
  --logo: Cinzel, 'Trajan Pro', Georgia, serif;
  --text: 'DM Sans', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--text); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
.app { display: grid; grid-template-columns: 1fr 390px; height: 100vh; height: 100dvh; }
[hidden] { display: none !important; }

/* viewer */
.viewer { position: relative; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
#scene { position: relative; flex: 1; min-height: 0; }
#scene canvas { display: block; touch-action: none; cursor: grab; outline: none; }
#scene canvas:active { cursor: grabbing; }
.viewer-head { position: absolute; top: 18px; left: 22px; z-index: 1; pointer-events: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; background: var(--green); color: #fff; padding: 7px 14px; font-family: var(--logo); font-size: 16px; letter-spacing: .04em; margin-bottom: 12px; }
.brand i { width: 1px; height: 18px; background: rgba(255, 255, 255, .7); }
.brand .w { letter-spacing: .14em; font-size: 14px; }
h1 { font-family: var(--head); font-weight: 400; font-size: 30px; line-height: 1.05; margin: 0; letter-spacing: .02em; }
.dims { color: var(--muted); font-size: 14px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.chips { position: absolute; top: 18px; right: 18px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 40%; pointer-events: none; }
.chips span { background: rgba(23, 57, 43, .92); color: #fff; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; transition: background .3s; }
.chips span.bump { background: var(--rust); }
/* buttons in their own strip under the 3D view, never on top of the model */
.view-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.chip { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip:hover { border-color: #cfc9ba; }
.chip.mob { display: none; }
.chip.toggle { border-style: dashed; color: var(--green); font-weight: 600; }
.view-tools.closed .chip:not(.toggle) { display: none !important; }
/* hidden: no strip, the 3D view gets the space and only a see-through "Show buttons" floats over it */
.view-tools.closed { position: absolute; left: 12px; bottom: 12px; padding: 0; background: transparent; border: 0; z-index: 1; }
.view-tools.closed .toggle { background: rgba(255, 255, 255, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border: 1px solid rgba(23, 57, 43, .25); }
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.hint { position: absolute; right: 18px; top: 92px; text-align: right; max-width: 300px; font-size: 12px; color: var(--muted); pointer-events: none; }
.dim { background: var(--green); color: #fff; font: 600 11.5px var(--text); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.dim.top { background: #fff; color: var(--green); border: 1px solid var(--green); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); transition: opacity .5s; z-index: 3; }
.loading.off { opacity: 0; pointer-events: none; }
.loading span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* panel */
.panel { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.controls { flex: 1; overflow-y: auto; padding: 8px 24px 12px; }
.group { padding: 18px 0; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h2 { margin: 0 0 14px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 6px; gap: 8px; }
.field-top .note, .note { color: var(--muted); font-size: 12px; }
.field-top label .note { display: block; margin-top: 1px; }
.field-top output { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--green); height: 24px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 9px 6px; font-size: 13px; font-weight: 500; cursor: pointer; line-height: 1.2; }
.seg button[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.seg button i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; border: 1px solid rgba(0, 0, 0, .15); vertical-align: -1px; }
.profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.profile { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 8px 8px; cursor: pointer; font-size: 12px; font-weight: 500; text-align: center; }
.profile svg { display: block; width: 100%; height: 34px; margin-bottom: 6px; }
.profile[aria-pressed="true"] { background: var(--oak-soft); border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 40px; height: 38px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; font-size: 18px; cursor: pointer; }
.stepper button:hover:not(:disabled) { border-color: var(--green); }
.stepper button:disabled { opacity: .4; cursor: not-allowed; }
.stepper output { min-width: 34px; text-align: center; font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; }
.stepper .reco { width: auto; margin-left: auto; padding: 0 12px; font-size: 12.5px; font-weight: 500; color: var(--green); }
.info { margin: 12px 0 0; padding: 12px 14px 12px 30px; background: var(--oak-soft); border-radius: 8px; font-size: 13px; line-height: 1.5; }
.info:empty { display: none; }

/* lines (specification and price) */
.lines { font-size: 13px; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.line span:first-child { color: var(--muted); }
.line span:last-child { text-align: right; }
.line.sub { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 8px; }
.line.sub span { color: var(--ink) !important; font-weight: 600; }

/* summary */
.summary { border-top: 1px solid var(--line); background: var(--card); padding: 14px 24px 18px; }
.price-lines { font-size: 13px; margin-bottom: 4px; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); padding-top: 8px; }
.total-label { font-size: 13px; font-weight: 600; }
.total { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.exvat { display: none; }
.cta { width: 100%; margin-top: 12px; border: 0; border-radius: 10px; padding: 11px; background: var(--green); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.cta:hover { background: var(--green-hover); }
.save-row { display: flex; gap: 8px; margin-top: 8px; }
.save-row button { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 9px; font-size: 13px; font-weight: 500; color: var(--green); cursor: pointer; }
.save-row button:hover { border-color: var(--green); }
.save-row.mobile-only { display: none; margin-top: 14px; }
.note-sm { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 8px; }

/* dialogs */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(20, 28, 24, .45); }
.dlg { padding: 22px; }
.dlg h3 { font-family: var(--head); font-weight: 400; font-size: 22px; margin: 0 0 6px; }
.dlg p { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.dlg p b { color: var(--ink); }
.dlg img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; margin-bottom: 14px; background: var(--bg); }
.dlg input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12.5px; background: #f6f5f0; }
.dlg pre { background: #f6f5f0; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 11.5px; overflow: auto; max-height: 220px; margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; }
.dlg details { font-size: 13px; margin-top: 10px; }
.dlg summary { cursor: pointer; color: var(--green); font-weight: 600; }
.dlg .row { display: flex; gap: 8px; margin-top: 16px; }
.dlg .row button { flex: 1; border-radius: 10px; padding: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: #fff; }
.dlg .row .primary { background: var(--green); border-color: var(--green); color: #fff; }

/* PDF quote: only shown when printing */
.quote { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; height: auto; }
  .app, dialog { display: none !important; }
  .quote { display: block; font-size: 12px; color: #1f2a24; }
  .quote .q-head { display: flex; justify-content: space-between; align-items: flex-start; font-size: 11px; text-align: right; }
  .quote .brand { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .quote h1 { font-size: 24px; margin: 6px 0 10px; }
  .quote h2 { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
  .quote img { width: 100%; border-radius: 6px; }
  .quote .lines { margin-bottom: 8px; }
  .quote .info { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .quote .total-line { border-top: 1px solid #1f2a24; margin-top: 4px; padding-top: 6px; font-size: 15px; font-weight: 700; }
  .quote .total-line span { color: #1f2a24 !important; }
  .q-note { color: var(--muted); font-size: 10.5px; margin: 4px 0; word-break: break-all; }
}

/* phones and tablets: viewer on top (title above it, not over it), options below, price bar at the bottom */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; min-height: 100dvh; }
  .viewer { height: 46vh; height: 46dvh; position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; background: var(--bg); }
  .viewer-head { position: static; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
  .brand { font-size: 12px; padding: 4px 8px; margin: 0; gap: 7px; } .brand .w { font-size: 10.5px; } .brand i { height: 13px; }
  .titles { min-width: 0; }
  h1 { font-size: 16px; }
  .dims { font-size: 11px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chips, .hint, .chip.desk { display: none; }
  .view-tools { flex-wrap: nowrap; gap: 6px; padding: 6px 10px; }
  .chip { padding: 5px 12px; font-size: 12px; }
  .chip.mob { display: inline-block; }
  .dim { font-size: 10px; padding: 2px 6px; }
  .panel { border-left: 0; }
  .controls { overflow: visible; padding: 0 16px 8px; }
  .summary { position: sticky; bottom: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0, 0, 0, .06); }
  .price-lines, .total-label, .summary .save-row, .note-sm { display: none; }
  .save-row.mobile-only { display: flex; }
  .total-row { border: 0; padding: 0; grid-column: 1; grid-row: 2; }
  .exvat { display: block; grid-column: 1; grid-row: 1; font-size: 12px; color: var(--muted); }
  .total { font-size: 21px; }
  .total::after { content: ' inc. VAT'; font-size: 12px; font-weight: 500; color: var(--muted); }
  .cta { grid-column: 2; grid-row: 1 / 3; width: auto; margin: 0; padding: 13px 18px; font-size: 14px; }
}
/* phone turned sideways: not enough height to keep the 3D view fixed */
@media (max-width: 860px) and (max-height: 520px) {
  .viewer { position: relative; height: 85vh; }
}
