:root {
  --bg: #f5f2ec;
  --surface: #fcfbf8;
  --surface-2: #ffffff;
  --ink: #211f1a;
  --ink-soft: #6f6a5f;
  --ink-faint: #a9a294;
  --line: #e6e0d4;
  --line-soft: #efe9de;
  --accent: #9a7b63;        /* muted clay, used very sparingly */
  --wall: #ece8e0;          /* runtime-overridden by tone picker */
  --wall-rail: #d8d0c3;
  --frame: #ffffff;
  --mat: #f7f4ee;
  --shadow-card: 0 1px 2px rgba(33,31,26,.04), 0 14px 34px rgba(33,31,26,.05);
  --radius: 17px;
  --radius-sm: 12px;
  --maxw: 680px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg);
  line-height: 1.6; font-size: 16px; -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility; padding-bottom: 108px;
}
::selection { background: rgba(154,123,99,.22); }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Header */
.site-header { padding: 66px 0 8px; text-align: center; }
.eyebrow { margin: 0 0 18px; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-faint); font-weight: 500; }
h1 { margin: 0 0 18px; font-family: var(--serif); font-size: 42px; line-height: 1.04; font-weight: 400; letter-spacing: -.018em; font-optical-sizing: auto; }
.lede { margin: 0 auto; max-width: 42ch; color: var(--ink-soft); font-size: 16px; line-height: 1.65; }
.hairline { display: block; width: 56px; height: 1px; background: var(--ink-faint); opacity: .5; margin: 30px auto 0; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 22px; margin: 20px 0; box-shadow: var(--shadow-card); }
.panel-head { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.step { font-family: var(--serif); font-size: 13px; letter-spacing: .04em; color: var(--ink-faint); font-weight: 500; border: 1px solid var(--line); border-radius: 50px; padding: 3px 12px; }
h2 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 400; letter-spacing: -.01em; }
.hint { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; }

/* Template picker */
.template-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.template-card { position: relative; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px 8px 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 12px; font-family: inherit; color: var(--ink); transition: border-color .22s var(--ease), box-shadow .22s var(--ease), transform .22s var(--ease); }
.template-card:hover { border-color: var(--ink-faint); transform: translateY(-2px); }
.template-card[aria-selected="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.template-card .mini { width: 100%; height: 46px; display: block; }
.template-card .mini rect { fill: none; stroke: var(--ink-faint); stroke-width: 2.4; transition: stroke .22s var(--ease), fill .22s var(--ease); }
.template-card[aria-selected="true"] .mini rect { stroke: var(--ink); fill: rgba(33,31,26,.06); }
.template-card .tname { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.3; letter-spacing: .01em; }
.template-card[aria-selected="true"] .tname { color: var(--ink); }

/* Wall stage */
.wall-stage {
  position: relative; border-radius: 14px; padding: 38px 18px 34px; overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,.5), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, color-mix(in srgb, var(--wall) 92%, white) 0%, var(--wall) 58%, color-mix(in srgb, var(--wall) 88%, #000) 100%);
  transition: background .5s var(--ease);
}
.wall-stage::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 70px rgba(33,31,26,.06); pointer-events: none; }
.wall-stage::after { content: ""; position: absolute; left: 0; right: 0; bottom: 26px; height: 1px; background: linear-gradient(90deg, transparent, var(--wall-rail) 18%, var(--wall-rail) 82%, transparent); }

.wall { position: relative; width: 100%; margin: 0 auto; display: grid; gap: 14px; z-index: 1; }

.slot { position: relative; background: var(--frame); padding: 8px; border-radius: 2px; cursor: pointer; border: 1px solid #efe7da; box-shadow: 0 1px 1px rgba(33,31,26,.05), 0 12px 22px -6px rgba(33,31,26,.22); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.slot::before { content: ""; position: absolute; inset: 8px; box-shadow: inset 0 0 0 4px var(--mat), inset 0 0 0 5px rgba(33,31,26,.06); pointer-events: none; z-index: 2; border-radius: 1px; }
.slot img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 1px; }
.slot:hover { transform: translateY(-3px); box-shadow: 0 2px 2px rgba(33,31,26,.06), 0 22px 32px -8px rgba(33,31,26,.3); }
.slot .slot-empty { display: grid; place-items: center; width: 100%; height: 100%; color: var(--ink-faint); font-size: 12px; letter-spacing: .04em; background: var(--mat); }
.slot::after { content: "Swap"; position: absolute; left: 50%; bottom: 11px; transform: translateX(-50%) translateY(5px); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: rgba(33,31,26,.74); padding: 4px 12px; border-radius: 40px; opacity: 0; transition: opacity .2s var(--ease), transform .2s var(--ease); pointer-events: none; z-index: 3; }
.slot:hover::after, .slot:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Reveal */
.wall.reveal .slot { animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 65ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

/* Skeleton */
.wall.is-loading .skel { position: relative; background: var(--mat); border-radius: 2px; overflow: hidden; aspect-ratio: 1; }
.wall.is-loading .skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* Tone picker */
.tone-row { display: flex; align-items: center; gap: 12px; margin: 18px 2px 4px; }
.tone-label { font-size: 12px; letter-spacing: .04em; color: var(--ink-faint); text-transform: uppercase; }
.tone-swatches { display: flex; gap: 9px; }
.tone-dot { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 1px solid rgba(33,31,26,.14); padding: 0; transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.tone-dot:hover { transform: scale(1.08); }
.tone-dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--ink); }

/* Totals */
.wall-meta { margin: 18px 2px 6px; }
.totals { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.totals-count { color: var(--ink-soft); font-size: 14px; letter-spacing: .01em; }
.totals-prices { display: inline-flex; align-items: baseline; gap: 10px; }
.totals-full { font-size: 15px; color: var(--ink-faint); text-decoration: line-through; }
.totals-price { font-family: var(--serif); font-size: 27px; font-weight: 400; letter-spacing: -.01em; }
.discount-note { margin: 7px 0 0; font-size: 13px; color: var(--ink-soft); }
.discount-note b { font-weight: 500; color: var(--accent); }

/* Buttons */
.btn { font-family: var(--sans); font-size: 15px; font-weight: 500; border-radius: 12px; padding: 15px 18px; cursor: pointer; border: 1px solid transparent; transition: background .2s var(--ease), border-color .2s var(--ease), opacity .2s var(--ease), transform .12s var(--ease); }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--ink); color: #fcfbf8; border-color: var(--ink); white-space: nowrap; box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.btn-primary:hover { background: #100f0c; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: 12px 18px; }
.actions-secondary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); flex: 1 1 calc(50% - 4px); font-size: 13.5px; font-weight: 400; padding: 12px 8px; letter-spacing: .01em; }
.btn-ghost:hover { border-color: var(--ink-faint); background: var(--surface-2); }

.fine-print { font-size: 12px; color: var(--ink-faint); text-align: center; margin: 8px 0; line-height: 1.6; }

/* Sticky bar */
.cta-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(252,251,248,.82); backdrop-filter: saturate(150%) blur(14px); -webkit-backdrop-filter: saturate(150%) blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.cta-bar-inner { display: flex; align-items: center; gap: 14px; padding-top: 12px; padding-bottom: 12px; }
.cta-summary { display: flex; flex-direction: column; line-height: 1.2; }
.cta-count { font-size: 12px; color: var(--ink-soft); letter-spacing: .02em; }
.cta-price { font-family: var(--serif); font-size: 22px; font-weight: 400; }
.cta-bar .btn-primary { margin-left: auto; flex: 0 0 auto; }

/* Sheets */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(33,31,26,.4); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .22s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { background: var(--surface); width: 100%; max-width: var(--maxw); border-radius: 24px 24px 0 0; padding: 10px 20px 30px; max-height: 86vh; overflow-y: auto; box-shadow: 0 -12px 48px rgba(33,31,26,.22); animation: slideup .3s var(--ease); }
@keyframes slideup { from { transform: translateY(18px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.sheet--center { border-radius: 20px; margin: auto; max-height: none; padding-top: 18px; }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 14px; }
.sheet-head h3 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 400; }
.icon-btn { background: none; border: none; font-size: 27px; line-height: 1; color: var(--ink-soft); cursor: pointer; padding: 0 4px; }

/* Search */
.search-wrap { margin: 0 0 14px; }
.search-wrap input { width: 100%; font-family: var(--sans); font-size: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.search-wrap input::placeholder { color: var(--ink-faint); }

/* Poster grid */
.poster-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.poster-pick { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px; cursor: pointer; text-align: left; font-family: inherit; color: var(--ink); transition: border-color .2s var(--ease), transform .2s var(--ease); }
.poster-pick:hover { border-color: var(--ink-faint); transform: translateY(-2px); }
.poster-pick img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; display: block; }
.poster-pick .pp-title { font-size: 12.5px; line-height: 1.35; margin: 9px 2px 2px; }
.poster-pick .pp-price { font-size: 12px; color: var(--ink-soft); margin: 0 2px; }
.poster-pick.is-current { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.grid-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-faint); font-size: 14px; padding: 24px 0; }

/* Share */
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; font-family: var(--sans); font-size: 13px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink-soft); }

/* Frame guide */
.frame-guide table { width: 100%; border-collapse: collapse; font-size: 14px; }
.frame-guide th, .frame-guide td { text-align: left; padding: 11px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.frame-guide th { color: var(--ink-soft); font-weight: 500; white-space: nowrap; padding-right: 16px; }
.frame-guide p { font-size: 13px; color: var(--ink-soft); margin: 16px 2px 0; line-height: 1.6; }

/* Footer */
.site-footer { padding: 30px 0 40px; text-align: center; }
.site-footer p { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); margin: 0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 98px; transform: translateX(-50%); background: var(--ink); color: #fcfbf8; padding: 12px 20px; border-radius: 40px; font-size: 14px; z-index: 70; box-shadow: var(--shadow-card); animation: fade .22s var(--ease); }

/* Desktop */
@media (min-width: 620px) {
  .site-header { padding: 84px 0 10px; }
  h1 { font-size: 54px; }
  .panel { padding: 32px 34px; }
  .poster-grid { grid-template-columns: 1fr 1fr 1fr; }
  .btn-ghost { flex: 1 1 auto; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; }
  .sheet-handle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, .sheet, .sheet-backdrop, .wall.reveal .slot { animation: none !important; transition: none !important; }
}
