/* DCCG Collection (Detective Conan Card Game Collection) - a detective agency's case archive, after hours.
   Navy night and blazer panels keep the cards in focus; the manila case folder is the one bold object;
   bow-tie red is the ink of stamps and alerts. */
:root {
  --night: #0f1834;       /* page: the city outside the agency window */
  --blazer: #1b2a55;      /* raised panels */
  --blazer-2: #22346a;    /* hover, inputs on panels */
  --line: #2e3f75;        /* lines and borders on navy */
  --chalk: #eaeef8;       /* text */
  --fog: #9aa7c7;         /* secondary text */
  --red: #d7263d;         /* bow tie: stamps, alerts */
  --red-ink: #b81d31;     /* stamp ink on manila */
  --manila: #e3c47f;      /* the case folder */
  --manila-2: #d6b266;    /* folder shadow side, tracks */
  --manila-3: #c49d4f;    /* folder lines */
  --ink: #2f240e;         /* text on manila */
  --ink-2: #66532c;       /* secondary text on manila */
  --sky: #7cc3ea;         /* bought, not arrived */

  --display: "Dela Gothic One", "Zen Kaku Gothic New", system-ui, sans-serif;
  --body: "Zen Kaku Gothic New", system-ui, "Hiragino Sans", "Yu Gothic", sans-serif;

  /* type scale, 1.25 steps from 15px */
  --t-xs: .75rem;   /* 12 */
  --t-sm: .8125rem; /* 13 */
  --t-md: .9375rem; /* 15 */
  --t-lg: 1.125rem; /* 18 */
  --t-xl: 1.5rem;   /* 24 */
  --t-2xl: 2rem;    /* 32 */

  --r-s: 6px;       /* controls */
  --r-m: 10px;      /* panels */
  --gap: 1rem;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--night); color: var(--chalk);
  font: 400 var(--t-md)/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--manila); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header: brand and the two pages ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: flex-end; gap: 1.5rem;
  padding: .55rem max(1rem, calc((100vw - 1280px) / 2 + 1rem)) 0;
  background: rgba(15, 24, 52, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 3px solid var(--manila);
}
/* the full title can wrap onto two lines on narrower screens rather than push the tabs off */
.brand { display: flex; align-items: center; gap: .55rem; padding-bottom: .6rem; flex: 0 1 auto; min-width: 0; }
.bowtie { flex: none; }
.bowtie { width: 30px; fill: var(--red); }
.brand h1 { font: var(--t-lg)/1.15 var(--display); margin: 0; letter-spacing: .01em; text-wrap: balance; }
.tabs { display: flex; gap: 4px; min-width: 0; flex: none; }
.tab {
  flex: none; border: 0; cursor: pointer;
  padding: .5rem 1.1rem .42rem; border-radius: 10px 10px 0 0;
  background: var(--blazer); color: var(--fog); font-weight: 700;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 100%, 0 100%);
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--chalk); background: var(--blazer-2); }
.tab[aria-selected="true"] { background: var(--manila); color: var(--ink); }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.status { color: var(--fog); text-align: center; padding: 3rem 1rem; }

/* ---------- page titles ---------- */
.search-head { margin: .25rem 0 1rem; }
.search-head h2 { font: var(--t-2xl)/1.1 var(--display); margin: 0 0 .3rem; letter-spacing: .01em; }
.set-name { margin: 0; color: var(--fog); font-size: var(--t-sm); }

/* ---------- the case folder (Our Collection) ---------- */
.folder { margin: 0 0 1.25rem; }
/* folder tabs: one per player, sitting on top of the folder */
/* tabs wrap onto a second row if there are many players, so no name is ever cut off */
.players { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 3px; padding-left: .75rem; }
.player {
  flex: none; cursor: pointer; border: 0;
  padding: .45rem 1.15rem .35rem; border-radius: 9px 9px 0 0;
  font: var(--t-md)/1.2 var(--display); letter-spacing: .01em;
  background: var(--blazer); color: var(--fog);
  transition: background .15s, color .15s;
}
.player:hover { color: var(--chalk); background: var(--blazer-2); }
.player[aria-pressed="true"] { background: var(--manila); color: var(--ink); }
.folder-body {
  background: var(--manila); color: var(--ink);
  border-radius: 4px var(--r-m) var(--r-m) var(--r-m);
  padding: 1rem 1.25rem 1.15rem;
  box-shadow: 0 1px 0 var(--manila-3) inset, 0 10px 30px rgba(0, 0, 0, .35);
}
.folder-body :focus-visible { outline-color: var(--ink); }

/* set strip, inside the folder: which case */
.sets { display: grid; gap: .45rem; padding: 0 0 .9rem; margin: 0 0 1rem; border-bottom: 1.5px dashed var(--manila-3); }
.set-row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); align-items: start; gap: .75rem; }
.set-row-label { font-size: var(--t-xs); font-weight: 700; color: var(--ink-2); padding-top: .55rem; }
.set-pills { display: flex; flex-wrap: wrap; gap: .35rem; }
.set {
  flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; cursor: pointer;
  border: 1.5px solid var(--manila-3); background: rgba(255, 255, 255, .18); color: var(--ink);
  border-radius: var(--r-s); padding: .3rem .65rem .25rem; min-width: 5.4rem; text-align: left;
  transition: background .15s, border-color .15s;
}
.set:hover { background: rgba(255, 255, 255, .38); }
.set-code { font: var(--t-sm)/1.15 var(--display); letter-spacing: .01em; }
.set-prog { font-size: var(--t-xs); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.set-prog.done { color: var(--red-ink); font-weight: 700; }
.set[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--manila); }
.set[aria-pressed="true"] .set-prog { color: #d9c18a; }
.set[aria-pressed="true"] .set-prog.done { color: #ff9aa6; }

/* case summary */
.file-head { display: flex; align-items: center; gap: 1.4rem; }
.stamp {
  flex: none; display: grid; justify-items: center; gap: .1rem;
  color: var(--red-ink); border: 3px solid var(--red-ink); border-radius: 7px;
  padding: .4rem .7rem .35rem; min-width: 7.2rem; text-align: center;
  transform: rotate(-5deg); background: rgba(215, 38, 61, .06);
  box-shadow: 0 0 0 1.5px rgba(184, 29, 49, .35) inset;
  font-variant-numeric: tabular-nums;
}
.stamp-num { font: var(--t-2xl)/1 var(--display); }
.stamp-num small { font-size: .5em; opacity: .7; }
.stamp-cap { font: var(--t-xs)/1.1 var(--display); letter-spacing: .04em; }
.stamp.solved { background: rgba(215, 38, 61, .12); }
.stamp.solved .stamp-cap { font-size: var(--t-sm); }
/* the one orchestrated moment: completing a set stamps it */
.stamp.thud { animation: thud .42s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes thud {
  0% { transform: rotate(-12deg) scale(1.7); opacity: 0; }
  60% { transform: rotate(-4deg) scale(.94); opacity: 1; }
  100% { transform: rotate(-5deg) scale(1); }
}
.file-meta { flex: 1; min-width: 0; }
.file-title { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .75rem; margin: 0 0 .65rem; }
.file-title .titles { margin-right: auto; min-width: 0; }
.file-meta h2 { font: var(--t-xl)/1.15 var(--display); margin: 0 0 .15rem; letter-spacing: .01em; }
.folder-body .set-name { color: var(--ink-2); }
.goal-wrap { display: flex; align-items: center; gap: .45rem; }
.goal-label { color: var(--ink-2); font-size: var(--t-sm); }
.goal-label::after { content: ":"; }
.goal { display: flex; align-items: center; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; font-size: var(--t-sm); }
.goal button { border: 0; background: transparent; color: var(--ink); padding: .28rem .75rem; cursor: pointer; font-weight: 700; }
.goal button:hover { background: rgba(255, 255, 255, .3); }
.goal button + button { border-left: 1.5px solid var(--ink); }
.goal button[aria-pressed="true"] { background: var(--ink); color: var(--manila); }
.lock {
  flex: none; display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  border-radius: 999px; padding: .26rem .75rem .26rem .6rem; font-size: var(--t-sm); font-weight: 700;
}
.lock svg { width: 15px; height: 15px; fill: currentColor; stroke: currentColor; }
.lock:hover { background: rgba(255, 255, 255, .3); }
.lock.open { color: #fff; background: var(--red-ink); border-color: var(--red-ink); }
.lock.open .shackle { transform: translate(4px, -2px) rotate(18deg); transform-origin: 13px 9px; }
.progress { display: grid; grid-template-columns: 5.4rem 1fr auto; align-items: center; gap: .65rem; margin-top: .35rem; }
.p-label { font-size: var(--t-xs); color: var(--ink); font-weight: 700; }
.p-num { font-size: var(--t-xs); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { display: flex; height: 8px; background: var(--manila-2); border-radius: 4px; overflow: hidden;
  box-shadow: 0 1px 1px rgba(47, 36, 14, .18) inset; }
.bar span { display: block; height: 100%; width: 0; background: var(--ink); transition: width .4s ease; }
.progress.play .fill { background: var(--red-ink); }
.bar .px { background: repeating-linear-gradient(135deg, var(--ink) 0 4px, var(--ink-2) 4px 8px); opacity: .55; }
.file-stats { margin: .55rem 0 0; color: var(--ink); font-size: var(--t-sm); }

/* ---------- filters (both pages) ---------- */
.filters {
  padding: .7rem; background: var(--blazer); border-radius: var(--r-m);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem;
}
.f-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.refine { padding-top: .6rem; border-top: 1px solid var(--line); gap: .5rem .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.filters input[type=search], .filters select {
  background: var(--night); border: 1px solid var(--line); border-radius: var(--r-s);
  padding: .4rem .65rem; min-height: 36px; color: var(--chalk);
}
.filters input[type=search]::placeholder { color: #7482a6; }
.filters input[type=search]:focus, .filters select:focus { border-color: var(--manila); outline: none; box-shadow: 0 0 0 3px rgba(227, 196, 127, .18); }
.filters input[type=search] { flex: 1 1 180px; min-width: 0; }
/* dropdowns: one look everywhere, with room for the arrow so no text runs under it */
.filters select {
  font: inherit; font-size: var(--t-sm); min-width: 0; max-width: 100%; cursor: pointer;
  padding-right: 1.8rem; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%239aa7c7' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .55rem center; background-size: 12px;
}
.filters select:hover { border-color: var(--fog); }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: .38rem .75rem; cursor: pointer; color: var(--fog); font-size: var(--t-sm); }
.seg button:hover { color: var(--chalk); background: var(--blazer-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--chalk); color: var(--night); font-weight: 700; }
.colors { display: flex; gap: 6px; }
.chip {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
  opacity: .5; transition: opacity .15s, transform .15s;
}
.chip:hover { opacity: .85; }
.chip[aria-pressed="true"] { opacity: 1; border-color: var(--chalk); transform: scale(1.08); }
.fchip {
  border: 1px solid var(--line); background: transparent; color: var(--fog); cursor: pointer;
  border-radius: 999px; padding: .2rem .65rem; font-size: var(--t-sm); font-variant-numeric: tabular-nums;
}
.fchip:hover { color: var(--chalk); border-color: var(--fog); }
.fchip[aria-pressed="true"] { background: var(--chalk); border-color: var(--chalk); color: var(--night); font-weight: 700; }
.fchip.more-traits { border-style: dashed; color: var(--manila); }
.fchip.more-traits:hover { border-color: var(--manila); }
.obtain { display: inline-flex; align-items: center; gap: .45rem; font-size: var(--t-sm); color: var(--fog); min-width: 0; max-width: 100%; }
.obtain span { white-space: nowrap; }
.obtain select { min-height: 0; padding-top: .28rem; padding-bottom: .28rem; }
.obtain.on select { border-color: var(--chalk); font-weight: 700; }
.more-btn {
  display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; cursor: pointer;
  border: 1px solid var(--line); background: var(--night); color: var(--chalk);
  border-radius: var(--r-s); padding: .32rem .7rem; font-size: var(--t-sm); font-weight: 700;
}
.more-btn:hover { border-color: var(--fog); }
.more-btn svg { width: 12px; height: 12px; transition: transform .15s; }
.more-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.more-count {
  background: var(--manila); color: var(--ink); border-radius: 999px; min-width: 1.25rem;
  padding: 0 .35rem; font-size: var(--t-xs); line-height: 1.25rem; text-align: center;
}
.clear-btn { border: 0; background: transparent; color: var(--manila); cursor: pointer; font-size: var(--t-sm); text-decoration: underline; text-underline-offset: 3px; padding: .2rem; }
.more-panel { display: grid; gap: .5rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.f-line { display: grid; grid-template-columns: 4rem minmax(0, 1fr); align-items: start; gap: .6rem; }
.f-label { font-size: var(--t-xs); font-weight: 700; color: var(--fog); padding-top: .25rem; }

/* Card Search: the search box leads, with a magnifying glass */
.s-top { gap: .6rem; }
.s-search { position: relative; flex: 1 1 320px; min-width: 0; display: flex; }
.s-search svg {
  position: absolute; left: .75rem; top: 50%; width: 20px; height: 20px; transform: translateY(-50%);
  fill: none; stroke: var(--manila); stroke-width: 2.2; stroke-linecap: round; pointer-events: none;
}
.filters .s-search input[type=search] { flex: 1; min-height: 44px; padding-left: 2.6rem; font-size: var(--t-md); }
.s-sel { display: inline-flex; align-items: center; gap: .45rem; color: var(--fog); font-size: var(--t-sm); min-width: 0; }
.s-top #sSet { max-width: 22rem; }
.s-top select { min-height: 44px; }
.s-opts { gap: .4rem 1.2rem; }
.s-check { display: inline-flex; align-items: center; gap: .45rem; color: var(--fog); font-size: var(--t-sm); cursor: pointer; min-height: 28px; }
.s-check:hover { color: var(--chalk); }
.s-check input { accent-color: var(--manila); width: 16px; height: 16px; margin: 0; }
.s-unique select { min-height: 0; padding-top: .28rem; padding-bottom: .28rem; }
.s-unique.on select { border-color: var(--chalk); font-weight: 700; }

/* ---------- result line and bulk buttons ---------- */
.count-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem .75rem;
  flex-wrap: wrap; margin: 1rem .1rem .6rem; }
.count, #sCount { color: var(--fog); font-size: var(--t-sm); margin: 0; min-width: 0; }
#sCount { margin: 1rem .1rem .6rem; }
.bulk { display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; }
.bulk-label { color: var(--fog); font-size: var(--t-sm); white-space: nowrap; }
.bulk button {
  font-size: var(--t-sm); font-weight: 700; min-width: 2.75rem; min-height: 32px; padding: .25rem .65rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--blazer); color: var(--chalk); cursor: pointer;
}
.bulk button:hover { border-color: var(--manila); color: var(--manila); }
.bulk button:disabled { opacity: .4; cursor: default; color: var(--fog); border-color: var(--line); }

/* ---------- card grids ---------- */
.grid, .s-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .75rem .6rem; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
}
/* long grids: let the browser skip drawing tiles that are off screen */
.grid > li, .s-grid > li { content-visibility: auto; contain-intrinsic-size: auto 230px; }
.card { position: relative; }
.card .art {
  display: block; width: 100%; padding: 0; border: 0; background: var(--blazer);
  border-radius: var(--r-s); overflow: hidden; cursor: pointer; aspect-ratio: 63 / 88;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .2s, opacity .2s; }
.card.case img, .s-card.case img { object-fit: contain; }
/* not collected: a grey photocopy in the file */
.card.missing img { filter: grayscale(1) brightness(.5) contrast(1.05); }
.card.missing .art { box-shadow: none; }
.card .meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 5px; }
.card .num { font-size: var(--t-xs); color: var(--fog); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qty { display: flex; align-items: center; background: var(--blazer); border-radius: var(--r-s); }
.qty button {
  border: 0; background: transparent; width: 26px; height: 26px; cursor: pointer;
  color: var(--chalk); font-size: 1rem; line-height: 1; border-radius: var(--r-s);
}
.qty button:hover { background: var(--blazer-2); }
.qty button:disabled { opacity: .3; cursor: default; background: transparent; }
.qty output { min-width: 1.5ch; text-align: center; font-weight: 700; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.card .badge {
  position: absolute; top: 5px; right: 5px; pointer-events: none;
  background: var(--red); color: #fff; font: var(--t-xs)/1 var(--display);
  padding: .25rem .4rem; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}
.ps {
  position: absolute; right: 5px; bottom: 36px; cursor: help;
  font: 700 .6875rem/1 var(--body); padding: .25rem .4rem; border-radius: 4px;
  background: rgba(15, 24, 52, .9); color: var(--chalk); font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}
.ps.done { background: var(--chalk); color: var(--night); }
.ps-p {
  display: inline-block; margin-left: .25rem; padding: 0 .22rem; border-radius: 3px;
  background: var(--manila); color: var(--ink); font-size: .625rem; line-height: 1.35;
}
/* proxy tag on the tile: always shown when set, otherwise on hover/focus (and faintly on touch screens) */
.proxy-tag {
  position: absolute; top: 5px; left: 5px; border: 0; cursor: pointer;
  font: 700 .6875rem/1 var(--body); padding: .3rem .45rem; border-radius: 4px;
  background: rgba(15, 24, 52, .88); color: var(--chalk); box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  opacity: 0; transition: opacity .15s;
}
.card:hover .proxy-tag, .proxy-tag:focus-visible { opacity: 1; }
@media (hover: none) { .card.missing .proxy-tag { opacity: .7; } }
.proxy-tag.on { opacity: 1; background: var(--manila); color: var(--ink); }
.card.proxied .art { outline: 2px dashed var(--manila); outline-offset: -2px; }
.card.proxied img { filter: saturate(.75); }
.bought-tag {
  position: absolute; left: 5px; bottom: 36px; pointer-events: none;
  font: 700 .6875rem/1 var(--body); padding: .3rem .45rem; border-radius: 4px;
  background: var(--sky); color: var(--night); box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}
.card.bought .art { outline: 2px solid var(--sky); outline-offset: -2px; }

/* Card Search tiles */
.s-card { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; border-radius: var(--r-s); }
.s-card img {
  display: block; width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: var(--r-s);
  background: var(--blazer); box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .15s, box-shadow .15s;
}
.s-card:hover img { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0, 0, 0, .45); }
.s-card:focus-visible { outline: 2px solid var(--manila); outline-offset: 3px; }
.s-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 6px; margin-top: 6px; font-size: var(--t-xs); color: var(--fog); font-variant-numeric: tabular-nums; }
.s-set { margin-left: auto; text-align: right; }
.s-name { display: block; margin-top: 1px; font-size: var(--t-sm); font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.s-more { display: flex; justify-content: center; margin: 1.5rem 0 .5rem; }
.s-more .more-btn { margin: 0; padding: .55rem 1.3rem; font-size: var(--t-md); min-height: 44px; }

/* ---------- card popup ---------- */
dialog {
  border: 0; padding: 0; border-radius: 14px; max-width: min(880px, 94vw); width: 100%;
  max-height: calc(100dvh - 2rem); overflow: auto; overscroll-behavior: contain;
  background: var(--blazer); color: var(--chalk); box-shadow: 0 24px 70px rgba(0, 0, 0, .65);
  border-top: 5px solid var(--manila);
}
dialog::backdrop { background: rgba(6, 10, 24, .78); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.d-close { position: sticky; top: 0; height: 0; margin: 0; z-index: 2; display: flex; justify-content: flex-end; }
.d-close button {
  border: 0; background: rgba(15, 24, 52, .7); font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--fog);
  width: 40px; height: 40px; border-radius: 50%; margin: .5rem .5rem 0 0;
}
.d-close button:hover { color: var(--chalk); background: var(--night); }
.d-body { display: grid; grid-template-columns: minmax(200px, 310px) 1fr; gap: 1.5rem; padding: 1.4rem; }
.d-body > img { width: 100%; border-radius: 10px; align-self: start; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); position: sticky; top: 1.4rem; }
.d-num { white-space: pre; margin: 0; color: var(--manila); font-weight: 700; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.d-info { min-width: 0; }
.d-info h3 { font: var(--t-xl)/1.25 var(--display); margin: .15rem 2.5rem .75rem 0; letter-spacing: .01em; }
.d-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 0 0 .9rem; }
.d-tabs button {
  border: 0; background: transparent; color: var(--fog); cursor: pointer; font-weight: 700;
  padding: .5rem .85rem; margin-bottom: -1px; border-bottom: 3px solid transparent;
}
.d-tabs button:hover { color: var(--chalk); }
.d-tabs button[aria-selected="true"] { color: var(--chalk); border-bottom-color: var(--manila); }
#detail.search .d-tabs { display: none; }
.d-panel { min-height: 14rem; }
.d-who-label { color: var(--fog); font-size: var(--t-sm); margin: -.3rem 0 .4rem; }
.d-play { margin: -.15rem 0 .75rem; font-size: var(--t-sm); line-height: 1.6; }
.d-counts { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .4rem; }
.d-qty { display: flex; align-items: center; gap: .5rem; }
.d-label { font-size: var(--t-sm); color: var(--fog); min-width: 5.5rem; }
.d-qty button {
  width: 38px; height: 38px; border-radius: var(--r-s); border: 1px solid var(--line);
  background: var(--night); cursor: pointer; font-size: 1.15rem;
}
.d-qty button:hover { border-color: var(--manila); }
.d-qty button:disabled { opacity: .35; cursor: default; }
.d-qty output { font: var(--t-xl) var(--display); min-width: 2ch; text-align: center; }
.d-qty.bought output { color: var(--sky); }
.d-qty.proxy { cursor: pointer; min-height: 38px; }
.d-qty .d-received {
  width: auto; padding: 0 .8rem; font-size: var(--t-sm); font-weight: 700;
  background: var(--sky); color: var(--night); border-color: var(--sky);
}
.switch {
  appearance: none; width: 42px; height: 24px; border-radius: 12px; margin: 0 .2rem 0 0; cursor: pointer;
  background: var(--line); position: relative; transition: background .15s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--chalk); transition: transform .15s;
}
.switch:checked { background: var(--manila); }
.switch:checked::after { transform: translateX(18px); }
.d-switch-text { font-size: var(--t-sm); color: var(--fog); }
.d-hint { margin: 0 0 1rem; font-size: var(--t-xs); color: var(--fog); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; font-size: var(--t-sm); }
dt { color: var(--fog); }
dd { margin: 0; overflow-wrap: anywhere; }
.d-text { font-size: var(--t-sm); line-height: 1.7; white-space: pre-line; }
.d-text p { margin: 0 0 .6rem; padding: .65rem .8rem; background: var(--night); border-radius: var(--r-s); border-left: 3px solid var(--manila); }
.d-text a { color: var(--manila); }
.d-text details { margin-top: .4rem; }
.d-text summary { cursor: pointer; color: var(--manila); font-weight: 700; }
.d-section { margin-top: 1.1rem; }
.d-section h4 { font: var(--t-md) var(--display); margin: 0 0 .25rem; letter-spacing: .01em; }
#dAllPrintings:not(:empty) { margin-top: 1.25rem; padding-top: .25rem; border-top: 1px solid var(--line); }
.d-others-note { margin: 0 0 .55rem; font-size: var(--t-sm); color: var(--fog); }
.d-others { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
.other { position: relative; display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; color: inherit; }
.other img { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 5px; display: block; }
.other.case img { object-fit: contain; background: var(--night); }
.other.missing img { filter: grayscale(1) brightness(.5); }
.other:hover img { outline: 2px solid var(--manila); outline-offset: 1px; }
.other.ref img { outline: 1px dashed var(--fog); outline-offset: 1px; }
.other.current img { outline: 2px solid var(--manila); outline-offset: 1px; }
.o-here {
  position: absolute; top: 4px; left: 4px; padding: .1rem .3rem; border-radius: 3px;
  background: var(--manila); color: var(--ink); font-size: .625rem; font-weight: 700; line-height: 1.2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.o-num { display: block; font-size: var(--t-xs); color: var(--fog); margin-top: 3px; font-variant-numeric: tabular-nums; }
.o-qty { display: block; font-size: var(--t-xs); font-weight: 700; }
.other.missing .o-qty { color: var(--fog); font-weight: 400; }
#detail.ref .d-counts, #detail.ref .d-hint, #detail.ref .d-owners, #detail.ref #dWho { display: none; }
.d-owners h4 { margin-bottom: .4rem; }
.d-owners ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.d-owners li { background: var(--night); border-radius: 999px; padding: .2rem .7rem; font-size: var(--t-sm); }
.d-owners li.proxy-only { border: 1px dashed var(--manila); color: var(--manila); }
.d-owners li.none { color: var(--fog); background: transparent; padding-left: 0; }

/* ---------- PIN prompt ---------- */
.pin-dlg { max-width: min(380px, 92vw); }
.pin-dlg form { padding: 1.35rem 1.4rem 1.2rem; }
.pin-dlg h3 { font: var(--t-lg)/1.25 var(--display); margin: 0 0 .4rem; }
.pin-help { margin: 0 0 1.1rem; color: var(--fog); font-size: var(--t-sm); }
.pin-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .65rem; }
.pin-row span { width: 3.2rem; color: var(--fog); font-size: var(--t-sm); }
.pin-row input {
  flex: 1; min-width: 0; background: var(--night); border: 1px solid var(--line); border-radius: 8px;
  padding: .55rem .7rem; font: var(--t-xl)/1 var(--display); letter-spacing: .45em; text-align: center;
}
.pin-row input:focus { border-color: var(--manila); outline: none; box-shadow: 0 0 0 3px rgba(227, 196, 127, .18); }
.pin-msg { min-height: 1.3em; margin: .2rem 0 .75rem; color: #ff8f9c; font-size: var(--t-sm); }
.pin-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.pin-actions button {
  border: 1px solid var(--manila); background: var(--manila); color: var(--ink);
  font-weight: 700; border-radius: 8px; padding: .5rem 1.1rem; min-height: 40px; cursor: pointer;
}
.pin-actions button.ghost { background: transparent; color: var(--chalk); border-color: var(--line); }
.pin-actions button.ghost:hover { border-color: var(--fog); }
.pin-actions button:disabled { opacity: .6; cursor: default; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translate(-50%, 160%);
  background: var(--chalk); color: var(--night); padding: .6rem 1rem; border-radius: 10px;
  font-weight: 700; font-size: var(--t-sm); transition: transform .25s; z-index: 20; max-width: 92vw;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45); visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.error { background: var(--red); color: #fff; }
.toast-act {
  font-weight: 800; margin-left: .75rem; padding: .15rem .65rem; border-radius: 6px;
  border: 1.5px solid currentColor; background: transparent; color: inherit; cursor: pointer;
}

/* ---------- tablets ---------- */
@media (max-width: 900px) {
  .top { gap: 1rem; }
  .brand h1 { font-size: var(--t-md); }
  .set-row { grid-template-columns: 6.2rem minmax(0, 1fr); }
  .d-body { grid-template-columns: minmax(170px, 240px) 1fr; gap: 1.1rem; padding: 1.1rem; }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  main { padding: 1rem .75rem 2.5rem; }
  /* one slim row: bow tie and the two pages */
  .top { gap: .75rem; padding: .45rem .75rem 0; align-items: flex-end; }
  .brand { padding-bottom: .55rem; }
  .brand h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bowtie { width: 28px; }
  .tabs { flex: 1; }
  .brand { flex: none; }
  .tab { flex: 1; padding: .5rem .5rem .42rem; text-align: center; }
  .search-head h2 { font-size: var(--t-xl); }

  /* folder */
  .players { padding-left: .4rem; gap: 2px; }
  .player { padding: .4rem .7rem .3rem; font-size: var(--t-sm); }
  .folder-body { padding: .8rem .8rem .95rem; border-radius: 4px var(--r-m) var(--r-m) var(--r-m); }
  .sets { gap: .5rem; padding-bottom: .75rem; margin-bottom: .85rem; }
  .set-row { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
  .set-row-label { padding-top: 0; }
  .set-pills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; }
  .set { min-width: 0; padding: .25rem .4rem .2rem; }
  .set-code { font-size: var(--t-xs); }
  /* the stamp sits in the corner beside the title, so the summary stays short */
  .file-head { display: block; position: relative; }
  .stamp { position: absolute; top: 0; right: 0; min-width: 0; padding: .25rem .5rem .2rem; transform: rotate(-4deg); }
  .stamp-num { font-size: var(--t-lg); }
  .stamp-cap { font-size: .625rem; }
  .stamp.solved .stamp-cap { font-size: .6875rem; }
  .file-title .titles { padding-right: 6.5rem; min-height: 3.2rem; }
  .file-meta h2 { font-size: var(--t-lg); }
  .file-title { gap: .5rem; }
  .file-title .titles { flex: 1 1 100%; }
  .progress { grid-template-columns: 4.6rem 1fr; row-gap: .1rem; }
  .p-num { grid-column: 2; white-space: normal; }

  /* filters */
  .seg { width: 100%; min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seg button { padding: .45rem .3rem; border-left: 0; }
  .seg button:not(:nth-child(3n + 1)) { border-left: 1px solid var(--line); }
  .seg button:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .obtain { flex: 1 0 100%; flex-direction: column; align-items: stretch; gap: .25rem; }
  .obtain select { width: 100%; }
  .more-btn { margin-left: 0; }
  .f-line { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
  .s-search { flex-basis: 100%; }
  .s-top .s-sel, .s-opts .s-unique { flex: 1 1 100%; }
  .s-top .s-sel select, .s-top #sSet, .s-unique select { flex: 1; width: 100%; max-width: none; }

  /* grids */
  .grid, .s-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem .45rem; }
  .card .meta { gap: 2px; }
  .card .num { min-width: 0; font-size: .6875rem; }
  .qty button { width: 24px; height: 28px; }
  .bulk { margin-left: 0; }

  /* popup: a sheet from the bottom */
  dialog#detail { max-width: 100vw; width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  dialog#detail[open] { animation: sheet .22s ease-out; }
  @keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .d-body { grid-template-columns: 1fr; padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); }
  .d-body > img { max-width: 220px; justify-self: center; position: static; }
  .d-others { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
