@font-face { font-family: 'Bricolage Grotesque'; src: url(../fonts/bricolage.woff2) format('woff2'); font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url(../fonts/figtree.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }

/* Tokens. Light is the base; dark redefines only the values. */
:root {
  --board: #e8d9bd;
  --hole: rgba(96, 66, 30, .30);
  --paper: #fffaf0;
  --paper-2: #f5ecda;
  --ink: #2a2017;
  --muted: #6c5d4b;
  --line: #e2d3b6;
  --accent: #c23c26;
  --accent-ink: #fff;
  --chip-on: #2a2017;
  --chip-on-ink: #fffaf0;
  --good: #2c7a4b;
  --ok: #946414;
  --warn: #c24e17;
  --bad: #b3261e;
  --info: #7a6c5c;
  --tab-fill: var(--paper);
  --shadow: 0 1px 2px rgba(70, 45, 15, .12), 0 8px 22px rgba(70, 45, 15, .12);
  --tag-shadow: drop-shadow(0 5px 5px rgba(60, 38, 12, .28));
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --board: #1f1b17;
    --hole: rgba(0, 0, 0, .55);
    --paper: #2a251f;
    --paper-2: #231f1a;
    --ink: #f2e9da;
    --muted: #b6a891;
    --line: #3e362c;
    --accent: #ff7a5a;
    --accent-ink: #2a120c;
    --chip-on: #f2e9da;
    --chip-on-ink: #231f1a;
    --good: #72d09a;
    --ok: #e9b650;
    --warn: #ff8e5c;
    --bad: #ff6d63;
    --info: #a99c89;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 26px rgba(0, 0, 0, .35);
    --tag-shadow: drop-shadow(0 6px 6px rgba(0, 0, 0, .5));
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --board: #1f1b17; --hole: rgba(0, 0, 0, .55); --paper: #2a251f; --paper-2: #231f1a; --ink: #f2e9da; --muted: #b6a891;
  --line: #3e362c; --accent: #ff7a5a; --accent-ink: #2a120c; --chip-on: #f2e9da; --chip-on-ink: #231f1a; --good: #72d09a;
  --ok: #e9b650; --warn: #ff8e5c; --bad: #ff6d63; --info: #a99c89; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 26px rgba(0, 0, 0, .35);
  --tag-shadow: drop-shadow(0 6px 6px rgba(0, 0, 0, .5)); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 var(--body);
  color: var(--ink);
  background-color: var(--board);
  background-image: radial-gradient(circle, var(--hole) 0 2.7px, transparent 3.3px);
  background-size: 26px 26px;
  background-position: 13px 13px;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; }
h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1[tabindex="-1"]:focus { outline: none; } /* where the focus goes on a page change: nothing to press there */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Header and tabs ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(60, 40, 15, .08);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font: 800 1.3rem/1 var(--display); letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  position: relative; display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 700;
}
.tabs a:hover { color: var(--ink); background: var(--paper-2); }
.tabs a[aria-current="page"] { color: var(--chip-on-ink); background: var(--chip-on); --tab-fill: var(--chip-on); }
.tabs .count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 800 .75rem/1 var(--body);
}

main { max-width: 1240px; margin: 0 auto; padding: 22px 16px 60px; }
/* A swinging tag can poke past the edge for a moment; don't let that scroll the page sideways. */
@supports (overflow: clip) { main { overflow-x: clip; } }
.jd-foot { max-width: 1240px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom, 0px)); text-align: center; font-size: .85rem; color: var(--muted); text-shadow: 0 0 2px var(--board), 0 0 4px var(--board); }
.jd-foot a { color: inherit; }
.jd-foot a:hover { color: var(--ink); }
.page { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.lede { color: var(--muted); margin-top: 6px; }
.hint { font-weight: 500; color: var(--muted); font-size: .85rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Buttons and chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
  font-weight: 700; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { min-height: 52px; font-size: 1.05rem; }
.btn.heart[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

fieldset { border: 0; margin: 18px 0 0; padding: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  min-height: 38px; padding: 0 13px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--paper);
  font-weight: 600; font-size: .92rem; line-height: 1;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-ink); }
.chips.seg { gap: 0; flex-wrap: nowrap; }
.chips.seg .chip { border-radius: 0; margin-left: -1.5px; flex: 1 1 auto; }
.chips.seg .chip:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.chips.seg .chip:last-child { border-radius: 0 999px 999px 0; }
.chips.small .chip { min-height: 34px; font-size: .85rem; padding: 0 11px; }

details { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; }
summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 32px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: '+'; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); font-weight: 800; line-height: 1; }
details[open] summary::before { content: '–'; }
details > fieldset:first-of-type { margin-top: 8px; }

.field { display: grid; gap: 6px; font-weight: 700; font-size: .92rem; margin-top: 12px; }
.field input, .letter input {
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--paper-2); font-weight: 600;
}
.fields { margin-top: 16px; align-items: flex-start; }
.letter { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.letter input { width: 64px; text-transform: uppercase; text-align: center; }
.tick { display: flex; gap: 10px; align-items: flex-start; flex: 1 1 240px; font-size: .92rem; color: var(--muted); }
.tick input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.tick span { color: var(--ink); }

/* ---------- Find ---------- */
.find-layout { display: grid; gap: 22px; }
.criteria .btn.big { width: 100%; margin-top: 22px; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.results-head h2 {
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px;
  font-size: 1rem; box-shadow: var(--shadow);
}

/* Tags hanging on the pegboard. */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 14px;
  align-items: start;
}
.hang { position: relative; margin: 0; display: grid; justify-items: center; gap: 8px; }
.tagbtn { position: relative; display: block; width: 100%; max-width: 176px; padding: 0; border: 0; background: none; border-radius: 12px; }
.tag { display: block; width: 100%; height: auto; overflow: visible; filter: var(--tag-shadow); }
.tag text { font-kerning: normal; }
.hang .tag { animation: swing 1.5s cubic-bezier(.3, .6, .4, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }
/* Swing stays in the list, so it isn't started over (blinking the tag out) when the pointer leaves. */
.tagbtn:hover .tag { animation: swing 1.5s cubic-bezier(.3, .6, .4, 1) both, nudge .7s ease; animation-delay: calc(var(--i, 0) * 70ms), 0s; }
@keyframes swing {
  0% { transform: rotate(-16deg); opacity: 0; }
  12% { opacity: 1; }
  30% { transform: rotate(10deg); }
  52% { transform: rotate(-5deg); }
  72% { transform: rotate(2.5deg); }
  88% { transform: rotate(-1deg); }
  100% { transform: rotate(0); }
}
@keyframes nudge { 30% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 100% { transform: rotate(0); } }
.hang figcaption { display: grid; justify-items: center; gap: 6px; text-align: center; }
.why {
  font-size: .78rem; font-weight: 600; color: var(--muted);
  background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px;
}
.acts { display: flex; gap: 6px; }
.mini {
  min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--paper); font-weight: 700; font-size: .85rem;
}
.mini:hover { border-color: var(--ink); }
.mini.heart[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.empty { color: var(--muted); background: var(--paper); border: 1px dashed var(--line); border-radius: 14px; padding: 16px; }

/* ---------- The stamp ---------- */
.stamp {
  position: absolute; left: 50%; bottom: 3%; z-index: 3;
  transform: translateX(-50%) rotate(-9deg);
  padding: 6px 12px 5px; border: 3.5px solid currentColor; border-radius: 8px;
  font: 800 1.35rem/1 var(--display); font-stretch: 85%; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  pointer-events: none;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, currentColor 18%, transparent);
}
.stamp.small { bottom: 0; font-size: .8rem; padding: 4px 8px 3px; border-width: 2.5px; border-radius: 6px; }
.s-great, .s-good { color: var(--good); }
.s-fine { color: var(--ok); }
.s-again { color: var(--warn); }
.s-dont { color: var(--bad); }
.stamp.thump { animation: thump .45s cubic-bezier(.2, .9, .3, 1.3) .35s both; }
@keyframes thump {
  0% { transform: translateX(-50%) rotate(-9deg) scale(2.2); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translateX(-50%) rotate(-9deg) scale(1); opacity: 1; }
}

/* ---------- Check ---------- */
.check-layout { display: grid; gap: 22px; align-items: start; }
/* A very long one-word name breaks where it has to, rather than pushing the page wider than the phone. */
.check-layout > *, .report > * { min-width: 0; }
.receipt { overflow-wrap: anywhere; }
.engrave { display: block; margin-top: 16px; }
.engrave input {
  width: 100%; min-height: 60px; padding: 0 18px; border-radius: 14px;
  border: 2px solid var(--ink); background: var(--paper-2);
  font: 700 1.6rem/1 var(--display); letter-spacing: .01em;
}
.engrave input::placeholder { color: var(--muted); opacity: .7; }
.engraver .chips { margin-top: 14px; }
.try { margin-top: 16px; color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.try button { border: 0; background: var(--paper-2); border-radius: 999px; padding: 5px 11px; font-weight: 700; font-size: .85rem; color: var(--ink); }
.try button:hover { background: var(--line); }

.report { display: grid; gap: 22px; }
.report-tag { display: grid; justify-items: center; gap: 14px; }
.hang.big { position: relative; width: min(78vw, 260px); padding-bottom: 18px; }
.hang.big .tagbtn, .hang.big > .tag { max-width: none; }
.hang.big .tag { animation: none; }
.hang.big.swing .tag { animation: swing 1.6s cubic-bezier(.3, .6, .4, 1) both; }
.report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(100%, 320px); }
.report-actions .heart { grid-column: 1 / -1; }
.voice {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; padding-left: 16px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 999px;
  font-weight: 700; font-size: .9rem; color: var(--muted);
}
.voice select {
  flex: 1; min-width: 0; min-height: 42px; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink); font: 700 .95rem var(--body);
}
.receipt { padding: 18px 18px 20px; position: relative; }
.verdict { font-size: 1.1rem; padding-bottom: 12px; border-bottom: 1.5px dashed var(--line); }
.verdict strong { font-family: var(--display); font-weight: 800; }
.v-great .verdict strong, .v-good .verdict strong { color: var(--good); }
.v-fine .verdict strong { color: var(--ok); }
.v-again .verdict strong { color: var(--warn); }
.v-dont .verdict strong { color: var(--bad); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks b { font-weight: 700; }
.checks p { color: var(--muted); font-size: .95rem; margin-top: 2px; }
.ico {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font: 800 .85rem/1 var(--body); color: #fff; margin-top: 1px;
}
.c-good .ico { background: var(--good); }
.c-ok .ico { background: var(--ok); }
.c-warn .ico { background: var(--warn); }
.c-bad .ico { background: var(--bad); }
.c-info .ico { background: var(--info); font-style: italic; font-family: Georgia, serif; }
:root:not([data-theme="light"]) .ico { color: var(--paper-2); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .ico { color: #fff; } }
.extras { display: grid; gap: 14px; margin-top: 6px; padding-top: 14px; border-top: 1.5px dashed var(--line); }
.nicks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.nicks span { background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-weight: 600; font-size: .92rem; }
.trouble { margin-top: 6px; font: 800 1.15rem/1.2 var(--display); text-transform: uppercase; letter-spacing: .02em; color: var(--accent); overflow-wrap: anywhere; }
.alts h3 {
  display: inline-block; background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.mini-board { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 10px; }
.hang.small .tagbtn { max-width: 120px; }
.empty-report { justify-items: center; }
.empty-report .hang.big { opacity: .9; }
.empty-report .empty { max-width: 460px; }

/* ---------- Shortlist ---------- */
.list-head { margin-bottom: 26px; }
.list-head .row { margin-top: 14px; }
/* The lift goes on the button, since the tag's own transform is held by its swing-in. */
.hang.lit .tagbtn { transform: translateY(-4px) rotate(2deg); }
.hang.lit .tag { filter: var(--tag-shadow) brightness(1.15); }
/* As with the nudge, swing stays in the list so the tag doesn't swing in again when the next draw starts. */
.hang.picked .tag { animation: swing 1.5s cubic-bezier(.3, .6, .4, 1) both, pick 1s cubic-bezier(.3, .6, .4, 1) both; animation-delay: calc(var(--i, 0) * 70ms), 0s; }
.hang.picked::after {
  content: ''; position: absolute; inset: -6px -4px auto; height: calc(100% - 50px); z-index: -1;
  border-radius: 24px; background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 35%, transparent), transparent);
}
@keyframes pick { 0% { transform: scale(1); } 35% { transform: scale(1.12) rotate(-6deg); } 65% { transform: scale(1.08) rotate(4deg); } 100% { transform: scale(1.06); } }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--chip-on); color: var(--chip-on-ink); font-weight: 700;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { max-width: 520px; margin: 40px auto; padding: 16px; background: var(--paper); border-radius: 12px; }

/* ---------- Wide screens ---------- */
@media (min-width: 960px) {
  .find-layout { grid-template-columns: 400px 1fr; align-items: start; }
  .criteria { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; overscroll-behavior: contain; }
  .criteria .btn.big { display: none; }
  .results { padding-top: 4px; }
  .board { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 30px 18px; }
  .check-layout { grid-template-columns: 380px 1fr; }
  .engraver { position: sticky; top: 76px; }
  .report { grid-template-columns: 260px 1fr; align-items: start; }
  .report .alts { grid-column: 1 / -1; }
  .extras { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1180px) {
  .report { grid-template-columns: 300px 1fr; }
  .hang.big { width: 280px; }
}

/* ---------- Phones: tabs move to the bottom ---------- */
@media (max-width: 719px) {
  .bar { justify-content: center; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--paper); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(60, 40, 15, .1);
  }
  .tabs a { flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .78rem; border-radius: 12px; }
  .tabs a[aria-current="page"] { background: var(--paper-2); color: var(--ink); --tab-fill: var(--paper-2); }
  .tabs .count { position: absolute; top: 2px; left: calc(50% + 8px); }
  main { padding: 16px 16px 40px; }
  .jd-foot { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.65rem; }
  .panel { padding: 18px 16px; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .mini-board { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; }
  .stamp { font-size: 1.2rem; }
  .stamp.small { font-size: .72rem; }
  .chips.seg .chip { padding: 0 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
#results, #report { scroll-margin-top: 76px; }
