/* Switch in, backup & restore, wishlist rules and the collection tools
   (templates/switch, restore, wishrules, colltools, compare). Tokens from
   style.css; motion is transform/opacity only and honours reduced motion. */

.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ guides / hero */
.sw-wrap { max-width: 1080px; margin: 0 auto; padding: 0 0 2rem; }
.mkt-main .sw-wrap { padding: 2.2rem 16px 3rem; }
.sw-hero { position: relative; padding: 1.6rem 0 1.4rem; }
.sw-hero h1 { font-size: clamp(1.9rem, 6vw, 3rem); line-height: 1.05; letter-spacing: -0.03em; margin: 0.3rem 0 0.6rem; }
.sw-hero.is-small h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); }
.sw-lede { color: var(--ink-dim); max-width: 44rem; font-size: 1.02rem; line-height: 1.55; margin: 0; }
.sw-hero-cta { margin-top: 1.2rem; gap: 0.6rem; flex-wrap: wrap; }
.sw-foil { background: var(--foil); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; }
.sw-arrow { color: var(--muted); font-weight: 400; }
.sw-crumbs { margin: 0 0 0.4rem; color: var(--muted); }
.sw-h2 { margin: 1.4rem 0 0.8rem; font-size: 1.1rem; }
.sw-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 0.7rem; }
.sw-app {
  position: relative; display: grid; gap: 0.35rem; align-content: start; padding: 1rem 1.1rem 1.1rem; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; overflow: hidden; transition: transform 0.18s var(--ease), border-color 0.18s var(--ease);
}
.sw-app::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--foil); opacity: 0.55; }
.sw-app:hover, .sw-app:focus-visible { transform: translateY(-2px); border-color: var(--line-2); }
.sw-app-name { font-weight: 800; font-size: 1.05rem; }
.sw-app-exp { color: var(--muted); }
.sw-app .badge { justify-self: start; }
.sw-app .badge svg { width: 0.9em; height: 0.9em; vertical-align: -0.1em; }
.sw-go { position: absolute; right: 1rem; top: 0.95rem; color: var(--gold); font-weight: 800; }
.sw-how { margin-top: 1.4rem; }
.sw-steps { margin: 0.4rem 0 0; padding-left: 1.3rem; display: grid; gap: 0.55rem; line-height: 1.5; }
.sw-steps li::marker { color: var(--gold); font-weight: 800; }
.sw-evidence { margin-top: 1rem; }
.sw-ev { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.sw-ev p { margin: 0.3rem 0 0; }
.sw-ev .tiny { overflow-wrap: anywhere; }

/* ------------------------------------------------------------ upload / mapper */
.sw-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 860px) { .sw-grid { grid-template-columns: minmax(0, 1fr); } }
.sw-file {
  position: relative; display: flex; align-items: center; gap: 0.9rem; padding: 1.1rem 1.2rem; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line-2); background: var(--surface); cursor: pointer;
}
.sw-file:focus-within { border-color: var(--gold); }
.sw-file input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.sw-file-ico svg { width: 2rem; height: 2rem; }
.sw-drop form { margin-top: 0.4rem; }
.sw-drop .btn { justify-self: start; }
.sw-guide-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.sw-guide-list li { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.sw-saved { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.sw-saved li { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-xs); background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.sw-saved li:target { border-color: rgba(191, 232, 247, 0.55); }
.sw-report { margin-bottom: 1rem; border-color: rgba(143, 233, 166, 0.35); }
.sw-report h2 svg { width: 1.1em; height: 1.1em; vertical-align: -0.15em; }
.sw-list { margin: 0.4rem 0; padding-left: 1.1rem; display: grid; gap: 0.2rem; }

.sw-preset { margin-bottom: 1rem; }
.sw-preset p { margin: 0.35rem 0 0; }
.sw-preset svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.sw-preset.is-warn { border-color: rgba(230, 181, 74, 0.45); }
.sw-warn { color: var(--warn); }
.sw-problem { padding: 0.6rem 0.8rem; border-radius: var(--radius-xs); background: rgba(224, 115, 106, 0.1); border: 1px solid rgba(224, 115, 106, 0.4); color: var(--ink); }
.sw-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 0.55rem; margin: 0.4rem 0 0.8rem; }
.sw-col {
  display: grid; gap: 0.45rem; padding: 0.7rem 0.8rem; border-radius: var(--radius-sm); background: var(--surface);
  border: 1px solid var(--line); min-width: 0;
}
.sw-col.is-on { border-color: rgba(191, 232, 247, 0.4); background: linear-gradient(180deg, rgba(191, 232, 247, 0.07), rgba(191, 232, 247, 0.015)); }
.sw-col-h { display: grid; gap: 0.2rem; min-width: 0; }
.sw-col-name { overflow-wrap: anywhere; }
.sw-samples { display: flex; flex-wrap: wrap; gap: 0.25rem; min-width: 0; }
.sw-samples span { padding: 0.05rem 0.4rem; border-radius: 6px; background: var(--surface-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 0.7rem; }
.sw-col-f select { width: 100%; }
.sw-defaults { margin: 0.4rem 0 1rem; }
.sw-defaults h2 { margin: 0 0 0.5rem; }
.sw-dest { border: 0; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.35rem; min-width: 0; }
.sw-dest legend { padding: 0; margin-bottom: 0.2rem; color: var(--muted); }
.sw-dest .check { align-items: flex-start; }
.sw-actions { align-items: center; gap: 0.8rem; flex-wrap: wrap; margin: 1rem 0; }

.sw-counts { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sw-counts li { padding: 0.45rem 0.8rem; border-radius: var(--pill); background: var(--surface); border: 1px solid var(--line); font-size: 0.86rem; }
.sw-counts li.is-ok { border-color: rgba(143, 233, 166, 0.45); }
.sw-counts li.is-skip { border-color: rgba(224, 115, 106, 0.45); }
.sw-counts li.is-fix { border-color: rgba(230, 181, 74, 0.45); }
.sw-problems { margin-bottom: 1rem; }
.sw-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.sw-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.45rem 0.6rem; border-radius: var(--radius-xs); background: var(--surface); min-width: 0; }
.sw-row .grow { min-width: 0; overflow-wrap: anywhere; }
.sw-row.is-skip { background: rgba(224, 115, 106, 0.07); }
.sw-thumb { flex: 0 0 40px; width: 40px; height: 55px; border-radius: 4px; overflow: hidden; background: var(--bg-2); display: grid; place-items: center; }
.sw-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sw-thumb.is-miss { color: var(--neg); font-weight: 900; }
.sw-why { color: var(--warn); }
.sw-remap { margin: 1rem 0; }
.sw-remap > summary { cursor: pointer; font-weight: 700; }
.sw-remap svg { width: 1em; height: 1em; vertical-align: -0.12em; }

/* ------------------------------------------------------------ restore */
.sw-backup .btn { margin: 0.2rem 0 0.4rem; }
.sw-remind { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.sw-rtable th[scope=row] { font-weight: 700; text-align: left; }
.sw-rtable td, .sw-rtable th { vertical-align: top; }
.sw-apply { margin-top: 1rem; display: grid; gap: 0.7rem; justify-items: start; }
.sw-apply.is-danger { border-color: rgba(224, 115, 106, 0.5); }
.sw-apply .field input { max-width: 14rem; }

/* ------------------------------------------------------------ wishlist rules */
.wl-row > .wr-rules { grid-column: 2 / -1; }
@media (max-width: 900px) { .wl-row > .wr-rules { grid-column: 1 / -1; } }
.wr-wants .panel-head { flex-wrap: wrap; gap: 0.3rem 1rem; }
.wr-wants .panel-head h2 { white-space: nowrap; }
.wr-rules { display: grid; gap: 0.35rem; min-width: 0; }
.wr-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.wr-chip { padding: 0.12rem 0.55rem; border-radius: var(--pill); font-size: 0.72rem; font-weight: 700; background: rgba(191, 232, 247, 0.1); color: var(--gold); border: 1px solid rgba(191, 232, 247, 0.28); }
.wr-blocked { margin: 0; padding-left: 1rem; color: var(--warn); display: grid; gap: 0.1rem; }
.wr-note { margin: 0; }
.wr-edit > summary { cursor: pointer; }
.wr-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; margin: 0.5rem 0; }
.wr-form .field { font-size: 0.7rem; min-width: 0; }
.wr-form input, .wr-form select { padding: 0.42rem 0.6rem; font-size: 0.86rem; border-radius: 9px; }
.wr-money input { width: 6.4rem; }
.wr-know { flex-basis: 100%; margin: 0; }
.wr-any { margin: 0.2rem 0 0.4rem; }
.wr-any svg, .wr-wants h2 svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.wr-wants { margin-top: 1.2rem; scroll-margin-top: 80px; }
.wr-wlist { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.55rem; }
.wr-want { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 0.8rem; align-items: start; padding: 0.7rem 0.8rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.wr-want.is-deal { border-color: rgba(143, 233, 166, 0.5); }
.wr-want-art { display: block; width: 44px; aspect-ratio: 63 / 88; border-radius: 4px; overflow: hidden; background: var(--bg-2); }
.wr-want-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wr-want-main { display: grid; gap: 0.2rem; min-width: 0; overflow-wrap: anywhere; }
.wr-want .wr-edit { grid-column: 1 / -1; }
@media (min-width: 700px) { .wr-want .wr-edit { grid-column: auto; } }
.wr-add { display: grid; gap: 0.2rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.wr-pick { position: relative; flex: 1 1 16rem; }
.wr-pick input { width: 100%; }
.wr-sugg, .cmp-sugg { flex-basis: 100%; }
.wr-sugg:empty, .cmp-sugg:empty { display: none; }

/* ------------------------------------------------------------ collection */
.sw-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: -0.4rem 0 1rem; }
.sw-tools .chip svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.sw-ccnote { margin: -0.6rem 0 1rem; }
.sw-bulkall { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.sw-bulkall select { width: auto; max-width: 12rem; padding: 0.38rem 0.6rem; font-size: 0.84rem; }
.sw-lotpill { position: absolute; left: 0.45rem; bottom: 0.45rem; padding: 0.1rem 0.45rem; border-radius: var(--pill); font-size: 0.66rem; font-weight: 800; color: #101115; background: var(--foil); }
.viewtoggle svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.sw-sealedbadge { background: linear-gradient(90deg, rgba(191, 232, 247, 0.22), rgba(206, 198, 246, 0.22)); color: var(--ink); }

/* slabs */
.sw-tabs { margin-bottom: 1rem; }
.sl-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 1rem; }
.slab {
  position: relative; display: grid; gap: 0; border-radius: 14px; overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02) 45%, rgba(255, 255, 255, 0.07));
  border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
}
.slab::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.07) 45%, transparent 60%); pointer-events: none; }
.slab-label { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 0.6rem; padding: 0.6rem 0.75rem; background: linear-gradient(90deg, rgba(191, 232, 247, 0.16), rgba(206, 198, 246, 0.16)); border-bottom: 1px solid var(--line-2); }
.slab-grader { font-size: 0.66rem; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.slab-grade { grid-row: 1 / span 3; grid-column: 2; align-self: center; font-size: 1.7rem; font-weight: 900; letter-spacing: -0.03em; }
.slab-name { font-weight: 800; font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slab-meta { font-size: 0.68rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slab-window { display: block; margin: 0.7rem 0.9rem; aspect-ratio: 63 / 88; border-radius: 6px; overflow: hidden; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); }
.slab-window img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slab-facts { margin: 0; padding: 0 0.8rem 0.8rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.8rem; }
.slab-facts dt { font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.slab-facts dd { margin: 0; font-size: 0.86rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.slab-facts dd small { display: block; font-size: 0.66rem; color: var(--muted); }

/* add a set */
.sw-setadd { margin: 0.6rem 0 0; }
.sw-setadd svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.sw-setopts { display: flex; flex-wrap: wrap; gap: 0.8rem 1.4rem; align-items: flex-end; margin-bottom: 1rem; }
.sw-setopts .sw-dest { margin: 0; }
.sw-setbar { align-items: flex-end; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.sw-setlist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 0.4rem; }
.sw-setcard { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; border-radius: var(--radius-xs); background: var(--surface); border: 1px solid var(--line); cursor: pointer; min-width: 0; }
.sw-setcard .grow { min-width: 0; overflow-wrap: anywhere; }
.sw-setcard:has(input:not(:checked)) { opacity: 0.55; }
.sw-setcard input { width: auto; flex: 0 0 auto; }

/* spread */
.sw-spread .row { align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.sw-spread .sw-dest { margin: 0; }

/* custom cards */
.sw-customadd > summary { cursor: pointer; }
.sw-customadd svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.cc-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 0.6rem; margin-top: 0.8rem; align-items: end; }
.cc-form .cc-wide { grid-column: 1 / -1; }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 0.9rem; margin-top: 1rem; }
.cc-card { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 0.8rem; padding: 0.8rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); scroll-margin-top: 80px; }
.cc-card:target { border-color: rgba(191, 232, 247, 0.55); }
.cc-card .cc-edit { grid-column: 1 / -1; }
.cc-art { position: relative; aspect-ratio: 63 / 88; border-radius: 6px; overflow: hidden; background: var(--bg-2); display: grid; place-items: center; }
.cc-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-noart svg { width: 2.2rem; height: 2.2rem; }
.cc-tag { position: absolute; left: 0.3rem; top: 0.3rem; padding: 0.05rem 0.4rem; border-radius: var(--pill); font-size: 0.6rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: #101115; background: var(--foil); }
.cc-body { display: grid; gap: 0.25rem; align-content: start; min-width: 0; overflow-wrap: anywhere; }
.cc-name { font-weight: 800; }
.cc-val { font-variant-numeric: tabular-nums; }
.cc-edit > summary { cursor: pointer; }

/* sealed */
.sw-openbox { margin-top: 0.35rem; }
.sw-openbox > summary { cursor: pointer; }
.sw-openbox svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.sw-openform { display: grid; gap: 0.5rem; margin-top: 0.5rem; max-width: 18rem; }
.sw-openform p { margin: 0; }
.sw-sealedlot > summary { cursor: pointer; }

/* set value + compare charts */
.sw-setvalue { margin: 0 0 1.4rem; }
.sw-setvalue .viewtoggle button { font: inherit; }
.sw-setvalue .panel-head { flex-wrap: wrap; gap: 0.5rem 1rem; }
.sw-setvalue .panel-head h2 { white-space: nowrap; }
.sw-setvalue .viewtoggle { flex: 0 0 auto; }
.sw-svchart, .cmp-chart { position: relative; }
.sw-svchart canvas, .cmp-chart canvas { display: block; width: 100%; height: 240px; }
.cmp-controls { display: grid; gap: 0.8rem; margin-bottom: 1rem; }
.cmp-opts { align-items: flex-end; gap: 0.8rem; flex-wrap: wrap; }
.cmp-add { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cmp-add .field { flex: 1 1 18rem; }
.cmp-add input { width: 100%; }
.cmp-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cmp-chip { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.4rem 0.3rem 0.7rem; border-radius: var(--pill); background: var(--surface); border: 1px solid var(--line); font-size: 0.84rem; max-width: 100%; }
.cmp-chip a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-x { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: var(--muted) !important; }
.cmp-x:hover, .cmp-x:focus-visible { background: var(--surface-2); color: var(--ink) !important; }
.cmp-sw { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; margin-right: 0.35rem; vertical-align: -0.05em; background: var(--muted); }
.cmp-chip[data-i="0"] .cmp-sw, .cmp-sw[data-i="0"] { background: #9fe3f5; }
.cmp-chip[data-i="1"] .cmp-sw, .cmp-sw[data-i="1"] { background: #ff9fc4; }
.cmp-chip[data-i="2"] .cmp-sw, .cmp-sw[data-i="2"] { background: #ffe08a; }
.cmp-chip[data-i="3"] .cmp-sw, .cmp-sw[data-i="3"] { background: #8fe9a6; }
:root[data-theme="light"] .cmp-chip[data-i="0"] .cmp-sw, :root[data-theme="light"] .cmp-sw[data-i="0"] { background: #2a9ccb; }
:root[data-theme="light"] .cmp-chip[data-i="1"] .cmp-sw, :root[data-theme="light"] .cmp-sw[data-i="1"] { background: #e0508f; }
:root[data-theme="light"] .cmp-chip[data-i="2"] .cmp-sw, :root[data-theme="light"] .cmp-sw[data-i="2"] { background: #d99a14; }
:root[data-theme="light"] .cmp-chip[data-i="3"] .cmp-sw, :root[data-theme="light"] .cmp-sw[data-i="3"] { background: #2fae62; }
.cmp-chartp { display: grid; gap: 1rem; }
.cmp-table td { vertical-align: middle; }

@media (prefers-reduced-motion: reduce) {
  .sw-app { transition: none; }
  .sw-app:hover { transform: none; }
}
@media (max-width: 600px) {
  .cmp-table th:nth-child(2), .cmp-table td:nth-child(2) { display: none; }
  .cmp-table td .small, .cmp-table td .tiny { display: none; }
  .cmp-table th, .cmp-table td { padding-left: 0.5rem; padding-right: 0.5rem; }
}
