/* Design system faithfully ported from Source-blip's catalog (MIT) —
   their tokens/layout verified from source; dark theme & zh/en toggle are our additions. */
:root {
  --bg: #f4f5f8;
  --paper: #fff;
  --line: #e4e6ec;
  --text: #181b24;
  --muted: #737986;
  --accent: #5548e7;
  --soft: #efefff;
  --green: #087d55;
  --orange: #9a5700;
  --top-h: 70px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0a0d14;
  --paper: #141927;
  --line: #232b3e;
  --text: #e6eaf2;
  --muted: #8b94a8;
  --accent: #818cf8;
  --soft: rgba(129, 140, 248, 0.14);
  --green: #34d399;
  --orange: #fbbf24;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
button, input, select { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hide { display: none !important; }
code {
  background: var(--soft); border: 0; border-radius: 6px; padding: 2px 8px;
  font-size: 12px; word-break: break-all; color: #4338ca;
}
[data-theme="dark"] code { color: #c7d2fe; }

/* ---------- top ---------- */
.top {
  height: var(--top-h); padding: 0 24px;
  display: flex; align-items: center; gap: 13px;
  background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
}
.top h1 { font-size: 19px; margin: 0; min-width: 0; white-space: nowrap; }
.top .tagline { color: var(--muted); font-size: 12px; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.snap { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ctl {
  height: 34px; padding: 0 12px;
  border: 1px solid #d8dbe4; border-radius: 999px; background: var(--paper);
  color: #373c49; font-size: 12px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
[data-theme="dark"] .ctl { border-color: var(--line); color: var(--text); }
.ctl:hover { border-color: #bdb7ff; background: var(--soft); color: #4338ca; text-decoration: none; }
[data-theme="dark"] .ctl:hover { color: var(--accent); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 340px;
  min-height: calc(100vh - var(--top-h));
}

/* sidebar — flush, full height */
.sidebar {
  padding: 20px 13px;
  border-right: 1px solid var(--line);
  background: #fafafd;
  position: sticky; top: var(--top-h);
  height: calc(100vh - var(--top-h));
  overflow: auto;
}
[data-theme="dark"] .sidebar { background: #0f1320; }
.side-title { padding: 0 10px 9px; color: #9297a4; font-size: 11px; font-weight: 800; letter-spacing: 0.1em; }
.side-btn {
  width: 100%; border: 0; background: transparent;
  padding: 9px 10px; border-radius: 9px; text-align: left;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; color: var(--text); font-size: 14px;
}
.side-btn:hover, .side-btn.active { background: var(--soft); color: #4338ca; }
[data-theme="dark"] .side-btn:hover, [data-theme="dark"] .side-btn.active { color: var(--accent); }
.side-btn span:last-child { color: #969baa; font-size: 11px; }

/* ---------- controls (sticky white bar) ---------- */
.main { min-width: 0; }
.controls {
  padding: 17px 20px 13px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: var(--top-h); z-index: 20;
}
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 9px; align-items: center; }
.search {
  width: 100%; height: 48px;
  border: 1px solid #d5d8e0; border-radius: 12px; padding: 0 16px;
  font-size: 15px; outline: none; background: var(--paper); color: var(--text);
}
[data-theme="dark"] .search { border-color: var(--line); }
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(85, 72, 231, 0.1); }
.toggle { color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; }
.clear {
  height: 39px; border: 1px solid #dfe2e9; border-radius: 9px;
  background: #252936; color: #fff; padding: 0 15px; cursor: pointer;
}
.quick-filters { display: flex; gap: 7px; margin-top: 9px; align-items: center; flex-wrap: wrap; }
.quick-btn {
  height: 34px; border: 1px solid #dfe2e9; border-radius: 999px;
  background: var(--paper); padding: 0 12px; color: #555b68; font-size: 12px; cursor: pointer;
}
[data-theme="dark"] .quick-btn { border-color: var(--line); color: var(--muted); }
.quick-btn:hover, .quick-btn.active { border-color: #c6c0ff; background: var(--soft); color: #4338ca; }
[data-theme="dark"] .quick-btn:hover, [data-theme="dark"] .quick-btn.active { color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.filters select {
  flex: 1 1 130px; min-width: 0; height: 39px;
  border: 1px solid #dfe2e9; border-radius: 9px;
  background: var(--paper); color: var(--text); padding: 0 9px;
}
[data-theme="dark"] .filters select { border-color: var(--line); }
.summary { margin-top: 9px; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---------- grid & cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  padding: 18px 19px 48px;
}
.card {
  min-height: 260px; padding: 17px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--paper); cursor: pointer; transition: 0.18s;
}
.card:hover { transform: translateY(-2px); border-color: #c4c0ff; box-shadow: 0 10px 24px rgba(48, 44, 112, 0.09); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(85, 72, 231, 0.12); }
.icon {
  width: 58px; height: 58px; object-fit: contain; border-radius: 14px;
  filter: drop-shadow(0 4px 7px rgba(20, 23, 34, 0.1));
  background: transparent;
}
.tile {
  width: 58px; height: 58px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; color: #fff;
}
.card h3 { font-size: 15px; margin: 13px 0 2px; line-height: 1.4; }
.en { color: #858b98; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desc {
  font-size: 12px; color: #525866; line-height: 1.55; margin: 10px 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
[data-theme="dark"] .desc { color: var(--muted); }
.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge { font-size: 10px; padding: 4px 7px; border-radius: 7px; background: #eef0f4; color: #626876; }
[data-theme="dark"] .badge { background: #1c2334; color: var(--muted); }
.badge.ok { background: #e0f3e9; color: var(--green); }
.badge.warn { background: #fff0da; color: var(--orange); }
.badge.new { background: #ede9fe; color: #6d28d9; font-weight: 700; }
.badge.kind { background: var(--soft); color: #4338ca; font-weight: 700; }
[data-theme="dark"] .badge.kind { color: var(--accent); }

/* ---------- detail pane ---------- */
.detail {
  position: sticky; top: var(--top-h);
  height: calc(100vh - var(--top-h)); overflow: auto;
  padding: 25px; border-left: 1px solid var(--line); background: var(--paper);
}
.detail .icon, .detail .tile { width: 80px; height: 80px; font-size: 30px; }
.detail h2 { font-size: 21px; margin: 16px 0 3px; line-height: 1.35; }
.detail-en { color: #858b98; font-size: 13px; }
.detail-desc { font-size: 14px; line-height: 1.75; color: #474d5a; margin: 18px 0; white-space: pre-wrap; }
[data-theme="dark"] .detail-desc { color: var(--text); }
.detail-close, .detail-backdrop { display: none; }
.detail-close {
  width: 100%; height: 42px; margin: 0 0 18px;
  border: 1px solid #dfe2e9; border-radius: 10px;
  background: var(--paper); color: #343946; font-weight: 700; cursor: pointer;
}
.block { padding: 14px 0; border-top: 1px solid #eceef2; font-size: 13px; line-height: 1.65; }
.block strong { display: block; color: #8b909d; font-size: 10px; letter-spacing: 0.08em; margin-bottom: 5px; }
.original { color: #747a88; }
.link {
  display: block; text-align: center; text-decoration: none;
  background: var(--accent); color: #fff; padding: 11px; border-radius: 10px; font-weight: 700;
}
.link:hover { text-decoration: none; filter: brightness(1.06); }
.notice {
  padding: 10px; border-radius: 9px;
  background: #fff5df; color: #865300; font-size: 12px; margin-top: 12px;
}
[data-theme="dark"] .notice { background: rgba(251, 191, 36, 0.1); color: var(--orange); }
.install-title { font-weight: 800; font-size: 15px; margin-bottom: 10px; color: #4338ca; }
[data-theme="dark"] .install-title { color: var(--accent); }
.install ol { margin: 0 0 12px; padding-left: 20px; font-size: 13px; }
.install li { margin: 8px 0; }
.copybtn {
  display: block; width: 100%; margin-top: 8px;
  height: 39px; border: 1px dashed #bfc4cf; border-radius: 9px;
  background: var(--bg); color: var(--text); cursor: pointer; font-size: 12px;
  word-break: break-all;
}
.copybtn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- footer ---------- */
footer {
  padding: 16px 24px 34px;
  color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
footer a { color: var(--accent); }

/* ---------- mobile drawer (their pattern) ---------- */
@media (max-width: 1120px) {
  .layout { grid-template-columns: 190px minmax(0, 1fr); }
  .detail {
    display: none; position: fixed; top: var(--top-h); right: 0;
    width: min(430px, 100%); height: calc(100vh - var(--top-h));
    z-index: 60; box-shadow: -18px 0 50px rgba(26, 29, 42, 0.18);
  }
  .detail-backdrop { position: fixed; inset: var(--top-h) 0 0; border: 0; background: rgba(24, 27, 36, 0.32); z-index: 50; }
  .detail-close { display: block; }
  body.detail-open { overflow: hidden; }
  body.detail-open .detail, body.detail-open .detail-backdrop { display: block; }
}
@media (max-width: 760px) {
  .top { height: 64px; padding: 0 14px; }
  .top .tagline, .snap { display: none; }
  :root { --top-h: 64px; }
  .layout { display: block; }
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line);
    display: flex; overflow: auto; padding: 8px;
  }
  .side-title { display: none; }
  .side-btn { min-width: max-content; }
  #rail { display: flex; gap: 6px; min-width: max-content; }
  .controls { top: 64px; padding: 12px; }
  .quick-filters { overflow-x: auto; scrollbar-width: none; }
  .quick-filters::-webkit-scrollbar { display: none; }
  .quick-btn { white-space: nowrap; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  .card { min-height: 245px; }
}
@media (max-width: 460px) {
  .grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
}
