:root {
  --bg: #fff;
  --fg: #1a1a1a;
  --muted: #666;
  --border: #e3e3e3;
  --accent: #c8102e;
  --accent-hover: #a00d24;
  --card: #fafafa;
  --in-stock: #1a7f37;
  --out-of-stock: #999;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  margin-bottom: 2rem;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-header .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
}
.site-header nav { display: flex; gap: 1.25rem; }
.site-header nav a { color: var(--fg); }
.site-header nav a:hover { color: var(--accent); }

h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 0; }

.muted { color: var(--muted); font-size: 0.95rem; }

/* Category tree */
.tree {
  list-style: none;
  padding-left: 0;
  border-left: 2px solid var(--border);
  margin: 1rem 0;
}
.tree .tree {
  margin: 0.25rem 0 0.25rem 1rem;
  border-left-color: var(--border);
}
.tree-node {
  padding: 0.25rem 0 0.25rem 0.75rem;
}
.tree-label {
  font-weight: 500;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.tree-label:hover {
  text-decoration-thickness: 2px;
  background: rgba(200, 16, 46, 0.07);
  border-radius: 3px;
  padding: 1px 4px;
  margin: -1px -4px;
}
.tree-id {
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Product grid */
.product-grid {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, transform 0.15s;
}
.product-card:hover { border-color: var(--accent); }
.product-card-link {
  display: block;
  padding: 1rem;
  color: inherit;
  text-decoration: none;
}
.product-card-link:hover { text-decoration: none; }
.product-name {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  line-height: 1.3;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
}
.sku {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
}
.price { font-weight: 600; }
.stock {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #f0f0f0;
  color: var(--out-of-stock);
}
.stock-in-stock { background: #ddf4e1; color: var(--in-stock); }
.badge {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  background: #fff7e0;
  color: #8a6d00;
  border-radius: 4px;
}

/* Product detail */
.product-detail header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.product-detail .product-meta { font-size: 1rem; margin-top: 0.5rem; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--card);
  border: 1px solid var(--border);
}

.rich-text { font-size: 0.95rem; }
.rich-text img { max-width: 100%; height: auto; }
.rich-text iframe { max-width: 100%; }
/* Autoterm marks inline body icons with .description--icon. Constrain them
   so SVGs don't render at their unbounded native size. */
.rich-text img.description--icon {
  width: 28px;
  height: 28px;
  margin-right: 0.6rem;
  vertical-align: middle;
  display: inline-block;
}

.specs {
  border-collapse: collapse;
  width: 100%;
  max-width: 520px;
  font-size: 0.95rem;
}
.specs th, .specs td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.specs th { font-weight: 500; color: var(--muted); width: 40%; }

.tag-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
}
