:root {
  --bg: #faf8f4;
  --ink: #2b2724;
  --ink-soft: #7a736b;
  --line: #e8e2d8;
  --card: #ffffff;
  --accent: #f28f6b;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

.hidden { display: none !important; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.logo-dots { display: inline-flex; gap: 4px; align-self: center; }
.logo-dots i {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--c);
  animation: bob 2.6s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.18s);
}
.logo-dots i:nth-child(2) { animation-delay: .15s; }
.logo-dots i:nth-child(3) { animation-delay: .3s; }
.logo-dots i:nth-child(4) { animation-delay: .45s; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.logo-text {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 2px;
}

.logo-sub { font-size: 11px; color: var(--ink-soft); letter-spacing: 1px; }

.nav { display: flex; gap: 6px; }

.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .18s ease;
}
.nav-btn:hover { color: var(--ink); background: #f1ece2; }
.nav-btn.active {
  color: var(--ink);
  background: var(--card);
  border-color: var(--line);
  box-shadow: 0 1px 4px rgba(43, 39, 36, .06);
  font-weight: 600;
}

/* ---------- discover ---------- */
#view-discover { padding: 40px 28px 64px; max-width: 1200px; margin: 0 auto; }

.hero h1 {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: 2px;
}
.hero p { margin-top: 8px; color: var(--ink-soft); font-size: 15px; }

.toolbar {
  margin: 28px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tabs { display: flex; background: #f1ece2; border-radius: 999px; padding: 4px; }
.tab {
  border: none; background: transparent;
  padding: 7px 20px; border-radius: 999px;
  font-size: 13.5px; color: var(--ink-soft); cursor: pointer;
  transition: all .18s ease;
}
.tab.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(43,39,36,.08); }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--ink-soft);
  min-width: 260px;
}
.searchbox input {
  border: none; outline: none; background: transparent;
  font-size: 13.5px; color: var(--ink); width: 100%;
  font-family: inherit;
}
.searchbox:focus-within { border-color: #d9cfc0; box-shadow: 0 0 0 3px rgba(242, 143, 107, .12); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
  animation: rise .4s ease backwards;
  animation-delay: calc(var(--d, 0) * 35ms);
}
.card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px -12px rgba(43, 39, 36, .22); }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.stripes { display: flex; height: 132px; }
.stripe {
  flex: 1;
  position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 6px;
}
.stripe .hex {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10.5px;
  letter-spacing: .3px;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  padding: 2px 7px;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: all .15s ease;
  pointer-events: none;
}
.stripe:hover .hex { opacity: 1; transform: translateY(0); }

.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
}
.card-name { font-size: 14px; font-weight: 600; letter-spacing: .5px; }
.like-btn {
  display: flex; align-items: center; gap: 5px;
  border: none; background: transparent;
  color: var(--ink-soft); font-size: 13px; cursor: pointer;
  padding: 4px 6px; border-radius: 8px;
  transition: all .15s ease;
}
.like-btn:hover { background: #f6efe4; color: #d9534f; }
.like-btn.liked { color: #d9534f; }
.like-btn.liked svg { fill: #d9534f; stroke: #d9534f; }
.like-btn svg { transition: transform .15s ease; }
.like-btn:active svg { transform: scale(1.35); }

.empty {
  text-align: center; color: var(--ink-soft);
  padding: 60px 0; font-size: 14.5px;
}

/* ---------- generator ---------- */
#view-generator { display: flex; flex-direction: column; height: calc(100vh - 62px); }
#view-generator.hidden { display: none !important; }

.gen { display: flex; flex: 1; }
.gen-col {
  flex: 1;
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 90px;
  transition: background-color .3s ease;
  cursor: pointer;
  user-select: none;
}
.gen-col .hex-label {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: clamp(13px, 1.6vw, 18px);
  letter-spacing: 1px;
  font-weight: 600;
  opacity: .92;
}
.gen-col .lock {
  position: absolute; top: 22px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: none; cursor: pointer;
  font-size: 16px;
  background: rgba(0, 0, 0, .14);
  opacity: 0;
  transform: translateY(-4px);
  transition: all .18s ease;
}
.gen-col:hover .lock { opacity: 1; transform: translateY(0); }
.gen-col .lock.locked { opacity: 1; background: rgba(0, 0, 0, .3); }

.gen-bar {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  z-index: 10;
}
.gen-hint {
  position: absolute; bottom: 40px; left: 0; right: 0;
  text-align: center;
  font-size: 12.5px; letter-spacing: 1px;
  z-index: 10;
}

.btn {
  border: 1px solid rgba(0, 0, 0, .18);
  background: rgba(255, 255, 255, .9);
  color: #1c1a17;
  font-size: 13.5px; font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
  transition: all .15s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(0, 0, 0, .18); }
.btn:active { transform: translateY(0); }
.btn.primary { background: #1c1a17; color: #fff; border-color: #1c1a17; }
.btn kbd {
  font-family: inherit; font-size: 11px;
  background: rgba(255, 255, 255, .18);
  padding: 1px 6px; border-radius: 5px; margin-left: 2px;
}
.select {
  border: 1px solid rgba(0, 0, 0, .18);
  background: rgba(255, 255, 255, .9);
  font-size: 13px; font-weight: 600;
  padding: 10px 14px; border-radius: 999px;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
  outline: none;
}

/* ---------- footer / toast ---------- */
.site-footer {
  padding: 18px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #1c1a17; color: #fff;
  font-size: 13.5px;
  padding: 11px 22px;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3);
  z-index: 100;
  animation: toast-in .22s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .site-header { padding: 12px 16px; }
  .logo-sub { display: none; }
  #view-discover { padding: 26px 16px 48px; }
  .searchbox { min-width: 0; flex: 1; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .tabs { justify-content: center; }
  .gen { flex-direction: column; }
  .gen-col { padding-bottom: 34px; min-height: 60px; }
  .gen-col .hex-label { font-size: 12px; }
  .gen-col .lock { top: 10px; right: 12px; width: 30px; height: 30px; font-size: 13px; }
  .gen-bar { flex-wrap: wrap; justify-content: center; width: calc(100% - 24px); bottom: 74px; }
  .gen-hint { display: none; }
}
