/* Apps gallery (/apps on the public site, /app/apps in the console). Prefix app-. Shared tokens only; style-src 'self', so nothing inline. */
.app-wrap { max-width: 1040px; padding-top: 28px; padding-bottom: 40px; }
.app-a { --app-a: var(--accent, var(--bar)); }
.app-head h1 { margin: 4px 0 8px; }
.app-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 18px 0 6px; }
.app-stats div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--panel); }
.app-stats b { display: block; font-size: 26px; line-height: 1.2; }
.app-stats span { font-size: 13px; color: var(--muted); }
.app-filters { margin: 18px 0 14px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; min-width: 0; }
.app-filters input { font: inherit; font-size: 16px; flex: 1 1 100%; min-width: 0; max-width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); box-sizing: border-box; }
.app-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.app-chips button { font: inherit; font-size: 13.5px; padding: 4px 11px; border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.app-chips button:hover { border-color: var(--muted); }
.app-chips button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.app-count { margin: 0; flex: 1 1 100%; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.app-card { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; color: inherit; text-decoration: none !important; transition: transform .15s, border-color .15s; }
.app-card:hover { border-color: var(--muted); transform: translateY(-2px); }
.app-card h3 { margin: 4px 0 0; font-size: 16px; }
.app-card p { margin: 0; font-size: 14px; color: var(--muted); flex: 1; }
.app-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.app-pills .pill { white-space: nowrap; }
.app-peek { margin: 6px 0 0; padding: 7px 9px; font: 11px/1.5 var(--mono, ui-monospace, monospace); color: var(--muted); background: var(--sunk); border-radius: 6px; overflow: hidden; white-space: pre; max-height: 58px; }
.app-empty { margin: 18px 0; }
.app-fine { margin: 18px 0 0; }
.app-page h1 { margin: 2px 0 8px; }
.app-crumb { margin: 0 0 6px; }
.app-page .guide-lead { margin: 10px 0 12px; }
.app-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 12px 0; }
.app-note { margin: 14px 0; }
.app-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.app-sec { min-width: 0; margin: 20px 0 0; }
.app-sec h2 { font-size: 18px; margin: 14px 0 6px; }
.app-sec h2:first-child { margin-top: 0; }
.app-sec p { margin: 0 0 8px; }
.app-list { margin: 4px 0 0; padding-left: 20px; }
.app-list li { margin: 3px 0; }
.app-term { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--sunk); }
.app-term-bar { display: flex; gap: 5px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.app-term-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.app-out { background: none; font-size: 12.5px; margin: 0; }
.app-json { margin: 10px 0 0; }
.app-json summary { cursor: pointer; font-size: 14px; }
.app-json pre, .app-tools { max-height: 420px; overflow: auto; }
.app-code { margin: 10px 0 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.app-code-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 7px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.app-code-head button { margin-left: auto; }
.app-code pre { max-height: 460px; overflow: auto; border-radius: 0; font-size: 12.5px; }
.app-howto { margin: 10px 0 0; }
.app-rel { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.app-run { margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.app-run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.app-run-res { margin-top: 10px; display: grid; gap: 8px; min-width: 0; }
.app-run-res:empty { display: none; }
.app-run-item { min-width: 0; animation: app-in .25s ease both; }
.app-run-item b { display: block; font-size: 13.5px; margin-bottom: 3px; overflow-wrap: anywhere; }
.app-run-item pre { max-height: 240px; overflow: auto; }
@keyframes app-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .app-card, .app-run-item { transition: none; animation: none; } .app-card:hover { transform: none; } }
@media (max-width: 760px) {
  .app-two { grid-template-columns: minmax(0, 1fr); }
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .app-wrap { padding-top: 18px; }
}

/* Apps that run in the browser (bin/build-html-apps.js). Prefix hx-. */
.hx-card { padding-top: 0; overflow: hidden; }
.hx-thumb { display: block; width: calc(100% + 2 * var(--card-pad, 18px)); max-width: none; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top left; margin: 0 calc(-1 * var(--card-pad, 18px)) 6px; border-bottom: 1px solid var(--line); background: var(--sunk); }
.pill.hx-run { background: var(--good, #0a7a4b); color: var(--bg); border-color: transparent; font-weight: 600; }
.hx-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 10px; }
.hx-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.hx-modes button { font: inherit; font-size: 14px; font-weight: 600; min-height: 38px; padding: 4px 16px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.hx-modes button.on { background: var(--text); color: var(--bg); }
.hx-status { margin: 0; flex: 1 1 240px; min-width: 0; }
.hx-link { font-weight: 600; }
.hx-frame { display: block; width: 100%; height: 900px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
@media (max-width: 640px) { .hx-frame { border-radius: 8px; } .hx-bar .btn { width: 100%; text-align: center; } }

/* Showcase apps (html-wow-stage). Prefix wx-. */
.wx-show { margin: 18px 0 26px; }
.wx-show h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.01em; }
.wx-show > p { margin: 0 0 12px; max-width: 74ch; }
.wx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.wx-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); color: inherit; text-decoration: none; }
.wx-card:hover { border-color: var(--text); }
.wx-film { display: block; position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #070a12; }
.wx-strip { display: block; width: 100%; height: auto; max-width: none; }
.wx-t { display: block; padding: 9px 11px 11px; font-size: 13.5px; line-height: 1.35; }
.wx-t b { display: block; font-size: 15px; margin-bottom: 2px; }
.wx-b { color: var(--muted, inherit); }
.wx-page .wx-frame { --wx-w: min(100vw - 24px, 1500px); height: 1000px; width: var(--wx-w); max-width: none; margin-left: calc(50% - var(--wx-w) / 2); }
@media (min-width: 1180px) { .wx-page .wx-frame { --wx-w: min(100vw - 212px - 24px, 1500px); } }
@media (max-width: 640px) { .wx-grid { grid-template-columns: 1fr 1fr; gap: 8px; } .wx-t { padding: 7px 8px 9px; font-size: 12.5px; } .wx-t b { font-size: 13.5px; } .wx-page .wx-frame { height: 860px; } }

/* /apps/<slug>: the choice under the description (inc/app_intro.php) */
.hx-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.hx-option { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); cursor: pointer; }
.hx-option:hover { border-color: var(--text); }
.hx-option b { font-size: 15px; }
.hx-option span { font-size: 14px; color: var(--muted); }
.hx-hero { max-width: 640px; border-radius: 12px; margin: 14px 0 20px; }
/* The console has its own sidebar: a showcase frame fills the column rather than the window */
#appsBody .wx-page .wx-frame { --wx-w: 100%; width: 100%; margin-left: 0; }
.hx-need { margin: 10px 0 0; }

/* Levels and kinds on the gallery */
.app-filters { display: block; margin: 18px 0 18px; padding: 12px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.app-f-top { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.app-filters .app-f-top input { flex: 1 1 auto; width: auto; }
.app-f-count { flex: 0 0 auto; display: flex; gap: 10px; align-items: baseline; white-space: nowrap; margin: 0; min-width: 118px; justify-content: flex-end; }
.app-f-count button { font: inherit; padding: 0; border: 0; background: none; color: var(--link); cursor: pointer; text-decoration: underline; }
.app-f-count button[hidden] { display: inline; visibility: hidden; }
.app-filters .app-chips { margin-top: 8px; }
.app-chips-scroll { flex-wrap: wrap; }
.app-chips button { min-height: 32px; white-space: nowrap; }
.app-chips button:focus-visible, .app-f-count button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.app-chips button.dim:not(.on) { color: var(--muted); border-style: dashed; }
.app-f-hint { margin: 6px 0 0; min-height: 1.45em; line-height: 1.45; }
.app-card[hidden], .wx-card[hidden], [data-app-sec][hidden] { display: none; }
[data-app-results][data-pending] { visibility: hidden; }
@media (min-width: 900px) { .app-results { min-height: 100vh; } }
.app-sec-note { margin: 0 0 12px; max-width: 74ch; }
/* Stays in reach on a long gallery, on screens with room for it. The public site has a top bar below the width where its rail appears. */
@media (min-width: 900px) and (min-height: 800px) { .app-filters { position: sticky; top: 0; z-index: 12; } }
@media (min-width: 900px) and (max-width: 1179px) and (min-height: 800px) { .sx .app-filters { top: 65px; } }
@media (max-width: 720px) {
  /* one line per group on a phone: the row scrolls sideways, so the bar keeps its height */
  .app-chips-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding: 2px 16px 2px 2px; }
  .app-chips-scroll::-webkit-scrollbar { display: none; }
  .app-chips-scroll button { flex: 0 0 auto; min-height: 36px; }
  .app-f-hint { min-height: 2.9em; }
  .app-f-count { min-width: 0; }
}
/* The level badge */
.lv { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 1.5; padding: 1px 8px; border-radius: 99px; background: var(--sunk); color: var(--text); white-space: nowrap; text-decoration: none; }
a.lv, a.pill { text-decoration: none; color: var(--text); }
a.lv:hover, a.pill:hover { text-decoration: underline; }
.lv i { display: block; width: 3px; height: 10px; border-radius: 1px; background: currentColor; opacity: .22; margin-right: -3px; }
.lv i:nth-of-type(3) { margin-right: 2px; }
.lv-1 i:nth-of-type(1), .lv-2 i:nth-of-type(-n+2), .lv-3 i { opacity: 1; }
.app-kind { font-size: 12px; color: var(--muted); }
a.app-kind:hover { color: var(--text); }
.wx-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 7px; }
.wx-card .wx-t { flex: 1 1 auto; display: flex; flex-direction: column; }
.wx-card .wx-meta { margin-top: auto; padding-top: 7px; }
.app-card .app-pills .pill.app-kind-pill { color: var(--muted); }
