/* The /apps/ pages: the overview (index.html) and every app page (app-page.js), plus the
   download box (download.js). The site's is-back look (GitHub-dark palette, fx-panel glass) with
   the apps' own blue → violet accent. */
:root {
  --app-bg: #0d1117;
  --app-surface: rgba(22, 27, 34, 0.72);
  --app-surface-2: #21262d;
  --app-border: #30363d;
  --app-text: #e6edf3;
  --app-heading: #f0f6fc;
  --app-muted: #8b949e;
  --app-link: #58a6ff;
  --app-teal: #00ffcc;
  --app-blue: #4f8cff;
  --app-violet: #9b5cff;
  --app-gradient: linear-gradient(120deg, var(--app-blue), var(--app-violet));
  --app-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --app-mono: ui-monospace, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
}

body.apps-body {
  color: var(--app-text);
  font-family: var(--app-font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.apps-main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 24px;
  box-sizing: border-box;
}
.apps-main a { color: var(--app-link); }
.apps-main img { max-width: 100%; }

/* ── Overview (/apps/) ──────────────────────────────────────────────────────────── */
.apps-intro { margin: 8px 0 28px; }
.apps-intro h1 {
  font-family: var(--app-font);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 800;
  margin: 0 0 8px;
  background: var(--app-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.apps-intro p { margin: 0; color: var(--app-muted); line-height: 1.6; }

.apps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.apps-card {
  display: flex;
  flex-direction: column;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.apps-card:hover { border-color: rgba(155, 92, 255, 0.55); }
.apps-card-shot { display: block; aspect-ratio: 1500 / 920; overflow: hidden; border-bottom: 1px solid var(--app-border); background: #0b0e13; }
.apps-card-shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.apps-card:hover .apps-card-shot img { transform: scale(1.03); }
.apps-card-body { display: flex; flex-direction: column; gap: 12px; padding: 18px; flex: 1; }
.apps-card-title { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.apps-card-title img { width: 52px; height: 52px; border-radius: 12px; flex: 0 0 auto; }
.apps-card-title strong { display: block; color: var(--app-heading); font-size: 1.25rem; }
.apps-card-title small { color: var(--app-muted); font-size: 0.85rem; }
.apps-card-tagline { margin: 0; color: var(--app-text); line-height: 1.5; flex: 1; }
.apps-card-more { font-size: 0.9rem; text-decoration: none; }
.apps-card-more:hover { text-decoration: underline; }

/* ── App page: hero ────────────────────────────────────────────────────────────── */
.app-hero {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.4fr);
  gap: 28px;
  align-items: center;
  padding: 28px;
  background:
    radial-gradient(700px circle at 0% 0%, rgba(79, 140, 255, 0.14), transparent 60%),
    radial-gradient(600px circle at 100% 100%, rgba(155, 92, 255, 0.12), transparent 60%),
    var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 16px;
}
.app-hero-text { min-width: 0; }
.app-hero-notes { grid-column: 1 / -1; min-width: 0; font-size: 0.9rem; }
.app-hero-notes:empty { display: none; }
.app-hero-notes .app-dl-notes { margin-top: 0; }
/* The picked version's example song (download.js renderPreview()): /mp3-tracks' song card. */
.app-hero-preview { grid-column: 1 / -1; min-width: 0; }
.app-hero-preview:empty { display: none; }
.app-preview-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.app-preview-head h2 { margin: 0; font-size: 1.05rem; color: var(--app-heading); }
.app-preview-card .pc-card { margin: 0; }
.app-title-row { display: flex; align-items: center; gap: 16px; }
.app-icon { width: 84px; height: 84px; border-radius: 20px; flex: 0 0 auto; filter: drop-shadow(0 6px 22px rgba(120, 100, 255, 0.35)); }
h1.app-name {
  font-family: var(--app-font);
  font-size: clamp(2rem, 4vw, 2.7rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
  color: var(--app-heading);
}
.app-kind { color: var(--app-muted); margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #f0c674;
  background: rgba(210, 153, 34, 0.14);
  border: 1px solid rgba(210, 153, 34, 0.45);
}
.app-tagline { font-size: 1.15rem; line-height: 1.5; margin: 18px 0 20px; color: var(--app-text); }
.app-shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  overflow: hidden;
  background: #0b0e13;
  cursor: zoom-in;
}
.app-shot img { display: block; width: 100%; height: auto; transition: transform 0.35s ease; }
.app-shot:hover img { transform: scale(1.02); }
.app-shot:focus-visible { outline: 2px solid var(--app-link); outline-offset: 2px; }
.app-hero.no-shot { grid-template-columns: minmax(0, 1fr); }
.app-hero.no-shot .app-hero-shot-slot { display: none; }
.app-hero-shot-slot { min-width: 0; }
.app-hero-shot { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(155, 92, 255, 0.15); }

/* ── Download box ──────────────────────────────────────────────────────────────── */
.app-dl { display: flex; flex-direction: column; gap: 12px; }
.app-dl-loading, .app-dl-empty { color: var(--app-muted); font-size: 0.95rem; padding: 10px 0; }
.app-dl-selects { display: flex; gap: 10px; flex-wrap: wrap; }
.app-dl-selects label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 130px; min-width: 0; }
.app-dl-selects label span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--app-muted); }
.app-dl-selects select {
  width: 100%;
  padding: 8px 32px 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--app-border);
  background: rgba(13, 17, 23, 0.85) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238b949e' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 11px center / 11px;
  color: var(--app-text);
  font: inherit;
  font-size: 0.95rem;
  appearance: none;
  cursor: pointer;
}
.app-dl-selects select:focus { outline: none; border-color: var(--app-link); box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18); }
.app-dl-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 10px;
  background: var(--app-gradient);
  color: #fff !important;
  font-weight: 700;
  font-size: 1.02rem;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(110, 100, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.app-dl-btn:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 12px 30px rgba(110, 100, 255, 0.45); }
.app-dl-btn svg { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.app-dl-btn span { flex: 1; min-width: 0; }
.app-dl-btn small { font-weight: 500; opacity: 0.85; white-space: nowrap; }
.app-dl-btn.is-disabled { background: var(--app-surface-2); color: var(--app-muted) !important; box-shadow: none; cursor: default; transform: none; filter: none; }
.app-dl-meta { font-size: 0.88rem; line-height: 1.5; }
.app-dl-req { color: var(--app-text); }
.app-dl-hint { color: var(--app-muted); }
.app-dl-install {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-radius: 8px;
  background: rgba(1, 4, 9, 0.6);
  border: 1px solid var(--app-border);
}
.app-dl-install code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-family: var(--app-mono); font-size: 0.85rem; color: var(--app-text); }
.app-dl-install .prompt { color: var(--app-teal); margin-right: 6px; user-select: none; }
.app-dl-copy {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--app-border);
  background: var(--app-surface-2);
  color: var(--app-muted);
  cursor: pointer;
}
.app-dl-copy:hover { color: var(--app-text); background: #30363d; }
.app-dl-copy.is-done { color: var(--app-teal); border-color: var(--app-teal); }
.app-dl-copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.app-dl-sha { font-size: 0.75rem; color: var(--app-muted); display: flex; gap: 6px; min-width: 0; }
.app-dl-sha code { font-family: var(--app-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.app-dl-release { font-size: 0.82rem; color: var(--app-muted); }
.app-dl-release p { margin: 6px 0 0; color: var(--app-text); line-height: 1.5; }
.app-dl-notes { color: var(--app-text); line-height: 1.5; margin-top: 6px; }
.app-dl-notes summary { cursor: pointer; color: var(--app-muted); width: fit-content; }
.app-dl-notes summary:hover, .app-dl-notes[open] summary { color: var(--app-text); }
.app-dl-notes[open] { padding-bottom: 20px; }
.app-dl-notes h1, .app-dl-notes h2, .app-dl-notes h3, .app-dl-notes h4 { font-size: 0.95rem; margin: 14px 0 4px; color: var(--app-text); }
.app-dl-notes ul, .app-dl-notes ol { margin: 4px 0 0; padding-left: 20px; }
.app-dl-notes li { margin: 3px 0; }
.app-dl-notes code { font-family: var(--app-mono); font-size: 0.9em; padding: 1px 4px; border-radius: 4px; background: var(--app-surface-2); }
.app-dl[compact] .app-dl-btn { padding: 11px 14px; font-size: 0.95rem; }

/* ── Tabs (the site's view-toggle look) ────────────────────────────────────────── */
.app-tabs { display: flex; gap: 8px; margin: 28px 0 18px; overflow-x: auto; }
.app-tab {
  padding: 9px 18px;
  border-radius: 8px;
  background: rgba(26, 26, 26, 0.8);
  border: 1px solid #333;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.app-tab:hover { border-color: #555; }
.app-tab.active { border-color: var(--app-teal); box-shadow: 0 0 0 2px rgba(0, 255, 204, 0.1); }

/* ── Info tab ──────────────────────────────────────────────────────────────────── */
.app-gallery:empty { display: none; }
.app-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; margin-bottom: 24px; }
.app-shot-card { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.app-shot-card figcaption { display: flex; flex-direction: column; gap: 2px; font-size: 0.9rem; line-height: 1.45; }
.app-shot-card figcaption strong { color: var(--app-heading); }
.app-shot-card figcaption span { color: var(--app-muted); }
.app-info { display: grid; gap: 18px; }
.app-loading { color: var(--app-muted); }

/* ── Rendered Markdown ─────────────────────────────────────────────────────────── */
.app-md {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 24px 28px;
  line-height: 1.65;
  min-width: 0;
}
.app-md > :first-child { margin-top: 0; }
.app-md > :last-child { margin-bottom: 0; }
.app-md h1, .app-md h2, .app-md h3, .app-md h4 { font-family: var(--app-font); color: var(--app-heading); line-height: 1.25; scroll-margin-top: calc(var(--topbar-h, 60px) + 16px); }
.app-md h1 { font-size: 1.8rem; font-weight: 800; margin: 0 0 16px; }
.app-md h2 { font-size: 1.4rem; margin: 32px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--app-border); }
.app-md h3 { font-size: 1.1rem; margin: 24px 0 8px; color: #c9b8ff; }
.app-md h4 { font-size: 1rem; margin: 18px 0 6px; }
.app-md p { margin: 0 0 12px; }
.app-md ul, .app-md ol { margin: 0 0 12px; padding-left: 1.4em; }
.app-md li { margin: 3px 0; }
.app-md li::marker { color: var(--app-violet); }
.app-md strong { color: var(--app-heading); }
.app-md code { font-family: var(--app-mono); font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: rgba(110, 118, 129, 0.2); }
.app-md pre {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(1, 4, 9, 0.7);
  border: 1px solid var(--app-border);
  overflow-x: auto;
  line-height: 1.35;
}
.app-md pre code { padding: 0; background: none; font-size: 0.82rem; white-space: pre; }
.app-md blockquote { margin: 0 0 14px; padding: 10px 16px; border-left: 3px solid var(--app-violet); background: rgba(155, 92, 255, 0.08); border-radius: 0 8px 8px 0; }
.app-md blockquote p { margin: 0; }
.app-md hr { border: 0; border-top: 1px solid var(--app-border); margin: 24px 0; }
.app-md .md-table { overflow-x: auto; margin: 0 0 14px; }
.app-md table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.app-md th, .app-md td { border: 1px solid var(--app-border); padding: 7px 10px; text-align: left; vertical-align: top; }
.app-md th { background: var(--app-surface-2); color: var(--app-heading); }
.app-md tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }

/* ── Documentation tab ─────────────────────────────────────────────────────────── */
.app-docs-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.app-toc {
  position: sticky;
  top: calc(var(--topbar-h, 60px) + 16px);
  max-height: calc(100vh - var(--topbar-h, 60px) - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  font-size: 0.88rem;
}
.app-toc-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--app-muted); margin: 0 0 6px 8px; }
.app-toc a { color: var(--app-text) !important; text-decoration: none; padding: 5px 8px; border-radius: 6px; line-height: 1.35; }
.app-toc a:hover { background: var(--app-surface-2); color: var(--app-heading) !important; }
.app-toc code { font-family: var(--app-mono); font-size: 0.9em; }

/* ── More apps ─────────────────────────────────────────────────────────────────── */
.app-others { margin-top: 32px; }
.app-others h2 { font-family: var(--app-font); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--app-muted); margin: 0 0 12px; }
.app-others-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.app-other {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.app-other:hover { border-color: rgba(155, 92, 255, 0.55); }
.app-other img { width: 48px; height: 48px; border-radius: 11px; flex: 0 0 auto; }
.app-other span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-other strong { color: var(--app-heading); }
.app-other small { color: var(--app-muted); line-height: 1.4; }
.app-other--all { justify-content: center; text-align: center; }

/* ── Lightbox ──────────────────────────────────────────────────────────────────── */
html.app-lb-open { overflow: hidden; }
.app-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(1, 4, 9, 0.92);
}
.app-lightbox[hidden] { display: none; }
.app-lightbox figure { margin: 0; max-width: min(1500px, 100%); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.app-lightbox img { max-width: 100%; max-height: calc(100vh - 120px); width: auto; height: auto; border-radius: 8px; border: 1px solid var(--app-border); align-self: center; }
.app-lightbox figcaption { color: var(--app-muted); text-align: center; line-height: 1.5; }
.app-lightbox figcaption strong { color: var(--app-heading); margin-right: 4px; }
.app-lightbox figcaption span { margin-left: 8px; font-size: 0.85rem; }
.app-lb-nav, .app-lb-close {
  flex: 0 0 auto;
  border: 1px solid var(--app-border);
  background: rgba(33, 38, 45, 0.85);
  color: var(--app-text);
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
}
.app-lb-nav { width: 46px; height: 46px; font-size: 1.9rem; padding-bottom: 4px; }
.app-lb-nav:hover, .app-lb-close:hover { background: #30363d; }
.app-lb-close { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; font-size: 1.6rem; }

/* ── Smaller screens ───────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .apps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-hero { grid-template-columns: minmax(0, 1fr); }
  .app-hero-shot-slot { order: -1; }
}
@media (max-width: 760px), (pointer: coarse) and (max-height: 500px) {
  .apps-main { padding: 0 16px 16px; }
  .apps-grid { grid-template-columns: minmax(0, 1fr); }
  .app-hero { padding: 18px; gap: 18px; border-radius: 14px; }
  .app-icon { width: 64px; height: 64px; border-radius: 15px; }
  .app-tagline { font-size: 1.02rem; margin: 14px 0 16px; }
  .app-dl-selects select { font-size: 16px; min-height: 44px; }
  .app-gallery { grid-template-columns: minmax(0, 1fr); }
  .app-md { padding: 18px 16px; }
  .app-docs-layout { grid-template-columns: 1fr; }
  .app-toc { display: none; }
  .app-lightbox { padding: 12px 8px; }
  .app-lb-nav { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .app-shot img, .apps-card-shot img, .app-dl-btn { transition: none; }
}
