/*
  Site styles. Sections, in order:
    1. Colours and sizes (change the look of the whole site here)
    2. Base elements
    3. Layout helpers
    4. Header and footer
    5. Buttons and forms
    6. Cards, badges, lists
    7. Home and browse
    8. Themed pages (app landing pages and their forums)
    9. Forum
   10. Account
   11. Admin dashboard
   12. Theme editor
*/

/* 1. Colours and sizes -------------------------------------------------- */

:root {
  --bg: #0e1016;
  --surface: #171a23;
  --surface-2: #1f2330;
  --text: #e8eaf1;
  --muted: #9aa1b5;
  --border: #2a2f3d;
  --accent: #6d8cff;
  --accent-text: #ffffff;
  --link: #93a9ff;
  --good: #3ecf8e;
  --bad: #ff6b6b;
  --info: #5ab4ff;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.25), 0 8px 24px rgb(0 0 0 / 0.18);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --heading-font: var(--font);
  --mono: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
  --gutter: 16px;
  --max: 1180px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --text: #1b1e27;
    --muted: #5d6476;
    --border: #dde1ea;
    --accent: #3d5ce6;
    --link: #3150d6;
    --shadow: 0 1px 2px rgb(20 30 60 / 0.06), 0 8px 24px rgb(20 30 60 / 0.06);
  }
}

@media (min-width: 720px) {
  :root { --gutter: 24px; }
}

/* 2. Base elements ------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

/* Anything with the hidden attribute stays hidden, whatever else applies. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  overflow-wrap: break-word;
}

h1, h2, h3 { font-family: var(--heading-font); line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.25rem, 2.6vw, 1.5rem); }
h3, .h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; display: block; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
blockquote { margin: 0 0 1em; padding: 0.5em 1em; border-left: 3px solid var(--border); color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--accent); color: var(--accent-text); padding: 0.5rem 1rem; }
.skip-link:focus { left: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--mono); font-size: 0.875rem; }
.pre-wrap { white-space: pre-wrap; }
.danger-text { color: var(--bad) !important; }
.key-box { margin: 0; padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); word-break: break-all; user-select: all; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* 3. Layout helpers ----------------------------------------------------- */

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: 760px; }
.narrow-sm { max-width: 460px; }
.container.narrow, .container.narrow-sm { margin: 0 auto; }
.main { flex: 1; padding: 2rem 0 4rem; }
.center-block { text-align: center; padding-top: 3rem; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.75rem; }
.stack-xl > * + * { margin-top: 3rem; }
.two-col { display: grid; gap: 1.25rem; }
@media (min-width: 860px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.section-head h1, .section-head h2 { margin: 0; }

/* 4. Header and footer -------------------------------------------------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; gap: 1rem; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.site-nav { display: flex; align-items: center; gap: 0.25rem 1rem; flex: 1; flex-wrap: wrap; }
.site-nav a:not(.button) { color: var(--muted); text-decoration: none; font-weight: 500; padding: 0.4rem 0; }
.site-nav a:not(.button):hover, .site-nav a.active { color: var(--text); }
.nav-spacer { flex: 1; }
.menu-toggle { display: none; }

/* On phones the menu folds away behind a button (only when JavaScript runs,
   so the links stay reachable without it). */
@media (max-width: 759px) {
  .js .menu-toggle {
    display: inline-flex; margin-left: auto; width: 44px; height: 44px; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); cursor: pointer;
  }
  .menu-bars, .menu-bars::before, .menu-bars::after { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative; }
  .menu-bars::before, .menu-bars::after { content: ''; position: absolute; left: 0; }
  .menu-bars::before { top: -6px; }
  .menu-bars::after { top: 6px; }
  .js .site-nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding: 0.5rem 0 1rem; gap: 0.25rem; }
  .js .site-nav.open { display: flex; }
  .site-nav .nav-spacer { display: none; }
  .site-nav a:not(.button), .site-nav .link-button { padding: 0.6rem 0; }
  .site-nav .button { justify-content: center; }
}

.site-footer { border-top: 1px solid var(--border); padding: 1.5rem 0; color: var(--muted); font-size: 0.9rem; }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 1.5rem; }
.footer-row nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.footer-row a { color: var(--muted); }

.flash-list { margin-bottom: 1.5rem; display: grid; gap: 0.5rem; }
.notice-bar { background: color-mix(in srgb, var(--info) 18%, var(--bg)); border-bottom: 1px solid var(--border); padding: 0.55rem 0; font-size: 0.9rem; }
.flash { margin: 0; padding: 0.75rem 1rem; border-radius: var(--radius-sm); border: 1px solid; background: var(--surface); }
.flash-success { border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.flash-error { border-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.flash-info { border-color: color-mix(in srgb, var(--info) 50%, transparent); }

/* 5. Buttons and forms -------------------------------------------------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; padding: 0.55rem 1.1rem;
  background: var(--accent); color: var(--accent-text);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.button.danger { background: var(--bad); color: #fff; }
.button.small { min-height: 36px; padding: 0.35rem 0.8rem; font-size: 0.9rem; }
.button.wide { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.site-nav .link-button { color: var(--muted); text-decoration: none; font-weight: 500; }
.buy-form { display: grid; gap: 0.5rem; justify-items: start; }
.stars { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; white-space: nowrap; }
.stars-bar {
  letter-spacing: 1px;
  background: linear-gradient(90deg, #f5b301 calc(var(--stars) / 5 * 100%), color-mix(in srgb, currentColor 25%, transparent) 0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* Half star steps for the fill above. */
.stars.s0 { --stars: 0; } .stars.s1 { --stars: 0.5; } .stars.s2 { --stars: 1; } .stars.s3 { --stars: 1.5; } .stars.s4 { --stars: 2; } .stars.s5 { --stars: 2.5; } .stars.s6 { --stars: 3; } .stars.s7 { --stars: 3.5; } .stars.s8 { --stars: 4; } .stars.s9 { --stars: 4.5; } .stars.s10 { --stars: 5; }
.rate-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.rate-stars { display: inline-flex; flex-direction: row-reverse; }
.rate-stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rate-stars label { font-size: 1.6rem; line-height: 1; cursor: pointer; color: color-mix(in srgb, currentColor 30%, transparent); padding: 0 0.1rem; }
.rate-stars input:checked ~ label, .rate-stars label:hover, .rate-stars label:hover ~ label { color: #f5b301; }
.rate-stars input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }
.pwyw-amount { display: grid; gap: 0.25rem; }
.pwyw-amount input { max-width: 9rem; }
.buy-form .waiver { color: var(--muted); max-width: 32ch; }
.inline-form { display: inline-flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0; }

label { display: block; font-weight: 500; }
label small { display: block; font-weight: 400; color: var(--muted); margin-top: 0.3rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 0.35rem;
  padding: 0.6rem 0.75rem; min-height: 44px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit;
}
textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
input[type='checkbox'], input[type='radio'] { width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; accent-color: var(--accent); flex: none; }
input[type='color'] { padding: 0.2rem; height: 44px; cursor: pointer; }
input[type='range'] { padding: 0; accent-color: var(--accent); }
input[type='file'] { padding: 0.45rem; }
input:disabled { opacity: 0.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; }
label.check { display: flex; align-items: flex-start; gap: 0.6rem; font-weight: 400; }
label.check input { margin-top: 0.2rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; margin: 0; }
legend { font-weight: 700; padding: 0 0.4rem; }

.form-stack { display: grid; gap: 1rem; }
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2, .form-grid > h2, .form-grid > .form-errors { grid-column: 1 / -1; }
}
.form-grid > h2 { margin: 0.5rem 0 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.form-row > label { flex: 1 1 200px; }
.form-row > input, .form-row > select { flex: 1 1 200px; width: auto; margin: 0; }
.form-row label input, .form-row label select { margin: 0; }
.input-prefix { display: flex; align-items: stretch; margin-top: 0.35rem; }
.input-prefix span { display: flex; align-items: center; padding: 0 0.6rem; background: var(--surface-2); border: 1px solid var(--border); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--muted); font-size: 0.9rem; }
.input-prefix input { margin: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.inline-label { display: inline-flex; align-items: center; gap: 0.5rem; }
.inline-label select { width: auto; margin: 0; }
.form-errors { border: 1px solid color-mix(in srgb, var(--bad) 60%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); border-radius: var(--radius-sm); padding: 0.75rem 1rem; }
.form-errors p { margin: 0 0 0.25rem; font-weight: 600; }
.form-errors ul { margin: 0; padding-left: 1.2rem; }
.search-bar { display: flex; gap: 0.5rem; max-width: 560px; }
.search-bar input { margin: 0; }
.wide { width: 100%; }

/* 6. Cards, badges, lists ----------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
@media (min-width: 720px) { .card { padding: 1.5rem; } }
.card > h2:first-child { margin-top: 0; }

.badge {
  display: inline-block; padding: 0.15rem 0.55rem; margin: 0 0.25rem;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5; text-transform: capitalize;
  border-radius: 999px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text);
  vertical-align: middle;
}
.badge:first-child { margin-left: 0; }
.badge-soft { background: var(--surface-2); color: var(--muted); }
.badge-good { background: color-mix(in srgb, var(--good) 22%, transparent); }
.badge-bad { background: color-mix(in srgb, var(--bad) 25%, transparent); }

.empty { padding: 2rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap table { min-width: 640px; }
.table-wrap tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; margin: 0; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 2rem; }

.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; color: #fff; flex: none; }
.avatar-img { object-fit: cover; background: var(--surface-2); }
.avatar-md { width: 40px; height: 40px; font-size: 0.9rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar-c0 { background: #5b6cff; } .avatar-c1 { background: #e0567a; } .avatar-c2 { background: #2fa677; } .avatar-c3 { background: #d9822b; }
.avatar-c4 { background: #8e5bd8; } .avatar-c5 { background: #1e9bc2; } .avatar-c6 { background: #c2513e; } .avatar-c7 { background: #5f7c2f; }

.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.6em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 1.4em; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.3em; }
.prose img { border-radius: var(--radius-sm); margin: 1rem 0; }
.prose table { margin: 1rem 0; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; }
.tag { display: inline-block; padding: 0.2rem 0.65rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; color: var(--text); text-decoration: none; }
.tag-bar { display: grid; gap: 0.6rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.tag-row { display: flex; align-items: center; gap: 0.4rem; overflow-x: auto; scrollbar-width: thin; padding-bottom: 0.25rem; }
.tag-row .tag { flex: none; white-space: nowrap; }
.tag-bar-label { flex: none; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-right: 0.25rem; }
.tag-more summary { cursor: pointer; font-size: 0.9rem; color: var(--link, var(--accent)); width: fit-content; }
.tag-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; max-height: 14rem; overflow-y: auto; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.tag-count { color: var(--muted); font-size: 0.75rem; margin-left: 0.15rem; }
.tag-clear { border-style: dashed; }
.tag:hover, .tag.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* 7. Home and browse ---------------------------------------------------- */

.hero { padding: 2.5rem 0 3rem; margin-top: -2rem; margin-bottom: 1rem; background: radial-gradient(80% 120% at 10% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%); }
.hero h1 { font-size: clamp(2rem, 6vw, 3.25rem); letter-spacing: -0.02em; }
.hero-lead { font-size: clamp(1.05rem, 2.2vw, 1.25rem); color: var(--muted); max-width: 60ch; }

.app-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.app-card { --card-c1: var(--accent); --card-c2: color-mix(in srgb, var(--accent) 55%, #fff); position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s; }
.app-card-link { display: block; color: inherit; text-decoration: none; height: 100%; }
.app-card-cover { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; isolation: isolate; }
.app-card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s; }
.app-card-backdrop { display: none; }
.card-editor { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 760px) { .card-editor { grid-template-columns: 280px 1fr; } }
.card-preview { max-width: 320px; }

/* Card looks, chosen per page on the Media tab (src/lib/cardStyle.js). */
/* Colours: two tones each, used by gradients, borders and glows. */
.card-color-gold { --card-c1: #f5b301; --card-c2: #ffe08a; }
.card-color-silver { --card-c1: #9aa4b2; --card-c2: #eef1f5; }
.card-color-rose { --card-c1: #e0567a; --card-c2: #ffc2d1; }
.card-color-emerald { --card-c1: #1fa971; --card-c2: #a8f0cf; }
.card-color-sky { --card-c1: #1e9bc2; --card-c2: #a9e6ff; }
.card-color-violet { --card-c1: #8e5bd8; --card-c2: #d9c2ff; }
.card-color-fire { --card-c1: #e2451d; --card-c2: #ffc048; }
.card-color-mono { --card-c1: #111; --card-c2: #f2f2f2; }

/* Image fit. "icon" shows a small rounded icon in the middle. */
.card-fit-contain .app-card-image { object-fit: contain; }
.card-fit-icon .app-card-image { position: absolute; inset: 0; margin: auto; width: 42%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 22%; box-shadow: 0 10px 28px rgb(0 0 0 / 0.35), 0 0 0 1px rgb(255 255 255 / 0.12); }

/* Background behind the image. */
.card-bg-gradient .app-card-cover { background: linear-gradient(135deg, var(--card-c1), var(--card-c2)); }
.card-bg-dark .app-card-cover { background: radial-gradient(circle at 50% 35%, #2a2f3a, #0d0f14); }
.card-bg-light .app-card-cover { background: radial-gradient(circle at 50% 35%, #ffffff, #e6e9ef); }
.card-bg-blur .app-card-backdrop { display: block; position: absolute; inset: 0; object-fit: cover; transform: scale(1.4); filter: blur(22px) saturate(1.4) brightness(0.85); z-index: -1; }

/* Frame around the card. */
.card-frame-subtle { border-color: color-mix(in srgb, var(--text) 18%, transparent); box-shadow: 0 1px 0 rgb(255 255 255 / 0.06) inset, 0 6px 18px rgb(0 0 0 / 0.18); }
.card-frame-color { border: 2px solid var(--card-c1); }
.card-frame-glow { border-color: var(--card-c1); box-shadow: 0 0 0 1px var(--card-c1), 0 0 22px color-mix(in srgb, var(--card-c1) 55%, transparent); }
.card-frame-gradient { border: 2px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, var(--card-c1), var(--card-c2), var(--card-c1)) border-box; }

/* Shine over the image. */
.card-shine-gloss .app-card-cover::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(170deg, rgb(255 255 255 / 0.35) 0%, rgb(255 255 255 / 0.08) 38%, transparent 40%); }
.card-shine-sweep .app-card-cover::after { content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%; pointer-events: none; transform: skewX(-20deg); background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.45), transparent); transition: left 0.7s ease; }
.card-shine-sweep:hover .app-card-cover::after { left: 130%; }

/* Hover effect. */
.card-hover-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card-hover-zoom:hover .app-card-image { transform: scale(1.06); }
.card-fit-icon.card-hover-zoom:hover .app-card-image { transform: scale(1.1); }
.card-hover-tilt:hover { transform: perspective(700px) rotateX(3deg) rotateY(-4deg) translateY(-3px); box-shadow: var(--shadow); }
.app-card:not(.card-frame-color, .card-frame-glow, .card-frame-gradient):hover { border-color: color-mix(in srgb, var(--card-c1) 50%, var(--border)); }
@media (prefers-reduced-motion: reduce) {
  .app-card, .app-card-cover img, .card-shine-sweep .app-card-cover::after { transition: none; }
  .card-hover-tilt:hover, .card-hover-lift:hover { transform: none; }
}
.cover-placeholder { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 3rem; font-weight: 800; color: var(--muted); }
.app-card-body { padding: 0.9rem 1rem 1rem; }
.app-card-body h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.app-card-tagline { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.6rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.app-card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem; margin: 0; }
.app-card-meta .badge { margin: 0; }
.price { margin-left: auto; font-weight: 700; font-size: 0.9rem; }

.filters { display: grid; gap: 0.5rem; grid-template-columns: 1fr 1fr; }
.filters label:first-child { grid-column: 1 / -1; }
.filters input, .filters select { margin: 0; }
.filters .button { grid-column: 1 / -1; }
@media (min-width: 860px) {
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
  .filters label:first-child, .filters .button { grid-column: auto; }
}

.offer-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.offer-card { display: flex; flex-direction: column; gap: 0.5rem; }
.offer-card .inline-form, .offer-card .badge { margin-top: auto; align-self: flex-start; }
.offer-price { font-weight: 800; font-size: 1.15rem; }

.profile-head { display: flex; gap: 1rem; align-items: center; }
.profile-head h1 { margin: 0; }
.profile-bio { white-space: pre-wrap; }

/* 8. Themed pages -------------------------------------------------------
   App pages (and their forums) take the colours, fonts and layout picked
   in the theme editor. The server writes the --page-* variables and adds
   class names like panel-glass or layout-left to .app-page. The rules
   below map those onto the normal site styles. */

body.themed {
  --bg: var(--page-bg);
  --surface: var(--page-surface);
  --surface-2: color-mix(in srgb, var(--page-surface) 80%, var(--page-text));
  --text: var(--page-text);
  --muted: color-mix(in srgb, var(--page-text) 68%, var(--page-surface));
  --border: color-mix(in srgb, var(--page-surface) 82%, var(--page-text));
  --accent: var(--page-accent);
  --accent-text: var(--page-accent-text);
  --link: var(--page-link);
  --font: var(--page-body-font);
  --heading-font: var(--page-heading-font);
}
body.themed .main { padding: 0; }
body.themed .flash-list { padding-top: 1.5rem; margin-bottom: 0; }

.app-page {
  --panel-bg: var(--surface);
  --panel-border: var(--border);
  --panel-blur: none;
  --page-width: var(--max);
  position: relative;
  min-height: 70vh;
  padding-bottom: 4rem;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* The page background image sits on its own layer so the dim overlay and
   the image itself can be styled separately. */
.app-page::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--bg) var(--page-dim), transparent), color-mix(in srgb, var(--bg) var(--page-dim), transparent)),
    var(--page-bg-image, none);
}
.app-page > * { position: relative; z-index: 1; }
.app-page.bg-none::before { display: none; }
.app-page.bg-cover::before { background-size: cover; background-position: center top; }
.app-page.bg-fixed::before { position: fixed; background-size: cover; background-position: center; }
.app-page.bg-tile::before { background-size: auto; background-repeat: repeat; }
.app-page.bg-top::before {
  background-image:
    linear-gradient(to bottom, color-mix(in srgb, var(--bg) var(--page-dim), transparent) 0, var(--bg) min(90vh, 900px)),
    var(--page-bg-image, none);
  background-size: 100% auto;
  background-repeat: no-repeat;
  background-position: center top;
}

.app-page .card, .app-page .post, .app-page .thread-list {
  background: var(--panel-bg);
  border-color: var(--panel-border);
  backdrop-filter: var(--panel-blur);
  -webkit-backdrop-filter: var(--panel-blur);
}
.app-page.panel-glass {
  --panel-bg: color-mix(in srgb, var(--surface) 68%, transparent);
  --panel-border: color-mix(in srgb, var(--text) 14%, transparent);
  --panel-blur: blur(14px) saturate(1.2);
}
.app-page.panel-outline {
  --panel-bg: transparent;
  --panel-border: color-mix(in srgb, var(--text) 35%, transparent);
}

.app-page.radius-sharp { --radius: 0; --radius-sm: 0; }
.app-page.radius-round { --radius: 22px; --radius-sm: 14px; }
.app-page.radius-round .button { border-radius: 999px; }

.app-page.width-wide { --page-width: 1440px; }
.app-page .container { max-width: var(--page-width); }

.admin-bar { background: color-mix(in srgb, var(--accent) 18%, var(--bg)); font-size: 0.9rem; padding: 0.4rem 0; }
.admin-bar .container { display: flex; gap: 0.75rem; align-items: center; }

/* Header area of a landing page. */
.app-hero { position: relative; overflow: hidden; padding: 2.5rem 0; }
.app-page.hero-short .app-hero { padding: 1.5rem 0; }
.app-page.hero-tall .app-hero { padding: clamp(3rem, 12vw, 8rem) 0; }
.app-hero-banner { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
/* Shades the banner so header text stays readable on bright images: a fade
   into the page at the bottom, and a darker side behind the text. */
.app-hero.has-banner::after {
  content: ''; position: absolute; inset: 0; z-index: 0;
  background:
    linear-gradient(to top, var(--bg) 0%, transparent 55%),
    linear-gradient(to right, color-mix(in srgb, var(--bg) 88%, transparent) 0%, color-mix(in srgb, var(--bg) 60%, transparent) 55%, color-mix(in srgb, var(--bg) 25%, transparent) 100%);
}
.app-page.hero-align-center .app-hero.has-banner::after {
  background:
    linear-gradient(to top, var(--bg) 0%, transparent 55%),
    color-mix(in srgb, var(--bg) 62%, transparent);
}
.app-hero.has-banner .app-hero-inner { color: var(--text); }
.app-hero-inner { position: relative; z-index: 1; display: grid; gap: 1.5rem; align-items: end; }
@media (min-width: 760px) { .app-hero-inner { grid-template-columns: minmax(0, 340px) 1fr; } }
.app-hero-inner:not(:has(.app-hero-cover:not([hidden]))) { grid-template-columns: 1fr; }
.app-hero-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--panel-border, var(--border)); }
.app-hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -0.02em; margin-bottom: 0.25em; }
.app-hero-name { font-weight: 700; color: var(--muted); margin-bottom: 0.25rem; }
.app-hero .hero-lead { margin-bottom: 1.25rem; }
.app-page.hero-align-center .app-hero-inner { grid-template-columns: 1fr; justify-items: center; text-align: center; }
.app-page.hero-align-center .app-hero-cover { max-width: 420px; }
.app-page.hero-align-center .app-hero .button-row, .app-page.hero-align-center .app-hero .hero-lead { justify-content: center; margin-left: auto; margin-right: auto; }
.app-hero-rating { margin: 0 0 0.25rem; }
.app-hero-by { margin: 0; color: var(--muted); }
/* A soft glow in the page colour behind the header text, so it stands out
   on any banner image. */
.app-hero.has-banner .app-hero-text > * {
  text-shadow: 0 2px 14px color-mix(in srgb, var(--bg) 85%, transparent), 0 1px 3px color-mix(in srgb, var(--bg) 75%, transparent);
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; font-weight: 700; color: var(--accent); margin: 0 0 0.5rem; }

/* Content column plus the full version box. On phones everything stacks in
   page order: buttons, screenshots, videos, description, full version, forum.
   On wide screens the full version box moves to the side. */
.app-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-top: 1.5rem; }
/* minmax(0, 1fr) keeps the sideways scrolling rows from stretching the page. */
.app-main, .app-after { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; align-content: start; }
.app-after:empty { display: none; }
.get-box { align-self: start; display: grid; gap: 1rem; }
.get-box h2 { margin: 0; }
@media (min-width: 960px) {
  .app-page.layout-right .app-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .app-page.layout-left .app-layout { grid-template-columns: 340px minmax(0, 1fr); }
  .app-page.layout-right .get-box { grid-column: 2; grid-row: 1 / span 2; }
  .app-page.layout-left .get-box { grid-column: 1; grid-row: 1 / span 2; }
  .app-page.layout-left .app-main, .app-page.layout-left .app-after { grid-column: 2; }
  .app-page.layout-right .get-box, .app-page.layout-left .get-box { position: sticky; top: 80px; }
}

/* The big buttons under the header. They share the full width. */
.action-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.action-bar .button { flex: 1 1 200px; justify-content: center; text-align: center; }
.button.big { font-size: 1.1rem; padding: 0.85rem 1.4rem; }

.app-page.layout-stacked .app-layout { max-width: 920px; margin: 0 auto; }

.app-section > h2 { margin-bottom: 0.75rem; }
.app-main > .app-section:not(.custom-html), .app-after > .app-section { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 1.25rem; backdrop-filter: var(--panel-blur); -webkit-backdrop-filter: var(--panel-blur); }
@media (min-width: 720px) { .app-main > .app-section:not(.custom-html), .app-after > .app-section { padding: 1.5rem; } }

.offer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.offer { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding-bottom: 0.75rem; border-bottom: 1px solid var(--panel-border, var(--border)); }
.offer:last-child { border-bottom: 0; padding-bottom: 0; }
.offer-text { display: grid; gap: 0.1rem; }
.download-box { display: grid; gap: 0.5rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; margin: 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Aspect ratio boxes for demos and videos. */
.ratio-16-9 { aspect-ratio: 16 / 9; }
.ratio-4-3 { aspect-ratio: 4 / 3; }
.ratio-1-1 { aspect-ratio: 1 / 1; }
.ratio-9-16 { aspect-ratio: 9 / 16; max-height: 85vh; margin: 0 auto; }
.ratio-3-4 { aspect-ratio: 3 / 4; max-height: 85vh; margin: 0 auto; }

/* Screenshots and videos scroll sideways in a row. */
.strip { display: flex; gap: 0.75rem; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; padding-bottom: 0.5rem; scrollbar-width: thin; }
.strip > * { flex: 0 0 auto; scroll-snap-align: start; }
.video-strip > .video { width: min(82%, 420px); }
.video { margin: 0; }
.video figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 0.4rem; }
.video-frame { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-start { position: absolute; inset: 0; display: block; }
.video-start img { width: 100%; height: 100%; object-fit: cover; }
.play-icon { position: absolute; left: 50%; top: 50%; width: 68px; height: 48px; transform: translate(-50%, -50%); background: rgb(0 0 0 / 0.7); border-radius: 12px; transition: background 0.15s; }
.play-icon::after { content: ''; position: absolute; left: 28px; top: 14px; border-style: solid; border-width: 10px 0 10px 16px; border-color: transparent transparent transparent #fff; }
.video-start:hover .play-icon { background: #f00; }

.shot { display: block; border-radius: var(--radius-sm); overflow: hidden; height: clamp(150px, 42vw, 260px); aspect-ratio: 16 / 10; background: var(--surface-2); }
.shot img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s; }
.shot:hover img { transform: scale(1.04); }

.lightbox { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; margin: 0; }
.lightbox::backdrop { background: rgb(0 0 0 / 0.88); }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox img { max-width: min(96vw, 1600px); max-height: 82vh; object-fit: contain; border-radius: 6px; }
.lightbox-caption { color: #eee; margin: 0.75rem 1rem 0; text-align: center; }
.lightbox button { position: fixed; background: rgb(0 0 0 / 0.55); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 1.75rem; line-height: 1; cursor: pointer; }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 12px; top: 50%; transform: translateY(-50%); }

.review-panel { margin-top: 1rem; display: grid; gap: 0.75rem; }
.review-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; max-height: 320px; overflow-y: auto; }
.review-notes li { padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.review-notes li.from-admin { border-left: 3px solid var(--accent); }
.review-notes p { margin: 0; }
.storage-bar { width: 100%; height: 12px; accent-color: var(--accent); }
.update-list { display: grid; gap: 1.25rem; }
.update h3 { margin: 0.1rem 0 0.5rem; }
.update + .update { border-top: 1px solid var(--panel-border, var(--border)); padding-top: 1.25rem; }
.report-box { font-size: 0.9rem; color: var(--muted); }
.report-box summary { cursor: pointer; }
.report-box form { margin-top: 0.75rem; }
.audio-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.audio-list li { display: grid; gap: 0.35rem; }
.audio-title { font-weight: 600; }
.audio-list audio, .media-list audio { width: 100%; }
/* AI assistant ----------------------------------------------------------- */
.assistant { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 860px) { .assistant:not(.assistant-compact) { grid-template-columns: 220px minmax(0, 1fr); } }
.assistant-side { display: grid; gap: 0.6rem; align-content: start; }
.assistant-compact .assistant-side { grid-template-columns: auto 1fr; align-items: center; }
.assistant-compact .assistant-chats { display: none; }
.assistant-chats { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; max-height: 50vh; overflow-y: auto; }
.assistant-chats a { display: block; padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assistant-chats a.active, .assistant-chats a:hover { background: var(--surface); color: var(--text); }
.assistant-main { display: grid; gap: 0.6rem; min-width: 0; }
.assistant-log { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; align-content: start; overflow-x: hidden; min-height: 40vh; max-height: 65vh; overflow-y: auto; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.assistant-compact .assistant-log { min-height: 0; height: calc(100vh - 190px); max-height: none; }
.ai-msg { max-width: 85%; min-width: 0; padding: 0.55rem 0.8rem; border-radius: 14px; overflow-wrap: anywhere; }
.ai-msg.ai-rich { max-width: 100%; }
.ai-msg p { margin: 0; }
.ai-user { justify-self: end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai-assistant { justify-self: start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.ai-rich p { margin: 0 0 0.5rem; }
.ai-rich > :last-child { margin-bottom: 0; }
.ai-rich ul, .ai-rich ol { margin: 0 0 0.5rem; padding-left: 1.2rem; }
.ai-rich a { color: var(--link, var(--accent)); text-decoration: underline; }
.ai-rich code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; background: rgb(0 0 0 / 0.25); padding: 0.05rem 0.3rem; border-radius: 4px; }
.ai-code-wrap { margin: 0 0 0.5rem; border-radius: 8px; overflow: hidden; background: #0d1117; }
.ai-code-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0.6rem; font-size: 0.75rem; color: #8b949e; background: #161b22; text-transform: lowercase; }
.ai-copy { border: 1px solid #30363d; background: transparent; color: #e6edf3; border-radius: 6px; padding: 0.15rem 0.5rem; font: inherit; cursor: pointer; }
.ai-code-wrap .ai-code { margin: 0; border-radius: 0; max-height: 22rem; overflow: auto; overscroll-behavior: contain; }
/* The chat bubble is small, so code scrolls inside a shorter panel. */
.assistant-compact .ai-code-wrap .ai-code { max-height: 14rem; }
.hl-k { color: #ff7b72; } .hl-s { color: #a5d6ff; } .hl-n { color: #79c0ff; } .hl-c { color: #8b949e; font-style: italic; }
.ai-coded::before { content: 'Coding model'; display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.3rem; }
.ai-typing { display: inline-flex; gap: 4px; padding: 0.3rem 0; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.4; animation: ai-dot 1.2s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay: 0.15s; } .ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 0.9; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-typing span { animation: none; } }
.button.ai-stop { background: #e5484d; }
.ai-code { margin: 0 0 0.5rem; padding: 0.7rem 0.8rem; border-radius: 8px; background: #0d1117; color: #e6edf3; overflow-x: auto; font-size: 0.85rem; line-height: 1.45; }
.ai-code code { background: none; padding: 0; white-space: pre; }
.ai-error { background: color-mix(in srgb, #e5484d 20%, var(--surface-2)); }
.assistant-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: end; }
.assistant-form textarea { resize: vertical; min-height: 44px; }
.ai-search-toggle { grid-column: 1 / -1; }
.ai-count { grid-column: 1 / -1; margin-top: -0.3rem; }
.ai-hint { margin: 0 0 -0.35rem; font-size: 0.75rem; color: var(--muted); max-width: 100%; overflow-wrap: anywhere; }
.ai-hint a { color: inherit; }
.assistant-embed .site-header, .assistant-embed .site-footer, .assistant-embed .notice-bar, .assistant-embed .skip-link { display: none; }
.assistant-embed .main { padding: 0.75rem; }
.ai-bubble { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 50; display: grid; justify-items: end; gap: 0.6rem; }
.ai-bubble-button { display: inline-flex; align-items: center; gap: 0.4rem; border: 0; border-radius: 999px; padding: 0.7rem 1rem; font: inherit; font-weight: 700; color: #fff; background: var(--accent); box-shadow: 0 8px 24px rgb(0 0 0 / 0.3); cursor: pointer; }
.ai-panel { width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100vh - 110px)); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: 0 16px 48px rgb(0 0 0 / 0.4); background: var(--bg); }
.ai-panel iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 520px) { .ai-bubble-label { display: none; } }
.memory-list li { justify-content: space-between; }

.contact-note { border-top: 1px solid var(--border); padding-top: 0.75rem; }

/* The page that runs a web build: a thin bar, then the app filling the rest. */
.player-html, .player-page { height: 100%; margin: 0; overflow: hidden; background: #000; }
.player-page { display: flex; flex-direction: column; height: 100dvh; }
.player-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 0.6rem; min-height: 44px;
  padding: 0.25rem max(0.6rem, env(safe-area-inset-right)) 0.25rem max(0.6rem, env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.player-back { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.player-back span[aria-hidden] { font-size: 1.4rem; line-height: 1; }
.player-title { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.player-title .badge { margin-left: 0.4rem; }
.player-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }
.player-stage { flex: 1 1 auto; position: relative; min-height: 0; }
.player-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.player-stage iframe:focus { outline: none; }
@media (max-width: 520px) {
  .player-title { display: none; }
  .player-actions { margin-left: auto; }
}

.custom-frame { width: 100%; min-height: 200px; border: 0; display: block; background: transparent; }

/* 9. Forum -------------------------------------------------------------- */

.forum { padding-top: 1.5rem; }
.breadcrumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); }
.thread-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.thread-row { display: grid; gap: 0.5rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--panel-border, var(--border)); }
.thread-row:last-child { border-bottom: 0; }
.thread-row p { margin: 0.2rem 0 0; }
.thread-title { font-weight: 600; font-size: 1.05rem; }
.thread-stats { display: grid; gap: 0.1rem; }
@media (min-width: 720px) { .thread-row { grid-template-columns: 1fr 240px; align-items: center; } .thread-stats { text-align: right; } }
.thread-list.compact { border: 0; border-radius: 0; background: transparent !important; backdrop-filter: none !important; }
.thread-list.compact li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--panel-border, var(--border)); }
.thread-list.compact li:last-child { border-bottom: 0; }
.thread-head { display: grid; gap: 0.5rem; }
.thread-head h1 { margin: 0; }
.mod-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.post { scroll-margin-top: 90px; }
.post:target { outline: 2px solid var(--accent); }
.post.is-hidden { opacity: 0.6; }
.post-author { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.post-author p { margin: 0; }
.user-link { font-weight: 600; }
.post-body p { margin: 0 0 0.75em; }
.post-body p:last-child { margin: 0; }
.post-actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--panel-border, var(--border)); }
.report summary { cursor: pointer; color: var(--muted); }
.report .form-row { margin-top: 0.5rem; }

/* 10. Account ----------------------------------------------------------- */

.library { list-style: none; margin: 0; padding: 0; }
.library li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1rem; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.library li:last-child { border-bottom: 0; }
.library p { margin: 0; }
.library-actions { display: flex; gap: 0.5rem; align-items: center; }
.change-email summary { cursor: pointer; color: var(--link); margin-top: 0.5rem; }
.change-email[open] summary { margin-bottom: 1rem; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }

/* 11. Admin dashboard --------------------------------------------------- */

.main.wide .container.admin { max-width: 1400px; }
.admin { display: grid; gap: 1.5rem; }
@media (min-width: 960px) { .admin { grid-template-columns: 210px minmax(0, 1fr); align-items: start; } }
.admin-nav { display: flex; gap: 0.25rem; overflow-x: auto; padding-bottom: 0.25rem; scrollbar-width: thin; }
.admin-nav a { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.admin-nav a:hover { color: var(--text); background: var(--surface); }
.admin-nav a.active { color: var(--text); background: var(--surface); }
@media (min-width: 960px) { .admin-nav { flex-direction: column; position: sticky; top: 80px; overflow: visible; } }
.count { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 0.45rem; font-size: 0.75rem; font-weight: 700; }
.admin-main { min-width: 0; }

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.stat { display: grid; gap: 0.25rem; color: inherit; text-decoration: none; }
.stat strong { font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.9rem; }
.stat:hover { border-color: var(--accent); }

.tabs { display: flex; gap: 0.25rem; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.tabs a { flex: none; padding: 0.6rem 0.9rem; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .tab-view { margin-left: auto; }

.image-slot { display: grid; gap: 0.6rem; align-content: start; }
.image-slot h3, .image-slot p { margin: 0; }
.slot-preview { border-radius: var(--radius-sm); border: 1px solid var(--border); max-height: 220px; object-fit: cover; width: 100%; }
.slot-cover { aspect-ratio: 16 / 9; }
.slot-empty { display: grid; place-items: center; min-height: 120px; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); }

.media-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.75rem; }
.media-list li { display: grid; gap: 0.75rem; align-items: center; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
@media (min-width: 640px) { .media-list li { grid-template-columns: 160px 1fr; } }
.media-list img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; }
.media-controls { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0; }
.media-controls input { flex: 1 1 180px; width: auto; margin: 0; }

.upload-box { margin-top: 1.25rem; padding: 1rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); display: grid; gap: 0.6rem; }
.upload-box h3, .upload-box p { margin: 0; }
.upload-box progress { width: 100%; height: 10px; accent-color: var(--accent); }

.db-table table { min-width: 100%; font-size: 0.85rem; }
.db-table td { max-width: 320px; word-break: break-word; vertical-align: top; }
.db-table th { white-space: nowrap; }
.message.unread { border-left: 4px solid var(--accent); }
.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.report-list li { padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.report-list li:last-child { border-bottom: 0; padding-bottom: 0; }

/* 12. Theme editor ------------------------------------------------------ */

.theme-editor { display: grid; gap: 1.5rem; }
@media (min-width: 1100px) {
  .theme-editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; }
  .theme-side { position: sticky; top: 80px; }
}
.theme-side { display: grid; gap: 1rem; }
.color-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.color-grid label { font-size: 0.9rem; }
.match-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 0.75rem 0; }
.theme-editor fieldset { display: grid; gap: 0.75rem; }
.advanced summary { cursor: pointer; font-weight: 600; }
.advanced[open] summary { margin-bottom: 0.75rem; }

.theme-preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
/* The preview reuses the real landing page styles, at a smaller size. The
   colour variables are mapped by hand because body.themed is not set. */
.preview-page {
  --bg: var(--page-bg);
  --surface: var(--page-surface);
  --surface-2: color-mix(in srgb, var(--page-surface) 80%, var(--page-text));
  --text: var(--page-text);
  --muted: color-mix(in srgb, var(--page-text) 68%, var(--page-surface));
  --border: color-mix(in srgb, var(--page-surface) 82%, var(--page-text));
  --accent: var(--page-accent);
  --accent-text: var(--page-accent-text);
  --link: var(--page-link);
  --font: var(--page-body-font);
  --heading-font: var(--page-heading-font);
  min-height: 0;
  padding: 0 1rem 1.25rem;
  font-size: 14px;
  isolation: isolate;
  overflow: hidden;
}
.preview-page.bg-fixed::before { position: absolute; }
.preview-page .app-hero { padding: 1.25rem 0; margin: 0 -1rem; }
.preview-page.hero-short .app-hero { padding: 0.75rem 0; }
.preview-page.hero-tall .app-hero { padding: 3rem 0; }
.preview-page .app-hero-inner { padding: 0 1rem; }
.preview-page .app-hero h1 { font-size: 1.6rem; }
.preview-page .app-hero-inner { grid-template-columns: 140px 1fr; }
.preview-page.hero-align-center .app-hero-inner { grid-template-columns: 1fr; }
.preview-page.hero-align-center .app-hero-cover { max-width: 200px; }
.preview-page .app-layout { padding-top: 0.5rem; grid-template-columns: 1fr; }
.preview-page.layout-right .app-layout { grid-template-columns: minmax(0, 1fr) 190px; }
.preview-page.layout-left .app-layout { grid-template-columns: 190px minmax(0, 1fr); }
.preview-page.layout-left .get-box { grid-column: 1; grid-row: 1; }
.preview-page .get-box { order: 0; position: static; }
.preview-page .button { min-height: 34px; padding: 0.3rem 0.8rem; font-size: 0.85rem; }
.preview-page .card, .preview-page .app-main > .app-section:not(.custom-html), .app-after > .app-section { padding: 1rem; }
@media (max-width: 560px) {
  .preview-page.layout-right .app-layout, .preview-page.layout-left .app-layout { grid-template-columns: 1fr; }
  .preview-page .app-hero-inner { grid-template-columns: 1fr; }
}

/* Markdown editor (dashboard) */
.md-field { display: grid; gap: 0.4rem; }
.md-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.md-label { font-weight: 500; }
.md-tabs { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.md-tab { background: none; border: 0; padding: 0.35rem 0.8rem; font: inherit; font-size: 0.85rem; color: var(--muted); cursor: pointer; }
.md-tab.active { background: var(--surface-2); color: var(--text); }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.md-tool { min-width: 36px; min-height: 32px; padding: 0.2rem 0.5rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.md-tool:hover { border-color: var(--accent); }
.md-tool[data-md='italic'] { font-style: italic; }
.md-field textarea { margin: 0; }
.md-preview { min-height: 10rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); max-width: none; }

/* Sign in and account security */
.divider { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); margin: 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.passkey-login { display: grid; gap: 0.75rem; }
.passkey-login[hidden] { display: none; }
.code-input { font-family: var(--mono); font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; max-width: 14rem; }
.setup-steps { display: grid; gap: 1.25rem; padding-left: 1.2rem; margin: 0; }
.setup-steps p { margin: 0.5rem 0 0; }
.qr { width: min(220px, 100%); margin-top: 0.5rem; background: #fff; padding: 6px; border-radius: var(--radius-sm); }
.qr svg { display: block; width: 100%; height: auto; }
.backup-codes { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; font-size: 1.05rem; }
.backup-codes li { padding: 0.5rem 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: center; }

/* Request an app */
.request-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem; }
.request-cta h2 { margin-bottom: 0.25rem; }
.request-cta p { margin: 0; max-width: 60ch; }
.request-form h2 { margin-top: 0.5rem; font-size: 1.1rem; }
.request-facts { margin: 0.25rem 0; }
.status-new { background: color-mix(in srgb, var(--info) 22%, transparent); }
.status-quoted, .status-accepted { background: color-mix(in srgb, var(--good) 22%, transparent); }
.status-declined { background: var(--surface-2); color: var(--muted); }
.status-done { background: var(--surface-2); }
