:root {
  --bg: #16130f;
  --panel: #201c17;
  --panel-2: #2a251f;
  --line: #3a332b;
  --text: #f1ebe2;
  --muted: #b2a797;
  --accent: #f2b544;
  --accent-ink: #231a06;
  --focus: #ffd27a;
  --radius: 14px;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --ui: "Figtree", ui-sans-serif, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 500px at 50% -200px, #2b2219 0%, var(--bg) 70%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--ui);
  overflow-x: hidden;
}
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { max-width: 1080px; margin: 0 auto; padding: 28px 20px 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; color: var(--accent); line-height: 1; }
.brand-name { font: 700 28px/1 var(--display); letter-spacing: -0.02em; }
.tagline { margin: 10px 0 0; color: var(--muted); max-width: 56ch; }

.launcher {
  max-width: 1080px; margin: 0 auto 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.04);
  overflow: hidden;
}
@media (max-width: 1119px) { .launcher { margin-left: 12px; margin-right: 12px; } }

.searchbar { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.search-ico { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
#q { flex: 1; min-width: 0; height: 60px; border: 0; background: transparent; color: var(--text); font: 500 18px var(--ui); }
#q:focus { outline: none; }
#q::placeholder { color: #8a7f70; }
kbd {
  font: 500 12px var(--ui); color: var(--muted);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 1px 6px; background: var(--panel-2);
}

.body { display: grid; grid-template-columns: 1fr; }
@media (min-width: 820px) { .body { grid-template-columns: 250px 1fr; min-height: 520px; } }

.rail { padding: 12px; border-bottom: 1px solid var(--line); min-width: 0; }
@media (min-width: 820px) { .rail { border-bottom: 0; border-right: 1px solid var(--line); } }
.packs { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.packs::-webkit-scrollbar { display: none; }
@media (min-width: 820px) { .packs { flex-direction: column; overflow: visible; } }
.pack {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: 44px; padding: 6px 12px 6px 6px;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text); font: 500 15px var(--ui);
  cursor: pointer; white-space: nowrap; text-align: left;
}
.pack:hover { background: var(--panel-2); }
.pack[aria-current="true"] { background: var(--panel-2); border-color: var(--line); }
.pack[aria-current="true"] .pack-name { color: var(--accent); }
.pack.sub { padding-left: 14px; font-size: 14px; color: var(--muted); }
@media (min-width: 820px) { .pack.sub { padding-left: 46px; } }
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--line); object-fit: cover; flex: none; display: grid; place-items: center; font: 600 13px var(--ui); color: var(--muted); }
.pack-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pack-n { margin-left: auto; color: #8a7f70; font-size: 13px; padding-left: 8px; }
.pack-x { margin-left: 4px; width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: #8a7f70; cursor: pointer; font-size: 16px; flex: none; }
.pack-x:hover { color: var(--text); background: var(--line); }
.pack-row { display: flex; align-items: center; }
.pack-row .pack { flex: 1; min-width: 0; }

.add { margin-top: 12px; }
.add-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.add-row { display: flex; gap: 6px; }
.add-row input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: 15px var(--ui);
}
.add-msg { min-height: 1.4em; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.add-msg.err { color: #ff9f8f; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: 600 15px var(--ui); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--line); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.accent:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 6px; }

.results { padding: 14px; min-width: 0; }
.results-head { display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 10px; }
.section-title { font: 600 15px var(--display); margin: 0; letter-spacing: -0.01em; }
.count { color: #8a7f70; font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--panel-2); border: 2px solid transparent; padding: 0; cursor: pointer;
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover { border-color: var(--line); }
.tile[aria-selected="true"], .tile:focus-visible { border-color: var(--accent); outline: none; }
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px;
  background: linear-gradient(transparent, rgba(10,8,6,.85));
  font-size: 12px; color: #efe6d8; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .kind { position: absolute; top: 6px; left: 6px; font: 600 11px var(--ui); padding: 1px 6px; border-radius: 6px; background: rgba(10,8,6,.7); color: #efe6d8; }

.recent { margin-bottom: 16px; }
.recent .section-title { margin: 4px 2px 8px; }
.recent-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; }
.recent-row .tile { width: 72px; height: 72px; flex: none; }

.state { color: var(--muted); padding: 20px 4px; text-align: center; }
.state:empty { display: none; }
.state h3 { font: 600 18px var(--display); color: var(--text); margin: 0 0 6px; }
.state p { margin: 0 auto 12px; max-width: 42ch; }
.skeleton { aspect-ratio: 1; border-radius: 10px; background: linear-gradient(100deg, var(--panel-2) 30%, #332d26 50%, var(--panel-2) 70%); background-size: 300% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -150% 0; } }

.stash-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.stash-bar p { margin: 0; color: var(--muted); font-size: 14px; flex-basis: 100%; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); flex-basis: 100%; }
.drop.over { border-color: var(--accent); color: var(--text); }

.keys { display: none; gap: 18px; padding: 10px 16px; border-top: 1px solid var(--line); color: #8a7f70; font-size: 13px; }
.keys kbd { margin-right: 2px; }
@media (min-width: 820px) and (hover: hover) { .keys { display: flex; } }

.about { max-width: 1080px; margin: 0 auto; padding: 8px 20px 20px; display: grid; gap: 22px; }
@media (min-width: 820px) { .about { grid-template-columns: 1fr 1fr 1fr; } }
.about h2 { font: 600 19px var(--display); margin: 0 0 6px; letter-spacing: -0.01em; }
.about p { margin: 0 0 12px; color: var(--muted); }
.foot { max-width: 1080px; margin: 0 auto; padding: 10px 20px 40px; color: #8a7f70; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 12px;
  background: #f1ebe2; color: #1b1712; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { margin-left: 10px; background: none; border: 0; color: #7a4f00; font: 700 15px var(--ui); text-decoration: underline; cursor: pointer; min-height: 32px; }

.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; max-width: min(440px, calc(100vw - 32px)); padding: 22px; }
.dlg::backdrop { background: rgba(8,6,4,.7); }
.dlg h2 { font: 700 22px var(--display); margin: 0 0 8px; }
.dlg p { color: var(--muted); margin: 0 0 10px; }
.dlg .price { color: var(--text); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.manage > summary { list-style: none; width: 100%; margin-top: 8px; }
.manage > summary::-webkit-details-marker { display: none; }
.manage:not([open]) > summary::after { content: "+"; margin-left: 6px; color: var(--accent, #f2b544); }
@media (min-width: 820px) { .manage > summary { display: none; } }
@media (max-width: 819px) {
  .packs { mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 28px; }
  .manage[open] > summary { display: none; }
}
@media (hover: none) { .hint { display: none; } }
