/* ==========================================================================
   AJA Digital: site.css
   One stylesheet for the whole site. Tokens → base → layout → components
   → pages. Light/dark only, driven by data-theme on <html> (set before
   first paint by the inline script in partials/head.html).

   The "legacy aliases" block maps the token names that demos.css,
   emojiBattle*.css and atelier.css were written against onto the new
   palette, so those feature stylesheets keep working untouched.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
    color-scheme: light;

    --bg: #FFFFFF;
    --bg-subtle: #F5F5F7;
    --surface: #FFFFFF;
    --border: #E5E5EA;
    --border-strong: #D1D1D6;
    --text: #0B0B0F;
    --text-muted: #55555F;
    --text-faint: #6E6E78;
    --accent: #2350D8;
    --accent-hover: #1A3FB0;
    --on-accent: #FFFFFF;
    --brand: #FFC400;
    --live: #1C8A4B;
    --live-text: #146C3A;
    --soon: #D98B0B;
    --soon-text: #8A4B00;
    --danger: #C4321C;
    --overlay: rgba(10, 10, 15, 0.4);
    --header-bg: rgba(255, 255, 255, 0.82);

    --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.25rem;
    --fs-lead: 1.125rem;
    --fs-h1: clamp(2.125rem, 1.5rem + 2.6vw, 3.25rem);
    --fs-h2: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --r-pill: 999px;
    --icon-radius: 22.37%;

    --dur-1: 120ms;
    --dur-2: 200ms;
    --dur-3: 320ms;
    --dur-reveal: 480ms;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --shadow-sm: 0 1px 2px rgba(10, 10, 15, 0.06);
    --shadow-md: 0 1px 2px rgba(10, 10, 15, 0.04), 0 8px 24px -8px rgba(10, 10, 15, 0.12);
    --shadow-lg: 0 24px 64px -16px rgba(10, 10, 15, 0.28);

    --header-h: 60px;
    --wrap: 1120px;
    --gutter: clamp(16px, 4vw, 32px);

    --app-accent: var(--accent);

    /* Legacy aliases (demos.css, emojiBattle*.css, atelier.css) */
    --bg-0: var(--bg);
    --bg-1: var(--bg);
    --bg-2: var(--bg-subtle);
    --text-1: var(--text);
    --text-2: var(--text-muted);
    --text-3: var(--text-faint);
    --glass-bg: var(--bg-subtle);
    --glass-bg-strong: var(--surface);
    --glass-border: var(--border);
    --glass-border-hover: var(--border-strong);
    --glass-blur: 0px;
    --accent-text: var(--accent);
    --focus-ring: color-mix(in oklab, var(--accent) 45%, transparent);
    --neon-1: #7C5CFA;
    --neon-2: #0EA5B7;
    --neon-3: #E0488F;
    --gradient-brand: linear-gradient(135deg, #7C5CFA, #4F6BF0);
    --gradient-cta: linear-gradient(135deg, #6D4AF0, #3D5BE0);
    --shadow-card: var(--shadow-sm);
    --shadow-card-hover: var(--shadow-md);
    --shadow-btn: var(--shadow-sm);
    --shadow-btn-hover: var(--shadow-md);
    --os-statusbar-h: var(--header-h);
    --os-icon-radius: var(--icon-radius);
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0A0A0C;
    --bg-subtle: #151518;
    --surface: #111114;
    --border: #26262B;
    --border-strong: #3A3A41;
    --text: #F4F4F6;
    --text-muted: #A6A6B0;
    --text-faint: #8C8C96;
    --accent: #8AA9FF;
    --accent-hover: #AFC4FF;
    --on-accent: #0A0A0C;
    --live: #3DD68C;
    --live-text: #5BE3A0;
    --soon: #F5B83D;
    --soon-text: #F8C766;
    --danger: #FF7A66;
    --overlay: rgba(0, 0, 0, 0.6);
    --header-bg: rgba(10, 10, 12, 0.78);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, 0.8);

    --neon-1: #A78BFA;
    --neon-2: #22D3EE;
    --neon-3: #F472B6;
}

/* A text-safe version of whatever accent a page/demo sets. Declared where
   --app-accent is set (body, .demo) so it resolves against that value. */
body, .demo, [style*="--app-accent"] {
    --app-accent-ink: color-mix(in oklab, var(--app-accent) 62%, var(--text));
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

main { flex: 1 0 auto; display: block; }
main:focus { outline: none; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--text);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin: 0 0 0.5em;
    font-weight: 700;
    text-wrap: balance;
}
h1 { font-size: var(--fs-h1); letter-spacing: -0.035em; }
h2 { font-size: var(--fs-h2); letter-spacing: -0.025em; }
h3 { font-size: var(--fs-lg); letter-spacing: -0.01em; font-weight: 600; }

p { margin: 0 0 1em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }

img, svg, video, canvas { max-width: 100%; }
img { height: auto; }

ul, ol { padding-left: 1.25em; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

code, kbd, pre { font-family: var(--font-mono); font-size: 0.9em; }
code {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.05em 0.35em;
}
kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 0.05em 0.4em;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.78em;
    line-height: 1.5;
    text-align: center;
}

::selection { background: color-mix(in oklab, var(--accent) 25%, transparent); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

button { font: inherit; color: inherit; }

table { border-collapse: collapse; width: 100%; }

.visually-hidden {
    position: absolute !important;
    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: 12px;
    top: -100px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--r-sm);
    background: var(--text);
    color: var(--bg);
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--bg); }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.wrap {
    width: 100%;
    max-width: calc(var(--wrap) + var(--gutter) * 2);
    margin-inline: auto;
    padding-inline: var(--gutter);
}
.wrap-narrow { max-width: calc(760px + var(--gutter) * 2); }

.section { padding-block: clamp(40px, 6vw, 72px); }
.section + .section { border-top: 1px solid var(--border); }
.section-tight { padding-block: clamp(28px, 4vw, 44px); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.section-head h2 { margin: 0; }
.section-head p { margin: 0; color: var(--text-muted); }
.section-link { font-weight: 600; text-decoration: none; white-space: nowrap; }
.section-link:hover { text-decoration: underline; }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0;
}

.lead {
    font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
    color: var(--text-muted);
    line-height: 1.55;
    max-width: 60ch;
}

.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-h);
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-mark { width: 28px; height: 28px; flex: none; border-radius: 8px; }
:root[data-theme="dark"] .brand-mark { box-shadow: 0 0 0 1px var(--border-strong); }

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.site-nav a {
    padding: 8px 12px;
    border-radius: var(--r-pill);
    color: var(--text-muted);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--dur-1), background-color var(--dur-1);
}
.site-nav a:hover { color: var(--text); background: var(--bg-subtle); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--bg-subtle); }

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--fs-sm);
    transition: color var(--dur-1), border-color var(--dur-1), background-color var(--dur-1);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn kbd { margin-left: 2px; }

.search-btn { padding: 0 8px 0 12px; min-width: 180px; justify-content: flex-start; }
.search-btn .search-label { flex: 1; text-align: left; }

.menu-btn { display: none; }

@media (max-width: 560px) {
    .app-grid { gap: 8px; }
    .app-card { padding: 12px; }
    .app-card .app-icon { width: 48px; height: 48px; }
}

@media (max-width: 860px) {
    .search-btn { min-width: 40px; padding: 0 10px; }
    .search-btn .search-label, .search-btn kbd { display: none; }
}

@media (max-width: 720px) {
    .header-inner { gap: 12px; }
    .js-ready .menu-btn { display: inline-flex; }
    .header-actions { margin-left: auto; }
    .site-nav { margin-left: 0; }
    .js-ready .site-nav {
        position: absolute;
        top: var(--header-h);
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px var(--gutter) 16px;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
    }
    .js-ready .site-nav.is-open { display: flex; }
    .js-ready .site-nav a { padding: 14px 4px; border-radius: 0; font-size: 1.0625rem; color: var(--text); }
    .js-ready .site-nav a + a { border-top: 1px solid var(--border); }
    .js-ready .site-nav a:hover, .js-ready .site-nav a[aria-current="page"] { background: none; }
    .js-ready .site-nav a[aria-current="page"] { font-weight: 600; }
    /* Without JS, the nav sits on its own row under the brand. */
    html:not(.js-ready) .site-header { height: auto; }
    html:not(.js-ready) .header-inner { flex-wrap: wrap; padding-block: 10px; }
    html:not(.js-ready) .site-nav { order: 3; width: 100%; overflow-x: auto; }
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(2, 1fr);
    gap: 32px;
    padding-block: 48px 32px;
}
.footer-about p { margin: 12px 0 0; max-width: 34ch; }
.footer-col h2 {
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: 0;
    margin: 0 0 12px;
    color: var(--text);
}
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-col a, .footer-base a { color: var(--text-muted); text-decoration: none; }
.footer-col a:hover, .footer-base a:hover { color: var(--text); text-decoration: underline; }

.footer-base {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-block: 20px 32px;
    border-top: 1px solid var(--border);
}
.footer-base p { margin: 0; }

.footer-easter { display: none; }
.footer-easter.is-unlocked { display: inline; font-family: var(--font-mono); }

@media (max-width: 720px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-about { grid-column: 1 / -1; }
}

/* Segmented control (theme picker) */
.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
}
.segmented button {
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
    background: var(--text);
    color: var(--bg);
}

/* --------------------------------------------------------------------------
   Buttons, badges, chips
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform var(--dur-1);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: color-mix(in oklab, var(--text) 85%, var(--bg)); color: var(--bg); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--text-faint); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text); padding-inline: 12px; }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* App Store badge, drawn in CSS so it follows the theme */
.store-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 6px 18px 6px 14px;
    border-radius: var(--r-md);
    background: #000;
    color: #fff;
    border: 1px solid #000;
    text-decoration: none;
    line-height: 1.1;
    transition: transform var(--dur-1), opacity var(--dur-1);
}
:root[data-theme="dark"] .store-badge { border-color: #4A4A52; }
.store-badge:hover { color: #fff; opacity: 0.88; }
.store-badge:active { transform: scale(0.98); }
.store-badge svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.store-badge-text { display: flex; flex-direction: column; }
.store-badge-text small { font-size: 0.65rem; font-weight: 500; letter-spacing: 0.01em; }
.store-badge-text span { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.store-badge--soon { background: var(--bg-subtle); color: var(--text-muted); border-color: var(--border-strong); cursor: default; }
.store-badge--soon:hover { color: var(--text-muted); opacity: 1; }
.store-badge--compact { min-height: 40px; padding: 4px 14px 4px 10px; }
.store-badge--compact .store-badge-text span { font-size: 0.95rem; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    line-height: 1.6;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
    white-space: nowrap;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.badge-live { color: var(--live-text); border-color: color-mix(in oklab, var(--live) 35%, transparent); background: color-mix(in oklab, var(--live) 8%, var(--surface)); }
.badge-review { color: var(--soon-text); border-color: color-mix(in oklab, var(--soon) 40%, transparent); background: color-mix(in oklab, var(--soon) 10%, var(--surface)); }
.badge-plain::before { content: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--dur-1), border-color var(--dur-1), background-color var(--dur-1);
}
a.chip:hover, button.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
span.chip { cursor: default; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }

/* --------------------------------------------------------------------------
   Cards & lists
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: clamp(18px, 3vw, 28px);
}

.list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    overflow: hidden;
}
.list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    color: var(--text);
    text-decoration: none;
}
.list-item + .list-item { border-top: 1px solid var(--border); }
a.list-item:hover { background: var(--bg-subtle); color: var(--text); }
.list-icon {
    width: 36px;
    height: 36px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--bg-subtle);
    color: var(--text-muted);
}
.list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-title { font-weight: 600; }
.list-sub { font-size: var(--fs-sm); color: var(--text-muted); }
.list-chevron { color: var(--text-faint); font-size: 1.25rem; }

/* --------------------------------------------------------------------------
   App icon + app cards (home grid)
   -------------------------------------------------------------------------- */
.app-icon {
    display: block;
    flex: none;
    border-radius: var(--icon-radius);
    box-shadow: 0 0 0 1px color-mix(in oklab, var(--text) 8%, transparent), var(--shadow-sm);
    background: var(--bg-subtle);
}

.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 24px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr));
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: border-color var(--dur-2), box-shadow var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.app-card:hover {
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.app-card .app-icon { width: 56px; height: 56px; }
.app-card-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.app-card-name { font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-card-tagline { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.4; }
.app-card .badge { font-size: 0.6875rem; padding: 0 8px; }

.is-filtered-out { display: none !important; }

.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-lg);
}

/* --------------------------------------------------------------------------
   Home
   -------------------------------------------------------------------------- */
.hero { padding-block: clamp(56px, 10vw, 120px) clamp(40px, 6vw, 72px); }
.hero h1 { max-width: 14ch; margin-bottom: 20px; }
.hero .lead { margin-bottom: 32px; }
.hero-icons {
    display: flex;
    margin: 0 0 28px;
    padding: 0;
    list-style: none;
}
.hero-icons { gap: 8px; }
.hero-icons img {
    width: 44px;
    height: 44px;
    border-radius: var(--icon-radius);
    box-shadow: 0 0 0 3px var(--bg);
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 32px;
    margin: 40px 0 0;
    padding: 0;
    list-style: none;
    color: var(--text-muted);
    font-size: var(--fs-sm);
}
.stats strong { display: block; color: var(--text); font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }

.news {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 12px;
}
.news-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
.news-item:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.news-item .app-icon { width: 48px; height: 48px; }
.news-item p { margin: 4px 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.news-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-faint); }
.news-title { font-weight: 600; margin-top: 4px; }
.since-count { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.principles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: 32px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.principles h3 { margin-bottom: 6px; }
.principles p { color: var(--text-muted); margin: 0; }
.principle-glyph { display: block; font-size: 1.5rem; line-height: 1; margin-bottom: 12px; }

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: clamp(24px, 5vw, 64px);
    align-items: start;
}
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   FAQ (details/summary)
   -------------------------------------------------------------------------- */
.faq { border-top: 1px solid var(--border); }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
    content: "";
    flex: none;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-faint);
    border-bottom: 2px solid var(--text-faint);
    transform: translateY(-3px) rotate(45deg);
    transition: transform var(--dur-2) var(--ease-out);
}
.faq details[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.faq summary:hover { color: var(--accent); }
.faq details > :not(summary) { margin: 0 0 18px; color: var(--text-muted); max-width: 68ch; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
label { font-size: var(--fs-sm); font-weight: 600; }
.req { color: var(--danger); }
.optional { color: var(--text-faint); font-weight: 400; }

input[type="text"], input[type="email"], input[type="search"], select, textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
    transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

.success-message { display: none; margin: 0; font-weight: 600; color: var(--live-text); }
.success-message.is-visible { display: block; }
.form-error { display: none; margin: 12px 0 0; color: var(--danger); font-size: var(--fs-sm); }
.form-error.is-visible { display: block; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; max-width: 460px; }
.inline-form input[type="email"] { flex: 1 1 220px; width: auto; }
.inline-form .success-message.is-visible { padding: 12px 0; }

.search-field { position: relative; flex: 1 1 260px; max-width: 360px; }
.search-field svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search-field input { padding-left: 42px; }

/* --------------------------------------------------------------------------
   App catalogue (apps.html)
   -------------------------------------------------------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.toolbar .filters { margin: 0; }

.catalogue { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.catalogue-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 6px 18px;
    align-items: center;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}
.catalogue-row .app-icon { width: 64px; height: 64px; grid-row: span 2; }
.catalogue-main { min-width: 0; }
.catalogue-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; font-size: 1.0625rem; }
.catalogue-name a { color: var(--text); text-decoration: none; }
.catalogue-name a::after { content: ""; position: absolute; inset: 0; }
.catalogue-row { position: relative; }
.catalogue-row:hover .catalogue-name a { text-decoration: underline; }
.catalogue-tagline { margin: 2px 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.catalogue-meta { margin: 6px 0 0; font-size: var(--fs-xs); color: var(--text-faint); }
.catalogue-action { position: relative; z-index: 1; display: flex; gap: 8px; }
.catalogue-cat { font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint); margin: 0; }

@media (max-width: 640px) {
    .catalogue-row { grid-template-columns: 52px minmax(0, 1fr); }
    .catalogue-row .app-icon { width: 52px; height: 52px; }
    .catalogue-action { grid-column: 2; }
}

/* --------------------------------------------------------------------------
   App page
   -------------------------------------------------------------------------- */
.breadcrumb { margin: 0; padding-top: 24px; font-size: var(--fs-sm); color: var(--text-faint); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }

.app-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
    gap: clamp(32px, 6vw, 80px);
    align-items: start;
    padding-block: clamp(28px, 5vw, 56px) clamp(40px, 6vw, 72px);
}
.app-hero-icon { width: 96px; height: 96px; margin-bottom: 24px; }
.app-hero h1 { margin-bottom: 8px; }
.app-hero-tagline { font-size: clamp(1.125rem, 1rem + 0.6vw, 1.375rem); color: var(--text); font-weight: 500; letter-spacing: -0.01em; margin: 0 0 16px; }
.app-hero-hook { color: var(--text-muted); max-width: 52ch; margin-bottom: 28px; }
.app-hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 28px; }
.app-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin: 0;
    padding: 20px 0 0;
    border-top: 1px solid var(--border);
}
.app-facts div { min-width: 0; }
.app-facts dt { font-size: var(--fs-xs); color: var(--text-faint); font-weight: 600; margin-bottom: 4px; }
.app-facts dd { margin: 0; font-size: var(--fs-sm); color: var(--text); }

.app-hero-demo { position: sticky; top: calc(var(--header-h) + 24px); }
.demo-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; font-size: var(--fs-sm); color: var(--text-muted); }
.demo-label strong { color: var(--text); }

@media (max-width: 900px) {
    .app-hero { grid-template-columns: 1fr; }
    .app-hero-demo { position: static; }
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.feature { padding: 24px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.feature-glyph {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 16px;
    border-radius: 12px;
    background: color-mix(in oklab, var(--app-accent) 14%, var(--surface));
    font-size: 1.35rem;
    line-height: 1;
}
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--text-muted); margin: 0; font-size: 0.9375rem; }

.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.check-list li { position: relative; padding-left: 30px; }
.check-list li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0.35em;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: color-mix(in oklab, var(--app-accent) 18%, var(--surface));
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--app-accent) 40%, transparent);
}
.check-list li::after {
    content: "";
    position: absolute;
    left: 8px;
    top: calc(0.35em + 4px);
    width: 5px;
    height: 9px;
    border-right: 2px solid var(--app-accent-ink);
    border-bottom: 2px solid var(--app-accent-ink);
    transform: rotate(45deg);
}

.detail-block + .detail-block { margin-top: 32px; }
.detail-block h3 { font-size: var(--fs-md); margin-bottom: 8px; }
.detail-block p { color: var(--text-muted); }

.cta-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: clamp(20px, 4vw, 32px);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-subtle);
}
.cta-band-app { display: flex; align-items: center; gap: 16px; }
.cta-band-app .app-icon { width: 56px; height: 56px; }
.cta-band h2 { font-size: var(--fs-xl); margin: 0; }
.cta-band p { margin: 2px 0 0; color: var(--text-muted); font-size: var(--fs-sm); }

/* --------------------------------------------------------------------------
   Demo slot base (demos.css extends it)
   -------------------------------------------------------------------------- */
.demo {
    position: relative;
    overflow: hidden;
    width: 100%;
    min-height: 380px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-subtle);
}
/* Once live, let the demo's own content set the height (no inner scroll). */
.demo[data-demo-state="ready"] { aspect-ratio: auto !important; }
.demo[data-demo-state="ready"] > .demo-stage { position: relative; min-height: 380px; }
.demo-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}
.demo-caption { font-size: var(--fs-sm); color: var(--text-faint); margin: 0; }

/* --------------------------------------------------------------------------
   Playground
   -------------------------------------------------------------------------- */
.jump-nav {
    position: sticky;
    top: var(--header-h);
    z-index: 30;
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
}
.jump-nav ul {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 10px 0;
    list-style: none;
    overflow-x: auto;
    scrollbar-width: none;
}
.jump-nav ul::-webkit-scrollbar { display: none; }
.jump-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.jump-nav a:hover { color: var(--text); border-color: var(--border-strong); }
.jump-nav li { flex: none; }
.jump-nav img { width: 24px; height: 24px; flex: none; border-radius: var(--icon-radius); }

.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 40px 24px;
    align-items: start;
}
.demo-card { scroll-margin-top: calc(var(--header-h) + 72px); }
.demo-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.demo-card-head .app-icon { width: 44px; height: 44px; }
.demo-card-head h2 { font-size: var(--fs-lg); margin: 0; letter-spacing: -0.015em; }
.demo-card-head h2 a { color: var(--text); text-decoration: none; }
.demo-card-head h2 a:hover { text-decoration: underline; }
.demo-card-head p { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.demo-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.demo-card-foot a.text-link { font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.demo-card-foot a.text-link:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Prose (privacy, long-form)
   -------------------------------------------------------------------------- */
.prose { max-width: 70ch; }
.prose h2 { margin-top: 2.25em; scroll-margin-top: calc(var(--header-h) + 24px); }
.prose h2:first-child { margin-top: 0; }
.prose > section + section { margin-top: 2.5rem; }
.prose h3 { margin-top: 1.75em; }
.prose p, .prose li { color: var(--text-muted); }
.prose strong { color: var(--text); }
.prose li + li { margin-top: 0.4em; }
.prose table { margin: 1.5em 0; font-size: var(--fs-sm); }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { color: var(--text); }

.doc-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: clamp(32px, 6vw, 80px);
    align-items: start;
}
.toc { position: sticky; top: calc(var(--header-h) + 32px); font-size: var(--fs-sm); }
.toc h2 { font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint); letter-spacing: 0.02em; margin-bottom: 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 1px solid transparent; color: var(--text-muted); text-decoration: none; }
.toc a:hover { color: var(--text); }
.toc a[aria-current="true"] { color: var(--text); border-left-color: var(--text); font-weight: 500; }
@media (max-width: 860px) {
    .doc-layout { grid-template-columns: 1fr; }
    .toc { position: static; }
    .toc ol { display: flex; flex-wrap: wrap; gap: 6px; border: 0; }
    .toc a { padding: 4px 12px; margin: 0; border: 1px solid var(--border); border-radius: var(--r-pill); }
}

.page-head { padding-block: clamp(40px, 7vw, 80px) clamp(24px, 4vw, 40px); }
.page-head h1 { margin-bottom: 12px; }
.page-head .lead { margin: 0; }

/* --------------------------------------------------------------------------
   Search dialog
   -------------------------------------------------------------------------- */
.search-dialog {
    width: min(600px, calc(100vw - 24px));
    max-height: min(560px, calc(100vh - 120px));
    margin: 12vh auto auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.search-dialog[open] { display: flex; flex-direction: column; }
.search-dialog::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.search-form { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 18px; border-bottom: 1px solid var(--border); }
.search-form svg { width: 20px; height: 20px; color: var(--text-faint); flex: none; }
.search-form input {
    flex: 1;
    min-height: 48px;
    border: 0;
    padding: 0;
    background: transparent;
    font-size: 1.0625rem;
    box-shadow: none !important;
}
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.search-results a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    color: var(--text);
    text-decoration: none;
}
.search-results a.is-active, .search-results a:hover { background: var(--bg-subtle); }
.search-results img { width: 32px; height: 32px; border-radius: var(--icon-radius); flex: none; }
.search-results .result-glyph { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--bg-subtle); color: var(--text-muted); flex: none; }
.search-results a.is-active .result-glyph { background: var(--surface); }
.search-results span span { display: block; }
.search-results small { display: block; color: var(--text-muted); font-size: var(--fs-sm); }
.search-group { padding: 8px 12px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint); }
.search-empty { padding: 24px 12px; text-align: center; color: var(--text-muted); }
.search-hint { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-faint); }
@media (max-width: 600px) { .search-hint { display: none; } .search-dialog { margin-top: 12px; } }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in var(--dur-3) var(--ease-out);
}
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--dur-2), transform var(--dur-2); }
.toast-icon { line-height: 1.4; }
.toast-body { flex: 1; min-width: 0; font-size: var(--fs-sm); }
.toast-title { font-weight: 600; }
.toast-text { color: var(--text-muted); }
.toast-action { display: inline-block; margin-top: 4px; font-weight: 600; }
.toast-close { border: 0; background: none; color: var(--text-faint); cursor: pointer; padding: 2px 4px; line-height: 1; }
.toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------------------
   Easter eggs
   -------------------------------------------------------------------------- */
.letter-rain { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.letter-rain span {
    position: absolute;
    top: -10vh;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--neon-1);
    animation: letter-fall var(--ld, 4s) linear forwards;
}
.letter-rain span:nth-child(3n) { color: var(--neon-2); }
.letter-rain span:nth-child(3n + 1) { color: var(--neon-3); }
@keyframes letter-fall {
    from { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    to { transform: translate(var(--lx, 0px), 120vh) rotate(var(--lr, 60deg)); opacity: 0.6; }
}

/* --------------------------------------------------------------------------
   404
   -------------------------------------------------------------------------- */
.not-found { padding-block: clamp(64px, 12vw, 140px); text-align: center; }
.not-found .code { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-faint); margin-bottom: 12px; }
.not-found h1 { margin-inline: auto; }
.not-found .lead { margin: 0 auto 32px; }
.not-found .btn-row { justify-content: center; }

/* --------------------------------------------------------------------------
   Emoji Battle wiki + changelog shell
   -------------------------------------------------------------------------- */
/* The wiki's own look lives in emojiBattle*.css; this only lays out the
   page width and the generic pieces of its hero. */
.wiki-page { max-width: 960px; margin-inline: auto; padding-inline: var(--gutter); padding-bottom: 48px; position: relative; overflow-x: clip; }
.wiki-page > #eb-changelog { padding: clamp(40px, 7vw, 80px) 0 0; }
.wiki-block { margin-top: clamp(32px, 5vw, 56px); }
.wiki-block .section-title { margin-bottom: 16px; }
#eb-dl-sticky { margin-block: 32px; }
.wiki-hero { text-align: center; padding-block: clamp(40px, 7vw, 80px) 24px; }
.wiki-hero .app-hero-icon { margin-inline: auto; }
.wiki-hero .app-hero-tagline { max-width: 40ch; margin-inline: auto; }
.wiki-hero .wiki-hero-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.wiki-hero .app-hero-cta { justify-content: center; }
.wiki-page .ghost-word { display: none; }
.wiki-page .eb-archive-banner a.store-badge { color: #fff; text-decoration: none; margin-top: 12px; }
