:root {
  --bg: #14161c; --bg2: #1d2029; --bg3: #272b36; --line: #333846;
  --fg: #eef0f5; --muted: #9aa1b2; --accent: #ff7a1a; --accent2: #ffb36b;
  --ok: #34c27a; --warn: #f2b33d; --err: #ef5350; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--accent2); }
h1 { font-size: 1.5rem; margin: .6rem 0 .8rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

.top { position: sticky; top: 0; z-index: 5; background: rgba(20,22,28,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 10px 16px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--fg); text-decoration: none; max-width: 760px; margin: 0 auto; }
.foot { text-align: center; font-size: .75rem; padding: 24px 16px; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: center; background: var(--bg2); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: .72rem; color: var(--muted); text-decoration: none; }
.tabbar a span { font-size: 1.25rem; line-height: 1; }
.tabbar a.active { color: var(--accent); }

.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card p:first-child { margin-top: 0; }
.warnbox { border-color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg3); color: var(--fg); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 44px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0d00; }
.btn.danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; min-height: 36px; font-size: .9rem; }
.btn.block { display: flex; width: 100%; margin: 10px 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

input, select, textarea { width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.form label { display: block; margin: 10px 0; font-size: .9rem; color: var(--muted); }
.form label input, .form label select, .form label textarea { margin-top: 4px; }
.form .check { display: flex; align-items: center; gap: 8px; color: var(--fg); }
.form .check input { width: auto; min-height: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.searchbar { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
@media (max-width: 560px) { .searchbar { grid-template-columns: 1fr 1fr; } .searchbar input { grid-column: 1 / -1; } }

.list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.part { display: flex; gap: 12px; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; color: var(--fg); text-decoration: none; flex: 1; min-width: 0; }
.part .thumb { width: 64px; height: 64px; flex: none; border-radius: 10px; overflow: hidden; background: var(--bg3); display: grid; place-items: center; }
.part .thumb img { width: 100%; height: 100%; object-fit: cover; }
.noimg { color: var(--muted); font-weight: 700; }
.part .info { display: flex; flex-direction: column; min-width: 0; }
.part .info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part .info .muted { font-size: .85rem; }
.badges { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--bg3); vertical-align: middle; }
.badge.ok { background: rgba(52,194,122,.18); color: var(--ok); }
.badge.warn { background: rgba(242,179,61,.18); color: var(--warn); }
.badge.score.hi { background: rgba(52,194,122,.18); color: var(--ok); }
.badge.score.mid { background: rgba(242,179,61,.18); color: var(--warn); }
.badge.score.lo { background: rgba(239,83,80,.15); color: var(--err); }

.hit { display: flex; flex-direction: column; gap: 6px; }
.hit .part { width: 100%; }
.hit-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-left: 4px; }
.list > .hit:has(.stepper) { flex-direction: row; align-items: center; }

.photo-drop { display: grid; place-items: center; min-height: 200px; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; overflow: hidden; background: var(--bg); color: var(--muted); font-weight: 600; }
.photo-drop img { max-width: 100%; max-height: 360px; display: block; }

.slots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.slot { position: relative; aspect-ratio: 1; border: 2px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; cursor: pointer; margin: 0 !important; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot-label { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px; gap: 4px; color: var(--fg); }
.slot-label small { color: var(--muted); font-size: .72rem; }
.slot.filled { border-style: solid; border-color: var(--accent); }
.slot.filled .slot-label { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.6); }
.slot.filled .slot-label small { display: none; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.owned { display: flex; justify-content: space-between; align-items: center; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper b { min-width: 2ch; text-align: center; font-size: 1.1rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--bg3); }
.gallery figcaption { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.gallery.small { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); margin: 8px 0; }
.photo-review { display: flex; gap: 12px; align-items: center; }
.photo-review img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.stats div { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; }
.stats b { font-size: 1.4rem; color: var(--accent); }
.stats span { font-size: .8rem; color: var(--muted); }

.back { display: inline-block; margin-top: 12px; text-decoration: none; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; transition: .25s; background: var(--bg3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }
