:root {
  --bg: #14161c;
  --bg2: #1b1e26;
  --panel: #20242e;
  --line: #2e3340;
  --text: #f1efe8;
  --muted: #9aa0ad;
  --gold: #f5c542;
  --gold-ink: #1d1600;
  --up: #5fd39a;
  --down: #ff7a6b;
  --ja: #ff8fa3;
  --radius: 14px;
  --display: "Bricolage Grotesque", system-ui, -apple-system, Segoe UI, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--down); }
#app { max-width: 1100px; margin: 0 auto; }
.view { min-height: 100dvh; padding-bottom: 110px; }
.pad { padding: 16px; }
.stack > * + * { margin-top: 14px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
}
.top .title { font: 700 18px var(--display); }
.spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 8px; font: 800 20px var(--display); letter-spacing: -.01em; flex: 1; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--gold); color: var(--gold-ink); }
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark.big { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; }
.brand-mark.big svg { width: 46px; height: 46px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); display: grid; place-items: center; cursor: pointer; }

/* hero */
.hero { padding: 8px 16px 18px; }
.hero-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.hero-value { font: 800 clamp(40px, 11vw, 64px)/1.05 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--line); }
.hero-split { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill { font: 500 12px var(--mono); padding: 5px 9px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.pill b { color: var(--text); font-weight: 700; }

/* toolbar */
.toolbar { padding: 0 16px 12px; position: sticky; top: 60px; z-index: 4; background: var(--bg); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 44px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.search input { flex: 1; background: none; border: 0; outline: 0; color: var(--text); min-width: 0; }
.chips { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.chip.select { appearance: none; padding-right: 12px; margin-left: auto; background: var(--bg2); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; padding: 4px 16px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.tile { cursor: pointer; border: 0; background: none; padding: 0; text-align: left; }
.tile .art { position: relative; aspect-ratio: 63/88; border-radius: 10px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); }
.tile .art img { width: 100%; height: 100%; object-fit: cover; }
.tile .badge { position: absolute; top: 6px; left: 6px; font: 700 10px var(--mono); padding: 3px 6px; border-radius: 6px; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
.tile .badge.ja { color: var(--ja); }
.tile .badge.grade { left: auto; right: 6px; color: var(--gold); }
.tile .qty { position: absolute; bottom: 6px; right: 6px; font: 700 11px var(--mono); padding: 3px 7px; border-radius: 6px; background: var(--gold); color: var(--gold-ink); }
.tile .nm { margin-top: 7px; font-weight: 600; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .val { font: 700 15px var(--mono); margin-top: 2px; }
.tile .val.none { color: var(--muted); font-weight: 500; font-size: 12px; }

.empty { text-align: center; padding: 40px 32px; }
.empty-art { width: 80px; height: 80px; margin: 0 auto 10px; color: var(--line); }
.empty-art svg { width: 80px; height: 80px; }
.empty h2 { font: 700 22px var(--display); margin: 6px 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn.ghost { background: var(--bg2); }
.btn.danger-ghost { background: transparent; color: var(--down); border-color: color-mix(in oklab, var(--down) 40%, transparent); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.fab-row { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; gap: 10px; justify-content: center; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 40%); }
.fab { height: 56px; padding: 0 26px; font-size: 16px; box-shadow: 0 10px 30px -8px rgba(245,197,66,.45); }
.fab-row .btn.ghost { height: 56px; }

/* login */
.login { display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card h1 { font: 800 34px var(--display); margin: 0; letter-spacing: -.02em; }
.login-card form { text-align: left; margin-top: 24px; }
.hint { color: var(--muted); font-size: 12px; text-align: center; }

/* forms */
.form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.form input, .form select, .form textarea, .keyrow input {
  display: block; width: 100%; margin-top: 5px; height: 44px; padding: 0 12px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 16px;
}
.form textarea { height: auto; padding: 10px 12px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus, .keyrow input:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.toggle { display: flex !important; align-items: center; gap: 10px; color: var(--text) !important; font-size: 15px !important; margin: 4px 0 14px; }
.toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--gold); }
.form:not(.is-graded) .graded-only { display: none; }
.actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin: 16px 0 12px; }

/* review */
.review { padding: 8px 16px 24px; max-width: 640px; margin: 0 auto; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare figure { margin: 0; }
.compare img { width: 100%; aspect-ratio: 63/88; object-fit: cover; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); }
.compare img:not([src]) { visibility: hidden; }
.compare figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; }
.status { margin: 14px 0; min-height: 22px; font-size: 14px; }
.status .conf { font: 600 12px var(--mono); padding: 3px 8px; border-radius: 999px; margin-left: 6px; }
.conf.hi { background: color-mix(in oklab, var(--up) 20%, transparent); color: var(--up); }
.conf.lo { background: color-mix(in oklab, var(--down) 20%, transparent); color: var(--down); }
.section-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 6px 0 8px; }
.cand-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 14px; scroll-snap-type: x mandatory; }
.cand { flex: none; width: 96px; border: 2px solid transparent; border-radius: 10px; background: none; padding: 0; cursor: pointer; text-align: left; scroll-snap-align: start; }
.cand.on { border-color: var(--gold); }
.cand img { width: 100%; aspect-ratio: 63/88; object-fit: cover; border-radius: 8px; background: var(--bg2); }
.cand div { font-size: 11px; color: var(--muted); padding: 4px 3px 2px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.price-panel { border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); padding: 14px; }
.price-main { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.price-main .v { font: 800 32px var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.price-main .b { color: var(--muted); font-size: 12px; text-align: right; }
.ptable { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.ptable td { padding: 6px 0; border-top: 1px solid var(--line); }
.ptable td:last-child { text-align: right; font-family: var(--mono); }
.ptable td.src { text-align: left; font-family: inherit; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding-top: 12px; border-top: 0; }
.ptable a { color: var(--gold); }
.spark { width: 100%; height: 60px; margin-top: 10px; }

/* manual results */
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 0 16px; }
.result { border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 8px; cursor: pointer; text-align: left; }
.result img { width: 100%; aspect-ratio: 63/88; object-fit: cover; border-radius: 8px; }
.result .nm { font-weight: 600; font-size: 13px; margin-top: 6px; }
.result .sub { color: var(--muted); font-size: 11px; }

/* settings */
.panel { border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); padding: 16px; }
.panel h3 { margin: 0 0 4px; font: 700 16px var(--display); }
.keyrow { display: flex; gap: 8px; margin-top: 10px; }
.keyrow input { margin-top: 0; flex: 1; min-width: 0; }
.keyrow .btn { height: 44px; }
.status-line { font-size: 13px; margin-top: 8px; color: var(--muted); }
.status-line .ok { color: var(--up); }

/* toast / busy */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.err { background: var(--down); color: #200; }
.busy { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(10,11,14,.72); backdrop-filter: blur(3px); font-weight: 600; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--bg2), var(--panel), var(--bg2)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* import + settings additions */
.field-label { display: block; font-size: 12px; color: var(--muted); margin-top: 14px; }
.select-input { flex: 1; height: 44px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); padding: 0 12px; font-size: 16px; }
.imp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bar { height: 8px; border-radius: 99px; background: var(--bg2); margin: 10px 0; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--gold); transition: width .3s; }
.imp-actions { display: flex; justify-content: flex-end; }
.imp-actions .btn { height: 36px; }
.imp-list { display: grid; gap: 8px; }
.imp-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.imp-row img { width: 44px; height: 61px; object-fit: cover; border-radius: 6px; background: var(--bg2); }
.imp-row .nm { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-row .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-row .st { font: 600 11px var(--mono); padding: 3px 8px; border-radius: 99px; background: var(--bg2); color: var(--muted); white-space: nowrap; }
.st.ok { color: var(--up); } .st.warn { color: var(--gold); } .st.err { color: var(--down); }
.tile .badge.review { top: auto; bottom: 6px; left: 6px; color: var(--gold); }
.setup-note { text-align: left; margin-top: 18px; }
.form:not(.is-sold) .sold-only { display: none; }
.owner-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.owner-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.owner-chip button { width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--panel); color: var(--muted); cursor: pointer; }
.tile .owner { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.badge.sold { left: auto !important; right: 6px; top: auto !important; bottom: 6px; color: var(--up) !important; }
.groups { padding: 0 0 8px; }
.grp { margin-bottom: 18px; }
.grp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 16px 8px; position: sticky; top: 150px; z-index: 3; background: var(--bg); }
.grp-head h3 { margin: 0; font: 700 17px var(--display); }
.grp-head span { font: 500 12px var(--mono); color: var(--muted); white-space: nowrap; }
.meta-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.meta-tags span { font: 500 11px var(--mono); padding: 4px 8px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
#rv-photo { cursor: pointer; }
