:root {
  --bg: #0b0c0f;
  --bg-elev: #14161c;
  --bg-card: #181b22;
  --bg-card-hover: #1e2230;
  --line: #2a2f3a;
  --text: #eef0f5;
  --muted: #9aa3b5;
  --faint: #6b7385;
  --accent: #7c9cff;
  --accent-2: #ff7cac;
  --ok: #5ddea6;
  --warn: #f0c674;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
  --radius: 16px;
  --radius-sm: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --top: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124,156,255,.18), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(255,124,172,.12), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  backdrop-filter: blur(14px);
  background: rgba(11,12,15,.78);
  border-bottom: 1px solid var(--line);
  min-height: var(--top);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; flex-shrink: 0;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #7c9cff, #ff7cac);
  color: #0b0c0f; font-weight: 800;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.tabs {
  display: flex; gap: 4px; flex: 1; overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
  text-decoration: none;
  font-size: 14px;
}
.tabs a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tabs a.active {
  color: #0b0c0f;
  background: linear-gradient(135deg, #c9d6ff, #ffd0e1);
  font-weight: 600;
}

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  cursor: pointer; color: var(--muted);
}
.icon-btn.on { color: #ffd27a; border-color: #5a4a22; background: #2a2314; }

.toolbar {
  max-width: 1280px; margin: 0 auto;
  padding: 16px 16px 8px;
}
.search-wrap {
  position: relative;
  display: flex; align-items: center;
}
.search-wrap input {
  width: 100%;
  padding: 12px 44px 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  outline: none;
}
.search-wrap input:focus { border-color: #4a5d9b; box-shadow: 0 0 0 3px rgba(124,156,255,.18); }
.search-wrap kbd {
  position: absolute; right: 12px;
  font: 11px var(--mono);
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  background: var(--bg);
}

.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 12px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: #3d4558; }
.chip.active {
  color: #0b0c0f;
  background: var(--accent);
  border-color: transparent;
  font-weight: 600;
}

.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; color: var(--faint); font-size: 13px; gap: 12px;
}
.tray-hint { color: var(--ok); }

.grid {
  max-width: 1280px; margin: 0 auto;
  padding: 8px 16px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.grid.compose-mode {
  grid-template-columns: 1fr;
  max-width: 900px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  display: flex; flex-direction: column;
  min-height: 160px;
}
.card:hover {
  transform: translateY(-2px);
  border-color: #3d465c;
  background: var(--bg-card-hover);
}
.card-media {
  aspect-ratio: 3/4;
  background: #10131a;
  display: grid; place-items: center;
  overflow: hidden;
  position: relative;
}
.card-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.card-media .fallback {
  padding: 16px; text-align: center; color: var(--muted); font-size: 13px;
}
.card-body { padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-code {
  font: 11px/1.2 var(--mono); color: var(--accent); letter-spacing: .02em;
}
.card-title {
  font-size: 14px; font-weight: 650; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub {
  font-size: 12px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.tag {
  font-size: 11px; color: var(--faint);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 8px;
}
.card-actions {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 6px;
}
.mini-btn {
  width: 32px; height: 32px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.mini-btn.fav.on { color: #ffd27a; }
.mini-btn.add.on { color: var(--ok); }

.empty {
  grid-column: 1 / -1;
  text-align: center; color: var(--muted);
  padding: 64px 16px; border: 1px dashed var(--line); border-radius: var(--radius);
}

/* Drawer */
.drawer[hidden] { display: none; }
.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(520px, 100%);
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: auto;
  padding: 20px 20px 40px;
}
.drawer-close {
  position: sticky; top: 0; float: right;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-card);
  cursor: pointer; font-size: 20px; line-height: 1; z-index: 2;
}
.detail-media {
  width: 100%; border-radius: 14px; overflow: hidden;
  background: #10131a; margin: 8px 0 16px;
  aspect-ratio: 3/4; display: grid; place-items: center;
}
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.angle-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}
.angle-item {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #10131a;
}
.angle-item img {
  display: block;
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}
.angle-item figcaption {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px 2px 6px;
}
.compose-thumb {
  width: 72px;
  height: 96px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  margin-bottom: 10px;
  border: 1px solid var(--line);
}
.detail-kicker { font: 12px var(--mono); color: var(--accent); }
.detail-title { font-size: 22px; margin: 6px 0 10px; line-height: 1.3; }
.detail-block {
  margin: 14px 0; padding: 12px 14px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px;
}
.detail-block h4 {
  margin: 0 0 8px; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.detail-block p, .detail-block pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-size: 14px; line-height: 1.55;
}
.detail-block pre { font-family: var(--font); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn {
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { border-color: #4a556c; }
.btn.primary {
  background: linear-gradient(135deg, #7c9cff, #a9bfff);
  color: #0b0c0f; border: none; font-weight: 650;
}
.btn.ghost { background: transparent; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1f2430; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; z-index: 100;
  box-shadow: var(--shadow); font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.compose-box {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.compose-box h2 { margin: 0 0 8px; font-size: 20px; }
.compose-box .help { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.compose-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 720px) {
  .compose-pair { grid-template-columns: 1fr; }
  .brand-text span { display: none; }
  .tabs a { padding: 8px 10px; font-size: 13px; }
}
.slot {
  border: 1px dashed var(--line);
  border-radius: 14px; padding: 14px; min-height: 120px;
  background: rgba(255,255,255,.02);
}
.slot h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.slot .filled-title { font-weight: 650; margin-bottom: 6px; }
.slot .muted { color: var(--muted); font-size: 13px; }
.compose-result {
  margin-top: 14px;
  white-space: pre-wrap; word-break: break-word;
  background: #10131a; border-radius: 12px; padding: 14px;
  border: 1px solid var(--line); font-size: 14px; line-height: 1.6;
}

.site-footer {
  max-width: 1280px; margin: 0 auto;
  padding: 8px 16px 40px;
  color: var(--faint); font-size: 12px;
}
.site-footer p { margin: 0; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card-title { font-size: 13px; }
}
