:root { color-scheme: light; font-family: Inter, ui-sans-serif, system-ui, sans-serif; color: #171714; background: #dfddd4; }
* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100dvh; margin: 0; padding: clamp(18px, 4vw, 56px); display: grid; place-items: center; background: radial-gradient(circle at 18% 12%, #f7f4e9 0, transparent 38%), linear-gradient(145deg, #e7e4da, #d2d0c8); }
main { width: min(1180px, 100%); height: min(760px, calc(100dvh - clamp(36px, 8vw, 112px))); min-height: 520px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; overflow: hidden; border: 1px solid #ffffffb8; border-radius: 24px; background: #fff; box-shadow: 0 26px 80px #4d493526, 0 3px 12px #4d49351a; }
.viewer { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #f8f7f2; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
output { position: absolute; left: 20px; bottom: 20px; max-width: calc(100% - 40px); padding: 8px 12px; overflow: hidden; border-radius: 999px; background: #171714d9; color: white; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
aside { min-width: 0; padding: 40px 30px; overflow-y: auto; background: #fff; box-shadow: -12px 0 40px #00000010; }
aside.is-pending { opacity: .42; filter: saturate(.35); pointer-events: none; }
.eyebrow { color: #8c5d2e; text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 750; }
h1 { margin: 8px 0; font: 500 36px/1.05 Georgia, serif; }
h2 { margin: 30px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
p { color: #66645e; line-height: 1.55; }
label { display: block; padding: 10px 0; border-bottom: 1px solid #ebe9e2; }
input { accent-color: #9e6733; margin-right: 9px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
button { border: 1px solid #d7d3c9; padding: 9px; background: #faf9f5; border-radius: 7px; cursor: pointer; }
button.active { color: white; border-color: #282721; background: #282721; }
button:disabled { opacity: .4; cursor: wait; }
.price { margin-top: 32px; padding-top: 18px; border-top: 1px solid #d7d3c9; display: flex; justify-content: space-between; align-items: baseline; }
.price strong { font: 500 28px Georgia, serif; }
/* Any portrait viewport stacks, plus anything narrow in landscape. Width alone
   was not enough: an 834px tablet, a 912px Surface and a 1024px 12.9in tablet
   all cleared the old 760px breakpoint in portrait and kept the desktop
   columns, which pins a 340px panel beside a squat viewer for the whole height
   of a tall screen. */
@media (orientation: portrait), (max-width: 900px) {
  body { min-height: 100dvh; padding: 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-bottom: max(14px, env(safe-area-inset-bottom)); place-items: start center; }
  main { height: auto; min-height: 0; grid-template-columns: 1fr; border-radius: 18px; }
  .viewer { height: clamp(300px, 52dvh, 460px); }
  aside { padding: 28px 22px 32px; overflow: visible; box-shadow: 0 -12px 40px #0000000c; }
  h1 { font-size: 32px; }
}

/* The stacked panel runs the full width of the card, so two option buttons per
   row leaves them absurdly wide on a tablet. Six heads fit 3 x 2. Two queries
   because the `or` combinator is newer than the browsers these demos target. */
@media (min-width: 620px) and (orientation: portrait) {
  .options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
}
@media (min-width: 620px) and (max-width: 900px) {
  .options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
}

@media (max-width: 420px) {
  body { padding: 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  main { border-radius: 15px; }
  .viewer { height: clamp(270px, 44dvh, 350px); }
  output { left: 14px; bottom: 14px; max-width: calc(100% - 28px); }
}

/* Phone or small tablet held sideways. The desktop columns are already the
   right shape here, but a fixed 340px panel eats half a 667px viewport, so
   make it proportional and drop the prose to buy the viewer back some width. */
@media (orientation: landscape) and (max-height: 560px) and (max-width: 1100px) {
  body { padding: 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); place-items: center; }
  main { height: calc(100dvh - 20px); min-height: 0; grid-template-columns: minmax(0, 1fr) min(44%, 320px); border-radius: 16px; }
  .viewer { height: auto; }
  aside { padding: 16px 18px 20px; overflow-y: auto; overscroll-behavior: contain; }
  aside > p:not(.eyebrow) { display: none; }
  h1 { margin: 4px 0 0; font-size: 24px; }
  h2 { margin: 18px 0 8px; }
  label { padding: 7px 0; }
  .price { margin-top: 18px; padding-top: 14px; }
}

/* Short desktop window: keep the card inside the viewport instead of letting
   min-height push its foot off screen. */
@media (orientation: landscape) and (min-width: 901px) and (max-height: 650px) {
  body { padding: 16px; }
  main { height: calc(100dvh - 32px); min-height: 0; }
  aside { padding-top: 28px; padding-bottom: 28px; }
}

/* Touch: a 13px checkbox and a 9px-padded button are too small to hit. */
@media (pointer: coarse) {
  input[type=checkbox] { width: 20px; height: 20px; }
  label { padding: 13px 0; }
  button { padding: 13px 9px; }
}
