:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-alt: #eef2f6;
  --border: #dce3ec;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.11);
  --ok: #16a34a;
  --code-bg: #111827;
  --code-head: #1b2436;
  --code-border: #28354d;
  --code-text: #e5edf7;
  --code-muted: #94a3b8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.04);
  --radius: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

[data-theme="dark"] {
  --bg: #0b111b;
  --surface: #111927;
  --surface-alt: #182234;
  --border: #233046;
  --text: #e6edf6;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --ok: #22c55e;
  --code-bg: #090e17;
  --code-head: #121b2b;
  --code-border: #1e2b42;
  --code-text: #e2e8f0;
  --code-muted: #7f91ab;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 26px rgba(0, 0, 0, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--code-bg);
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--code-border);
}

.brand-host {
  font-family: var(--font-mono);
  font-size: 13.5px;
}

.nav-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-alt);
  text-decoration: none;
}

.nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.theme-btn:hover {
  border-color: var(--accent);
}

.theme-btn svg {
  width: 15px;
  height: 15px;
}

/* Main */
main {
  flex: 1;
  padding: 28px 0 48px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.hero-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.hero h1 {
  margin: 0;
  font-size: clamp(24px, 3.2vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 72ch;
  color: var(--text-muted);
  font-size: 15px;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1 1 280px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 70px 9px 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.kbd-hint {
  position: absolute;
  right: 10px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: none;
}

.clear-search {
  position: absolute;
  right: 36px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.clear-search.is-visible {
  display: inline-flex;
}

.clear-search:hover {
  color: var(--text);
}

.result-count {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tag-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.tag-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.tag-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Grid & Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 490px), 1fr));
  gap: 18px;
}

.card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card.is-hidden {
  display: none;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-desc {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.badge {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.cmd-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cmd-box {
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
}

.cmd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: var(--code-head);
  border-bottom: 1px solid var(--code-border);
}

.cmd-label {
  color: var(--code-muted);
  font-size: 12px;
  font-family: var(--font-sans);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 11.5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.copy-btn:hover {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.5);
  color: #ffffff;
}

.copy-btn.is-copied {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.55);
  color: #86efac;
}

.copy-btn svg {
  width: 13px;
  height: 13px;
}

.cmd-box pre {
  margin: 0;
  padding: 11px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.8px;
  line-height: 1.5;
  color: var(--code-text);
  tab-size: 2;
}

.cmd-box code {
  font-family: inherit;
  white-space: pre;
}

/* Empty State */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 42px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px dashed var(--border);
}

.empty-state.is-visible {
  display: flex;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted);
}

.reset-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.reset-btn:hover {
  border-color: var(--accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.footer-links a:hover {
  color: var(--accent);
}

@media (max-width: 640px) {
  .container {
    padding: 0 14px;
  }
  .header-inner {
    gap: 10px;
  }
  .card {
    padding: 14px;
  }
  .card-head {
    flex-direction: column;
    gap: 6px;
  }
  .card-tags {
    justify-content: flex-start;
  }
  .kbd-hint {
    display: none;
  }
  .search-input {
    padding-right: 38px;
  }
  .clear-search {
    right: 10px;
  }
}
