:root {
  --bg: #0e1120;
  --bg2: #161a2e;
  --card: #1b2038;
  --card2: #232946;
  --line: #2e3558;
  --text: #e8e9f3;
  --muted: #9aa0c3;
  --green: #39ff88;
  --green-d: #1fbf63;
  --amber: #ffb000;
  --red: #ff5d73;
  --blue: #6cb6ff;
  --beige: #efe4ca;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --mono: ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4efe2; --bg2: #ebe4d2; --card: #fffdf7; --card2: #f6f1e4; --line: #ddd3bb;
    --text: #1e2133; --muted: #6b6a7a; --green: #0f9d50; --green-d: #0b7a3e; --amber: #c27c00;
    --shadow: 0 4px 16px rgba(60, 50, 20, .12); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4efe2; --bg2: #ebe4d2; --card: #fffdf7; --card2: #f6f1e4; --line: #ddd3bb;
  --text: #1e2133; --muted: #6b6a7a; --green: #0f9d50; --green-d: #0b7a3e; --amber: #c27c00;
  --shadow: 0 4px 16px rgba(60, 50, 20, .12); color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: .02em; }
.brand img { width: 34px; height: 34px; }
.brand .word { font-family: var(--mono); font-size: 1.15rem; }
.brand .word b { color: var(--green); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 7px 12px; border-radius: 10px; color: var(--muted); white-space: nowrap; font-weight: 600; }
.nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--card2); color: var(--green); }
.who { color: var(--muted); font-size: .85rem; white-space: nowrap; }
main { max-width: 1280px; margin: 0 auto; padding: 22px 20px 80px; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  main { padding: 16px 16px 80px; }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .k { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
.stat .v.green { color: var(--green); }
.stat .v.amber { color: var(--amber); }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.section { margin-top: 22px; }

/* bars */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 150px 1fr 70px; align-items: center; gap: 10px; color: var(--text); }
.bar:hover { text-decoration: none; }
.bar .track { height: 12px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--green-d); border-radius: 6px; }
.bar .n { text-align: right; font-family: var(--mono); color: var(--muted); }
@media (max-width: 520px) { .bar { grid-template-columns: 110px 1fr 50px; } }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=number], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-d); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }
textarea { min-height: 90px; resize: vertical; }
label.f { display: block; }
label.f > span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.form .wide { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card2); cursor: pointer; font-weight: 600; white-space: nowrap; color: var(--text);
}
.btn:hover { border-color: var(--green-d); text-decoration: none; }
.btn.primary { background: var(--green-d); border-color: var(--green-d); color: #04150b; }
.btn.primary:hover { background: var(--green); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* toolbar + filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 280px; position: relative; }
.toolbar .search input { padding-left: 36px; font-size: 1.02rem; }
.toolbar .search::before { content: "⌕"; position: absolute; left: 12px; top: 6px; font-size: 1.3rem; color: var(--muted); }
.toolbar select { width: auto; min-width: 120px; }

/* item grid */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .items { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.tile:hover { border-color: var(--green-d); text-decoration: none; transform: translateY(-1px); }
.tile .ph { aspect-ratio: 1; background: var(--bg2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 2rem; }
.tile .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.tile .t { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .t.unknown { color: var(--muted); font-style: italic; font-weight: 500; }
.tile .meta { display: flex; justify-content: space-between; align-items: center; gap: 4px 6px; margin-top: auto; flex-wrap: wrap; }
.tile .id { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.65); color: #fff; font: 700 .78rem var(--mono); padding: 3px 7px; border-radius: 7px; }
.tile .qty { position: absolute; top: 8px; right: 8px; background: var(--amber); color: #201400; font: 700 .78rem var(--mono); padding: 3px 7px; border-radius: 7px; }
.tile .check { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px; background: rgba(0,0,0,.6); border: 2px solid #fff; display: none; }
.selecting .tile .check { display: block; }
.selecting .tile.sel .check { background: var(--green); border-color: var(--green); }
.selecting .tile.sel { outline: 3px solid var(--green); }
.value { font-family: var(--mono); font-weight: 500; color: var(--muted); font-size: .85rem; white-space: nowrap; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; background: var(--card2); color: var(--muted); white-space: nowrap; }
.pill.new { background: #2b3566; color: #b9c4ff; }
.pill.identified { background: #12402a; color: var(--green); }
.pill.needs_info { background: #4d3500; color: var(--amber); }
.pill.reviewed { background: #173a55; color: var(--blue); }
.pill.listed { background: #3e2a5c; color: #d4b3ff; }
.pill.sold { background: #0d5c34; color: #c9ffe0; }
.pill.disposed, .pill.discard { background: #3a2a2a; color: #d9a0a0; }
.pill.donate { background: #2f3a2a; color: #c7e0a8; }
.pill.keep { background: #4a2440; color: #ffb3e6; }
.pill.notable { background: linear-gradient(90deg, #ffb000, #ff6ad5); color: #1b0c00; }
.pill.sell { background: #12402a; color: var(--green); }
.pill.lot { background: #2f3550; color: #c5cbea; }
.pill.kept { background: #4a2440; color: #ffb3e6; }
:root[data-theme="light"] .pill, html:not([data-theme="dark"]) .pill { filter: none; }

/* item page */
.item-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .item-layout { grid-template-columns: 1fr; } }
.gallery .main { aspect-ratio: 4/3; background: var(--bg2) center/contain no-repeat; border-radius: var(--radius); border: 1px solid var(--line); cursor: zoom-in; }
.gallery .thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.gallery .thumbs .th { position: relative; width: 76px; height: 76px; border-radius: 10px; background: var(--bg2) center/cover; border: 2px solid transparent; cursor: pointer; }
.gallery .thumbs .th.on { border-color: var(--green); }
.gallery .thumbs .th .x { position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--red); color: #fff; border: none; font-size: 13px; line-height: 22px; padding: 0; cursor: pointer; display: none; }
.gallery .thumbs .th:hover .x { display: block; }
.gallery .thumbs .add { display: grid; place-items: center; font-size: 1.8rem; color: var(--muted); border: 2px dashed var(--line); background: none; }
.question { border: 1px solid var(--amber); background: color-mix(in srgb, var(--amber) 12%, var(--card)); }
.question h3 { color: var(--amber); }
.listing pre { white-space: pre-wrap; font: inherit; background: var(--bg2); border-radius: 10px; padding: 12px; margin: 8px 0; max-height: 420px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.tablewrap { overflow-x: auto; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.feed li:last-child { border: none; }
.feed .who { font-weight: 700; color: var(--text); font-size: .9rem; }
.feed .ai { color: var(--green); }

/* misc */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 3rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--green-d); color: var(--text); padding: 10px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 100; animation: pop .2s; }
.toast.err { border-color: var(--red); }
@keyframes pop { from { transform: translate(-50%, 10px); opacity: 0; } }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 90; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 94vh; }
.qrbox { background: #fff; padding: 14px; border-radius: 16px; width: min(320px, 100%); }
.qrbox svg { display: block; width: 100%; height: auto; }
.copy { display: flex; gap: 8px; }
.copy input { font-family: var(--mono); font-size: .85rem; }
.steps { padding-left: 1.2em; }
.steps li { margin-bottom: .5em; }
code { font-family: var(--mono); background: var(--bg2); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
.bulkbar { position: sticky; bottom: 12px; margin-top: 16px; background: var(--card2); border: 1px solid var(--green-d); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); z-index: 10; }
.login { max-width: 380px; margin: 10vh auto; text-align: center; }
.login img { width: 120px; }
.hero-word { font-family: var(--mono); font-size: 2rem; font-weight: 800; margin: 10px 0 4px; }
.hero-word b { color: var(--green); }
.top-items { display: grid; grid-auto-flow: column; grid-auto-columns: 190px; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kbd { font-family: var(--mono); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 5px; font-size: .8em; }
