/* GridUnit site: catalog + part pages */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --text: #1d2330;
  --muted: #646c7e;
  --border: #dde1e8;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --amber: #e9a520;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-hover: 0 4px 16px rgb(16 24 40 / 12%);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #232832;
    --text: #e3e7ee;
    --muted: #949cad;
    --border: #2d333e;
    --accent: #6b9bf5;
    --accent-text: #0d1117;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-hover: 0 6px 20px rgb(0 0 0 / 45%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.92em; }
img { max-width: 100%; height: auto; display: block; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 1160px; padding: 12px 20px;
  font-weight: 700; font-size: 17px; letter-spacing: 0.01em;
  color: var(--text); text-decoration: none;
}
.brand svg { width: 20px; height: 20px; fill: var(--amber); }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.top-nav { display: flex; padding-right: 8px; }
.top-nav a { padding: 12px 12px; font-weight: 600; font-size: 14px; color: var(--text); text-decoration: none; }
.top-nav a:hover { color: var(--accent); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px;
  border-radius: 10px; background: var(--accent); color: var(--accent-text);
  font-size: 12px; line-height: 20px; text-align: center;
}
.count[hidden] { display: none; }

/* Catalog */
.hero { padding: 40px 0 8px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; }
.hero p { margin: 0; color: var(--muted); max-width: 60ch; font-size: 16px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 24px 0 4px; }
.filters input[type=search] {
  flex: 0 1 280px; min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.empty { color: var(--muted); }

.section { margin: 36px 0 8px; scroll-margin-top: 64px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 22px; }
.section-head p { margin: 0; color: var(--muted); }

.cards {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.card:hover, .card:focus-within { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card-main { flex: 1; display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.card-actions {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px 8px;
  border-top: 1px solid var(--border);
}
.card-actions a {
  padding: 4px 8px; border-radius: 6px;
  font-size: 13px; font-weight: 600; text-decoration: none; color: var(--muted);
}
.card-actions a:hover { background: var(--surface-2); color: var(--text); }
.card-actions a.primary { color: var(--accent); margin-right: auto; }
.thumb {
  aspect-ratio: 4 / 3;
  background: radial-gradient(circle at 50% 40%, var(--surface) 0%, var(--surface-2) 100%);
  display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.no-model { color: var(--muted); font-size: 13px; }
.card-body { padding: 10px 14px 14px; }
.card h3 { margin: 0; font-size: 15px; }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tags span {
  font-size: 12px; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}

/* Part page */
.crumbs { margin: 24px 0 16px; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--muted); }
.part { display: grid; gap: 28px; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
.part-media { display: grid; gap: 12px; }
.part-media .photo { border-radius: var(--radius); border: 1px solid var(--border); }
.render {
  display: block; aspect-ratio: 4 / 3;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: radial-gradient(circle at 50% 40%, var(--surface) 0%, var(--surface-2) 100%);
}
.render img { width: 100%; height: 100%; object-fit: contain; }
div.render { display: grid; place-items: center; padding: 20px; text-align: center; }
.part-info h1 { margin: 0; font-size: clamp(26px, 3.4vw, 34px); line-height: 1.2; }
.summary { margin: 8px 0 0; color: var(--muted); font-size: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 6px; }
.button {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; text-decoration: none;
}
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
.build-parts { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.build-parts .values { font-size: 12px; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: 0; }
.facts { margin: 22px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
.facts dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.facts dd { margin: 0; }
.facts dd ul { margin: 0; padding-left: 18px; }
.facts .tags { margin: 0; }

.prose { max-width: 72ch; margin-top: 36px; }
.params { margin: 36px 0 12px; }
.params h2, .prose h2 { font-size: 20px; }
.params table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.params th, .params td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.params thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.params tr.group th { background: var(--surface-2); font-size: 13px; }
.params tbody tr:last-child td { border-bottom: none; }

/* Cart */
.hero-small { padding-top: 32px; }
.muted { color: var(--muted); }
.cart-list { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; }
.cart-item {
  display: grid; grid-template-columns: auto 120px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.cart-item img {
  width: 120px; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 6px;
  background: radial-gradient(circle at 50% 40%, var(--surface) 0%, var(--surface-2) 100%);
}
.cart-item h3 { margin: 0; font-size: 16px; }
.cart-item .include { display: flex; padding: 4px; cursor: pointer; }
.cart-item .include input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.cart-item.off img, .cart-item.off .cart-item-body, .cart-item.off .qty { opacity: .45; }
.cart-item p { margin: 2px 0 0; font-size: 13.5px; overflow-wrap: anywhere; }
.cart-item .values { font-family: var(--mono); font-size: 12.5px; }
.cart-item-controls { display: flex; align-items: center; gap: 14px; }
.qty { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.qty button { width: 30px; height: 32px; border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px; cursor: pointer; }
.qty input { width: 44px; height: 32px; border: 0; text-align: center; background: var(--surface); color: var(--text); font: inherit; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cart-item-controls a, .link {
  border: 0; background: none; padding: 0; font: inherit; font-size: 14px;
  color: var(--accent); cursor: pointer; text-decoration: none;
}
.cart-item-controls .remove { color: var(--muted); }

.plate { margin-top: 36px; }
.plate-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.plate-head h2 { margin: 0; font-size: 20px; }
.plate-head p { margin: 0; }
.bed-settings { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 18px; margin: 14px 0; font-size: 13px; color: var(--muted); }
.bed-settings label { display: grid; gap: 4px; }
.unit-input { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.unit-input input {
  width: 80px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
.bed-presets { margin: -4px 0 14px; font-size: 13px; color: var(--muted); }
.bed-presets .preset { font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.bed-presets .preset.active { background: var(--accent); color: var(--accent-text); }
.plate-view {
  height: min(60vh, 520px); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; touch-action: none;
}
.plate-view canvas { display: block; }
.warning { margin: 10px 0 0; color: #c2410c; font-size: 14px; }
.plate .actions { margin-top: 16px; }
.button { cursor: pointer; font-family: inherit; }
.button:disabled { opacity: .5; cursor: default; }
.button.subtle { margin-left: auto; color: var(--muted); }

.load-banner {
  margin: 20px 0 0; padding: 14px 16px; border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--surface);
}
.load-banner p { margin: 0; }
.load-banner .load-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.load-banner .button.subtle { margin-left: 0; }
.save-cart { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.save-cart h2 { margin: 0 0 6px; font-size: 20px; }
.save-cart .actions { margin-top: 14px; }
.save-cart label.button { display: inline-flex; align-items: center; }
#save-status { margin-top: 8px; min-height: 1.4em; }
.link-field {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font-family: var(--mono); font-size: 12px;
}

.footer { margin-top: 56px; padding-top: 18px; padding-bottom: 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .brand { padding: 12px 16px; }
  .part { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card-actions { padding: 4px 4px 6px; }
  .card-actions a { padding: 4px 6px; }
  .card-actions a.primary { flex-basis: 100%; }
  .params td:nth-child(3), .params th:nth-child(3) { display: none; }
  .cart-link { padding: 12px 16px; }
  .cart-item { grid-template-columns: auto 88px minmax(0, 1fr); }
  .cart-item img { width: 88px; }
  .cart-item-controls { grid-column: 1 / -1; justify-content: space-between; }
  .button.subtle { margin-left: 0; }
}

/* Elements with display set in CSS still hide with the hidden attribute */
[hidden] { display: none !important; }

/* Designer */
body.wide main.wrap { max-width: none; }
.designer {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px;
  margin: 16px 0; height: calc(100vh - 140px); min-height: 480px;
}
.design-view {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; outline: none; touch-action: none;
}
.design-view:focus-visible { border-color: var(--accent); }
.design-view canvas { display: block; width: 100%; height: 100%; }
.design-empty {
  position: absolute; inset: 0; margin: auto; height: fit-content; max-width: 36ch;
  text-align: center; color: var(--muted); pointer-events: none;
}
.design-toolbar {
  position: absolute; top: 10px; left: 10px; display: flex; gap: 14px; align-items: center;
  padding: 6px 10px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border);
}
.design-toolbar label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.design-status { position: absolute; bottom: 8px; left: 12px; margin: 0; font-size: 13px; color: var(--muted); pointer-events: none; }
.design-side { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.design-side section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.design-side h2 { margin: 0 0 6px; font-size: 15px; }
.design-side .small { font-size: 12.5px; margin: 4px 0 8px; }
.sel-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.sel-buttons .button { padding: 5px 10px; font-size: 13px; }
.sel-buttons .button.subtle { margin-left: 0; }
.design-selected { border-color: var(--accent) !important; }
.design-parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.design-parts li { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; }
.design-parts img { width: 48px; height: 36px; object-fit: contain; background: var(--surface-2); border-radius: 6px; }
.design-parts .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.design-parts .count-line { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.design-parts .button { padding: 4px 10px; font-size: 13px; }
.design-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.design-actions .button.subtle { margin-left: 0; }
.design-help { font-size: 13px; color: var(--muted); padding: 0 4px; }
.design-help summary { cursor: pointer; color: var(--text); }
.design-help ul { padding-left: 18px; margin: 8px 0; }
.in-design { margin: 2px 0 0; font-size: 13px; }
@media (max-width: 800px) {
  .designer { grid-template-columns: 1fr; height: auto; }
  .design-view { height: 60vh; }
}
