/* PalVault: ResoPal tokens, dark only. */
:root {
  --bg: #070b17; --glow-1: #17224a; --glow-2: #101a3c;
  --text: #e8ecfa; --text-2: #9aa6c8; --text-3: #69769c;
  --accent: #a9abee; --accent-hover: #b8baf4;
  --cyan: #a3cfd8; --gold: #e3c893; --sage: #a4d4ba; --rose: #d8a2ab; --purple: #c2a3e2;
  --teal: #62c7bd;
  --panel: rgba(20, 28, 54, .86); --pop: #101936; --border: rgba(150, 170, 230, .16);
  --radius: 28px; --radius-sm: 14px;
  --font-ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; max-width: 100%; overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; max-width: 100%; overflow-x: clip;
  color: var(--text); font: 15px/1.5 var(--font-ui);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 8% -8%, var(--glow-1), transparent 62%),
    radial-gradient(780px 480px at 102% 2%, var(--glow-2), transparent 58%);
  background-attachment: fixed;
  overflow-wrap: break-word;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 500; letter-spacing: .01em; margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 32px; }
h2 { font-size: 22px; }
p { margin: 0 0 .6em; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.hint { color: var(--text-3); font-size: 13px; margin: 6px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 200; padding: 8px 14px; background: var(--accent); color: #0b1020; border-radius: var(--radius-sm); }
.skip:focus { top: 8px; }
.noscript { padding: 24px 16px; text-align: center; }

/* ---------- header ---------- */
.topbar { max-width: 1280px; margin: 0 auto; padding: 14px 16px 0; }
.pill {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 8px 10px 8px 22px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.logo { display: flex; flex-direction: column; text-decoration: none; line-height: 1; padding: 4px 0; }
.logo-name { font-family: var(--font-head); font-size: 25px; font-weight: 600; color: var(--text); }
.logo-sub { font-family: var(--font-mono); font-size: 9px; letter-spacing: .22em; color: var(--text-3); margin-top: 3px; }
.nav { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav a { display: block; padding: 9px 16px; border-radius: 999px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a:hover { color: var(--text); background: rgba(150, 170, 230, .1); }
.nav a[aria-current='page'] { color: var(--text); background: rgba(169, 171, 238, .18); }

main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 48px; outline: none; }

/* ---------- shared components ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 15px; font: 600 14px/1.2 var(--font-ui); color: var(--text); text-decoration: none;
  background: rgba(150, 170, 230, .1); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s, border-color .15s; list-style: none;
}
.btn::-webkit-details-marker { display: none; }
.btn:hover { background: rgba(150, 170, 230, .18); border-color: rgba(169, 171, 238, .4); color: var(--text); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; color: #0b1020; }
.btn.primary:hover { background: var(--accent-hover); color: #0b1020; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--rose); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }

.input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; font: 500 14px/1.3 var(--font-ui); color: var(--text);
  background: rgba(7, 11, 23, .55); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input::placeholder { color: var(--text-3); }
select option { background: #0f1730; color: var(--text); }
textarea { resize: vertical; line-height: 1.45; }
textarea.mono { font-family: var(--font-mono); font-size: 13px; }
.num { width: 92px; text-align: right; font-family: var(--font-mono); }
input[type='checkbox'], input[type='radio'], input[type='range'], progress { accent-color: var(--accent); }
input[type='checkbox'] { width: 18px; height: 18px; margin: 0; flex: none; }

.field { margin-bottom: 16px; min-width: 0; }
.field > label, .label-row label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.label-row label { margin: 0 0 6px; }
.counter { font: 500 12px var(--font-mono); color: var(--text-3); }
.counter.over { color: var(--rose); }
label.check, .field > label.check { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.out { margin-top: 4px; }
.flag { color: var(--gold); font-weight: 600; }

.notice { margin: 10px 0; padding: 10px 14px; font-size: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); border-left-width: 4px; background: rgba(150, 170, 230, .07); }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice.ok { border-left-color: var(--sage); }
.notice.warn { border-left-color: var(--gold); background: rgba(227, 200, 147, .08); }
.notice.error { border-left-color: var(--rose); background: rgba(216, 162, 171, .09); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 18px; }
.page-head h1 { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.back { font-size: 13px; text-decoration: none; }
.save-state { font: 500 12px var(--font-mono); color: var(--text-3); }
.empty, .state { text-align: center; padding: 36px 20px; }
.state { max-width: 560px; margin: 32px auto; }
.state .row { justify-content: center; }
.spinner { width: 28px; height: 28px; margin: 0 auto 14px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } * { scroll-behavior: auto !important; } }

.badge { margin-left: 6px; padding: 0 7px; font-size: 12px; font-weight: 700; color: #0b1020; background: var(--accent); border-radius: 999px; }

.seg { display: inline-flex; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(7, 11, 23, .45); }
.seg-btn { min-height: 38px; padding: 6px 14px; font: 600 14px var(--font-ui); color: var(--text-2); background: none; border: 0; cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed='true'] { color: var(--text); background: rgba(169, 171, 238, .22); }
.seg-btn:focus-visible { outline-offset: -3px; }

.ms, .menu { position: relative; }
.ms > summary, .menu > summary { white-space: nowrap; }
.ms-pop, .menu-pop {
  position: absolute; z-index: 40; width: min(300px, calc(100vw - 32px)); max-height: 340px; overflow: auto;
  background: var(--pop); border: 1px solid var(--border); border-radius: 18px; padding: 10px; box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
}
.ms-pop { top: calc(100% + 6px); left: 0; }
.ms-bar { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 6px; }
.ms-opt { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.ms-opt:hover { background: rgba(150, 170, 230, .1); }
.ms-label { flex: 1; min-width: 0; }
.ms-count { color: var(--text-3); font: 500 12px var(--font-mono); }

.choice { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.choice legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.chip { position: relative; display: inline-block; margin: 0 8px 8px 0; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 8px 15px; font-weight: 600; font-size: 14px; color: var(--text-2); background: rgba(150, 170, 230, .08); border: 1px solid var(--border); border-radius: 999px; }
.chip input:checked + span { color: var(--text); background: rgba(169, 171, 238, .2); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

#toasts { position: fixed; left: 16px; right: 16px; bottom: 92px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 14px; align-items: center; max-width: 520px; padding: 10px 16px; font-size: 14px; background: var(--pop); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.toast.ok { border-left-color: var(--sage); }
.toast.warn { border-left-color: var(--gold); }
.toast.error { border-left-color: var(--rose); }

/* ---------- binder ---------- */
.toolbar { position: relative; z-index: 20; padding: 14px 16px; border-radius: 24px; }
.tb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tb-row + .tb-row { margin-top: 10px; }
.tb-row > .input[type='search'] { flex: 1 1 260px; }
.tb-row > select { width: auto; min-width: 160px; }
.range { display: flex; align-items: center; gap: 6px; color: var(--text-3); }
.range .input { width: 78px; min-width: 0; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 12px 0 0; font-size: 13px; color: var(--text-2); }
.stat-l { color: var(--text-3); }
.stat b { color: var(--text); font-weight: 600; }

.grid { --tile-min: 150px; display: grid; gap: 12px; margin-top: 16px; grid-template-columns: repeat(auto-fill, minmax(min(var(--tile-min), 100%), 1fr)); }
.grid.size-s { --tile-min: 104px; }
.grid.size-l { --tile-min: 210px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 8px;
  background: rgba(20, 28, 54, .6); border: 1px solid var(--border); border-radius: 18px;
}
.tile.owned { border-color: var(--teal); box-shadow: 0 0 0 1px rgba(98, 199, 189, .28), 0 8px 24px rgba(0, 0, 0, .25); }
.tile.picked { background: rgba(169, 171, 238, .16); border-color: var(--accent); }
.tile-art { aspect-ratio: 5 / 7; overflow: hidden; background: #0d1530; border-radius: 12px; }
.art-img { display: block; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); opacity: .5; transition: filter .2s, opacity .2s; }
.tile.owned .art-img { filter: none; opacity: 1; }
.tile-art.landscape .art-img { object-fit: contain; }
.tile-art.broken { background: repeating-linear-gradient(45deg, #0d1530, #0d1530 8px, #111a3a 8px, #111a3a 16px); }
.tile-art.broken .art-img { visibility: hidden; }
.tile-sel {
  position: absolute; top: 12px; right: 12px; z-index: 2; display: grid; place-items: center;
  width: 28px; height: 28px; background: rgba(7, 11, 23, .7); border-radius: 9px; cursor: pointer;
}
.tile-sel input { width: 18px; height: 18px; cursor: pointer; }
.tile-code { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, .08); }
.tile-rarity { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-name { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-qty { display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; gap: 4px; margin-top: 2px; }
.qty-btn { min-height: 30px; font: 700 16px/1 var(--font-ui); color: var(--text); background: rgba(150, 170, 230, .12); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.qty-btn:hover:not(:disabled) { background: rgba(169, 171, 238, .25); }
.qty-btn:disabled { opacity: .35; cursor: default; }
.qty-in { width: 100%; min-width: 0; min-height: 30px; padding: 0 2px; text-align: center; font: 600 13px var(--font-mono); color: var(--text); background: rgba(7, 11, 23, .55); border: 1px solid var(--border); border-radius: 10px; -moz-appearance: textfield; appearance: textfield; }
.qty-in::-webkit-outer-spin-button, .qty-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tile-price { font: 600 12px var(--font-mono); text-align: center; min-height: 22px; }
.price-btn { padding: 2px 8px; font: inherit; color: var(--gold); background: none; border: 1px dashed transparent; border-radius: 8px; cursor: pointer; }
.price-btn:hover, .price-btn:focus-visible { border-color: var(--gold); }
.price-none { color: var(--text-3); }
.pricepop { position: fixed; z-index: 60; min-width: 176px; padding: 10px 12px; background: var(--pop); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 36px rgba(0, 0, 0, .55); font-size: 13px; text-align: left; }
.pp-head { margin-bottom: 6px; font-weight: 700; color: var(--text); }
.pp-row { display: flex; justify-content: space-between; gap: 18px; color: var(--text-2); }
.pp-row b { color: var(--text); font-weight: 600; }
.pp-link { display: block; margin-top: 8px; font-weight: 600; }

.selbar {
  position: sticky; bottom: 12px; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 18px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 22px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.sel-info { font-size: 14px; color: var(--text-2); }
.sel-info b { color: var(--text); }
.selbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.menu-pop { bottom: calc(100% + 8px); right: 0; width: min(300px, calc(100vw - 32px)); }
.menu-item { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 10px; text-align: left; font: 500 14px var(--font-ui); color: var(--text); background: none; border: 0; border-radius: 10px; cursor: pointer; }
.menu-item:hover { background: rgba(150, 170, 230, .12); }
.menu-item small { color: var(--text-3); white-space: nowrap; }

/* ---------- listings ---------- */
.lcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 16px; }
.lcard { display: flex; flex-direction: column; min-width: 0; }
.thumbs { display: flex; gap: 4px; margin-bottom: 12px; min-height: 56px; }
.thumbs img { width: 40px; height: 56px; object-fit: cover; border-radius: 6px; }
.lcard-title { margin: 0 0 6px; font-size: 19px; line-height: 1.3; }
.meta { margin: 0; color: var(--text-2); font-size: 14px; }
.sub { margin: 2px 0 14px; color: var(--text-3); font-size: 13px; }
.lcard-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

/* ---------- editor ---------- */
.ed-sec { margin-bottom: 18px; }
.ed-sec > h2 { margin-bottom: 14px; }
.cover-wrap { max-width: 420px; }
.cover-prev { display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; background: rgba(7, 11, 23, .55); border: 1px solid var(--border); border-radius: 18px; }
.cover-prev .hint { padding: 16px; text-align: center; }
.cover-canvas { display: block; width: 100%; height: auto; }
.cover-prev[aria-busy='true'] { opacity: .6; }
.cover-status { margin: 12px 0 0; }
.cover-status.ok { color: var(--sage); }
.cover-status.stale { color: var(--gold); }
.cover-status b { color: var(--text); }
.cover-link a { word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.chip-btn { padding: 5px 10px; font-size: 12px; color: var(--cyan); background: rgba(163, 207, 216, .08); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.chip-btn:hover { background: rgba(163, 207, 216, .18); }
.custom-desc { margin-bottom: 16px; }
.custom-desc > label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.preview-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 8px 0; }
.preview-head .hint { margin: 0; }
.desc-frame { display: block; width: 100%; height: 420px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.slider { display: block; width: 100%; margin: 4px 0; }
.range-scale { display: flex; justify-content: space-between; font: 500 12px var(--font-mono); color: var(--text-3); }

.table-wrap { max-width: 100%; margin: 14px 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.items { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 14px; }
.items th { padding: 9px 10px; text-align: left; font: 600 11px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); background: rgba(7, 11, 23, .4); white-space: nowrap; }
.items td { padding: 7px 10px; vertical-align: middle; border-top: 1px solid var(--border); }
.items .input { min-height: 34px; padding: 4px 8px; }
.items .num { width: 88px; }
.cell-name { min-width: 180px; }
.row-thumb { display: block; width: 36px; height: 50px; object-fit: cover; border-radius: 4px; }
.items tr.needs-price td { background: rgba(227, 200, 147, .07); }
.summary { display: flex; flex-wrap: wrap; gap: 10px 32px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.sum-stat { display: flex; flex-direction: column; }
.sum-stat .stat-l { font: 600 11px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.sum-stat b { font-size: 18px; font-weight: 600; }
.sum-stat.warn b { color: var(--gold); }
.progress { width: 100%; max-width: 360px; height: 10px; }

/* ---------- settings ---------- */
.set-group { margin-bottom: 18px; }
.set-group > h2 { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 4px 20px; }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
  h1 { font-size: 28px; }
  .pill { padding: 6px 8px 6px 16px; }
  .logo-name { font-size: 22px; }
  .nav { gap: 0; }
  .nav a { padding: 8px 9px; font-size: 13.5px; }
  .panel { padding: 16px; border-radius: 22px; }
  .grid { gap: 10px; }
  .grid.size-s { --tile-min: 100px; }
  .grid.size-l { --tile-min: 300px; }
  .tile-sel { top: 10px; right: 10px; }
  .selbar { bottom: 8px; border-radius: 20px; }
  .selbar-actions .btn { flex: 1 1 auto; }
  .tb-row > select { flex: 1 1 140px; }
  #toasts { bottom: 150px; }
}
