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

:root {
  --bg: #100c08;
  --surface: #100c08;
  --surface-strong: #100c08;
  --border: #1e2030;
  --accent: #8826f9;
  --text: #cdd6f4;
  --muted: #6c7086;
  --danger: #f7768e;
  --font-body: 'JetBrains Mono', monospace;
  --font-code: 'Space Mono', monospace;
}

::selection {
  background: var(--accent);
  color: #fff;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg);
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
}

body {
  margin: 0;
}

body.guides-home {
  padding: 48px 20px;
}

a {
  color: inherit;
}

.shell {
  width: min(980px, 100%);
  margin: 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
}

.shell > header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

.breadcrumb span {
  color: var(--text);
}

.hero {
  padding: 28px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  color: var(--accent);
  font-size: 18px;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.hero p {
  color: var(--text);
  max-width: 64ch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  display: block;
  min-height: 240px;
  padding: 24px;
  border-right: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.card:last-child {
  border-right: none;
}

.card:hover {
  background: rgba(17, 14, 12, 0.1);
}

.card .label {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card h2 {
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}

.card p {
  color: var(--muted);
  margin-bottom: 18px;
}

.card .link {
  color: var(--accent);
  font-family: var(--font-code);
  font-size: 13px;
}

#app {
  display: grid;
  grid-template-rows: 48px 1fr;
  height: 100vh;
}

#app > header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

#app > header h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.body {
  display: grid;
  grid-template-columns: 220px 1fr;
  overflow: hidden;
  height: 100%;
}

aside {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}

aside nav a,
.site-links a {
  display: block;
  padding: 8px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: color 0.15s ease, border-left-color 0.15s ease, background 0.15s ease;
  border-left: 2px solid transparent;
}

aside nav a:hover,
.site-links a:hover {
  color: var(--text);
}

aside nav a.active,
.site-links a.current {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(136, 38, 249, 0.08);
}

.site-links {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding: 12px 0 4px;
}

.site-links span {
  display: block;
  padding: 0 20px 6px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-links a {
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 12px;
}

main {
  overflow-y: auto;
  padding: 36px 48px;
}

.content {
  max-width: 860px;
  margin: 0 auto;
  transition: max-width 0.2s ease;
}

#app.wide .content {
  max-width: none;
}

.search-wrap {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
}

#search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-code);
  font-size: 12px;
  padding: 4px 10px;
  width: 180px;
  outline: none;
  transition: border-color 0.15s ease, width 0.2s ease;
  -webkit-appearance: none;
}

#search-input:focus {
  border-color: var(--accent);
  width: 240px;
}

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

#search-input::-webkit-search-cancel-button {
  display: none;
}

#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  z-index: 200;
  max-height: 360px;
  overflow-y: auto;
}

#search-results.open {
  display: block;
}

.search-result {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover,
.search-result.active {
  background: rgba(136, 38, 249, 0.08);
}

.search-result-label {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.search-result-snippet {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.search-result-snippet mark {
  background: rgba(136, 38, 249, 0.25);
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}

.search-empty {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12px;
}

#width-toggle {
  margin-left: 12px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-code);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

#width-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

#app.wide #width-toggle {
  color: var(--accent);
  border-color: var(--accent);
}

.content h1 {
  color: var(--accent);
  font-size: 22px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.content h2 {
  color: var(--text);
  font-size: 16px;
  margin: 28px 0 10px;
}

.content h3 {
  color: var(--text);
  font-size: 14px;
  margin: 20px 0 8px;
}

.content p {
  margin-bottom: 14px;
  color: var(--text);
}

.content a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.content a:hover {
  opacity: 0.75;
}

.content code {
  font-family: var(--font-code);
  background: var(--surface);
  color: #bb9af7;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 14px 0;
}

.content pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.content th {
  background: var(--surface);
  color: var(--accent);
  padding: 8px 12px;
  text-align: left;
  border: 1px solid var(--border);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.content td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  color: var(--text);
}

.content tr:nth-child(even) td {
  background: rgba(31, 35, 53, 0.5);
}

.content blockquote {
  border-left: 2px solid var(--accent);
  padding: 8px 16px;
  margin: 14px 0;
  color: var(--muted);
  background: var(--surface);
  border-radius: 0 4px 4px 0;
}

.content ul,
.content ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

.content li {
  margin-bottom: 4px;
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

#loader {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
}

#error {
  color: var(--danger);
  font-size: 13px;
  padding: 12px 0;
}

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

  .card {
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .card:last-child {
    border-bottom: none;
  }
}

@media (max-width: 700px) {
  .body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  aside {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0;
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
  }

  aside nav {
    display: flex;
    padding: 8px 0;
  }

  aside nav a,
  .site-links a {
    padding: 6px 14px;
    border-left: none;
    border-bottom: 2px solid transparent;
    flex-shrink: 0;
  }

  aside nav a.active,
  .site-links a.current {
    border-bottom-color: var(--accent);
    border-left: none;
    background: none;
  }

  .site-links {
    display: none;
  }

  .search-wrap,
  #width-toggle {
    display: none;
  }

  main {
    padding: 20px 16px;
  }

  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: calc(100vw - 32px);
  }

  .content pre {
    max-width: calc(100vw - 32px);
  }
}

@media (max-width: 480px) {
  body.guides-home {
    padding: 20px 12px;
  }

  .hero {
    padding: 20px 16px 14px;
  }

  .hero h1 {
    font-size: 15px;
  }

  .shell > header {
    padding: 14px 16px;
  }

  .card {
    padding: 18px 16px;
  }
}
