:root {
  --bg: #16130f;
  --panel: #1f1b16;
  --panel-2: #29241d;
  --line: #3a3229;
  --text: #f1e9dc;
  --muted: #a89a86;
  --accent: #e8a33d;
  --accent-2: #c4472b;
  --ok: #6fbf73;
  --warn: #e8a33d;
  --bad: #e06050;
  --radius: 14px;
  --font: "Inter", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
body { min-height: 100vh; background:
  radial-gradient(1200px 600px at 10% -10%, #2a1f14 0%, transparent 60%),
  radial-gradient(900px 500px at 110% 0%, #24120e 0%, transparent 55%), var(--bg); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: #0005; padding: 1px 5px; border-radius: 4px; }

/* Logo */
.logo { font-family: var(--display); font-weight: 800; font-size: 44px; letter-spacing: -0.02em; margin: 0; }
.logo span { color: var(--accent); }
.logo.small { font-size: 26px; }

/* Buttons & inputs */
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #1a1208; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #6a2a22; color: var(--bad); background: transparent; }
.btn.wide { width: 100%; padding: 11px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #e8a33d22; }
label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
input[type="color"] { padding: 2px; height: 40px; width: 100%; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: 0 30px 80px #0008; }
.tagline { color: var(--muted); margin: 4px 0 24px; }
.auth form { display: grid; gap: 14px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 10px; padding: 4px; }
.tab { background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--panel-2); color: var(--text); }
.msg { min-height: 1.2em; margin: 0; font-size: 13px; color: var(--muted); }
.msg.error { color: var(--bad); }
.msg.ok { color: var(--ok); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: #16130fe6; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.views { display: flex; gap: 4px; flex: 1; }
.view { background: none; border: 0; padding: 8px 14px; border-radius: 999px; color: var(--muted); cursor: pointer; }
.view b { font-weight: 600; font-size: 12px; background: var(--panel-2); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.view.active { background: var(--panel-2); color: var(--text); }
.view.active b { background: var(--accent); color: #1a1208; }
.account { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.banner { margin: 16px 24px 0; padding: 10px 14px; border: 1px dashed var(--accent); border-radius: 10px; color: var(--muted); font-size: 13px; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px; padding: 18px 24px 8px; }
.controls #q { flex: 1 1 260px; }
.families { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 24px 8px; }
.fam { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 10px 4px 5px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.fam i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.fam.active { border-color: var(--accent); color: var(--text); background: var(--panel-2); }

/* Stats */
.stats { margin: 8px 24px; display: flex; flex-wrap: wrap; gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-width: 120px; }
.stat b { display: block; font-family: var(--display); font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; }

.result-count { padding: 0 24px; color: var(--muted); font-size: 13px; margin: 8px 0; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; padding: 4px 24px 32px; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; cursor: pointer; transition: transform .12s, border-color .12s; }
.card:hover { transform: translateY(-2px); border-color: #5a4a38; }
.card.owned { border-color: #4a5a3a; background: linear-gradient(180deg, #232a1c, var(--panel)); }
.card.wishlist { border-color: #5a3a5a; }
.card .name { font-weight: 600; line-height: 1.2; }
.card .meta { font-size: 12px; color: var(--muted); }
.card .chip { position: absolute; top: 8px; right: 8px; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chip.owned { background: #2f4a2a; color: #b8e0a8; }
.chip.low { background: #4a3a1a; color: #f0c870; }
.chip.empty { background: #4a221d; color: #f0a090; }
.chip.wishlist { background: #3e2645; color: #e0b0f0; }
.card .quick { grid-column: 1 / -1; display: flex; gap: 6px; }
.quick button { flex: 1; white-space: nowrap; font-size: 12.5px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.quick button:hover { border-color: var(--accent); }
.quick button.on { background: var(--accent); color: #1a1208; border-color: var(--accent); font-weight: 600; }
.quick .qty { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.quick .qty button { flex: 0 0 26px; padding: 5px 0; }
.quick .qty span { min-width: 18px; text-align: center; font-weight: 600; }

/* Paint pot swatch */
.pot { width: 48px; height: 48px; border-radius: 12px 12px 14px 14px; background: var(--c); position: relative;
  box-shadow: inset 0 -8px 12px #0004, inset 0 6px 8px #ffffff22, 0 2px 6px #0006; }
.pot::before { content: ""; position: absolute; left: 8px; right: 8px; top: -6px; height: 8px; border-radius: 4px 4px 0 0; background: #2b2722; box-shadow: inset 0 2px 0 #ffffff14; }
.pot.metal { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 60%, #fff) 0%, var(--c) 40%, color-mix(in srgb, var(--c) 60%, #000) 70%, var(--c) 100%); }
.pot.wash { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, transparent), var(--c)); }
.pot.big { width: 72px; height: 72px; flex: none; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* Dialogs */
.dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100% - 24px)); box-shadow: 0 40px 100px #000a; }
.dialog::backdrop { background: #000a; backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 14px; padding: 22px; }
.detail-head { display: flex; gap: 16px; align-items: center; }
.detail-head h2 { margin: 2px 0; font-family: var(--display); font-size: 24px; }
.detail-head .meta { margin: 0; color: var(--muted); font-size: 13px; }
.x { margin-left: auto; align-self: flex-start; background: none; border: 0; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog h3 { margin: 6px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.similar { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.similar li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: var(--panel-2); cursor: pointer; font-size: 13.5px; }
.similar li:hover { outline: 1px solid var(--accent); }
.similar .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--c); flex: none; box-shadow: inset 0 -3px 4px #0004; }
.similar small { color: var(--muted); margin-left: auto; white-space: nowrap; }
.similar .have { color: var(--ok); font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }

.foot { padding: 20px 24px 40px; color: var(--muted); font-size: 12.5px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; border-top: 1px solid var(--line); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 10px 30px #0008; z-index: 100; }
.toast.error { border-color: var(--bad); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .views { order: 3; flex-basis: 100%; overflow-x: auto; }
  .account #user-email { display: none; }
  .controls, .families, .grid, .result-count { padding-left: 14px; padding-right: 14px; }
  .controls select { flex: 1 1 45%; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card { padding: 10px; }
  .quick { flex-wrap: wrap; }
  .quick .qty { flex-basis: 100%; justify-content: space-between; }
  .card { grid-template-columns: 1fr; text-align: left; }
  .row { grid-template-columns: 1fr; }
}
