:root {
  --bg: #ffffff;
  --surface: #f4f4f6;
  --text: #111114;
  --muted: #6b6b73;
  --line: #e6e6ea;
  --accent: #0a7cff;
  --green: #1f9d55;
  --green-bg: #e7f6ed;
  --red: #e5373a;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d10;
    --surface: #1b1b20;
    --text: #f2f2f5;
    --muted: #9a9aa3;
    --line: #2a2a31;
    --accent: #3d9bff;
    --green: #3ccf7a;
    --green-bg: #15301f;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0d10; --surface: #1b1b20; --text: #f2f2f5; --muted: #9a9aa3;
  --line: #2a2a31; --accent: #3d9bff; --green: #3ccf7a; --green-bg: #15301f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { font-weight: 800; font-size: 20px; color: var(--text); letter-spacing: -0.02em; }
nav a { color: var(--muted); font-size: 15px; }

.hero { padding: 36px 0 12px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.03em; }
.hero p { margin: 0 0 18px; color: var(--muted); }
#search {
  width: 100%; max-width: 560px; height: 46px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--text); font: inherit; outline: none;
}
#search:focus { border-color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: 999px; padding: 8px 15px; cursor: pointer;
  background: var(--surface); color: var(--text); font: 500 14px/1 inherit; font-family: inherit;
}
.chip[aria-selected="true"] { background: var(--text); color: var(--bg); }

h2 { font-size: 21px; margin: 28px 0 12px; letter-spacing: -0.01em; }
.count { color: var(--muted); font-weight: 400; font-size: 15px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

.card {
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--surface); border-radius: var(--radius); color: var(--text);
  transition: transform .15s ease;
}
.card:hover { transform: translateY(-2px); }
.thumb {
  aspect-ratio: 1; border-radius: 12px; background: #fff;
  display: grid; place-items: center; overflow: hidden;
}
.thumb img { width: 88%; height: 88%; object-fit: contain; }
.thumb .icon { font-size: 44px; }
.brand { color: var(--muted); font-size: 13px; }
.title { font-size: 15px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.price { font-size: 14px; color: var(--muted); }
.code-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge { background: var(--green-bg); color: var(--green); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 999px; }
.code {
  border: 1.5px dashed var(--green); color: var(--text); background: transparent; border-radius: 8px;
  padding: 3px 8px; font: 700 13px ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
}
.cta {
  margin-top: auto; text-align: center; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 9px 12px; font-weight: 600; font-size: 14px;
}

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.foot { border-top: 1px solid var(--line); margin-top: 48px; padding-top: 20px; padding-bottom: 40px; color: var(--muted); font-size: 14px; }

.doc { max-width: 720px; padding-top: 24px; padding-bottom: 40px; }
.doc h1 { letter-spacing: -0.02em; }
.doc h2 { margin-top: 28px; }
.doc p, .doc li { color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
