:root {
  --bg: #0f1117;
  --bg-elevated: #171b26;
  --bg-card: #1c2233;
  --border: #2a3348;
  --text: #e8ecf4;
  --text-muted: #8b95ad;
  --accent: #6c5ce7;
  --accent-hover: #7d6ff0;
  --accent-glow: rgba(108, 92, 231, 0.35);
  --success: #00c878;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Nunito", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --header-h: 72px;
  --sidebar-w: 260px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 92, 231, 0.18), transparent),
    var(--bg);
}

a {
  color: #7eb8ff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
}

.btn-sm {
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--border);
}

/* Layout */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-wrap input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-family: var(--font);
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
}

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

.category-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cat-btn {
  text-align: left;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cat-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.cat-btn.active {
  background: var(--accent);
  color: #fff;
}

.cat-count {
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: 700;
}

/* Content */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.how-to h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.how-to ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.how-to li {
  margin-bottom: 0.35rem;
}

.how-to kbd {
  font-family: var(--mono);
  font-size: 0.8em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.note {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.results-meta {
  margin: 1.25rem 0 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.cheat-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cheat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: start;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cheat-card:hover {
  border-color: #3d4a66;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.cheat-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.cheat-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2em 0.5em;
  border-radius: 4px;
  background: rgba(108, 92, 231, 0.2);
  color: #a99cf7;
  margin-bottom: 0.35rem;
}

.cheat-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.cheat-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.cheat-preview {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.75rem 1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 4.5em;
  color: #9aa5c4;
  white-space: pre-wrap;
  word-break: break-all;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Footer */
.site-footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0.25rem 0;
}

.credits a {
  color: var(--text-muted);
}

.credits a:hover {
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65rem 1.25rem;
  background: var(--success);
  color: #0a1a12;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 8px 32px rgba(0, 200, 120, 0.35);
  z-index: 200;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Modal */
.modal {
  border: none;
  padding: 0;
  max-width: min(720px, 92vw);
  width: 100%;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0.15rem 0 0;
  font-size: 1.2rem;
}

.modal-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a99cf7;
}

.modal-file {
  margin: 0;
  padding: 0.5rem 1.25rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.code-block {
  margin: 0.75rem 1.25rem;
  padding: 1rem;
  max-height: 50vh;
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.code-block code {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre;
  color: #c5cee0;
}

.modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .category-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .cat-btn {
    flex: 0 1 auto;
  }

  .cheat-card {
    grid-template-columns: 1fr;
  }

  .cheat-actions {
    flex-direction: row;
  }

  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
  }
}
