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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
  color: #1a1a1a;
  line-height: 1.6;
  background: #fff;
}

a {
  color: #2563eb;
}

code, pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* --- Header --- */

header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.75rem;
  margin-bottom: 2rem;
}

header a {
  text-decoration: none;
  color: #111;
  font-weight: 600;
}

header h1 {
  font-size: 1.4rem;
  margin: 0;
}

/* --- Badges --- */

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2em 0.5em;
  border-radius: 3px;
  vertical-align: middle;
}

.badge-function         { background: #dbeafe; color: #1d4ed8; }
.badge-macro            { background: #d1fae5; color: #065f46; }
.badge-special-operator { background: #fef9c3; color: #854d0e; }
.badge-generic-function { background: #ede9fe; color: #5b21b6; }
.badge-variable         { background: #ffe4e6; color: #9f1239; }
.badge-constant         { background: #fce7f3; color: #9d174d; }
.badge-type             { background: #f1f5f9; color: #334155; }
.badge-condition-type   { background: #fef3c7; color: #92400e; }
.badge-built-in-class   { background: #ecfdf5; color: #064e3b; }
.badge-unknown          { background: #f3f4f6; color: #6b7280; }

/* --- Symbol detail page --- */

.symbol-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

h1.symbol-name {
  font-size: 1.8rem;
  margin: 0;
  font-family: monospace;
  font-weight: 700;
}

.package {
  color: #6b7280;
  font-size: 0.85rem;
}

pre.usage {
  background: #f8fafc;
  border-left: 3px solid #3b82f6;
  padding: 0.7rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

p.summary {
  font-size: 1.05rem;
  margin: 1rem 0;
  color: #374151;
}

/* --- Description --- */

.description {
  margin: 1.5rem 0;
  color: #1f2937;
}

.description p {
  margin: 0.75rem 0;
}

.description code {
  background: #f1f5f9;
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.875em;
}

.description a code {
  background: none;
  padding: 0;
  color: #2563eb;
}

/* --- Examples --- */

.examples,
.see-also {
  margin: 2rem 0;
}

.examples h2,
.see-also h2 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}

.example {
  margin-bottom: 1.25rem;
}

pre.example-code {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  margin: 0;
  border-radius: 4px 4px 0 0;
  font-size: 0.875rem;
  overflow-x: auto;
}

pre.example-result {
  background: #0f172a;
  color: #94a3b8;
  padding: 0.5rem 1rem;
  margin: 0;
  border-radius: 0 0 4px 4px;
  font-size: 0.875rem;
  overflow-x: auto;
}

.result-arrow {
  color: #475569;
  user-select: none;
}

/* --- See Also --- */

.see-also ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.see-also li a,
.see-also li code {
  display: inline-block;
  background: #f1f5f9;
  color: #1d4ed8;
  text-decoration: none;
  padding: 0.2em 0.55em;
  border-radius: 3px;
  font-size: 0.875rem;
}

.see-also li a:hover {
  background: #dbeafe;
}

/* --- CLHS link --- */

p.clhs-link {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

p.clhs-link a {
  color: #6b7280;
  font-size: 0.875rem;
  text-decoration: none;
}

p.clhs-link a:hover {
  color: #374151;
  text-decoration: underline;
}

/* --- Footer --- */

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  color: #9ca3af;
  font-size: 0.8rem;
}

/* ==========================================
   Index / search page
   ========================================== */

p.tagline {
  color: #6b7280;
  margin: 0 0 1.25rem;
}

.search-box {
  margin-bottom: 0.75rem;
}

#search {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  outline: none;
  background: #fff;
}

#search:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.package-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.type-btn {
  padding: 0.25em 0.65em;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  color: #374151;
  line-height: 1.5;
}

.type-btn:hover {
  border-color: #9ca3af;
}

.type-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

p.result-count {
  color: #6b7280;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

p.loading,
p.no-results {
  color: #9ca3af;
  text-align: center;
  padding: 3rem 0;
}

/* --- Symbol table --- */

.symbol-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.symbol-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 2px solid #e5e7eb;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.symbol-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: baseline;
}

.symbol-table td:first-child {
  font-family: monospace;
  font-weight: 600;
  white-space: nowrap;
}

.symbol-table td:first-child a {
  text-decoration: none;
  color: #1d4ed8;
}

.symbol-table td:first-child a:hover {
  text-decoration: underline;
}

.symbol-table td:nth-child(2),
.symbol-table td:nth-child(3) {
  white-space: nowrap;
}

.package-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15em 0.45em;
  border-radius: 3px;
  font-family: monospace;
}

.package-badge-cl         { background: #f1f5f9; color: #475569; }
.package-badge-uiop       { background: #ecfdf5; color: #065f46; }
.package-badge-asdf       { background: #dbeafe; color: #1e40af; }
.package-badge-alexandria { background: #ede9fe; color: #5b21b6; }

.symbol-table td:last-child {
  color: #4b5563;
}
