:root {
  color-scheme: light dark;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --tag-bg: #eef2ff;
  --tag-line: #dbeafe;
  --tag-text: #1e3a8a;
  --banner-text-color-light: #111827;
  --banner-background-color-light: #fef3c7;
  --banner-text-color-dark: #111827;
  --banner-background-color-dark: #fef3c7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #111827;
    --text: #f9fafb;
    --muted: #9ca3af;
    --line: #374151;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --tag-bg: #1e293b;
    --tag-line: #334155;
    --tag-text: #bfdbfe;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.site-banner {
  text-align: center;
  font-weight: 600;
  padding: 0.7rem 1rem;
  color: var(--banner-text-color-light);
  background: var(--banner-background-color-light);
}

@media (prefers-color-scheme: dark) {
  .site-banner {
    color: var(--banner-text-color-dark);
    background: var(--banner-background-color-dark);
  }
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: flex-start;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.search-wrap {
  position: relative;
  flex: 0 1 320px;
  max-width: 34rem;
  margin-left: auto;
}

.search-input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.nav-icon-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

.nav-icon-link:hover {
  color: var(--accent);
  background: var(--tag-bg);
}

.search-results {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgb(0 0 0 / 18%);
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 0.35rem;
  z-index: 20;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}

.search-result:hover,
.search-result.active {
  background: var(--tag-bg);
}

.search-result-icon {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: var(--bg);
}

.search-result-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.search-result-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-meta {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-empty {
  padding: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 2rem);
}

.page-heading {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.page-heading h1 {
  margin: 0;
}

.page-icon {
  flex: none;
  border-radius: 12px;
}

.lead, .meta {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.parser-card:hover,
.artifact-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgb(0 0 0 / 10%);
  border-color: var(--accent);
}

.parser-card,
.artifact-card {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  text-decoration: none;
  color: inherit;
}

.parser-card {
  align-items: center;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  flex: 1 1 auto;
}

.artifact-card h3 {
  margin: 0;
}

.card-icon {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--bg);
  padding: 6px;
}

.card-description {
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  background: var(--tag-bg);
  border: 1px solid var(--tag-line);
  color: var(--tag-text);
  border-radius: 999px;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
}

.download-button {
  display: inline-block;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.download-button:hover {
  background: var(--accent-hover);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
}

th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.55rem;
  vertical-align: top;
}

.artifact-detail-page .page-icon {
  width: 96px;
  height: 96px;
  border-radius: 16px;
}

.artifact-detail-page .page-heading h1 {
  font-size: 1.85rem;
}

.extension-header {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin: 0 calc(-1 * clamp(1rem, 2vw, 2rem)) 2.25rem;
  padding: clamp(1rem, 2vw, 2rem) clamp(1rem, 2vw, 2rem) 1.75rem;
}

.extension-header .lead {
  margin: 0.6rem 0 0;
}

.extension-subheader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

.extension-meta {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.extension-publisher {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.extension-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.extension-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  flex: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.extension-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2rem;
  align-items: start;
}

.extension-main {
  min-width: 0;
}

.extension-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.sidebar-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.sidebar-card h2 {
  margin: 0 0 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.resource-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.resource-list a,
.resource-list button {
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.resource-list a:hover,
.resource-list button:hover {
  text-decoration: underline;
}

.detail-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-list dd {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.detail-list dd.hash {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

/* Rendered README markdown (see GenerateCommand#renderMarkdown) */
.readme {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  overflow-wrap: anywhere;
}

.readme > :first-child, .install-guide > :first-child {
  margin-top: 0;
}

.readme > :last-child, .install-guide > :last-child {
  margin-bottom: 0;
}

.readme h1, .readme h2, .readme h3, .readme h4, .readme h5, .readme h6,
.install-guide h1, .install-guide h2, .install-guide h3, .install-guide h4, .install-guide h5, .install-guide h6 {
  margin: 1.4em 0 0.6em;
  line-height: 1.3;
}

.readme h1, .install-guide h1 { font-size: 1.5rem; border-bottom: 1px solid var(--line); padding-bottom: 0.4rem; }
.readme h2, .install-guide h2 { font-size: 1.25rem; border-bottom: 1px solid var(--line); padding-bottom: 0.35rem; }
.readme h3, .install-guide h3 { font-size: 1.1rem; }
.readme h4, .install-guide h4 { font-size: 1rem; }

.readme p, .readme ul, .readme ol, .readme blockquote, .readme pre, .readme table,
.install-guide p, .install-guide ul, .install-guide ol, .install-guide blockquote, .install-guide pre, .install-guide table {
  margin: 0.8em 0;
}

.readme ul, .readme ol, .install-guide ul, .install-guide ol {
  padding-left: 1.5em;
}

.readme li + li, .install-guide li + li {
  margin-top: 0.25em;
}

.readme img, .install-guide img {
  max-width: 100%;
  height: auto;
}

.readme a, .install-guide a {
  color: var(--accent);
}

.readme code, .install-guide code {
  background: var(--tag-bg);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.readme pre, .install-guide pre {
  background: var(--tag-bg);
  border-radius: 8px;
  padding: 1em;
  overflow-x: auto;
  position: relative;
}

.readme pre code, .install-guide pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}

.readme blockquote, .install-guide blockquote {
  margin-left: 0;
  padding-left: 1em;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.readme hr, .install-guide hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.6em 0;
}

.readme table, .install-guide table {
  width: 100%;
  border-collapse: collapse;
}

.readme th, .readme td, .install-guide th, .install-guide td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.install-guide {
  overflow-wrap: anywhere;
}

/* "How to Install" popup (see artifact.ftl) */
.modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  background: var(--card);
  color: var(--text);
  width: min(32rem, calc(100vw - 2rem));
}

.modal::backdrop {
  background: rgb(0 0 0 / 50%);
}

.modal-content {
  padding: 1.25rem 1.4rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

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

.modal-close {
  background: none;
  border: none;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg);
}

.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
}

.copy-button:hover {
  color: var(--text);
  border-color: var(--muted);
}

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

@media (max-width: 768px) {
  .top-nav {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand brand"
      "search icon";
    align-items: center;
  }

  .brand {
    grid-area: brand;
  }

  .search-wrap {
    grid-area: search;
    max-width: none;
    margin-left: 0;
  }

  .nav-icon-link {
    grid-area: icon;
  }

  .artifact-detail-page .page-icon {
    width: 56px;
    height: 56px;
  }

  .extension-subheader {
    flex-direction: column;
  }
}

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

  .card-icon {
    width: 44px;
    height: 44px;
  }

  .page-icon {
    width: 44px;
    height: 44px;
  }
}
