/* quick-html gallery — the human interface layer.
   Layout patterned on template-gallery UIs (category tabs, big preview cards,
   preview modal); visual identity stays quick-html: warm paper, ink, orange. */

:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #171a1f;
  --muted: #646b76;
  --line: #e3dfd6;
  --line-soft: #ece9e1;
  --accent: #d9540d;
  --accent-dark: #b64509;
  --accent-soft: #fdf0e7;
  --dark: #14171c;
  --ok: #4cb782;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-card: 0 1px 2px rgba(20, 23, 28, 0.05), 0 8px 24px rgba(20, 23, 28, 0.07);
  --shadow-lift: 0 2px 6px rgba(20, 23, 28, 0.08), 0 18px 44px rgba(20, 23, 28, 0.14);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.9em; background: rgba(23, 26, 31, 0.05); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.015em; }
[hidden] { display: none !important; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 28px; }
.muted { color: var(--muted); }

/* ---------- header ---------- */
.hd { position: sticky; top: 0; z-index: 50; background: rgba(244, 242, 238, 0.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.hd-in { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.wordmark { font-family: var(--mono); font-weight: 700; font-size: 17px; color: var(--ink); }
.wordmark:hover { color: var(--accent); text-decoration: none; }
.nav { display: flex; gap: 22px; font-size: 14.5px; font-weight: 500; }
.nav a { color: var(--ink); }
.nav a:hover { color: var(--accent-dark); text-decoration: none; }

.crumb { font-size: 13.5px; margin: 18px auto 0; color: var(--muted); }
.crumb a { color: var(--muted); }

/* ---------- hero ---------- */
.hero { padding: 56px 0 8px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-dark); margin: 0 0 16px; }
.hero h1 { font-size: clamp(36px, 5vw, 54px); font-weight: 800; margin: 0 0 14px; }
.lede { font-size: 17.5px; color: var(--muted); max-width: 560px; margin: 0 0 22px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.term {
  background: var(--dark); color: #e8e6e1; font-family: var(--mono); font-size: 13px;
  line-height: 1.75; padding: 20px 24px; border-radius: 12px; overflow-x: auto;
  margin: 0; box-shadow: 0 16px 40px rgba(20, 23, 28, 0.22);
}
.term .dim { color: #7d8590; }
.term .ok { color: var(--ok); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 9px; font-size: 14.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer;
  font-family: var(--sans); transition: border-color .15s, transform .05s, background .15s;
  text-align: center;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.mini {
  font-size: 11.5px; font-family: var(--mono); padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
}
.mini:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- gallery toolbar: tabs + search + sort ---------- */
.gallery-head { margin: 44px 0 6px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sec-title { font-size: 26px; font-weight: 780; margin: 0; }
.count { font-size: 13.5px; color: var(--muted); }

.toolbar {
  position: sticky; top: 60px; z-index: 40;
  background: linear-gradient(var(--bg) 85%, rgba(244, 242, 238, 0));
  padding: 10px 0 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.tabs { display: flex; gap: 2px; border-bottom: none; }
.tab {
  appearance: none; background: none; border: none; cursor: pointer;
  font: 600 14.5px var(--sans); color: var(--muted);
  padding: 8px 14px 10px; border-bottom: 2.5px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

.toolbar .spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; min-width: 260px;
}
.search svg { flex: none; opacity: 0.45; }
.search input { border: none; outline: none; background: none; font: 14px var(--sans); color: var(--ink); width: 100%; }
.sort {
  font: 500 13.5px var(--sans); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; outline: none;
}

/* ---------- template cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 26px; padding-bottom: 8px; }
.card {
  display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  color: var(--ink); box-shadow: var(--shadow-card); cursor: pointer;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.card:hover { text-decoration: none; transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: #d5d0c4; }
.card-preview {
  height: 300px; overflow: hidden; position: relative; background: #ebe8e2;
  border-bottom: 1px solid var(--line-soft);
}
.card-preview iframe {
  width: 794px; height: 1123px; border: 0; background: #fff;
  transform-origin: 0 0; pointer-events: none; display: block;
}
.card-preview::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(rgba(20,23,28,0) 82%, rgba(20, 23, 28, 0.06));
}
.card-use {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  background: var(--accent); color: #fff; font: 600 12.5px var(--sans);
  border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  opacity: 0; transform: translateY(4px); transition: opacity .16s, transform .16s;
  box-shadow: 0 6px 18px rgba(182, 69, 9, 0.35);
}
.card:hover .card-use { opacity: 1; transform: translateY(0); }
.card-body { padding: 15px 18px 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title h3 { font-size: 17.5px; margin: 0; font-weight: 720; }
.ver { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.card-body p { margin: 0; font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 9px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.uses { display: inline-flex; align-items: center; gap: 5px; }
.uses::before { content: "⬡"; color: var(--accent); font-size: 11px; }
.uses:empty { display: none; }

.empty-state { padding: 60px 0 30px; text-align: center; color: var(--muted); font-size: 15px; }

/* ---------- module cards ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 26px; }
.mod-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-card);
}
.mod-card .mod-icon { font-size: 22px; color: var(--accent); font-family: var(--mono); }
.mod-card h3 { font-size: 17px; margin: 8px 0 6px; }
.mod-card p { font-size: 13.5px; color: var(--muted); margin: 0 0 12px; }
.mod-card .mod-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(20, 23, 28, 0.52);
  display: flex; align-items: center; justify-content: center; padding: 28px;
}
.modal {
  background: var(--panel); border-radius: 18px; box-shadow: 0 32px 80px rgba(20, 23, 28, 0.4);
  width: min(1080px, 100%); max-height: calc(100vh - 56px);
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  overflow: hidden; position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: 17px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--ink); border-color: var(--muted); }
.modal-preview { background: #ebe8e2; overflow-y: auto; padding: 26px; }
.modal-paper {
  width: 100%; background: #fff; border-radius: 4px;
  box-shadow: 0 10px 30px rgba(20, 23, 28, 0.16); overflow: hidden;
}
.modal-paper iframe { width: 794px; height: 1123px; border: 0; transform-origin: 0 0; display: block; pointer-events: none; }
.modal-info { padding: 30px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-info h2 { font-size: 24px; margin: 4px 0 0; }
.modal-info .desc { font-size: 14.5px; color: var(--muted); margin: 0; }
.modal-info .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }
.modal-stats { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.modal-meta { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 4px; }

/* ---------- chips ---------- */
.chip {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 2.5px 9px; background: var(--panel);
}

/* ---------- detail page ---------- */
.detail-head { padding: 24px 0 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px 48px; flex-wrap: wrap; }
.detail-head > div:first-child { flex: 1 1 480px; max-width: 680px; }
.head-actions { flex: 0 1 320px; }
.detail-head h1 { font-size: 32px; margin: 4px 0 8px; }
.detail-head .desc { color: var(--muted); font-size: 15.5px; max-width: 640px; margin: 0 0 10px; }
.detail-head .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.head-actions { display: flex; flex-direction: column; gap: 9px; min-width: 280px; }
.head-actions .hint { font-size: 12px; color: var(--muted); margin: 0; }

.detail-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 22px 0 0; }
.detail-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; padding: 26px 0 56px; align-items: start; }

.paper {
  width: 100%; aspect-ratio: 794 / 1123; overflow: hidden; background: #fff;
  border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-lift);
}
.paper iframe { width: 794px; height: 1123px; border: 0; transform-origin: 0 0; display: block; }
.caption { font-size: 12.5px; color: var(--muted); margin-top: 12px; }

.panel-tab h3 { font-size: 15px; margin: 18px 0 6px; }
.pre {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; white-space: pre-wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin: 0;
  overflow-x: auto;
}
.contract { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 18px; background: var(--panel); border-radius: 10px; }
.contract th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px 10px; }
.contract td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.contract .ex { color: var(--muted); }

.versions { display: flex; flex-direction: column; gap: 0; margin-top: 6px; }
.version-row {
  display: grid; grid-template-columns: 110px 110px 1fr auto; gap: 16px; align-items: baseline;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 18px; margin-bottom: 10px; font-size: 13.5px;
}
.version-row .v { font-family: var(--mono); font-weight: 700; }
.version-row .d { color: var(--muted); font-size: 12.5px; }
.version-row .latest-chip { font-family: var(--mono); font-size: 10.5px; color: var(--accent-dark); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px; margin-left: 8px; }

.meta-col { position: sticky; top: 84px; }
.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 9px 12px; width: 96px; vertical-align: top; }
.kv td { padding: 9px 12px 9px 0; }
.kv tr + tr th, .kv tr + tr td { border-top: 1px solid var(--line-soft); }

/* ---------- docs / info ---------- */
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 36px; margin: 64px 0 48px; padding-top: 40px; border-top: 1px solid var(--line); }
.split h2 { font-size: 17px; margin: 0 0 8px; }
.split p { font-size: 14.5px; color: var(--muted); margin: 0; }

.doc { max-width: 780px; padding: 36px 0 64px; }
.doc h2 { font-size: 28px; margin: 10px 0 16px; }
.doc h3 { font-size: 20px; margin: 28px 0 10px; }
.doc h4 { font-size: 16px; margin: 22px 0 8px; }
.doc p, .doc li { font-size: 15.5px; }
.doc pre { margin: 14px 0; }
.doc blockquote { border-left: 3px solid var(--accent); margin: 14px 0; padding: 2px 18px; background: var(--panel); border-radius: 0 8px 8px 0; }
.doc blockquote p { color: var(--muted); }

/* ---------- footer ---------- */
.ft { border-top: 1px solid var(--line); margin-top: 40px; }
.ft-in { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 28px; font-size: 13px; color: var(--muted); }
.ft-links a { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .modal { grid-template-columns: 1fr; overflow-y: auto; }
  .modal-preview { max-height: 44vh; }
  .detail-body { grid-template-columns: 1fr; }
  .meta-col { position: static; }
}
@media (max-width: 640px) {
  .toolbar { top: 0; position: static; }
  .search { min-width: 0; flex: 1; }
}
