/* Lorcana Collection - a deck-builder's ledger, lit by ink.
   Deep ink-violet keeps the card art in focus; gold marks what's active; the hexagonal inkwell gauge,
   filling as playsets complete, is the one bold object. */
:root {
  --night: #15112b;       /* page */
  --panel: #221c40;       /* raised panels */
  --panel-2: #2c2552;     /* hover, inputs on panels */
  --line: #3a3166;        /* lines and borders */
  --text: #eeeaf8;
  --muted: #a79fc6;
  --gold: #d8b25c;        /* active, accents */
  --gold-2: #f0d58c;      /* light gold */
  --gold-ink: #2a2008;    /* text on gold */
  --good: #6fd3a5;        /* playset complete */
  --red: #e0475e;         /* errors */

  /* the six inks */
  --amber: #f2af00; --amethyst: #9b4a91; --emerald: #2a9a3c; --ruby: #e0132f; --sapphire: #068bc6; --steel: #a3abb8;

  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --t-xs: .75rem; --t-sm: .8125rem; --t-md: .9375rem; --t-lg: 1.125rem; --t-xl: 1.5rem; --t-2xl: 2rem;
  --r-s: 6px; --r-m: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--night); color: var(--text); 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(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: var(--gold-2); }

/* ---------- header ---------- */
.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(21, 17, 43, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: .55rem; padding-bottom: .6rem; flex: 0 1 auto; min-width: 0; color: var(--gold); }
.mark { width: 28px; height: 28px; flex: none; }
.brand h1 { font: 700 var(--t-lg)/1.15 var(--display); margin: 0; color: var(--text); letter-spacing: .005em; }
.tabs { display: flex; gap: 4px; flex: none; }
.tab {
  flex: none; border: 0; cursor: pointer; padding: .5rem 1.1rem .45rem; border-radius: 10px 10px 0 0;
  background: var(--panel); color: var(--muted); font-weight: 800;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab[aria-selected="true"] { background: var(--gold); color: var(--gold-ink); }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.status { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.page-head { margin: .25rem 0 1rem; }
.page-head h2 { font: 700 var(--t-2xl)/1.1 var(--display); margin: 0 0 .3rem; }
.sub { margin: 0; color: var(--muted); font-size: var(--t-sm); }

.foot { max-width: 1280px; margin: 0 auto; padding: 1rem 1rem 2rem; border-top: 1px solid var(--line); }
.foot p { margin: 0; max-width: 70ch; color: var(--muted); font-size: var(--t-xs); line-height: 1.6; }

/* ---------- the ledger (Our Collection) ---------- */
.ledger { margin: 0 0 1.25rem; }
.players { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .6rem; }
.player {
  flex: none; cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: .35rem 1rem; border-radius: 999px; font-weight: 800;
}
.player:hover { color: var(--text); border-color: var(--muted); }
.player[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.ledger-body {
  background: linear-gradient(180deg, #282050, var(--panel)); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 1rem 1.25rem 1.15rem; box-shadow: 0 12px 34px rgba(0, 0, 0, .35);
}
.tracked { display: flex; align-items: flex-start; gap: .5rem .75rem; flex-wrap: wrap; padding-bottom: .9rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.sets { display: flex; flex-wrap: wrap; gap: .4rem; flex: 1 1 auto; min-width: 0; }
.set {
  flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; cursor: pointer; text-align: left;
  border: 1px solid var(--line); background: var(--night); color: var(--text); border-radius: var(--r-s);
  padding: .3rem .65rem .25rem; min-width: 5.5rem; max-width: 12rem; transition: border-color .15s, background .15s;
}
.set:hover { border-color: var(--muted); }
.set-code { font: 700 var(--t-sm)/1.2 var(--display); }
.set-prog { font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.set-prog.done { color: var(--good); font-weight: 800; }
.set[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.set[aria-pressed="true"] .set-prog { color: #5a4613; }
.set[aria-pressed="true"] .set-prog.done { color: #1d5c3f; }
.edit-sets {
  flex: none; cursor: pointer; border: 1px dashed var(--gold); background: transparent; color: var(--gold-2);
  border-radius: var(--r-s); padding: .45rem .8rem; font-weight: 800; font-size: var(--t-sm); min-height: 40px;
}
.edit-sets:hover { background: rgba(216, 178, 92, .12); }
.no-sets { color: var(--muted); font-size: var(--t-sm); margin: .45rem 0 0; }

.file-head { display: flex; align-items: center; gap: 1.4rem; }
/* the inkwell gauge: ink rises inside a gold hexagon as playsets complete */
.gauge { position: relative; width: 92px; flex: none; }
.gauge svg { display: block; width: 100%; height: auto; }
.g-rim { fill: none; stroke: var(--gold); stroke-width: 4; }
.g-ink { fill: url(#gaugeFill); transition: transform .6s ease; }
.g-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  font: 700 var(--t-lg)/1.05 var(--display); color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); font-variant-numeric: tabular-nums; }
.g-text small { display: block; font: 800 .625rem/1.2 var(--body); opacity: .9; }
.gauge.full .g-rim { stroke: var(--gold-2); stroke-width: 5; filter: drop-shadow(0 0 6px rgba(240, 213, 140, .55)); }
.gauge.none .g-ink { display: none; }
.file-meta { flex: 1; min-width: 0; }
.file-title { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .75rem; margin: 0 0 .6rem; }
.titles { margin-right: auto; min-width: 0; }
.file-meta h2 { font: 700 var(--t-xl)/1.15 var(--display); margin: 0 0 .1rem; }
.lock {
  flex: none; display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--night); color: var(--text);
  border-radius: 999px; padding: .3rem .8rem .3rem .65rem; font-size: var(--t-sm); font-weight: 800; min-height: 36px;
}
.lock svg { width: 15px; height: 15px; fill: currentColor; stroke: currentColor; }
.lock:hover { border-color: var(--muted); }
.lock.open { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.lock.open .shackle { transform: translate(4px, -2px) rotate(18deg); transform-origin: 13px 9px; }
.progress { display: grid; grid-template-columns: 5rem 1fr auto; align-items: center; gap: .65rem; }
.p-label { font-size: var(--t-xs); font-weight: 800; }
.p-num { font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 8px; background: var(--night); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .4s ease; }
.file-stats { margin: .55rem 0 0; font-size: var(--t-sm); }

/* ---------- filters ---------- */
.filters { padding: .7rem; background: var(--panel); 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); }
.main-lines { display: grid; gap: .5rem; }
.refine-actions { gap: .5rem .9rem; }
.refine-actions .more-btn { margin-left: 0; }
.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(--text);
}
.filters input[type=search]::placeholder { color: #8279a8; }
.filters input[type=search]:focus, .filters select:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(216, 178, 92, .2); }
.filters input[type=search] { flex: 1 1 180px; min-width: 0; }
.filters select {
  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='%23a79fc6' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .55rem center; background-size: 12px;
}
.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(--muted); font-size: var(--t-sm); }
.seg button:hover { color: var(--text); background: var(--panel-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--night); font-weight: 800; }
/* ink chips: the ink's hexagon icon and its name; chosen inks glow in their colour */
.fchip.ink-chip { display: inline-flex; align-items: center; gap: .4rem; padding-left: .3rem; }
/* cost hexagons: the number on the plain hexagon symbol */
.cost-chip { border: 0; padding: 2px; background: none; cursor: pointer; border-radius: 8px; opacity: .8; transition: opacity .15s, transform .15s, filter .15s; }
.cost-chip:hover { opacity: 1; }
.cost-chip[aria-pressed="true"] { opacity: 1; transform: scale(1.12); filter: drop-shadow(0 0 6px rgba(240, 213, 140, .8)); }
.cost-hex { display: grid; place-items: center; width: 34px; height: 34px; background: url(symbols/uninkable.webp) center / contain no-repeat;
  color: #fff; font: 800 var(--t-sm)/1 var(--body); font-variant-numeric: tabular-nums; }
.cost-chip[aria-pressed="true"] .cost-hex { color: var(--gold-2); }
.cost-hex.sm { width: 26px; height: 26px; font-size: var(--t-xs); }
.cost-hex.wide { font-size: .6875rem; letter-spacing: -.02em; }   /* "10+" fits inside the hexagon */
/* inkwell symbols */
.fchip.iw-chip { display: inline-flex; align-items: center; gap: .35rem; padding-left: .35rem; }
.iw-icon { flex: none; display: block; }
.iw-name { display: inline-flex; align-items: center; gap: .4rem; }
/* illustrator search */
.art-pick { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-width: 0; }
.art-box { position: relative; flex: 0 1 20rem; min-width: 0; }
.filters .art-box input[type=search] { width: 100%; min-height: 36px; }
.art-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 6; list-style: none; margin: 0; padding: .3rem;
  max-height: 280px; overflow: auto; overscroll-behavior: contain;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-s); box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}
.art-list li { display: flex; justify-content: space-between; gap: .75rem; padding: .45rem .55rem; border-radius: 5px; cursor: pointer; font-size: var(--t-sm); }
.art-list li:hover, .art-list li[aria-selected="true"] { background: var(--gold); color: var(--gold-ink); }
.art-list li .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.art-list li:hover .n, .art-list li[aria-selected="true"] .n { color: #5a4613; }
.art-list li.more { cursor: default; color: var(--muted); font-size: var(--t-xs); }
.art-list li.more:hover { background: none; color: var(--muted); }
.art-hint { font-size: var(--t-xs); color: var(--muted); }

/* rarity symbols beside rarity names */
.fchip.rar-chip { display: inline-flex; align-items: center; gap: .35rem; padding-left: .4rem; }
.rar-icon { flex: none; display: block; object-fit: contain; }
.rar-tag { display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; min-width: 0; }
.tag-special { display: inline-flex; align-items: center; gap: .25rem; }
.ink-icon { width: 20px; height: 20px; flex: none; display: block; }
.fchip.ink-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 28%, var(--night)); border-color: var(--c); color: var(--text);
  box-shadow: 0 0 0 1px var(--c), 0 0 12px color-mix(in srgb, var(--c) 45%, transparent); }
.fchip {
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
  border-radius: 999px; padding: .2rem .65rem; font-size: var(--t-sm); font-variant-numeric: tabular-nums;
}
.fchip:hover { color: var(--text); border-color: var(--muted); }
.fchip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--night); font-weight: 800; }
.fchip.more-traits { border-style: dashed; color: var(--gold-2); }
.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(--text);
  border-radius: var(--r-s); padding: .32rem .7rem; font-size: var(--t-sm); font-weight: 800;
}
.more-btn:hover { border-color: var(--muted); }
.more-btn svg { width: 12px; height: 12px; transition: transform .15s; }
.more-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.more-count { background: var(--gold); color: var(--gold-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(--gold-2); 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: 6.5rem minmax(0, 1fr); align-items: start; gap: .6rem; }
.f-label { font-size: var(--t-xs); font-weight: 800; color: var(--muted); padding-top: .25rem; }
.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(--gold); 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(--muted); font-size: var(--t-sm); min-width: 0; }
.s-top select { min-height: 44px; }
.s-top #sSet { max-width: 22rem; }
.s-opts { gap: .4rem 1.2rem; }
.s-check { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: var(--t-sm); cursor: pointer; min-height: 28px; }
.s-check:hover { color: var(--text); }
.s-check input { accent-color: var(--gold); width: 16px; height: 16px; margin: 0; }

/* ---------- result line and bulk ---------- */
.count-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem .75rem; flex-wrap: wrap; margin: 1rem .1rem .6rem; }
.count { color: var(--muted); font-size: var(--t-sm); margin: 0; }
#sCount { margin: 1rem .1rem .6rem; }
.bulk { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .4rem .8rem; margin-left: auto; }
.bulk-label { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; }
.bulk-pair { display: inline-flex; align-items: center; gap: .3rem; }
.bulk-fin { font-size: var(--t-xs); font-weight: 800; color: var(--muted); }
.bulk button {
  font-size: var(--t-sm); font-weight: 800; min-width: 2.6rem; min-height: 32px; padding: .2rem .55rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer;
}
.bulk button:hover { border-color: var(--gold); color: var(--gold-2); }
.bulk button:disabled { opacity: .4; cursor: default; color: var(--muted); border-color: var(--line); }

/* ---------- card grids ---------- */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem .6rem; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.grid > li { content-visibility: auto; contain-intrinsic-size: auto 290px; }
.card { position: relative; }
.card .art { display: block; width: 100%; padding: 0; border: 0; background: var(--panel); border-radius: 7px; overflow: hidden; cursor: pointer; aspect-ratio: 488 / 681; box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }
.card .art img, .s-card > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.none .art img { filter: grayscale(1) brightness(.5); }
.card.none .art { box-shadow: none; }
.card .meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin: 5px 0 3px; font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.card .meta .rar { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counts { display: grid; gap: 3px; }
.qty { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; background: var(--panel); border-radius: var(--r-s); padding-left: .45rem; }
.qty .fin { font-size: .6875rem; font-weight: 800; color: var(--muted); }
.qty .fin.foil { color: var(--gold-2); }
.qty button { border: 0; background: transparent; width: 26px; height: 26px; cursor: pointer; font-size: 1rem; line-height: 1; border-radius: var(--r-s); }
.qty button:hover { background: var(--panel-2); }
.qty button:disabled { opacity: .3; cursor: default; background: transparent; }
.qty output { min-width: 1.6ch; text-align: center; font-weight: 800; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.ps {
  position: absolute; top: 6px; right: 6px; pointer-events: none; font: 800 .6875rem/1 var(--body); padding: .28rem .42rem; border-radius: 4px;
  background: rgba(21, 17, 43, .92); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .5); font-variant-numeric: tabular-nums;
}
.ps.done { background: var(--good); color: #0d2a1d; }
.tag-special {
  position: absolute; top: 6px; left: 6px; pointer-events: none; font: 800 .625rem/1 var(--body); padding: .28rem .42rem; border-radius: 4px;
  background: var(--gold); color: var(--gold-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.s-card { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; border-radius: 7px; }
.s-card > img { aspect-ratio: 488 / 681; border-radius: 7px; background: var(--panel); box-shadow: 0 3px 8px rgba(0, 0, 0, .4); transition: transform .15s; height: auto; }
.s-card:hover > img { transform: translateY(-2px); }
.s-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 6px; margin-top: 6px; font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.s-name { display: block; margin-top: 1px; font-size: var(--t-sm); font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.s-ver { display: block; font-size: var(--t-xs); color: var(--muted); line-height: 1.3; }
.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(900px, 94vw); width: 100%; max-height: calc(100dvh - 2rem); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); color: var(--text); box-shadow: 0 24px 70px rgba(0, 0, 0, .65); border-top: 4px solid var(--gold); }
dialog::backdrop { background: rgba(8, 6, 20, .8); 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(21, 17, 43, .75); font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); width: 40px; height: 40px; border-radius: 50%; margin: .5rem .5rem 0 0; }
.d-close button:hover { color: var(--text); background: var(--night); }
.d-body { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 1.5rem; padding: 1.4rem; }
.d-body > img { width: 100%; border-radius: 12px; align-self: start; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); position: sticky; top: 1.4rem; aspect-ratio: 488 / 681; }
.d-num { margin: 0; color: var(--gold-2); font-weight: 800; font-size: var(--t-sm); }
.d-info { min-width: 0; }
.d-info h3 { font: 700 var(--t-xl)/1.2 var(--display); margin: .15rem 2.5rem .9rem 0; }
.d-info h3 small { display: block; font: 600 var(--t-md)/1.35 var(--body); color: var(--muted); margin-top: .15rem; }
.d-counts { display: grid; gap: .5rem; margin-bottom: 1rem; }
.d-counts:empty { display: none; }
.d-play { font-size: var(--t-sm); margin: 0; }
.d-play.done { color: var(--good); font-weight: 800; }
.d-qty { display: flex; align-items: center; gap: .5rem; }
.d-label { font-size: var(--t-sm); color: var(--muted); min-width: 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(--gold); }
.d-qty button:disabled { opacity: .35; cursor: default; }
.d-qty output { font: 700 var(--t-xl) var(--display); min-width: 2ch; text-align: center; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; font-size: var(--t-sm); }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.ink-name { display: inline-flex; align-items: center; gap: .35rem; margin-right: .6rem; }
.ink-name .ink-icon { width: 18px; height: 18px; }
.d-text p { margin: 0 0 .6rem; padding: .65rem .8rem; background: var(--night); border-radius: var(--r-s); border-left: 3px solid var(--gold); font-size: var(--t-sm); line-height: 1.7; white-space: pre-line; }
.d-text p.flavor { border-left-color: var(--line); color: var(--muted); font-style: italic; }
.sym { display: inline-block; padding: 0 .35em; margin: 0 .1em; border-radius: 4px; background: var(--panel-2); color: var(--gold-2); font-size: .85em; font-weight: 800; font-style: normal; }
.d-section { margin-top: 1.1rem; }
.d-section h4 { font: 700 var(--t-md) var(--display); margin: 0 0 .3rem; }
.d-note { margin: 0 0 .55rem; font-size: var(--t-sm); color: var(--muted); }
.d-others { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(84px, 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: 488 / 681; object-fit: cover; border-radius: 6px; display: block; }
.other:hover > img, .other.current > img { outline: 2px solid var(--gold); outline-offset: 1px; }
.other.none > img { filter: grayscale(1) brightness(.5); }
.o-here { position: absolute; top: 4px; left: 4px; padding: .1rem .3rem; border-radius: 3px; background: var(--gold); color: var(--gold-ink); font-size: .625rem; font-weight: 800; }
.o-num { display: block; font-size: var(--t-xs); color: var(--muted); margin-top: 3px; }
.o-qty { display: block; font-size: var(--t-xs); font-weight: 800; }
.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.none { color: var(--muted); background: transparent; padding-left: 0; }

/* ---------- tracked sets and PIN dialogs ---------- */
.pin-dlg { max-width: min(380px, 92vw); }
.sets-dlg { max-width: min(560px, 94vw); }
.pin-dlg form, .sets-dlg form { padding: 1.35rem 1.4rem 1.2rem; }
.pin-dlg h3, .sets-dlg h3 { font: 700 var(--t-lg)/1.25 var(--display); margin: 0 0 .4rem; }
.pin-help { margin: 0 0 1rem; color: var(--muted); font-size: var(--t-sm); }
.sets-list { display: grid; gap: 1rem; margin-bottom: 1rem; }
/* keep Save in reach while scrolling a long list */
.sets-dlg .pin-actions { position: sticky; bottom: 0; margin: 0 -1.4rem -1.2rem; padding: .75rem 1.4rem calc(.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(34, 28, 64, .85), var(--panel) 35%); border-top: 1px solid var(--line); }
.sets-group h4 { font: 700 var(--t-md) var(--display); margin: 0 0 .4rem; }
.sets-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.sets-group label { display: flex; align-items: center; gap: .55rem; padding: .4rem .55rem; border-radius: var(--r-s); background: var(--night); cursor: pointer; font-size: var(--t-sm); min-height: 40px; }
.sets-group label:hover { outline: 1px solid var(--line); }
.sets-group input { accent-color: var(--gold); width: 17px; height: 17px; margin: 0; flex: none; }
.sets-group .n { margin-left: auto; color: var(--muted); font-size: var(--t-xs); white-space: nowrap; }
.pin-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .65rem; }
.pin-row span { width: 3.2rem; color: var(--muted); 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: 700 var(--t-xl)/1 var(--display); letter-spacing: .45em; text-align: center; }
.pin-row input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(216, 178, 92, .2); }
.pin-msg { min-height: 1.3em; margin: .2rem 0 .75rem; color: #ff9aab; font-size: var(--t-sm); }
.pin-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.pin-actions button { border: 1px solid var(--gold); background: var(--gold); color: var(--gold-ink); font-weight: 800; border-radius: 8px; padding: .5rem 1.1rem; min-height: 40px; cursor: pointer; }
.pin-actions button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.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%); visibility: hidden;
  background: var(--text); color: var(--night); padding: .6rem 1rem; border-radius: 10px; font-weight: 800; font-size: var(--t-sm);
  transition: transform .25s; z-index: 20; max-width: 92vw; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.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); }
  .d-body { grid-template-columns: minmax(170px, 240px) 1fr; gap: 1.1rem; padding: 1.1rem; }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  main { padding: 1rem .75rem 2rem; }
  .top { gap: .75rem; padding: .45rem .75rem 0; }
  .brand { flex: none; padding-bottom: .55rem; }
  .brand h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tabs { flex: 1; }
  .tab { flex: 1; padding: .5rem .5rem .45rem; text-align: center; }
  .page-head h2 { font-size: var(--t-xl); }
  .ledger-body { padding: .8rem .8rem .95rem; }
  .sets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .set { min-width: 0; max-width: none; padding: .25rem .45rem .2rem; }
  .edit-sets { flex: 1 1 100%; }
  .file-head { gap: .9rem; align-items: flex-start; }
  .gauge { width: 70px; }
  .g-text { font-size: var(--t-md); }
  .file-meta h2 { font-size: var(--t-lg); }
  .progress { grid-template-columns: 4.4rem 1fr; row-gap: .1rem; }
  .p-num { grid-column: 2; white-space: normal; }
  .seg { width: 100%; min-width: 0; display: grid; grid-template-columns: repeat(var(--segs, 3), minmax(0, 1fr)); }
  .seg button { padding: .45rem .3rem; }
  .more-btn { margin-left: 0; }
  .f-line { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
  .art-box { flex: 1 1 100%; }
  .s-search { flex-basis: 100%; }
  .s-top .s-sel { flex: 1 1 100%; }
  .s-top .s-sel select, .s-top #sSet { flex: 1; width: 100%; max-width: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem .55rem; }
  .s-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem .45rem; }
  .bulk { margin-left: 0; }
  dialog#detail { max-width: 100vw; width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .d-body { grid-template-columns: 1fr; padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom)); }
  .d-body > img { max-width: 230px; 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; }
}
