/* Catalogue, detail and dashboards pages. Tokens and chrome (header, palette, buttons, code blocks) come from style.css. */
.cat { padding: 36px 0 80px; }
.cat-head { max-width: 760px; margin-bottom: 24px; }
.cat-head h1 { font-size: clamp(32px, 4.4vw, 52px); font-weight: 800; margin: 12px 0 12px; letter-spacing: -.035em; }
.cat-head p { color: var(--muted); font-size: 17px; }
.cat-head code, .det code:not(pre code), .tpl-list code { background: var(--primary-wash); color: var(--accent-text); padding: 2px 7px; border-radius: 6px; font-size: .88em; }
.cat-grid { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 40px; align-items: start; }
.cat-side { position: sticky; top: 88px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.cat-search { position: relative; display: block; }
.cat-search svg { position: absolute; left: 14px; top: 50%; width: 17px; height: 17px; margin-top: -8.5px; fill: none; stroke: var(--muted); stroke-width: 1.9; stroke-linecap: round; pointer-events: none; }
.cat-search input { width: 100%; height: 46px; padding: 0 40px 0 40px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--raised); color: var(--ink); font: 500 15px var(--font); }
.cat-search input:focus-visible { border-color: var(--primary); }
.cat-search kbd { position: absolute; right: 10px; top: 50%; margin-top: -11px; }
.groups { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.groups a { display: flex; justify-content: space-between; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font: 500 14.5px var(--font); transition: background .15s, color .15s; }
.groups a i { font: 500 12px var(--mono); font-style: normal; opacity: .85; }
.groups a:hover { background: var(--raised-2); color: var(--ink); }
.groups a[aria-current='true'] { background: var(--ink); color: var(--surface); }
.cat-main, .stage-wrap, .blk { padding: 0; }
.cat-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; margin-bottom: 14px; }
.cat-count { font: 500 14px var(--font); color: var(--muted); }
.cat-count b { color: var(--ink); font-weight: 600; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tile { position: relative; background: var(--raised); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.tile:has(h2 a:focus-visible) { outline: 2px solid var(--signal); outline-offset: 2px; }
.tile h2 a { color: inherit; text-decoration: none; outline: none; }
.tile h2 a::after { content: ''; position: absolute; inset: 0; z-index: 2; }
.prev { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface); border-bottom: 1px solid var(--line); pointer-events: none; }
.prev-sk { position: absolute; inset: 0; background: var(--raised-2); opacity: .55; animation: sk 1.6s ease-in-out infinite; }
@keyframes sk { 50% { opacity: .2; } }
.prev iframe { position: absolute; left: 0; top: 0; width: 400px; height: 225px; border: 0; transform-origin: 0 0; transform: scale(var(--ps, .5)); opacity: 0; transition: opacity .3s; background: transparent; }
.prev iframe.ready { opacity: 1; }
.prev.has-frame .prev-sk { display: none; }
.tile-b { padding: 14px 16px 16px; display: grid; gap: 6px; flex: 1; align-content: start; }
.tile-t { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile-t h2 { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.tag { flex: none; font: 500 11px var(--mono); padding: 3px 9px; border-radius: 999px; background: var(--primary-wash); color: var(--accent-text); }
.tile-d { font-size: 14px; line-height: 1.5; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-s { font: 400 11.5px var(--mono); color: var(--muted); }
.cat-more { display: flex; justify-content: center; margin-top: 30px; }
.cat-empty { padding: 56px 24px; border: 1px dashed var(--line-strong); border-radius: 16px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.cat-empty h2 { font-size: 24px; } .cat-empty q { quotes: '\201C' '\201D'; color: var(--accent-text); }
.cat-empty p { color: var(--muted); max-width: 46ch; }
.cat-empty a { color: var(--accent-text); }

/* detail */
.det { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 52px; padding: 30px 0 96px; align-items: start; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 0; margin: 0 0 18px; font: 500 13px var(--font); color: var(--muted); }
.crumbs li + li::before { content: '/'; margin-right: 8px; color: var(--line-strong); }
.crumbs a { text-decoration: none; } .crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); }
.det h1 { font-size: clamp(32px, 4.4vw, 52px); font-weight: 800; letter-spacing: -.035em; }
.det-sub { color: var(--muted); font-size: 18px; max-width: 62ch; margin: 12px 0 28px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--raised); gap: 2px; }
.seg button { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 0; background: none; font: 600 13.5px var(--font); color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; align-self: stretch; transition: color .15s; }
.seg button:hover { color: var(--ink); }
.seg small { font: 400 11px var(--mono); opacity: .85; }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--surface); }
.tb-end { margin-left: auto; display: flex; gap: 8px; }
.stage { --stage-bg: #fbfaf7; --dot: #d6d1c3; --stage-ink: #635f54; position: relative; height: clamp(360px, 54vh, 540px); border: 1px solid var(--line-strong); border-radius: 20px; overflow: hidden; display: flex; justify-content: center; background: radial-gradient(var(--dot) 1px, transparent 1.3px) 0 0 / 20px 20px, var(--stage-bg); }
.stage[data-theme='dark'] { --stage-bg: #121210; --dot: #2d2b26; --stage-ink: #a8a396; }
.stage iframe { width: min(var(--sw, 480px), 100%); height: 100%; border: 0; border-inline: 1px dashed var(--dot); background: transparent; transition: width .25s var(--ease); flex: none; }
.stage[data-theme='light'] iframe { color-scheme: light; } .stage[data-theme='dark'] iframe { color-scheme: dark; }
.stage-w { position: absolute; right: 12px; bottom: 10px; font: 500 11px var(--mono); color: var(--stage-ink); pointer-events: none; }
.blk { margin-top: 48px; }
.blk h2 { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.blk p { max-width: 68ch; }
.blk p + p { margin-top: 8px; }
.small { font-size: 13.5px; }
.codes { display: grid; gap: 12px; }
.codes .code { margin: 0; }
.codes .code pre { padding-top: 12px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.files li { font-size: 14px; }
.files code { font-family: var(--mono); overflow-wrap: anywhere; }
.a11y { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 68ch; }
.a11y li { padding-left: 22px; position: relative; color: var(--muted); font-size: 15px; }
.a11y li::before { content: ''; position: absolute; left: 3px; top: .55em; width: 9px; height: 5px; border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg); }
.a11y b { color: var(--ink); }
.rail { position: sticky; top: 88px; display: grid; gap: 14px; max-height: calc(100vh - 108px); overflow-y: auto; align-content: start; padding: 2px; }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pn a { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); text-decoration: none; min-height: 56px; min-width: 0; align-content: center; transition: border-color .15s; }
.pn a:hover { border-color: var(--primary); }
.pn small { font: 500 11px var(--mono); color: var(--muted); }
.pn b { font: 600 14px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pn a[rel='next'] { text-align: right; }
.rail h2 { font: 500 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.rail h2 span { margin-left: 6px; }
.rail-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.rail-list a { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14.5px; }
.rail-list a:hover { background: var(--raised-2); color: var(--ink); }
.rail-list a[aria-current='page'] { background: var(--primary-wash); color: var(--accent-text); font-weight: 600; }
.rail-all { font-weight: 600; font-size: 14px; color: var(--accent-text); text-decoration: none; min-height: 36px; display: inline-flex; align-items: center; }
.rail-all:hover { text-decoration: underline; }
.det-main > .pn { display: none; margin-top: 44px; }

/* dashboards (stub) */
.tpl-g { margin-top: 40px; }
.tpl-g h2 { font-size: 24px; font-weight: 800; display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.tpl-g h2 span { font: 500 13px var(--mono); color: var(--muted); }
.tpl-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.tpl-list li { display: grid; gap: 14px; align-content: space-between; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); scroll-margin-top: 90px; }
.tpl-list li:target { border-color: var(--primary); }
.tpl-list h3 { font-size: 19px; margin-bottom: 6px; }
.tpl-list p { color: var(--muted); font-size: 14px; }
.tpl-list code { font-family: var(--mono); font-size: 12px; justify-self: start; }

@media (max-width: 1020px) {
  .det { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .rail { position: static; max-height: none; overflow: visible; }
  .rail .pn { display: none; }
  .det-main > .pn { display: grid; }
  .rail-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; }
  .rail-list a { min-height: 44px; }
}
@media (max-width: 860px) {
  .cat { padding-top: 28px; }
  .cat-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .cat-side { position: static; gap: 12px; }
  .cat-search kbd { display: none; }
  .cat-search input { height: 48px; }
  .cat-side nav { position: sticky; top: 64px; z-index: 20; margin: 0 -20px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .groups { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
  .groups::-webkit-scrollbar { display: none; }
  .groups a { flex: none; min-height: 44px; padding: 0 16px; gap: 8px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--raised); }
  .groups a[aria-current='true'] { border-color: var(--ink); }
  .tiles { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
@media (max-width: 640px) {
  .det { padding-top: 20px; }
  .det-sub { font-size: 16.5px; margin-bottom: 20px; }
  .toolbar { gap: 10px; }
  .tb-end { margin-left: 0; width: 100%; } .tb-end > * { flex: 1; }
  .two { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .stage { height: 380px; border-radius: 16px; }
  .rail-list { grid-template-columns: minmax(0, 1fr); }
  .blk { margin-top: 36px; }
}
@media (max-width: 640px) {
  .rail-list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  .rail-list a { flex: none; min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--raised); white-space: nowrap; }
  .rail-list a[aria-current='page'] { border-color: var(--primary); }
}
.prev-none { display: grid; place-items: center; text-align: center; padding: 16px; font: 500 12px var(--mono); color: var(--muted); }
.nodemo { padding: 14px 18px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 14px; }
.tpl-g { padding: 0; }

@media (pointer: coarse) { .seg button { min-height: 44px; } }
.det-main { min-width: 0; } .codes { grid-template-columns: minmax(0, 1fr); }

/* ---- dashboards & pages: gallery of real-size previews, and the template detail page ---- */
.tpl-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tpl-jump a { padding: 6px 14px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-weight: 550; font-size: 14px; text-decoration: none; }
.tpl-jump a:hover { color: var(--ink); border-color: var(--ink); }
.tpl-g { margin-top: 40px; scroll-margin-top: 84px; }
.tpl-g > h2 { font-size: 20px; letter-spacing: -0.02em; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
.tpl-g > h2 span { font: 500 12px var(--mono); color: var(--muted); padding: 2px 8px; border: 1px solid var(--line-strong); border-radius: 999px; }
.tgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.tcard { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--raised); transition: border-color .15s, transform .15s; }
.tcard:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.tcard-a { display: block; }
.tprev { aspect-ratio: 16 / 10; }
.tprev iframe { width: 1280px; height: 800px; }
.tcard-b { padding: 14px 16px 18px; display: grid; gap: 6px; }
.tcard-t { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tcard-t h3 { margin: 0; font-size: 17px; letter-spacing: -0.015em; }
.tcard-t h3 a { color: inherit; text-decoration: none; }
.tcard-t h3 a::after { content: ''; position: absolute; inset: 0; }
.tcard { position: relative; }
.tcard-b p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
@media (max-width: 900px) { .tgrid { grid-template-columns: 1fr; gap: 18px; } }

.tstage { position: relative; display: flex; justify-content: center; align-items: flex-start; padding: 20px; border: 1px solid var(--line-strong); border-radius: 20px; background-color: #fbfaf7; background-image: radial-gradient(var(--dot, #d6d1c3) 1px, transparent 1px); background-size: 18px 18px; overflow: hidden; }
.tstage[data-theme='dark'] { background-color: #121210; --dot: #2d2b26; }
.tframe { width: 100%; max-width: 100%; transition: width .3s var(--ease); border-radius: 12px; overflow: hidden; border: 1px solid var(--line-strong); box-shadow: 0 18px 50px rgba(0, 0, 0, .12); background: var(--surface); }
.tstage[data-d='tablet'] .tframe { width: 820px; }
.tstage[data-d='phone'] .tframe { width: 390px; }
.tframe iframe { display: block; width: 100%; height: clamp(560px, 78vh, 860px); border: 0; background: transparent; }
@media (max-width: 900px) { .tstage { padding: 10px; border-radius: 14px; } .tframe iframe { height: 620px; } .tstage[data-d='tablet'] .tframe, .tstage[data-d='phone'] .tframe { width: 100%; } .tstage-wrap [data-d='tablet'], .tstage-wrap [data-d='phone'] { display: none; } }
@media (prefers-reduced-motion: reduce) { .tframe, .tcard { transition: none; } }
