/* Coverline — template browser. Quiet editorial chrome on a greige paper ground; the templates carry the colour. */
:root {
  --paper: #efebe3;
  --paper-2: #e7e1d6;
  --sheet: #f8f5ef;
  --ink: #1e1c19;
  --ink-2: #5a544b;
  --ink-3: #6a6358;
  --rule: #cdc5b7;
  --rule-2: #ddd6ca;
  --accent: #9c3a28;
  --focus: #1e1c19;
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", serif;
  --rail: 236px;
  --pv: 440px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.6 var(--sans); font-feature-settings: "palt"; -webkit-font-smoothing: antialiased; }
::selection { background: #1e1c19; color: #f8f5ef; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: #bdb4a5 transparent; }

/* ---- top ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 28px; height: 60px; border-bottom: 1px solid var(--rule); }
.mark { font: 700 22px/1 var(--serif); letter-spacing: .02em; color: var(--ink); text-decoration: none; display: flex; align-items: baseline; gap: 8px; }
.views { display: flex; gap: 4px; }
.view { white-space: nowrap; border: 0; background: none; padding: 8px 12px; color: var(--ink-2); border-radius: 2px; transition: color .15s, background-color .15s; }
.view:hover { color: var(--ink); background: var(--paper-2); }
.view[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -1px 0 var(--ink); border-radius: 0; }
.view .n { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-left: 2px; }

/* ---- make: use + material ---- */
.make { padding: 16px 28px 18px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 14px; }
.label { font: 700 14px/1.3 var(--serif); margin: 0; letter-spacing: .04em; flex: none; }
.label .hint { font: 400 12px/1 var(--sans); color: var(--ink-3); letter-spacing: 0; margin-left: 10px; }
.uses-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.uses-wrap .label { width: 92px; }
.uses { display: flex; gap: 2px; flex-wrap: wrap; }
.use { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 10px; border: 1px solid transparent; background: none; border-radius: 3px; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.use:hover { background: var(--paper-2); color: var(--ink); }
.use .shape-box { width: 26px; height: 26px; display: grid; place-items: center; flex: none; }
.use .shape { display: block; border: 1.25px solid currentColor; background: transparent; transition: background-color .15s; }
.use[aria-checked="true"] { color: var(--ink); border-color: var(--ink); background: var(--sheet); font-weight: 700; }
.use[aria-checked="true"] .shape { background: var(--ink); }
.ratios { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-2); flex-basis: 100%; padding-left: 110px; margin-top: -8px; }
.ratio { border: 1px solid var(--rule); background: none; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-variant-numeric: tabular-nums; }
.ratio[aria-checked="true"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.ratios .note { color: var(--ink-3); margin-left: 4px; }

.material { display: flex; gap: 18px; align-items: flex-start; }
.material .label { width: 92px; padding-top: 22px; }
.material .label .hint { display: none; }
.fields { flex: 1; display: grid; grid-template-columns: minmax(200px, 1.6fr) minmax(140px, 1fr) minmax(120px, .8fr) minmax(140px, 1fr) auto auto; gap: 14px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); min-width: 0; }
.field small { color: var(--ink-3); font-size: 11.5px; line-height: 1.5; }
textarea, input[type=text], input[type=search] { background: var(--sheet); border: 1px solid var(--rule); border-radius: 2px; padding: 8px 10px; font-size: 14px; color: var(--ink); width: 100%; transition: border-color .15s; }
textarea { resize: vertical; min-height: 60px; line-height: 1.45; font-weight: 500; }
textarea:hover, input:hover { border-color: #b8ae9e; }
textarea:focus, input:focus { border-color: var(--ink); outline: none; }
::placeholder { color: #736b5f; }
.drops { display: flex; flex-direction: column; gap: 6px; padding-top: 22px; }
.drop { position: relative; display: flex; align-items: center; gap: 8px; width: 176px; height: 38px; padding: 0 10px; border: 1px dashed #b3a999; background: transparent; border-radius: 2px; color: var(--ink-2); font-size: 12px; overflow: hidden; white-space: nowrap; transition: border-color .15s, background-color .15s; }
.drop:hover, .drop.over { border-color: var(--ink); color: var(--ink); background: var(--sheet); }
.drop img { position: absolute; right: 0; top: 0; height: 100%; width: 54px; object-fit: cover; border-left: 1px solid var(--rule); background: repeating-conic-gradient(#e2dccf 0 25%, #f1ede5 0 50%) 0 0/10px 10px; }
.drop.has { border-style: solid; border-color: var(--ink-2); }
#drop-person img { object-fit: contain; }
.linkbtn { border: 0; background: none; padding: 2px 0; font-size: 12px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule); align-self: flex-start; white-space: nowrap; }
.linkbtn:hover { color: var(--ink); text-decoration-color: var(--ink); }
.linkbtn.clear { margin-top: 32px; }

/* ---- body: rail + results ---- */
.body { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); align-items: start; }
.rail { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 18px 20px 40px 28px; border-right: 1px solid var(--rule); min-height: calc(100vh - 60px); }
.facet { padding: 14px 0 16px; border-bottom: 1px solid var(--rule-2); }
.facet:first-child { padding-top: 4px; }
.facet h3 { font: 700 13px/1.3 var(--serif); letter-spacing: .06em; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; }
.facet h3 button { border: 0; background: none; padding: 0; display: flex; align-items: center; gap: 4px; font: inherit; width: 100%; justify-content: space-between; }
.facet h3 button svg { transition: transform .2s; color: var(--ink-3); }
.facet.folded h3 button svg { transform: rotate(-90deg); }
.facet.folded .opts { display: none; }
.facet.folded h3 { margin: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 5px; }
.opt { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--rule); background: transparent; padding: 3px 9px; border-radius: 99px; font-size: 12.5px; line-height: 1.5; color: var(--ink); transition: background-color .12s, border-color .12s, color .12s; }
.opt:hover { border-color: var(--ink-2); }
.opt .c { color: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.opt[aria-pressed="true"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.opt[aria-pressed="true"] .c { color: #cfc8bc; }
.opt:disabled { opacity: .38; cursor: default; }
.opts.list { flex-direction: column; gap: 1px; }
.opts.list .opt { border: 0; border-radius: 2px; justify-content: space-between; padding: 3px 8px; margin-left: -8px; width: calc(100% + 8px); }
.opts.list .opt:hover { background: var(--paper-2); }
.opts.list .opt[aria-pressed="true"] { background: var(--ink); }
.opts.swatches { gap: 7px; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(30, 28, 25, .25); padding: 0; position: relative; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
.sw:disabled { opacity: .3; cursor: default; }
.layout-ico { width: 22px; height: 14px; }
#clear-filters { margin-top: 14px; }

.results { padding: 16px 28px 60px; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.search { position: relative; flex: 0 1 460px; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 36px; }
.count { margin: 0; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.count b { color: var(--ink); font-weight: 700; }
.sortby { margin-left: auto; display: flex; gap: 2px; font-size: 13px; }
.sortby[hidden] { display: none; }
.sortby button { padding: 6px 10px; border: 0; background: none; color: var(--ink-2); font: inherit; cursor: pointer; border-bottom: 1px solid transparent; }
.sortby button:hover { color: var(--ink); }
.sortby button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.card .newmark { flex: none; margin-right: auto; padding: 0 5px; border: 1px solid currentColor; font-size: 10px; line-height: 16px; letter-spacing: .04em; }
.card .newmark[hidden] { display: none; }
.similar-bar { display: flex; align-items: center; gap: 12px; padding: 10px 0 12px; margin-bottom: 14px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.similar-bar canvas { width: 72px; border: 1px solid var(--rule); display: block; }
.similar-bar b { font-family: var(--serif); font-size: 15px; }

/* ---- grid of templates ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--cell, 260px), 1fr)); gap: 26px 20px; }
.card { margin: 0; position: relative; min-width: 0; }
.card .frame { position: relative; display: block; width: 100%; padding: 0; border: 0; background: var(--paper-2); aspect-ratio: var(--ar); box-shadow: 0 0 0 1px rgba(30, 28, 25, .14); transition: box-shadow .18s, transform .18s; overflow: hidden; }
.card .frame:hover { box-shadow: 0 0 0 1px var(--ink), 0 6px 18px -8px rgba(30, 28, 25, .35); }
.card canvas { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity .18s ease-out; }
.card canvas.on { opacity: 1; }
.card figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-top: 7px; font-size: 12px; }
.card .nm { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .fm { color: var(--ink-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.card:hover .acts, .card:focus-within .acts, .card .acts.keep { opacity: 1; }
.icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(248, 245, 239, .94); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.icon:hover { background: #fff; }
.icon.on { color: var(--accent); }
.card .series-note { position: absolute; left: 6px; top: 6px; background: rgba(248, 245, 239, .94); padding: 2px 8px; font-size: 11px; border-radius: 2px; }

.empty { padding: 60px 0; max-width: 460px; color: var(--ink-2); }
.empty h3 { font: 700 18px/1.4 var(--serif); color: var(--ink); margin: 0 0 8px; }
.empty p { margin: 0 0 14px; }

/* ---- preview drawer ---- */
.preview { position: fixed; top: 0; right: 0; bottom: 0; width: var(--pv); background: var(--sheet); border-left: 1px solid var(--rule); box-shadow: -12px 0 32px -20px rgba(30, 28, 25, .4); padding: 20px 24px 28px; overflow-y: auto; z-index: 10; animation: pv-in .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes pv-in { from { transform: translateX(24px); opacity: 0; } }
.pv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.pv-name { font: 700 19px/1.35 var(--serif); margin: 0; }
.pv-fam { margin: 2px 0 0; color: var(--ink-2); font-size: 12px; }
.pv-head .icon { box-shadow: none; background: transparent; }
.pv-head .icon:hover { background: var(--paper-2); }
.pv-stage { display: grid; place-items: center; background: var(--paper-2); padding: 16px; min-height: 240px; }
.pv-stage canvas { display: block; max-width: 100%; max-height: 52vh; box-shadow: 0 0 0 1px rgba(30, 28, 25, .14), 0 10px 24px -14px rgba(30, 28, 25, .5); }
.pv-formats { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 14px 0 6px; align-items: flex-end; }
.pv-formats button { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; padding: 4px; font-size: 10.5px; color: var(--ink-2); border-radius: 2px; font-variant-numeric: tabular-nums; }
.pv-formats button canvas { display: block; box-shadow: 0 0 0 1px rgba(30, 28, 25, .18); }
.pv-formats button[aria-checked="true"] { color: var(--ink); font-weight: 700; }
.pv-formats button[aria-checked="true"] canvas { box-shadow: 0 0 0 1.5px var(--ink); }
.pv-tags { color: var(--ink-3); font-size: 12px; margin: 8px 0 16px; }
.pv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ink-2); background: transparent; padding: 7px 14px; border-radius: 2px; font-size: 13px; transition: background-color .15s, color .15s; }
.btn:hover { background: var(--paper-2); }
.btn.on { color: var(--accent); border-color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.btn.primary:hover { background: #3a3631; }
.btn:disabled { opacity: .5; cursor: progress; }
.pv-series { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-2); }
.pv-series label { font: 700 13px/1.3 var(--serif); color: var(--ink); }
.pv-series .row { display: flex; gap: 8px; }
.pv-series small { color: var(--ink-3); }
body.pv-open .results { padding-right: calc(var(--pv) + 28px); }

@media (max-width: 1180px) {
  .fields { grid-template-columns: minmax(200px, 1.6fr) minmax(140px, 1fr) minmax(140px, 1fr); }
  .drops { flex-direction: row; padding-top: 0; }
  body.pv-open .results { padding-right: 28px; }
}
@media (max-width: 760px) {
  .top { padding: 0 16px; }
  .views { overflow-x: auto; }
  .make { padding: 16px; }
  .material { flex-direction: column; gap: 8px; }
  .material .label, .uses-wrap .label { width: auto; padding-top: 0; }
  .fields { grid-template-columns: 1fr; width: 100%; }
  .ratios { padding-left: 0; margin-top: 0; flex-wrap: wrap; }
  .linkbtn.clear { margin-top: 0; }
  .drops { flex-direction: row; flex-wrap: wrap; }
  .body { grid-template-columns: 1fr; }
  .rail { position: static; max-height: none; min-height: 0; border-right: 0; border-bottom: 1px solid var(--rule); padding: 12px 16px; }
  .results { padding: 16px; }
  .preview { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.facet-hint { margin: -4px 0 8px; color: var(--ink-3); font-size: 11px; }
.folded .facet-hint { display: none; }
