/*
 * weeQuesters Worksheets — Design System
 * Cream + Charcoal + Warm Apricot
 * Mobile-first, app-like, BigRock shared-hosting friendly
 * No external CSS dependencies
 * ============================================================
 */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    /* Palette — warm editorial cream */
    --cream-50:  #FBF6EB;
    --cream-100: #F6EEDC;   /* page background */
    --cream-200: #EFE3CB;
    --cream-300: #E5D3B0;
    --paper:     #FDFAF1;   /* card surface */
    --ink:       #14110F;   /* near-black */
    --ink-soft:  #2A2521;
    --ink-light: #5C544D;
    --ink-mute:  #8C857D;
    --line:      #E8DEC8;
    --line-soft: #F0E7D2;

    /* Apricot — primary accent */
    --apricot-50:  #FFF1E6;
    --apricot-100: #FFE0CB;
    --apricot-300: #FFB07A;
    --apricot-500: #FF8A4C;   /* main */
    --apricot-600: #F47233;
    --apricot-700: #D85A1F;

    /* Functional */
    --green:  #2F7D5B;
    --amber:  #B5851A;
    --red:    #C84431;
    --blue:   #2B6CB0;
    --violet: #6B46C1;

    /* Semantic aliases (kept for backward compat) */
    --color-primary: var(--apricot-500);
    --color-primary-dark: var(--apricot-700);
    --color-primary-light: var(--apricot-300);
    --color-primary-50: var(--apricot-50);
    --color-secondary: var(--blue);
    --color-secondary-dark: #1F4F86;
    --color-accent: var(--green);
    --color-accent-dark: #1F5C42;
    --color-bg: var(--cream-100);
    --color-surface: var(--paper);
    --color-surface-alt: var(--cream-200);
    --color-border: var(--line);
    --color-border-light: var(--line-soft);
    --color-text: var(--ink);
    --color-text-secondary: var(--ink-soft);
    --color-text-muted: var(--ink-light);
    --color-success: var(--green);
    --color-warning: var(--amber);
    --color-danger: var(--red);
    --color-info: var(--blue);
    --color-free: var(--green);
    --color-premium: var(--amber);
    --color-purple: var(--violet);

    /* Typography */
    --font-display: 'Fraunces', 'Source Serif Pro', Georgia, serif;
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    'JetBrains Mono', 'Menlo', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4.5rem;

    /* Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-pill: 99rem;

    /* Shadows — soft and warm */
    --shadow-sm: 0 1px 2px rgba(20,17,15,0.06);
    --shadow-md: 0 6px 18px -8px rgba(20,17,15,0.16), 0 2px 4px rgba(20,17,15,0.04);
    --shadow-lg: 0 18px 40px -16px rgba(20,17,15,0.22), 0 4px 12px -2px rgba(20,17,15,0.06);
    --shadow-glow: 0 8px 28px -10px rgba(255,138,76,0.55);
    --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 1px 2px rgba(20,17,15,0.05);

    /* Layout */
    --container-max: 1240px;
    --header-h: 72px;
    --header-h-mobile: 60px;
    --tabbar-h: 64px;

    /* Motion */
    --ease: cubic-bezier(0.32, 0.72, 0, 1);
    --t-fast: 140ms;
    --t-mid:  240ms;
    --t-slow: 420ms;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--cream-100);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle paper-grain texture on the body */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(20,17,15,0.025) 1px, transparent 1px);
    background-size: 4px 4px;
    z-index: 0;
    opacity: 0.6;
}
body > * { position: relative; z-index: 1; }

img, svg, video { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--apricot-700); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--apricot-600); }

::selection { background: var(--apricot-300); color: var(--ink); }

h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -0.015em; color: var(--ink); }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.25rem); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; }

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}
@media(max-width:600px){ .container { padding: 0 1rem; } }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.2;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease), color var(--t-fast) var(--ease);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--apricot-500); outline-offset: 3px; }

.btn-primary {
    background: linear-gradient(180deg, var(--apricot-500), var(--apricot-600));
    color: #fff;
    box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, var(--shadow-glow);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--apricot-500), var(--apricot-700)); color:#fff; }

.btn-dark {
    background: var(--ink);
    color: var(--cream-50);
}
.btn-dark:hover { background: var(--ink-soft); color: var(--cream-50); }

.btn-outline {
    background: transparent;
    border-color: var(--ink);
    color: var(--ink);
}
.btn-outline:hover { background: var(--ink); color: var(--cream-50); }

.btn-ghost {
    background: transparent;
    color: var(--ink);
}
.btn-ghost:hover { background: var(--cream-200); }

.btn-secondary {
    background: var(--cream-200);
    color: var(--ink);
    border-color: var(--line);
}
.btn-secondary:hover { background: var(--cream-300); color: var(--ink); }

.btn-sm  { padding: 0.5rem 0.95rem; font-size: 0.85rem; }
.btn-lg  { padding: 0.95rem 1.65rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }

/* ============================================================
   HEADER / NAV
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(246, 238, 220, 0.85);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.header-inner {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}
@media(max-width:768px){ .header-inner { height: var(--header-h-mobile); } }

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -0.02em;
}
.logo:hover { color: var(--ink); }
.logo-icon {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--ink);
    color: var(--apricot-300);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem;
    font-family: var(--font-body);
    font-weight: 700;
}
.logo span { color: var(--apricot-700); }
.logo-img { height: 36px; max-width: 180px; object-fit: contain; }

.nav-main {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.nav-main a {
    padding: 0.55rem 0.95rem;
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 0.92rem;
    border-radius: var(--radius-pill);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
    text-decoration: none;
}
.nav-main a:hover { background: var(--cream-200); color: var(--ink); }
.nav-main a.active { background: var(--ink); color: var(--cream-50); }

.nav-actions { display: flex; align-items: center; gap: 0.5rem; }

.menu-toggle {
    display: none;
    width: 40px; height: 40px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--line);
    font-size: 1.2rem;
}
.menu-toggle:hover { background: var(--cream-200); }

@media (max-width: 900px) {
    .menu-toggle { display: inline-flex; }
    .nav-main {
        position: fixed;
        top: var(--header-h-mobile);
        left: 0; right: 0;
        background: var(--cream-50);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0.75rem;
        border-bottom: 1px solid var(--line);
        transform: translateY(-110%);
        transition: transform var(--t-mid) var(--ease);
        max-height: calc(100vh - var(--header-h-mobile));
        overflow-y: auto;
    }
    .nav-main.open { transform: translateY(0); }
    .nav-main a { padding: 0.85rem 1rem; border-radius: var(--radius-md); }
    .nav-actions .btn { padding: 0.5rem 0.85rem; font-size: 0.85rem; }
    .nav-actions .btn-outline { display: none; }
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
    padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2rem, 5vw, 4rem);
    position: relative;
    overflow: hidden;
}
.hero-content { max-width: 760px; }
.hero h1 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.05;
    margin-bottom: 1.25rem;
}
.hero h1 .highlight {
    font-style: italic;
    color: var(--apricot-700);
    font-weight: 500;
    position: relative;
    white-space: nowrap;
}
.hero h1 .highlight::after {
    content: '';
    position: absolute;
    left: -2px; right: -2px; bottom: 0.05em;
    height: 0.25em;
    background: var(--apricot-300);
    z-index: -1;
    border-radius: 4px;
    opacity: 0.55;
}
.hero p {
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    color: var(--ink-light);
    max-width: 580px;
    margin-bottom: 2rem;
}
.hero-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 3rem;
}
.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    max-width: 580px;
}
.hero-stat {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
}
.hero-stat h3 {
    font-family: var(--font-display);
    font-size: 1.7rem;
    color: var(--ink);
    margin-bottom: 0.15rem;
    line-height: 1;
}
.hero-stat p {
    font-size: 0.78rem;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
}

/* Hero decorations */
.hero-deco {
    position: absolute;
    width: 380px; height: 380px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--apricot-100), transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.hero-deco-1 { top: -100px; right: -80px; }
.hero-deco-2 { bottom: -120px; left: -100px; width: 320px; height: 320px; opacity: 0.4; }

/* ============================================================
   SECTIONS
   ============================================================ */
.section { padding: clamp(2rem, 5vw, 4rem) 0; }
.section-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.section-header h2 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
}
.section-header h2 .emoji { display: none; }
.section-eyebrow {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--apricot-700);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.5rem;
}

/* ============================================================
   SUBJECT GRID
   ============================================================ */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}
.subject-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    text-align: center;
    text-decoration: none;
    color: var(--ink);
    transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease);
    box-shadow: var(--shadow-card);
}
.subject-card:hover {
    transform: translateY(-3px);
    border-color: var(--apricot-500);
    box-shadow: var(--shadow-md);
    color: var(--ink);
}
.subject-card .icon {
    font-size: 1.9rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}
.subject-card .name {
    font-size: 0.9rem;
    font-weight: 600;
}

/* ============================================================
   WORKSHEET CARDS
   ============================================================ */
.ws-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}
.ws-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease), border-color var(--t-fast) var(--ease);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-card);
}
.ws-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--apricot-300);
}
.ws-card-image {
    aspect-ratio: 4/3;
    background: var(--cream-200);
    overflow: hidden;
    position: relative;
}
.ws-card-image img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform var(--t-slow) var(--ease);
}
.ws-card:hover .ws-card-image img { transform: scale(1.05); }
.ws-card-badge {
    position: absolute;
    top: 0.65rem; left: 0.65rem;
    padding: 0.25rem 0.6rem;
    background: var(--paper);
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}
.ws-card-badge.premium { background: var(--ink); color: var(--apricot-300); }
.ws-card-body {
    padding: 1rem 1.1rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.ws-card-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ink);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.01em;
}
.ws-card-title:hover { color: var(--apricot-700); }
.ws-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.ws-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--cream-200);
    color: var(--ink-soft);
    border-radius: var(--radius-pill);
    text-decoration: none;
}
.ws-tag:hover { background: var(--ink); color: var(--cream-50); }
.ws-card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line-soft);
    font-size: 0.78rem;
    color: var(--ink-mute);
}

/* ============================================================
   WORKSHEET DETAIL PAGE
   ============================================================ */
.ws-detail {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: var(--space-2xl);
    align-items: start;
}
.ws-detail-main { min-width: 0; }

.ws-detail-preview {
    background: var(--cream-200);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ws-detail-preview img {
    width: 100%; height: 100%;
    object-fit: contain;
}
.ws-detail h1 {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3.2vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 1rem;
}
.ws-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.65rem;
    margin: 1.5rem 0 2rem;
}
.ws-meta-item {
    padding: 0.85rem 1rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}
.ws-meta-item .label {
    font-size: 0.7rem;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.2rem;
    font-weight: 600;
}
.ws-meta-item .value {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
}
.value.difficulty-easy { color: var(--green); }
.value.difficulty-medium { color: var(--amber); }
.value.difficulty-hard { color: var(--red); }

/* The sticky download sidebar */
.ws-sidebar {
    position: sticky;
    top: calc(var(--header-h) + 1rem);
}
.ws-sidebar-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}
.ws-sidebar-card .price-tag {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-pill);
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}
.price-tag.free { background: #DCEFE2; color: var(--green); }
.price-tag.premium { background: #F8E9C4; color: var(--amber); }

.share-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.share-btn {
    flex: 1;
    min-width: 80px;
    text-align: center;
    padding: 0.55rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--cream-200);
    color: var(--ink);
    border-radius: var(--radius-pill);
    text-decoration: none;
    transition: background var(--t-fast) var(--ease);
}
.share-btn:hover { background: var(--ink); color: var(--cream-50); }

/* Mobile fixed download bar */
.mobile-download-bar {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--paper);
    border-top: 1px solid var(--line);
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px -8px rgba(20,17,15,0.18);
    z-index: 80;
}
.mobile-download-bar .meta {
    font-size: 0.72rem;
    color: var(--ink-mute);
    margin-bottom: 0.45rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mobile-download-bar .meta strong {
    color: var(--ink);
    font-weight: 600;
    font-size: 0.85rem;
}

@media (max-width: 900px) {
    .ws-detail { grid-template-columns: 1fr; }
    .ws-detail-preview { aspect-ratio: 5/4; }
    .ws-sidebar { position: static; }
}
@media (max-width: 768px) {
    .ws-sidebar-card .download-cta-section { display: none; }
    .mobile-download-bar { display: block; }
    body.has-mobile-download-bar { padding-bottom: 84px; }
    body.has-mobile-tabbar.has-mobile-download-bar { padding-bottom: 152px; }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: var(--space-lg); }
.form-label {
    display: block;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}
.form-control {
    width: 100%;
    padding: 0.7rem 0.95rem;
    font-family: var(--font-body);
    font-size: 0.92rem;
    color: var(--ink);
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-md);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.form-control:focus {
    outline: none;
    border-color: var(--apricot-500);
    box-shadow: 0 0 0 3px var(--apricot-100);
}
.form-control::placeholder { color: var(--ink-mute); font-style: italic; }
textarea.form-control { resize: vertical; min-height: 100px; }

.multiselect-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.45rem;
    padding: 0.65rem;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-md);
    background: var(--paper);
    max-height: 220px;
    overflow-y: auto;
}
.multiselect-grid label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease);
}
.multiselect-grid label:hover { background: var(--cream-200); }
.multiselect-grid input[type="checkbox"] { accent-color: var(--apricot-500); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    border: 1px solid transparent;
    margin-bottom: 1rem;
}
.alert-success { background: #E8F4ED; color: #1F5C42; border-color: #B5DCC2; }
.alert-danger  { background: #FBE7E2; color: #8C2A1A; border-color: #EFC1B5; }
.alert-warning { background: #FBF1D6; color: #6E5208; border-color: #EBD799; }
.alert-info    { background: #E3EEF8; color: #1B4374; border-color: #B7D2E8; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--ink);
    color: var(--cream-200);
    padding: var(--space-3xl) 0 var(--space-lg);
    margin-top: var(--space-3xl);
}
.site-footer .logo, .site-footer .logo:hover { color: var(--cream-50); }
.site-footer .logo span { color: var(--apricot-300); }
.site-footer .logo-icon { background: var(--apricot-500); color: var(--ink); }
.footer-main {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr;
    gap: 2.5rem;
    margin-bottom: 2.5rem;
}
@media(max-width:768px){ .footer-main { grid-template-columns: 1fr 1fr; gap: 1.5rem; } .footer-brand { grid-column: 1 / -1; } }
.footer-brand p {
    margin-top: 1rem;
    color: var(--ink-mute);
    font-size: 0.92rem;
    max-width: 340px;
}
.footer-links h4 {
    color: var(--cream-50);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    font-family: var(--font-body);
    font-weight: 700;
}
.footer-links a {
    display: block;
    color: var(--ink-mute);
    font-size: 0.9rem;
    text-decoration: none;
    padding: 0.25rem 0;
    transition: color var(--t-fast) var(--ease);
}
.footer-links a:hover { color: var(--apricot-300); }
.footer-bottom {
    padding-top: var(--space-lg);
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.82rem;
    color: var(--ink-mute);
}

/* ============================================================
   MOBILE TAB BAR (app-like)
   ============================================================ */
.mobile-tabbar {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    background: rgba(253,250,241,0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--line);
    padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom));
}
.mobile-tabbar-inner {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
}
.mobile-tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0.4rem 0.25rem;
    color: var(--ink-mute);
    font-size: 0.66rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.mobile-tabbar a .ico { font-size: 1.3rem; line-height: 1; }
.mobile-tabbar a.active { color: var(--apricot-700); }
.mobile-tabbar a:active { background: var(--cream-200); }

@media (max-width: 768px) {
    .mobile-tabbar { display: block; }
    body.has-mobile-tabbar { padding-bottom: 76px; }
}

/* ============================================================
   FILTERS (worksheets index page)
   ============================================================ */
.filters-bar {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0 1.25rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.filters-bar::-webkit-scrollbar { display: none; }
.filter-chip {
    flex: 0 0 auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--paper);
    border: 1.5px solid var(--ink);
    color: var(--ink);
    border-radius: var(--radius-pill);
    text-decoration: none;
    scroll-snap-align: start;
    transition: all var(--t-fast) var(--ease);
}
.filter-chip:hover { background: var(--cream-200); color: var(--ink); }
.filter-chip.active { background: var(--ink); color: var(--cream-50); border-color: var(--ink); }

.filter-toggle {
    display: none;
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-pill);
    font-weight: 600;
    margin-bottom: 1rem;
    cursor: pointer;
}
@media(max-width:768px){
    .filter-toggle { display: block; }
    .filters-panel { display: none; }
    .filters-panel.open { display: block; }
}

.filters-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: calc(100vh - 56px);
}
.admin-header {
    background: var(--ink);
    color: var(--cream-50);
    padding: 0 1.25rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
}
.admin-header .logo, .admin-header .logo:hover { color: var(--cream-50); }
.admin-header .logo span { color: var(--apricot-300); }
.admin-sidebar {
    background: var(--paper);
    border-right: 1px solid var(--line);
    padding: 1.25rem 0.75rem;
    overflow-y: auto;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
}
.admin-nav-group { margin-bottom: 1.25rem; }
.admin-nav-group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-mute);
    font-weight: 700;
    padding: 0 0.75rem;
    margin-bottom: 0.4rem;
}
.admin-nav a {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    text-decoration: none;
    margin-bottom: 0.15rem;
    transition: background var(--t-fast) var(--ease);
}
.admin-nav a:hover { background: var(--cream-200); color: var(--ink); }
.admin-nav a.active { background: var(--ink); color: var(--cream-50); }

.admin-content { padding: 1.5rem 1.75rem; min-width: 0; }

.admin-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.admin-page-header h1 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    margin: 0;
}

.chart-card, .data-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1rem;
}

@media(max-width:900px){
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: fixed;
        top: 56px; left: 0; bottom: 0;
        width: 250px;
        z-index: 90;
        transform: translateX(-100%);
        transition: transform var(--t-mid) var(--ease);
        height: auto;
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-content { padding: 1rem; }
}

/* Admin tables */
.admin-table {
    width: 100%;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border-collapse: collapse;
}
.admin-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    background: var(--cream-100);
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    font-weight: 700;
}
.admin-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.9rem;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: var(--cream-100); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeUp 0.6s var(--ease) both; }
.animate-in.delay-1 { animation-delay: 0.08s; }
.animate-in.delay-2 { animation-delay: 0.16s; }
.animate-in.delay-3 { animation-delay: 0.24s; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--cream-100); }
::-webkit-scrollbar-thumb { background: var(--cream-300); border-radius: 99px; border: 2px solid var(--cream-100); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); }

/* ============================================================
   AD SLOTS
   ============================================================
   Ad slots are wrapped in `.container` (see renderAd in functions.php)
   so they automatically respect the page max-width and gutter. This
   block adds slot-specific framing and image constraints. */

/* Outer wrap = self-contained container (max-width + auto margins + gutter)
   so the ad lines up with page content even when not inside a parent .container.
   When nested in a .container (e.g. footer), the inner padding handles itself
   without double-padding because we use 100% width with a max-width cap. */
.ad-slot-wrap {
    width: 100%;
    max-width: var(--container-max);
    margin: 1rem auto 0.5rem;
    padding: 0 var(--space-lg);
    box-sizing: border-box;
}
@media (max-width: 600px) {
    .ad-slot-wrap { padding: 0 1rem; }
}
/* When the ad is already inside a .container (e.g. footer), kill the
   ad-slot-wrap padding so we don't double up with the parent's gutter. */
.container .ad-slot-wrap { padding: 0; }
.ad-slot {
    text-align: center;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    background: var(--cream-50);
    border: 1px solid var(--line-soft);
}
.ad-slot a { display: block; line-height: 0; }
.ad-slot img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Header banner — wide but height-capped so a tall ad image can't push the
   page content far down. object-fit:contain preserves aspect ratio. */
.ad-header img {
    width: 100%;
    max-height: 140px;
    object-fit: contain;
}
@media (max-width: 700px) {
    .ad-header img { max-height: 90px; }
}

/* Footer banner */
.ad-footer img {
    width: 100%;
    max-height: 160px;
    object-fit: contain;
}

/* Inside the dark footer, the ad needs more breathing room than the default
   1rem so it doesn't visually crowd "QUICK LINKS" or the band's top edge. */
.site-footer .ad-slot-wrap {
    margin-top: 0;             /* footer already has 4.5rem of top padding */
    margin-bottom: 2.5rem;     /* clean separation from the column grid below */
}
@media (max-width: 700px) {
    .site-footer .ad-slot-wrap { margin-bottom: 1.75rem; }
}

/* Sidebar/inline ads — typical 300px square or rectangle */
.ad-sidebar {
    margin-bottom: 1.25rem;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}
.ad-sidebar img { max-width: 100%; }

/* "Sponsored" label so users can clearly distinguish ads from content.
   Sits in the top-right of every slot. */
.ad-slot::before {
    content: "Sponsored";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-mute);
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 7px;
    border-radius: 4px;
    z-index: 1;
    pointer-events: none;
}
/* Ads inserted as raw HTML/script (e.g. AdSense) shouldn't get the
   background/border or the badge, since the network controls layout. */
.ad-slot:has(script):not(:has(img)),
.ad-slot:has(iframe):not(:has(img)) {
    background: transparent;
    border: none;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted { color: var(--ink-mute); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-md { margin-top: 1rem; } .mt-lg { margin-top: 1.5rem; } .mt-xl { margin-top: 2rem; }
.flex { display: flex; } .flex-1 { flex: 1; }
.gap-sm { gap: 0.5rem; } .gap-md { gap: 1rem; } .gap-lg { gap: 1.5rem; }
.hidden { display: none !important; }
.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; }

/* Prose / SEO content */
.prose { line-height: 1.7; color: var(--ink-soft); }
.prose h2 { margin-top: 1.75rem; margin-bottom: 0.75rem; font-size: 1.4rem; }
.prose h3 { margin-top: 1.25rem; margin-bottom: 0.5rem; }
.prose p { margin-bottom: 1rem; }
.prose ul, .prose ol { margin: 0.75rem 0 1rem 1.5rem; }
.prose ul li { list-style: disc; }
.prose ol li { list-style: decimal; }
.prose li { margin-bottom: 0.35rem; }
.prose blockquote {
    border-left: 4px solid var(--apricot-500);
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    background: var(--cream-100);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--ink-soft);
    font-style: italic;
}
.prose a { color: var(--apricot-700); text-decoration: underline; }
.prose img { border-radius: var(--radius-md); margin: 1rem 0; }
.prose table { border-collapse: collapse; margin: 1rem 0; width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.5rem 0.75rem; text-align: left; }
.prose th { background: var(--cream-100); font-weight: 700; }
.prose code { background: var(--cream-200); padding: 0.1rem 0.35rem; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; }

/* ============================================================
   STATS / DASHBOARD
   ============================================================ */
.stat-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}
.stat-card .label {
    font-size: 0.75rem;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.stat-card .value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--ink);
    font-weight: 600;
    margin-top: 0.25rem;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--ink-mute);
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.breadcrumb a { color: var(--ink-mute); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { color: var(--ink-mute); opacity: 0.5; }
.breadcrumb .current { color: var(--ink); font-weight: 500; }

/* ============================================================
   IN-HOUSE WYSIWYG EDITOR (used in admin worksheet form)
   ============================================================ */
.ww-editor {
    background: var(--paper);
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-md);
    overflow: visible;          /* was 'hidden'; popovers (button settings, blocks dropdown) need to escape */
    position: relative;         /* anchor for inline popovers */
}
.ww-editor-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.5rem 0;
    background: var(--cream-100);
    border-bottom: 1px solid var(--line);
}
.ww-editor-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    border: none;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease);
}
.ww-editor-tab:hover { background: var(--cream-200); }
.ww-editor-tab.active { background: var(--ink); color: var(--cream-50); }

.ww-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
    background: var(--cream-50);
}
.ww-tb-btn {
    width: 32px; height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ww-tb-btn:hover { background: var(--cream-200); border-color: var(--line); }
.ww-tb-btn.active { background: var(--ink); color: var(--cream-50); }
.ww-tb-btn[data-cmd="bold"] { font-weight: 800; }
.ww-tb-btn[data-cmd="italic"] { font-style: italic; }
.ww-tb-btn[data-cmd="underline"] { text-decoration: underline; }
.ww-tb-divider {
    width: 1px;
    height: 22px;
    background: var(--line);
    margin: 0 4px;
}
.ww-tb-select {
    height: 32px;
    padding: 0 0.6rem;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 120px;
}
.ww-tb-text {
    height: 32px;
    padding: 0 0.7rem;
    background: linear-gradient(180deg, var(--apricot-300), var(--apricot-500));
    color: #fff;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.78rem;
    border: 0;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 0.3rem;
}
.ww-tb-text:hover { filter: brightness(1.05); }

.ww-editor-canvas {
    min-height: 320px;
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
    line-height: 1.7;
    outline: none;
    background: var(--paper);
    color: var(--ink);
    overflow-y: auto;
    max-height: 600px;
}
.ww-editor-canvas:empty::before {
    content: attr(data-placeholder);
    color: var(--ink-mute);
    font-style: italic;
    pointer-events: none;
}
.ww-editor-canvas h1, .ww-editor-canvas h2, .ww-editor-canvas h3 { margin: 0.5em 0 0.3em; }
.ww-editor-canvas p { margin: 0.5em 0; }
.ww-editor-canvas ul, .ww-editor-canvas ol { margin: 0.5em 0 0.5em 1.5em; }
.ww-editor-canvas img { max-width: 100%; border-radius: var(--radius-sm); }
.ww-editor-canvas blockquote { border-left: 3px solid var(--apricot-500); padding-left: 1rem; color: var(--ink-soft); margin: 0.75em 0; }

.ww-editor-source {
    width: 100%;
    min-height: 320px;
    border: 0;
    padding: 1rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--paper);
    color: var(--ink);
    outline: none;
    resize: vertical;
    line-height: 1.6;
    display: block;
}

/* SEO panel tabs (matches screenshot: Content / SEO / AI SEO / Social / Schema) */
.seo-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.seo-tabs::-webkit-scrollbar { display: none; }
.seo-tab {
    flex: 0 0 auto;
    padding: 0.7rem 1.25rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink-soft);
    background: transparent;
    border: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: pointer;
    position: relative;
    bottom: -1px;
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
    border: 1px solid transparent;
    border-bottom: none;
}
.seo-tab:hover { background: var(--cream-200); }
.seo-tab.active {
    background: var(--ink);
    color: var(--cream-50);
    border-color: var(--ink);
}
.seo-tab-content { display: none; }
.seo-tab-content.active { display: block; animation: fadeUp 0.3s var(--ease); }

.seo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media(max-width:768px){ .seo-grid { grid-template-columns: 1fr; } }

.char-count { font-size: 0.72rem; color: var(--ink-mute); text-align: right; margin-top: 0.25rem; }
.char-count.warn { color: var(--amber); }
.char-count.over { color: var(--red); font-weight: 700; }

.seo-tip {
    font-size: 0.78rem;
    color: var(--ink-mute);
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: var(--cream-50);
    border-left: 3px solid var(--apricot-300);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.seo-tip b { color: var(--ink); }

.seo-section-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--apricot-700);
    font-weight: 700;
    margin: 1.5rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--line);
}
.seo-section-title:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* difficulty badges */
.difficulty-easy { color: var(--green); }
.difficulty-medium { color: var(--amber); }
.difficulty-hard { color: var(--red); }

/* Auth pages — clean centered card */
.auth-page {
    min-height: calc(100vh - var(--header-h));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.auth-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 440px;
}
.auth-card h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    margin-bottom: 0.4rem;
}
.auth-card p { color: var(--ink-light); margin-bottom: 1.5rem; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    background: var(--paper);
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--t-fast) var(--ease);
}
.pagination a:hover { background: var(--cream-200); }
.pagination .current { background: var(--ink); color: var(--cream-50); border-color: var(--ink); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--ink-light);
}
.empty-state .emoji { font-size: 3.5rem; margin-bottom: 1rem; line-height: 1; opacity: 0.6; }
.empty-state h3 { font-family: var(--font-display); margin-bottom: 0.5rem; }

/* ==========================================================================
   ADMIN — Worksheet form / SEO tabbed panel additions
   ========================================================================== */
.ws-form { max-width: 960px; }
.ws-form .form-control-lg {
    font-size: 1.1rem;
    padding: 14px 18px;
    font-family: var(--font-display);
    font-weight: 600;
    border-radius: 14px;
}
.ws-form .title-input { margin-bottom: 1.25rem; }
.ws-form .req { color: var(--apricot-600, #d96e2e); font-weight: 700; }
.form-help { color: var(--ink-mute); font-weight: 400; font-size: 0.8rem; }

/* Tab wrap container */
.seo-tabs-wrap {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.seo-tabs-wrap .seo-tabs {
    padding: 10px 14px;
    background: var(--cream-100);
    border-bottom: 1px solid var(--line);
    margin: 0;
    border-radius: 0;
}
.seo-tabs-wrap .seo-tab-content {
    padding: 1.5rem;
}
.seo-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}
@media (max-width: 720px) {
    .seo-grid, .seo-grid-3 { grid-template-columns: 1fr; }
    .seo-tabs-wrap .seo-tab-content { padding: 1rem; }
}

/* Callout box for AI/Schema sections */
.seo-callout {
    background: linear-gradient(135deg, rgba(255,138,76,0.08), rgba(255,176,122,0.04));
    border: 1px solid rgba(255,138,76,0.25);
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 1.25rem;
}
.seo-callout strong {
    display: block;
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--ink);
    margin-bottom: 4px;
}
.seo-callout p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.85rem;
}

/* Premium / Published flag cards */
.status-flags {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 0.75rem;
}
.flag-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.flag-card:has(input:checked) {
    border-color: var(--apricot-500);
    background: rgba(255,138,76,0.06);
    box-shadow: 0 0 0 3px rgba(255,138,76,0.08);
}
.flag-card input { accent-color: var(--apricot-500); flex-shrink: 0; }
.flag-card span { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.flag-card span strong { font-size: 0.85rem; }
.flag-card span small { font-size: 0.72rem; color: var(--ink-mute); }

/* File preview row */
.file-preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 10px;
    font-size: 0.85rem;
    color: #065f46;
    margin-bottom: 8px;
}
.file-preview-row span { flex: 1; word-break: break-all; }
.file-preview-row small { color: var(--ink-mute); }

/* Code-mode textarea */
.form-control.code {
    font-family: 'SF Mono', Monaco, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    background: #1c1917;
    color: #e7e5e4;
    border-color: #292524;
}
.form-control.code:focus {
    border-color: var(--apricot-500);
    box-shadow: 0 0 0 3px rgba(255,138,76,0.2);
}

/* Schema editor toolbar */
.schema-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.schema-validate-msg {
    margin-top: 8px;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 8px;
    display: none;
}
.schema-validate-msg.ok   { display: block; background: #d1fae5; color: #065f46; }
.schema-validate-msg.err  { display: block; background: #fee2e2; color: #991b1b; }
.schema-validate-msg.warn { display: block; background: #fef3c7; color: #92400e; }

/* Form actions bar */
.form-actions-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1.25rem;
    margin-top: 1.5rem;
    border-top: 1px solid var(--line);
}
.form-actions-bar .btn-primary { min-width: 200px; justify-content: center; }

/* Header w/ subtitle */
.admin-page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.admin-page-header h1 { margin: 0; }

/* Multiselect grid (already partially defined elsewhere — ensure consistency) */
.multiselect-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--cream-100);
}
.multiselect-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}
.multiselect-grid label:hover { background: var(--cream-200); }
.multiselect-grid input { accent-color: var(--apricot-500); }

/* SEO admin (per-page) — tabs inside cards */
.seo-page-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.seo-page-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--cream-100);
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}
.seo-page-card-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
}
.seo-page-card-header .badge { font-size: 0.72rem; padding: 3px 10px; border-radius: 999px; background: var(--cream-300); color: var(--ink-soft); }
.seo-page-card-body { padding: 0; }
.seo-page-card-body .seo-tabs { padding: 10px 14px; }
.seo-page-card-body .seo-tab-content { padding: 1.25rem 1.5rem; }
.seo-page-card.collapsed .seo-page-card-body { display: none; }
.seo-page-card-header::after {
    content: "▾";
    transition: transform 0.2s;
    color: var(--ink-mute);
}
.seo-page-card.collapsed .seo-page-card-header::after { transform: rotate(-90deg); }

/* ==========================================================================
   WORKSHEET DETAIL PAGE — additions
   ========================================================================== */

/* Outer section gives extra top breathing room and clears below the sticky header */
.ws-detail-section {
    padding: 1.5rem 0 4rem;
}
@media (min-width: 768px) {
    .ws-detail-section { padding: 2.25rem 0 5rem; }
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: var(--ink-mute);
}
.breadcrumb a { color: var(--ink-soft); text-decoration: none; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--apricot-500); }
.breadcrumb .sep { color: var(--ink-mute); opacity: 0.5; }
.breadcrumb .current { color: var(--ink); font-weight: 500; }

/* Detail preview wrapper — adds rounded corners + hover */
.ws-detail-preview {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: var(--cream-200);
    aspect-ratio: 4 / 3;
    margin-bottom: 1.5rem;
}
.ws-detail-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ws-detail-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    background: var(--ink);
    color: var(--cream-50);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.ws-detail-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    font-weight: 600;
    line-height: 1.15;
    color: var(--ink);
    margin: 0 0 0.6rem;
    letter-spacing: -0.01em;
}
.ws-detail-excerpt {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--ink-soft);
    margin: 0 0 1.5rem;
}

/* AEO summary callout */
.ws-aeo-summary {
    margin: 1.25rem 0 2rem;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(255,138,76,0.08), rgba(255,176,122,0.04));
    border-left: 4px solid var(--apricot-500);
    border-radius: 12px;
}
.ws-aeo-summary-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--apricot-500);
    margin-bottom: 6px;
}
.ws-aeo-summary p {
    margin: 0;
    font-size: 1rem;
    color: var(--ink);
    line-height: 1.55;
}

/* Meta grid is already styled but let's reinforce */
.ws-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin: 1.5rem 0 2rem;
    padding: 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
}
.ws-meta-item .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-mute);
    margin-bottom: 2px;
}
.ws-meta-item .value {
    font-weight: 600;
    color: var(--ink);
    font-size: 0.92rem;
}
.ws-meta-item .value.difficulty-easy   { color: #16a34a; }
.ws-meta-item .value.difficulty-medium { color: #d97706; }
.ws-meta-item .value.difficulty-hard   { color: #dc2626; }

/* Key facts */
.ws-keyfacts { margin: 2rem 0; }
.ws-keyfacts h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    color: var(--ink);
}
.ws-keyfacts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.ws-keyfacts li {
    position: relative;
    padding: 8px 0 8px 28px;
    border-bottom: 1px solid var(--cream-200);
    color: var(--ink);
}
.ws-keyfacts li:last-child { border-bottom: none; }
.ws-keyfacts li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 8px;
    color: var(--apricot-500);
    font-weight: 700;
}

/* FAQ */
.ws-faq { margin: 2rem 0; }
.ws-faq h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    color: var(--ink);
}
.ws-faq details {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: all 0.2s;
}
.ws-faq details[open] {
    border-color: var(--apricot-500);
    box-shadow: 0 4px 16px rgba(255,138,76,0.08);
}
.ws-faq summary {
    padding: 14px 18px;
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ws-faq summary::after {
    content: "+";
    font-size: 1.4rem;
    color: var(--apricot-500);
    font-weight: 300;
    transition: transform 0.2s;
}
.ws-faq details[open] summary::after { transform: rotate(45deg); }
.ws-faq summary::-webkit-details-marker { display: none; }
.ws-faq p {
    margin: 0;
    padding: 0 18px 14px;
    color: var(--ink-soft);
    line-height: 1.6;
}

/* Tags row */
.ws-tags-row { margin: 2rem 0; }
.ws-tags-row h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-mute);
    margin-bottom: 8px;
}
.ws-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-tag {
    padding: 5px 10px;
    background: var(--cream-200);
    color: var(--ink-soft);
    border-radius: 999px;
    font-size: 0.78rem;
    text-decoration: none;
    transition: all 0.15s;
}
.ws-tag:hover {
    background: var(--ink);
    color: var(--cream-50);
}

/* Sidebar — sticky on desktop */
.ws-sidebar {
    align-self: flex-start;
}
@media (min-width: 901px) {
    .ws-sidebar {
        position: sticky;
        top: calc(72px + 1.25rem); /* below sticky header */
    }
}
.ws-sidebar-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}

/* Sidebar pills row above the download CTA */
.ws-sidebar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.ws-sidebar-pill {
    padding: 4px 10px;
    background: var(--cream-200);
    color: var(--ink-soft);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.ws-sidebar-pill.premium { background: #fef3c7; color: #92400e; }
.ws-sidebar-pill.free    { background: #d1fae5; color: #065f46; }

/* Big primary download button */
.ws-download-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.02rem;
    font-weight: 600;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.ws-download-hint {
    text-align: center;
    margin: 10px 0 16px;
    font-size: 0.78rem;
    color: var(--ink-mute);
}

/* Bookmark button in sidebar */
.ws-bookmark {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1rem;
}
.ws-bookmark.active {
    background: rgba(255,138,76,0.08);
    border-color: var(--apricot-500);
    color: var(--apricot-500);
}

/* Share */
.ws-share {
    padding-top: 16px;
    border-top: 1px solid var(--cream-200);
}
.ws-share h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ink-mute);
    margin-bottom: 10px;
}
.ws-share-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.ws-share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--cream-100);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink-soft);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
}
.ws-share-btn:hover {
    background: var(--ink);
    color: var(--cream-50);
    border-color: var(--ink);
    transform: translateY(-1px);
}

/* Related section */
.related-section {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--cream-300);
}
.related-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--ink);
}

/* MOBILE: hide sticky desktop sidebar's download section duplication */
@media (max-width: 900px) {
    /* Mobile shows everything in sidebar still (bookmark, share) but the BIG download button
       is duplicated by the fixed mobile-download-bar — hide the sidebar one to avoid redundancy */
    .ws-sidebar-card .ws-sidebar-meta,
    .ws-sidebar-card .ws-download-btn,
    .ws-sidebar-card .ws-download-hint { display: none; }
    .ws-sidebar-card { padding: 1rem; }
    /* Two-column share grid is fine on mobile */
}

/* MOBILE FIXED DOWNLOAD BAR */
.mobile-download-bar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--paper);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding-bottom: env(safe-area-inset-bottom);
}
.mobile-download-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}
.mobile-download-bar-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.mobile-download-bar-meta strong {
    font-size: 0.88rem;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}
.mobile-download-bar-meta span {
    font-size: 0.72rem;
    color: var(--ink-mute);
}
.mobile-download-btn {
    flex-shrink: 0;
    padding: 10px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
@media (max-width: 768px) {
    .mobile-download-bar { display: block; }
}

/* Body class used to add bottom padding so content isn't covered by mobile bars */
body.has-mobile-download-bar {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
}
@media (min-width: 769px) {
    body.has-mobile-download-bar { padding-bottom: 0; }
}
/* If both download bar and tab bar are shown, stack them: tab bar below, download bar above tab bar */
body.has-mobile-download-bar.has-mobile-tabbar .mobile-download-bar {
    bottom: calc(64px + env(safe-area-inset-bottom));
}
body.has-mobile-download-bar.has-mobile-tabbar {
    padding-bottom: calc(140px + env(safe-area-inset-bottom));
}
@media (min-width: 769px) {
    body.has-mobile-download-bar.has-mobile-tabbar { padding-bottom: 0; }
    body.has-mobile-download-bar.has-mobile-tabbar .mobile-download-bar { bottom: 0; }
}

/* ==========================================================================
   WORKSHEET CARD — alias classes used by existing partial
   ========================================================================== */
.ws-card-image .ws-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    z-index: 2;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.ws-card-image .ws-badge.free    { background: rgba(209,250,229,0.95); color: #065f46; }
.ws-card-image .ws-badge.premium { background: rgba(20,17,15,0.92); color: var(--apricot-300); }

.ws-card-image .ws-bookmark {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.15s, background 0.15s, color 0.15s;
    font-size: 0;            /* hide any stray text content from older builds */
    line-height: 0;
    padding: 0;
    color: var(--ink-soft, #5c544e);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.ws-card-image .ws-bookmark svg { display: block; }
.ws-card-image .ws-bookmark:hover {
    transform: scale(1.08);
    color: #dc2626;          /* preview red on hover */
    background: #fff;
}
/* Active state — filled red heart on white circle */
.ws-card-image .ws-bookmark.active {
    color: #dc2626;
    background: #fff;
}
.ws-card-image .ws-bookmark.active:hover {
    color: #b91c1c;          /* darker red on hover-when-active */
}

.ws-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}
.ws-card-meta .ws-tag {
    padding: 2px 8px;
    background: var(--cream-200);
    color: var(--ink-soft);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
    text-decoration: none;
}
.ws-card-meta .ws-tag.subject { background: rgba(255,138,76,0.12); color: var(--apricot-700, #c95722); }
.ws-card-meta .ws-tag.grade   { background: var(--cream-300); color: var(--ink); }

.ws-card-desc {
    font-size: 0.86rem;
    color: var(--ink-soft);
    line-height: 1.5;
    margin: 6px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ws-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--cream-200);
    font-size: 0.78rem;
    color: var(--ink-mute);
}
.ws-card-footer .difficulty {
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.72rem;
}
.ws-card-footer .difficulty.difficulty-easy   { background: #d1fae5; color: #065f46; }
.ws-card-footer .difficulty.difficulty-medium { background: #fef3c7; color: #92400e; }
.ws-card-footer .difficulty.difficulty-hard   { background: #fee2e2; color: #991b1b; }

.ws-downloads {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
}

/* ==========================================================================
   HOME PAGE — additional sections
   ========================================================================== */
.home-cta {
    padding: 4rem 0;
}
.home-cta-card {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
    padding: 3rem 2rem;
    border-radius: 28px;
    background: linear-gradient(135deg, var(--cream-200), var(--cream-100) 60%, rgba(255,138,76,0.08));
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
}
.home-cta-card::before {
    content: "";
    position: absolute;
    top: -60px;
    right: -60px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,138,76,0.18), transparent 70%);
    z-index: 0;
}
.home-cta-card h2 {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: var(--ink);
    position: relative;
}
.home-cta-card p {
    color: var(--ink-soft);
    margin: 0 0 1.5rem;
    font-size: 1.02rem;
    position: relative;
}
.home-cta-card .btn { position: relative; }

/* ==========================================================================
   WORKSHEET LIST PAGE
   ========================================================================== */
.ws-list-header { padding: 1.5rem 0 0.5rem; }
.ws-list-header h1 {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2rem);
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.ws-list-header p {
    color: var(--ink-mute);
    font-size: 0.92rem;
    margin: 0 0 1.25rem;
}
.ws-list-header strong { color: var(--ink); font-weight: 600; }

.ws-list-search {
    display: flex;
    gap: 8px;
    max-width: 540px;
    margin-bottom: 16px;
}
.ws-list-search .form-control {
    flex: 1;
    border-radius: 999px;
    background: var(--paper);
}
.ws-list-search .btn { border-radius: 999px; padding: 8px 18px; }

/* Empty state */
.ws-list-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--ink-mute);
}
.ws-list-empty .emoji { font-size: 3rem; margin-bottom: 0.75rem; }
.ws-list-empty h3 {
    font-family: var(--font-display);
    margin: 0 0 0.5rem;
    color: var(--ink);
}

/* ============================================================================
   ADMIN UI REBUILD — components missing from earlier pass
   ============================================================================ */

/* Stat cards grid (markup uses .stat-cards plural) */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-cards .stat-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-cards .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(20,17,15,0.08);
}
.stat-cards .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-bottom: 0.25rem;
}
.stat-cards .stat-value {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.1;
    letter-spacing: -0.01em;
}
.stat-cards .stat-label {
    font-size: 0.78rem;
    color: var(--ink-mute);
    font-weight: 500;
}

/* Charts grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.charts-grid .chart-card,
.chart-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 0;
}
.chart-card h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 1rem;
}
.chart-card canvas { max-width: 100%; }

/* Data tables (.data-table) */
.data-table-wrap {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-bottom: 1rem;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table thead th {
    background: var(--cream-100);
    color: var(--ink-soft);
    text-align: left;
    padding: 0.85rem 1rem;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
    color: var(--ink);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--cream-50); }
.data-table a { color: var(--ink); text-decoration: none; }
.data-table a:hover { color: var(--apricot-700); }
.data-table .actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.data-table .actions a, .data-table .actions button {
    color: var(--apricot-700);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    background: transparent;
    border: 0;
    cursor: pointer;
}
.data-table .actions a:hover, .data-table .actions button:hover { background: var(--cream-200); }
.data-table .actions .edit { color: var(--apricot-700); }
.data-table .actions .delete { color: #dc2626; }
.data-table .actions .delete:hover { background: #fee2e2; }
.data-table .data-table-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    display: block;
}
.data-table-row-title { font-weight: 600; color: var(--ink); display: block; line-height: 1.3; }
.data-table-row-sub   { font-size: 0.78rem; color: var(--ink-mute); display: block; margin-top: 2px; }

/* Status pills inside tables */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
}
.status-pill::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.status-pill.published, .status-pill.active, .status-pill.success { background: #d1fae5; color: #065f46; }
.status-pill.published::before, .status-pill.active::before { background: #10b981; }
.status-pill.draft, .status-pill.pending { background: #fef3c7; color: #92400e; }
.status-pill.draft::before, .status-pill.pending::before { background: #f59e0b; }
.status-pill.deleted, .status-pill.error, .status-pill.banned { background: #fee2e2; color: #991b1b; }
.status-pill.deleted::before { background: #ef4444; }
.status-pill.premium { background: #fef3c7; color: #92400e; }
.status-pill.premium::before { background: #f59e0b; }
.status-pill.free { background: #ddd6fe; color: #5b21b6; }
.status-pill.free::before { background: #8b5cf6; }

/* Role pills */
.role-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.role-pill.admin      { background: rgba(255,138,76,0.15); color: var(--apricot-700); }
.role-pill.superadmin { background: var(--ink); color: var(--apricot-300); }
.role-pill.user       { background: var(--cream-200); color: var(--ink-soft); }

/* Search bar at top of admin lists */
.admin-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 1.25rem;
    max-width: 540px;
}
.admin-search-bar .form-control {
    flex: 1;
    border-radius: 999px;
    background: var(--paper);
}
.admin-search-bar .btn { border-radius: 999px; padding: 8px 18px; }

/* Empty state for admin lists */
.admin-empty {
    text-align: center;
    padding: 3.5rem 1rem;
    color: var(--ink-mute);
    background: var(--paper);
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
}
.admin-empty-emoji { font-size: 2.5rem; margin-bottom: 0.5rem; opacity: 0.6; }
.admin-empty h3 { font-family: var(--font-display); color: var(--ink); margin: 0 0 0.5rem; }
.admin-empty p  { margin: 0 0 1rem; }

/* CSV preview table (used in bulk-upload) */
.csv-preview-table-wrap {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: auto;
    margin-bottom: 1rem;
    max-height: 320px;
}
.csv-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-family: 'SF Mono', Monaco, Menlo, Consolas, monospace;
}
.csv-preview-table th {
    background: var(--ink);
    color: var(--cream-50);
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 2;
}
.csv-preview-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.csv-preview-table tr:nth-child(even) td { background: var(--cream-50); }

/* Admin form sections */
.admin-form-section {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-card);
}
.admin-form-section h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--ink);
}
.admin-form-section .section-desc {
    color: var(--ink-mute);
    font-size: 0.85rem;
    margin: 0 0 1.25rem;
}

/* ============================================================
   ADMIN HEADER — fix narrow viewport layout
   ============================================================ */
@media (max-width: 600px) {
    .admin-header {
        padding: 0 0.75rem;
    }
    .admin-header .logo { font-size: 1rem; }
    .admin-header > div { gap: 0.5rem !important; }
    .admin-header a[href*="logout"] { font-size: 0.78rem !important; }
    .admin-header a[href="/"], .admin-header a[href$="/"] { display: none; }
}

/* Mobile admin sidebar — open state shows backdrop */
@media (max-width: 900px) {
    .admin-sidebar.open + .admin-content::before,
    body.admin-sidebar-open::after {
        content: "";
        position: fixed;
        inset: 56px 0 0 250px;
        background: rgba(20,17,15,0.45);
        z-index: 80;
    }
    .admin-header .menu-toggle {
        display: inline-flex !important;
        background: transparent;
        border: 1px solid rgba(255,255,255,0.2);
        color: var(--cream-50);
        padding: 0;
        width: 36px; height: 36px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
    }
}
@media (min-width: 901px) {
    .admin-header .menu-toggle { display: none !important; }
}

/* ============================================================
   PUBLIC HEADER — mobile fixes (image 1 fix)
   ============================================================ */
@media (max-width: 600px) {
    /* Hide secondary CTAs that overflow narrow screens */
    .nav-actions .btn-outline { display: none; }
    .nav-actions .btn { padding: 0.45rem 0.75rem; font-size: 0.78rem; }
    .header-inner {
        /* Keep the natural container padding so the logo and hamburger don't
           sit flush against the screen edges. The previous 0/0 was making the
           header look cramped on small phones. */
        padding-left: 1rem;
        padding-right: 1rem;
        gap: 0.5rem;
    }
    .logo { font-size: 1rem; gap: 0.4rem; }
    .logo-icon { width: 30px; height: 30px; font-size: 0.9rem; }
    .logo-img { height: 30px; max-width: 130px; }
    .menu-toggle { width: 36px; height: 36px; font-size: 1.05rem; }
}

/* ============================================================
   EDITOR TOOLBAR — fix wrapping & label collisions
   ============================================================ */
.ww-editor-toolbar {
    flex-wrap: wrap;
    gap: 4px;
    row-gap: 4px;
}
.ww-editor-toolbar .ww-tb-btn {
    flex-shrink: 0;
    min-height: 32px;
    padding: 0 10px;
    white-space: nowrap;
}
.ww-editor-toolbar .ww-tb-text {
    /* AI buttons — slightly smaller, less dominant */
    font-size: 0.78rem !important;
    padding: 4px 12px !important;
    height: 30px;
    border-radius: 999px !important;
    font-weight: 500 !important;
}
.ww-editor-toolbar .ww-tb-text[data-cmd="ai-post"]    { background: linear-gradient(135deg, #FFD9B8, #FFB07A) !important; color: var(--ink) !important; }
.ww-editor-toolbar .ww-tb-text[data-cmd="ai-rewrite"] { background: linear-gradient(135deg, #FFC9A0, #FF9B5F) !important; color: var(--ink) !important; }
.ww-editor-toolbar .ww-tb-text[data-cmd="ai-image"]   { background: linear-gradient(135deg, #FFE4C4, #FFC288) !important; color: var(--ink) !important; }
.ww-editor-toolbar .ww-tb-text[data-cmd="ai-seo"]     { background: linear-gradient(135deg, #FFEFD5, #FFD2A0) !important; color: var(--ink) !important; }
.ww-editor-toolbar .ww-tb-text:disabled { opacity: 0.5; cursor: not-allowed; }
.ww-editor-toolbar .ww-tb-text.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.ww-editor-toolbar .ww-tb-text.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid var(--ink);
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* AI provider banner above editor */
.ww-ai-status {
    font-size: 0.75rem;
    color: var(--ink-mute);
    padding: 6px 12px;
    background: var(--cream-100);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.ww-ai-status.no-key { background: #fef3c7; color: #92400e; }
.ww-ai-status a { color: inherit; text-decoration: underline; font-weight: 600; }

/* ============================================================
   AI SETTINGS PAGE
   ============================================================ */
.ai-providers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}
.ai-provider {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all 0.15s;
}
.ai-provider.active {
    border-color: var(--apricot-500);
    box-shadow: 0 0 0 3px rgba(255,138,76,0.12);
}
.ai-provider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.ai-provider-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ai-provider-status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}
.ai-provider-status.configured { background: #d1fae5; color: #065f46; }
.ai-provider-status.not-set    { background: var(--cream-200); color: var(--ink-mute); }
.ai-provider-status.selected   { background: var(--apricot-500); color: #fff; }
.ai-provider-desc {
    font-size: 0.82rem;
    color: var(--ink-mute);
    margin: 0 0 0.75rem;
    line-height: 1.5;
}
.ai-provider .form-group { margin-bottom: 0.75rem; }
.ai-provider .form-control {
    font-family: 'SF Mono', Monaco, Menlo, monospace;
    font-size: 0.82rem;
}
.ai-test-result {
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 8px;
    margin-top: 8px;
    display: none;
}
.ai-test-result.show { display: block; }
.ai-test-result.ok  { background: #d1fae5; color: #065f46; }
.ai-test-result.err { background: #fee2e2; color: #991b1b; }

/* Aliases for action cells used in older admin views */
.data-table .table-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.data-table .table-actions a, .data-table .table-actions button {
    color: var(--apricot-700);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    background: transparent;
    border: 0;
    cursor: pointer;
}
.data-table .table-actions a:hover, .data-table .table-actions button:hover { background: var(--cream-200); }
.data-table .table-actions .edit { color: var(--apricot-700); }
.data-table .table-actions .delete { color: #dc2626; }
.data-table .table-actions .delete:hover { background: #fee2e2; }

/* Ads page two-column layout (form + list) */
.ads-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    align-items: start;
}
@media (min-width: 1100px) {
    .ads-layout { grid-template-columns: 460px 1fr; }
}

/* Chart canvas height — needed because charts use maintainAspectRatio:false */
.chart-card canvas {
    width: 100% !important;
    height: 280px !important;
    max-height: 320px;
}
.chart-card canvas[height] { height: 280px !important; }

/* Chart card title row gets a little breathing space below */
.chart-card h3 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Stat icon backgrounds — match new palette */
.stat-cards .stat-icon { background: var(--cream-200); color: var(--ink); }

/* ============================================================================
   PUBLIC HEADER — comprehensive mobile rebuild
   ============================================================================ */

/* Reset everything that was patched piecemeal earlier */
.site-header { width: 100%; overflow: visible; }
/* NOTE: .header-inner also has class .container which provides max-width + centering.
   We deliberately do NOT override width/max-width/padding here so the header
   aligns with the rest of the page content. */
.header-inner {
    position: relative;
}

/* Mobile-first: header is a 3-column flex layout — logo | menu toggle */
@media (max-width: 900px) {
    .header-inner {
        height: 60px;
        gap: 8px;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
    }
    .logo {
        flex: 1 1 auto;
        min-width: 0;          /* allow shrink */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1.05rem;
        gap: 0.4rem;
    }
    .logo-icon {
        width: 32px; height: 32px;
        flex-shrink: 0;
        font-size: 0.9rem;
    }
    .logo-img {
        height: 32px;
        max-width: 140px;
        flex-shrink: 0;
    }
    .menu-toggle {
        flex-shrink: 0;
        width: 40px; height: 40px;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: 1px solid var(--line);
        border-radius: 10px;
        color: var(--ink);
    }
    /* Hide CTA buttons on mobile — they're inside the dropdown menu */
    .nav-actions { display: none !important; }
    /* Mobile menu — drop DOWN from header, not up */
    .nav-main {
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: var(--cream-50);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 1rem 1rem 1.25rem;
        border-bottom: 1px solid var(--line);
        box-shadow: 0 8px 24px rgba(20,17,15,0.08);
        transform: translateY(-12px);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.2s, opacity 0.2s, visibility 0.2s;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        z-index: 95;
    }
    .nav-main.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    .nav-main a {
        padding: 0.85rem 1rem;
        border-radius: 12px;
        font-size: 1rem;
        text-align: left;
    }
    /* Show CTAs inside the dropdown menu instead */
    .nav-main::after {
        content: "";
        display: block;
        height: 1px;
        background: var(--line);
        margin: 0.75rem 0;
    }
}

/* Tighter still on phones */
@media (max-width: 480px) {
    .logo { font-size: 0.95rem; }
    .logo-img { max-width: 110px; }
}

/* Desktop unchanged */
@media (min-width: 901px) {
    .menu-toggle { display: none !important; }
    .nav-main {
        position: static;
        flex-direction: row;
        background: transparent;
        padding: 0;
        border: 0;
        box-shadow: none;
        transform: none;
        opacity: 1;
        visibility: visible;
        max-height: none;
        overflow: visible;
    }
}

/* Mobile menu CTAs — only visible inside the dropdown */
.nav-mobile-cta { display: none; flex-direction: column; gap: 8px; padding-top: 0.75rem; border-top: 1px solid var(--line); margin-top: 0.5rem; }
.nav-mobile-cta .btn-block { width: 100%; justify-content: center; }
@media (max-width: 900px) {
    .nav-mobile-cta { display: flex; }
}

/* ============================================================================
   EDITOR TOOLBAR — fix Link/Image/Video collision
   ============================================================================ */
.ww-editor-toolbar {
    flex-wrap: wrap !important;
    gap: 4px;
    row-gap: 6px;
    align-items: center;
    padding: 6px 8px;
}
.ww-editor-toolbar .ww-tb-btn {
    flex-shrink: 0;
    flex-grow: 0;
    min-width: auto;
    width: auto !important;
    height: 32px;
    padding: 0 10px;
    white-space: nowrap;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.85rem;
}
/* Single-letter format buttons get fixed compact size */
.ww-editor-toolbar .ww-tb-btn[data-cmd="bold"],
.ww-editor-toolbar .ww-tb-btn[data-cmd="italic"],
.ww-editor-toolbar .ww-tb-btn[data-cmd="underline"],
.ww-editor-toolbar .ww-tb-btn[data-cmd="removeFormat"],
.ww-editor-toolbar .ww-tb-btn[data-cmd="unlink"],
.ww-editor-toolbar .ww-tb-btn[data-cmd="insertHorizontalRule"] {
    width: 34px !important;
    padding: 0;
}
.ww-editor-toolbar .ww-tb-divider {
    flex-shrink: 0;
    width: 1px;
    height: 22px;
    background: var(--line);
    margin: 0 4px;
}
.ww-editor-toolbar .ww-tb-select {
    flex-shrink: 0;
    height: 32px;
    padding: 0 8px;
    font-size: 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--paper);
    cursor: pointer;
}
/* AI buttons — same height as others, distinct fill */
.ww-editor-toolbar .ww-tb-text {
    flex-shrink: 0;
    height: 32px !important;
    padding: 0 14px !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    border-radius: 999px !important;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ww-editor-toolbar .ww-tb-text:hover { transform: translateY(-1px); }
.ww-editor-toolbar .ww-tb-text:disabled { opacity: 0.5; cursor: not-allowed; }

/* Mobile: stack rows tighter */
@media (max-width: 600px) {
    .ww-editor-toolbar .ww-tb-btn { font-size: 0.78rem; padding: 0 8px; }
    .ww-editor-toolbar .ww-tb-text { font-size: 0.74rem !important; padding: 0 10px !important; }
}

/* ============================================================================
   DATE RANGE PICKER (dashboard + analytics)
   ============================================================================ */
.date-range-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}
.date-range-presets {
    display: flex;
    gap: 4px;
    background: var(--cream-100);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px;
}
.date-preset {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
    transition: all 0.12s;
}
.date-preset:hover { background: var(--cream-200); color: var(--ink); }
.date-preset.active { background: var(--ink); color: var(--cream-50); }

.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.date-range-inputs .form-control {
    height: 34px;
    padding: 0 10px;
    font-size: 0.85rem;
    width: 140px;
    border-radius: 8px;
}
.date-range-sep {
    color: var(--ink-mute);
    font-size: 0.85rem;
}
.date-range-inputs .btn {
    height: 34px;
    border-radius: 8px;
    padding: 0 14px;
}
@media (max-width: 700px) {
    .date-range-picker { width: 100%; align-items: stretch; }
    .date-range-inputs { width: 100%; }
    .date-range-inputs .form-control { flex: 1; min-width: 0; width: auto; }
}

/* ============================================================================
   HERO MASCOT — Hooty the Owl
   Inline SVG with CSS-driven idle animation, blink, hover wave.
   ============================================================================ */

/* Make hero a 2-column grid on desktop, stack on mobile */
.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
    align-items: center;
}
@media (max-width: 900px) {
    .hero-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .hero-mascot { display: none; }   /* save vertical space on mobile */
}

.hero-mascot {
    position: relative;
    max-width: 360px;
    margin: 0 auto;
    cursor: pointer;
    user-select: none;
}
.mascot-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

/* Body bobs gently up + down — main idle animation */
.mascot-body {
    transform-origin: 140px 280px;
    animation: mascotBob 3.5s ease-in-out infinite;
}
@keyframes mascotBob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-6px) rotate(0.5deg); }
}

/* Tassel / cap subtly sways with body */
.mascot-cap {
    transform-origin: 140px 50px;
    animation: mascotCapSway 3.5s ease-in-out infinite;
}
@keyframes mascotCapSway {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-1.5deg); }
}

/* Eyes blink every 4-5 seconds — each eye scaled vertically to 0 briefly */
.mascot-eye {
    transform-origin: center;
    transform-box: fill-box;
    animation: mascotBlink 4.5s ease-in-out infinite;
}
.mascot-eye.right-eye { animation-delay: 0.05s; }
@keyframes mascotBlink {
    0%, 92%, 100%  { transform: scaleY(1); }
    94%            { transform: scaleY(0.1); }
    96%            { transform: scaleY(1); }
}

/* Floating worksheet papers — each drifts at its own pace */
.mascot-paper {
    transform-origin: center;
    transform-box: fill-box;
}
.paper-1 { animation: paperFloat1 5s ease-in-out infinite; }
.paper-2 { animation: paperFloat2 6s ease-in-out infinite; }
.paper-3 { animation: paperFloat3 4.5s ease-in-out infinite; }
@keyframes paperFloat1 {
    0%, 100% { transform: translate(0, 0)   rotate(-6deg); }
    50%      { transform: translate(2px, -8px) rotate(-2deg); }
}
@keyframes paperFloat2 {
    0%, 100% { transform: translate(0, 0)   rotate(8deg); }
    50%      { transform: translate(-3px, -6px) rotate(4deg); }
}
@keyframes paperFloat3 {
    0%, 100% { transform: translate(0, 0)   rotate(-4deg); }
    50%      { transform: translate(2px, 6px) rotate(-8deg); }
}

/* Wave arm — completely hidden until JS adds .waving class on click */
.mascot-wave-wing {
    visibility: hidden;
    opacity: 0;
    transform-origin: 205px 180px;
    transform-box: fill-box;
}
.hero-mascot.waving .mascot-wave-wing {
    visibility: visible;
    opacity: 1;
    animation: mascotWave 0.55s ease-in-out 3;
}
@keyframes mascotWave {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(-20deg); }
    50%      { transform: rotate(8deg); }
    75%      { transform: rotate(-15deg); }
}

/* Eye-tracking — eyes follow cursor when JS adds .tracking class with --eye-x/y vars */
.hero-mascot.tracking .mascot-eye {
    animation: none;
    transform: translate(calc(var(--eye-x, 0) * 1px), calc(var(--eye-y, 0) * 1px));
    transition: transform 0.15s ease-out;
}

/* Pause everything for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mascot-body, .mascot-cap, .mascot-eye, .mascot-paper {
        animation: none;
    }
}

/* Hero needs some right padding so mascot doesn't crowd the edge */
@media (min-width: 901px) {
    .hero { overflow: visible; }
}

/* ============================================================================
   UPDATER — diff display
   ============================================================================ */
.updater-diff-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 1rem 0 1.25rem;
}
.diff-stat {
    background: var(--cream-100);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    text-align: center;
}
.diff-stat-num {
    display: block;
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1;
}
.diff-stat-label {
    display: block;
    font-size: 0.78rem;
    color: var(--ink-mute);
    margin-top: 4px;
}
.diff-stat.diff-added     { border-color: #86efac; background: rgba(187, 247, 208, 0.25); }
.diff-stat.diff-added .diff-stat-num { color: #15803d; }
.diff-stat.diff-modified  { border-color: #fcd34d; background: rgba(254, 240, 138, 0.3); }
.diff-stat.diff-modified .diff-stat-num { color: #92400e; }
.diff-stat.diff-protected { border-color: var(--line); }
.diff-stat.diff-protected .diff-stat-num { color: var(--ink-mute); }

.updater-diff-details {
    background: var(--cream-50);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: hidden;
}
.updater-diff-details summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    color: var(--ink);
    user-select: none;
}
.updater-diff-details summary::-webkit-details-marker { display: none; }
.updater-diff-details summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.15s;
    color: var(--ink-mute);
}
.updater-diff-details[open] summary::before { transform: rotate(90deg); }
.diff-file-list {
    list-style: none;
    margin: 0;
    padding: 0 16px 12px;
    max-height: 320px;
    overflow-y: auto;
}
.diff-file-list li {
    font-family: 'SF Mono', Monaco, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    padding: 3px 0;
    color: var(--ink-soft);
    border-bottom: 1px dashed var(--line);
}
.diff-file-list li:last-child { border-bottom: 0; }
.diff-marker {
    display: inline-block;
    width: 18px;
    text-align: center;
    font-weight: 700;
    margin-right: 6px;
}
.diff-file-list li.added     .diff-marker { color: #15803d; }
.diff-file-list li.modified  .diff-marker { color: #92400e; }
.diff-file-list li.protected .diff-marker { color: var(--ink-mute); }

/* Mascot click affordance */
.hero-mascot { cursor: pointer; }
.hero-mascot:active .mascot-body { transform: scale(0.98); transition: transform 0.1s; }
/* Subtle hint that mascot is interactive — slight bob speedup on hover */
@media (hover: hover) {
    .hero-mascot:hover .mascot-body { animation-duration: 2s; }
}

/* AI ping diagnostic result panel */
.ai-ping-result { margin-top: 0.75rem; }
.ai-ping-msg {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
}
.ai-ping-msg.ok      { background: #d1fae5; color: #065f46; }
.ai-ping-msg.err     { background: #fee2e2; color: #991b1b; }
.ai-ping-msg.loading { background: var(--cream-200); color: var(--ink); }
.ai-ping-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
    background: var(--cream-50);
    border-radius: 8px;
    overflow: hidden;
}
.ai-ping-table th, .ai-ping-table td {
    text-align: left;
    padding: 6px 12px;
    border-bottom: 1px solid var(--line-soft);
}
.ai-ping-table tr:last-child th, .ai-ping-table tr:last-child td { border-bottom: 0; }
.ai-ping-table th {
    width: 40%;
    color: var(--ink-soft);
    font-weight: 600;
    background: var(--cream-100);
}
.ai-ping-table td { font-family: 'SF Mono', Monaco, monospace; color: var(--ink); }
.ai-ping-table tr.ok td  { color: #065f46; }
.ai-ping-table tr.err td { color: #991b1b; font-weight: 600; }

/* ============================================================================
   AI SETTINGS PAGE — provider cards, key pills, test/fetch UI
   ============================================================================ */

/* Default-text/default-image radio rows */
.ai-defaults-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 700px) {
    .ai-defaults-grid { grid-template-columns: 1fr; }
}
.ai-default-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    background: var(--cream-50);
    font-size: 0.92rem;
}
.ai-default-radio:hover { background: var(--cream-100); }
.ai-default-radio input[type="radio"] { margin: 0; cursor: pointer; }
.ai-default-radio.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: transparent;
}
.ai-default-radio small { color: var(--ink-mute); font-size: 0.78rem; }
.ai-default-radio:has(input:checked) {
    background: var(--apricot-50);
    border-color: var(--apricot-300);
}

/* Provider cards grid */
.ai-providers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 700px) {
    .ai-providers-grid { grid-template-columns: 1fr; }
}

.ai-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    position: relative;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ai-card.is-on {
    border-color: var(--apricot-300);
    box-shadow: 0 1px 0 var(--apricot-100), 0 0 0 3px rgba(255,138,76,0.06);
}
.ai-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.ai-card-head h3 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    color: var(--ink);
}
.ai-card-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
}
.ai-card-toggle input[type="checkbox"] { margin: 0; cursor: pointer; }

.ai-card-desc {
    font-size: 0.85rem;
    color: var(--ink-soft);
    line-height: 1.5;
    margin: 0 0 1rem;
}

/* Saved-key pill row */
.ai-key-stored {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.ai-key-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #d1fae5;
    color: #065f46;
    font-size: 0.78rem;
    font-weight: 600;
}
.ai-key-pill code {
    background: rgba(255,255,255,0.5);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.74rem;
}

/* Action result message (test / fetch) */
.ai-action-result {
    display: none;
    margin: 8px 0 12px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 500;
    line-height: 1.4;
    background: var(--cream-200);
    color: var(--ink);
}
.ai-action-result.show { display: block; }
.ai-action-result.ok   { background: #d1fae5; color: #065f46; }
.ai-action-result.err  { background: #fee2e2; color: #991b1b; }

.ai-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.ai-card-actions .btn { flex: 1 1 auto; min-width: 140px; }

.ai-card-meta {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    color: var(--ink-mute);
}
.ai-card-meta small { font-size: 0.78rem; }

/* ============================================================================
   AI MODAL (used by editor's AI buttons)
   ============================================================================ */
.wq-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(20, 17, 15, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.wq-modal {
    background: var(--paper);
    border-radius: 18px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(20,17,15,0.3);
    animation: modalIn 0.2s ease-out;
}
@keyframes modalIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.wq-modal-head {
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--line);
}
.wq-modal-head h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin: 0 0 4px;
}
.wq-modal-head p { font-size: 0.85rem; color: var(--ink-soft); margin: 0; }

.wq-modal-body { padding: 1rem 1.5rem; }
.wq-modal-body label { display: block; font-size: 0.82rem; font-weight: 600; margin: 0.75rem 0 4px; color: var(--ink); }
.wq-modal-body input,
.wq-modal-body select,
.wq-modal-body textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 0.92rem;
    background: var(--cream-50);
    font-family: inherit;
}
.wq-modal-body textarea { resize: vertical; min-height: 80px; }

.wq-modal-foot {
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.wq-progress {
    margin-top: 1rem;
    padding: 12px;
    background: var(--cream-100);
    border-radius: 10px;
}
.wq-progress-bar {
    height: 6px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 8px;
}
.wq-progress-bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--apricot-400), var(--apricot-500));
    width: 0%;
    transition: width 0.3s;
    animation: progressShimmer 1.5s ease-in-out infinite;
}
@keyframes progressShimmer {
    0%   { width: 10%; }
    50%  { width: 70%; }
    100% { width: 95%; }
}
.wq-progress-status { font-size: 0.82rem; color: var(--ink-soft); }

.wq-modal-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ============================================================================
   UPDATER UPLOAD — progress bar with ETA + speed
   ============================================================================ */
.updater-file-meta {
    margin-top: 6px;
    padding: 6px 10px;
    background: var(--cream-100);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--ink);
    font-family: 'SF Mono', Monaco, Menlo, monospace;
}

.updater-progress {
    background: var(--cream-50);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 16px;
    margin-top: 1rem;
}

.updater-progress-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}
.updater-progress-label {
    font-weight: 600;
    color: var(--ink);
    font-size: 0.92rem;
}
.updater-progress-pct {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--apricot-500);
}

.updater-progress-bar {
    height: 8px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}
.updater-progress-bar > span {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--apricot-400), var(--apricot-500));
    border-radius: 999px;
    transition: width 0.2s ease-out;
}

.updater-progress-meta {
    font-size: 0.78rem;
    color: var(--ink-mute);
    font-family: 'SF Mono', Monaco, Menlo, monospace;
}

/* ============================================================================
   USER DASHBOARD (Overview / Downloads / Bookmarks / Profile)
   Two-column layout with a sticky profile + nav sidebar on the left.
   On mobile (<900px) the sidebar collapses to a horizontal pill nav.
   ============================================================================ */

.dashboard-layout {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--space-xl);
    align-items: start;
}
@media (max-width: 900px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
        padding: var(--space-lg) 1rem;
    }
}

/* ───── Sidebar ───── */
.dashboard-sidebar {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1.25rem 1rem;
    position: sticky;
    top: calc(var(--header-h, 64px) + 16px);
}
@media (max-width: 900px) {
    .dashboard-sidebar {
        position: static;
        padding: 1rem;
    }
}

.dashboard-profile {
    text-align: center;
    padding: 0.5rem 0 1rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1rem;
}
.dashboard-avatar {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--apricot-100), var(--apricot-300));
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.6rem;
    box-shadow: 0 1px 0 rgba(20,17,15,0.05), inset 0 -2px 0 rgba(216,90,31,0.15);
}
.dashboard-profile-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 2px;
    color: var(--ink);
    line-height: 1.2;
    word-break: break-word;
}
.dashboard-profile-meta {
    font-size: 0.78rem;
    color: var(--ink-mute);
    margin: 0;
}

/* Vertical nav, becomes horizontal on mobile */
.dashboard-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dashboard-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink-light);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    line-height: 1.2;
}
.dashboard-nav a:hover {
    background: var(--cream-100);
    color: var(--ink);
}
.dashboard-nav a.active {
    background: var(--ink);
    color: var(--cream-50);
    font-weight: 600;
}
.dashboard-nav a.active .nav-emoji { filter: brightness(1.2); }
.dashboard-nav .nav-emoji {
    display: inline-flex;
    width: 22px;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.dashboard-nav-logout {
    margin-top: 0.5rem;
    padding-top: 0.5rem !important;
    border-top: 1px dashed var(--line);
    border-radius: 10px;
    color: var(--red) !important;
}
.dashboard-nav-logout:hover { background: rgba(200,68,49,0.06) !important; }

/* Mobile: horizontal scrolling nav strip + smaller avatar */
@media (max-width: 900px) {
    .dashboard-profile { padding-bottom: 0.75rem; margin-bottom: 0.75rem; }
    .dashboard-avatar { width: 56px; height: 56px; font-size: 1.4rem; }
    .dashboard-nav {
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 4px;
        margin: 0 -4px;
        scrollbar-width: thin;
    }
    .dashboard-nav a {
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    .dashboard-nav-logout {
        margin-top: 0;
        padding-top: 8px !important;
        border-top: 0;
        border-left: 1px dashed var(--line);
        padding-left: 14px !important;
    }
}

/* ───── Main content area ───── */
.dashboard-content { min-width: 0; }   /* prevents grid overflow on narrow screens */

.dashboard-page-head {
    margin-bottom: 1.5rem;
}
.dashboard-page-head h1 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0 0 4px;
    line-height: 1.2;
    color: var(--ink);
}
.dashboard-page-sub {
    color: var(--ink-soft);
    font-size: 0.92rem;
    margin: 0;
}

/* ───── Stat tiles (overview page) ───── */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.dashboard-stat-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 1.25rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.dashboard-stat-tile:hover {
    transform: translateY(-2px);
    border-color: var(--apricot-300);
    box-shadow: 0 4px 12px rgba(20,17,15,0.06);
}
.dashboard-stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}
.dashboard-stat-body { flex: 1; min-width: 0; }
.dashboard-stat-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1;
    color: var(--ink);
}
.dashboard-stat-label {
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin-top: 4px;
}
.dashboard-stat-arrow {
    font-size: 1.4rem;
    color: var(--ink-mute);
    flex-shrink: 0;
    transition: transform 0.15s;
}
.dashboard-stat-tile:hover .dashboard-stat-arrow {
    transform: translateX(2px);
    color: var(--apricot-500);
}

/* ───── Card pattern ───── */
.dashboard-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.dashboard-card-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}
.dashboard-card-head h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--ink);
}
.dashboard-card-sub {
    font-size: 0.82rem;
    color: var(--ink-soft);
    margin: 4px 0 0;
}
.dashboard-card-link {
    font-size: 0.85rem;
    color: var(--apricot-700);
    text-decoration: none;
    font-weight: 500;
}
.dashboard-card-link:hover { color: var(--apricot-500); }
.dashboard-card-body {
    padding: 1.25rem;
}

/* Inside profile form, body has a max-width so inputs don't stretch absurdly wide */
.dashboard-profile-form .dashboard-card-body { max-width: 560px; }

/* ───── Empty state inside cards ───── */
.dashboard-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--ink-soft);
}
.dashboard-empty-emoji {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    opacity: 0.6;
}
.dashboard-empty h3 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--ink);
    margin: 0 0 6px;
}
.dashboard-empty p {
    margin: 0 0 1.25rem;
    font-size: 0.92rem;
}

/* ───── Pagination row inside dashboard cards ───── */
.dashboard-pagination {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--line);
}

/* ───── Disabled inputs (used on profile read-only fields) ───── */
.dashboard-content .form-control:disabled {
    background: var(--cream-100);
    color: var(--ink-mute);
    cursor: not-allowed;
}

/* ============================================================================
   POPUP TRIGGER ENGINE — front-end visitor popups
   ============================================================================ */

/* Lock body scroll while a full modal is open */
.ww-popup-no-scroll { overflow: hidden; }

/* Common popup envelope — all 4 types share this */
.ww-popup {
    position: fixed;
    z-index: 9990;
    font-family: var(--font-body);
    color: var(--ink);
    pointer-events: none;
}
.ww-popup.ww-popup-shown { pointer-events: auto; }
.ww-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 17, 15, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.25s;
}
.ww-popup-shown .ww-popup-overlay { opacity: 1; }

.ww-popup-card {
    position: relative;
    background: var(--paper);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(20, 17, 15, 0.25);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Modal (center) ─── */
.ww-popup-modal {
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.ww-popup-modal .ww-popup-card {
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}
.ww-popup-modal.ww-popup-shown .ww-popup-card {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Slide-in (corner) ─── */
.ww-popup-slide-in {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 360px;
    max-width: calc(100vw - 2rem);
}
.ww-popup-slide-in .ww-popup-card { transform: translateX(110%); }
.ww-popup-slide-in.ww-popup-shown .ww-popup-card {
    opacity: 1;
    transform: translateX(0);
}
@media (max-width: 600px) {
    .ww-popup-slide-in { left: 1rem; right: 1rem; bottom: 1rem; width: auto; }
}

/* ─── Banners (top/bottom) ─── */
.ww-popup-banner-top, .ww-popup-banner-bottom {
    left: 0;
    right: 0;
    width: 100%;
}
.ww-popup-banner-top { top: 0; }
.ww-popup-banner-bottom { bottom: 0; }
.ww-popup-banner-top .ww-popup-card,
.ww-popup-banner-bottom .ww-popup-card {
    border-radius: 0;
    transform: translateY(-100%);
    box-shadow: 0 4px 16px rgba(20, 17, 15, 0.2);
}
.ww-popup-banner-bottom .ww-popup-card { transform: translateY(100%); }
.ww-popup-banner-top.ww-popup-shown .ww-popup-card,
.ww-popup-banner-bottom.ww-popup-shown .ww-popup-card {
    opacity: 1;
    transform: translateY(0);
}
.ww-popup-banner-top .ww-popup-body,
.ww-popup-banner-bottom .ww-popup-body {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 1.25rem !important;
    max-width: var(--container-max);
    margin: 0 auto;
}
.ww-popup-banner-top .ww-popup-heading,
.ww-popup-banner-bottom .ww-popup-heading {
    margin: 0 !important;
    flex: 1;
    min-width: 200px;
    font-size: 0.95rem !important;
}
.ww-popup-banner-top .ww-popup-message,
.ww-popup-banner-bottom .ww-popup-message {
    margin: 0 !important;
    font-size: 0.85rem !important;
    color: var(--ink-soft);
    flex: 1;
    min-width: 200px;
}

/* ─── Closing animation ─── */
.ww-popup-closing .ww-popup-card { opacity: 0; transform: translateY(20px); }
.ww-popup-closing .ww-popup-overlay { opacity: 0; }

/* ─── Inner content ─── */
.ww-popup-close {
    position: absolute;
    top: 8px; right: 12px;
    background: rgba(255,255,255,0.85);
    border: 0;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--ink-mute);
    display: flex; align-items: center; justify-content: center;
    z-index: 1;
    transition: background 0.15s, color 0.15s;
}
.ww-popup-close:hover { background: var(--cream-200); color: var(--ink); }

.ww-popup-image {
    width: 100%;
    background: var(--cream-100);
    line-height: 0;
}
.ww-popup-image img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
    display: block;
}

.ww-popup-body { padding: 1.5rem 1.5rem 1.25rem; }
.ww-popup-heading {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.2;
    margin: 0 0 0.5rem;
    color: var(--ink);
}
.ww-popup-message {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--ink-soft);
    margin: 0 0 1.25rem;
}

.ww-popup-cta {
    display: inline-block;
    background: var(--apricot-500);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 11px 20px;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    width: 100%;
    transition: background 0.15s, transform 0.15s;
}
.ww-popup-cta:hover { background: var(--apricot-600); transform: translateY(-1px); }
.ww-popup-cta:active { transform: translateY(0); }

.ww-popup-cta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ww-popup-cta-row .ww-popup-cta { flex: 1 1 130px; width: auto; }
.ww-popup-cta-secondary {
    background: var(--cream-200);
    color: var(--ink);
}
.ww-popup-cta-secondary:hover { background: var(--cream-300); }

.ww-popup-form { display: flex; flex-direction: column; gap: 8px; }
.ww-popup-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 0.95rem;
    background: var(--cream-50);
    font-family: inherit;
    color: var(--ink);
    box-sizing: border-box;
}
.ww-popup-input:focus {
    outline: none;
    border-color: var(--apricot-500);
    background: var(--paper);
}
.ww-popup-success {
    background: #d1fae5;
    color: #065f46;
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
}

/* ─── Themes ─── */
.ww-popup-theme-dark .ww-popup-card { background: #1c1917; color: #f5f1e8; }
.ww-popup-theme-dark .ww-popup-heading { color: #f5f1e8; }
.ww-popup-theme-dark .ww-popup-message { color: #d6cfc1; }
.ww-popup-theme-dark .ww-popup-input { background: #2a2521; border-color: #44403c; color: #f5f1e8; }
.ww-popup-theme-dark .ww-popup-cta-secondary { background: #44403c; color: #f5f1e8; }
.ww-popup-theme-dark .ww-popup-cta-secondary:hover { background: #57534e; }
.ww-popup-theme-dark .ww-popup-image { background: #2a2521; }

.ww-popup-theme-light .ww-popup-card { background: #fff; }

.ww-popup-theme-green .ww-popup-cta { background: var(--green); }
.ww-popup-theme-green .ww-popup-cta:hover { background: #1f5c42; }

/* ─── Banner-type body needs CTA to NOT be full-width ─── */
.ww-popup-banner-top .ww-popup-cta,
.ww-popup-banner-bottom .ww-popup-cta {
    width: auto;
    flex-shrink: 0;
}

/* ============================================================================
   POPUP ADMIN — list & edit form
   ============================================================================ */

/* Toggle switch on the list page */
.popup-toggle {
    border: 0;
    background: var(--cream-300);
    width: 40px; height: 22px;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    padding: 0;
    transition: background 0.18s;
}
.popup-toggle.is-on { background: var(--apricot-500); }
.popup-toggle-knob {
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.18s;
}
.popup-toggle.is-on .popup-toggle-knob { transform: translateX(18px); }

/* Edit form layout */
.popup-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem 1.25rem;
}
.popup-form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}
.popup-form-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem 1.25rem;
}
@media (max-width: 600px) {
    .popup-form-grid-2, .popup-form-grid-3 { grid-template-columns: 1fr; }
}

/* Tabs on the edit form */
.popup-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}
.popup-tab {
    padding: 10px 16px;
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.popup-tab:hover { color: var(--ink); }
.popup-tab.is-active {
    color: var(--apricot-700);
    border-bottom-color: var(--apricot-500);
    font-weight: 600;
}
.popup-tab-pane { display: none; }
.popup-tab-pane.is-active { display: block; }

.popup-taxonomy-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.popup-taxonomy-grid details {
    background: var(--cream-50);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
}
.popup-taxonomy-grid summary {
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--ink-soft);
    user-select: none;
}
.popup-taxonomy-grid summary:hover { color: var(--ink); }
.popup-taxonomy-grid details[open] summary { margin-bottom: 8px; }

/* ─── Popup image upload UI on edit form ─── */
.popup-image-preview {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--cream-50);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
}
.popup-image-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--cream-100);
}
.popup-image-meta {
    flex: 1;
    min-width: 0;
}
.popup-image-meta code {
    display: block;
    font-size: 0.78rem;
    color: var(--ink-soft);
    word-break: break-all;
    background: transparent;
    padding: 0;
}
.popup-image-upload {
    margin-bottom: 6px;
}

/* ============================================================================
   MEDIA GALLERY (admin) + IMAGE PICKER MODAL (in editor)
   ============================================================================ */

/* ─── Admin gallery grid ─── */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.media-tile {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.media-tile:hover {
    border-color: var(--apricot-300);
    box-shadow: 0 2px 8px rgba(20,17,15,0.06);
}
.media-tile-img {
    aspect-ratio: 4 / 3;
    background: var(--cream-100);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.media-tile-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.media-tile-meta { padding: 8px 10px; }
.media-tile-name {
    font-size: 0.78rem;
    color: var(--ink);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-tile-info {
    font-size: 0.7rem;
    color: var(--ink-mute);
    margin: 2px 0 6px;
}
.media-tile-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.media-tile-actions .btn {
    flex: 1 1 auto;
    font-size: 0.7rem;
    padding: 4px 6px;
}

/* ─── Drag-drop upload zone ─── */
.media-dropzone {
    position: relative;
    border: 2px dashed var(--apricot-300);
    border-radius: 14px;
    background: var(--cream-50);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.media-dropzone:hover,
.media-dropzone.is-dragover {
    border-color: var(--apricot-500);
    background: var(--apricot-50);
}
.media-dropzone p { margin: 0.5rem 0; }
.media-help { color: var(--ink-mute); font-size: 0.82rem; }
.media-upload-status {
    margin-top: 0.75rem;
    padding: 8px 12px;
    background: var(--cream-100);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--ink);
}

/* ─── Image picker modal (in editor) ─── */
.img-picker-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 1.5rem;
    background: var(--cream-50);
}
.img-picker-tab {
    padding: 12px 18px;
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.img-picker-tab:hover { color: var(--ink); }
.img-picker-tab.is-active {
    color: var(--apricot-700);
    border-bottom-color: var(--apricot-500);
    font-weight: 600;
}
.img-picker-pane {
    display: none;
    padding: 1.25rem 1.5rem;
}
.img-picker-pane.is-active { display: block; }

.img-picker-dropzone {
    display: block;
    position: relative;
    border: 2px dashed var(--apricot-300);
    border-radius: 14px;
    background: var(--cream-50);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.img-picker-dropzone:hover {
    border-color: var(--apricot-500);
    background: var(--apricot-50);
}
.img-picker-dropzone p { margin: 0.5rem 0 0; }

.img-picker-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.5rem;
    max-height: 380px;
    overflow-y: auto;
    padding: 4px;
    background: var(--cream-50);
    border-radius: 10px;
}
.img-picker-tile {
    background: var(--paper);
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.12s, transform 0.12s;
}
.img-picker-tile:hover {
    border-color: var(--apricot-500);
    transform: translateY(-1px);
}
.img-picker-tile img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}
.img-picker-tile-name {
    font-size: 0.7rem;
    padding: 4px 6px;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--cream-50);
}

/* ============================================================================
   EDITOR — Blocks dropdown menu
   ============================================================================ */
.ww-tb-blocks { position: relative; }
.ww-tb-blocks-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(20,17,15,0.12);
    min-width: 240px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.ww-tb-blocks-menu[hidden] { display: none; }
.ww-tb-blocks-menu button {
    display: grid;
    grid-template-columns: 30px 1fr;
    align-items: center;
    gap: 0 10px;
    padding: 8px 10px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--ink);
    transition: background 0.12s;
}
.ww-tb-blocks-menu button:hover { background: var(--cream-100); }
.ww-tb-blocks-menu button > span {
    grid-column: 2;
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.2;
}
.ww-tb-blocks-menu button > small {
    grid-column: 2;
    color: var(--ink-mute);
    font-size: 0.74rem;
    line-height: 1.2;
}
.ww-tb-blocks-menu button:first-child { font-size: 1.1rem; grid-row: span 2; }

/* ============================================================================
   CONTENT BLOCKS — used in editor canvas AND on public-facing pages
   ============================================================================ */

/* Block: Button — alignment + size are controlled by modifier classes
   added to the wrap (.ww-align-*) and the anchor (.ww-size-*).
   The same classes work in the editor canvas AND on the public site. */
.ww-block-button-wrap {
    margin: 1.5rem 0;
    text-align: center;       /* default if no .ww-align-* class is set */
}
.ww-block-button-wrap.ww-align-left   { text-align: left; }
.ww-block-button-wrap.ww-align-center { text-align: center; }
.ww-block-button-wrap.ww-align-right  { text-align: right; }

.ww-block-button {
    display: inline-block;
    background: var(--apricot-500);
    color: #fff !important;
    border-radius: 999px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.15s, transform 0.15s;
    box-sizing: border-box;
    line-height: 1.3;

    /* Default size — overridden by .ww-size-* classes below */
    padding: 12px 28px;
    font-size: 1rem;
}
.ww-block-button:hover {
    background: var(--apricot-600);
    transform: translateY(-1px);
}

/* Size variants */
.ww-block-button.ww-size-sm   { padding: 8px 18px;  font-size: 0.85rem; }
.ww-block-button.ww-size-md   { padding: 12px 28px; font-size: 1rem; }
.ww-block-button.ww-size-lg   { padding: 14px 36px; font-size: 1.1rem; }
.ww-block-button.ww-size-full {
    display: block;            /* needs to be block to span full width */
    width: 100%;
    padding: 14px 28px;
    font-size: 1rem;
    text-align: center;        /* keep label centered when stretched */
}
/* When the button is full-width the wrap's text-align becomes irrelevant —
   make sure no horizontal margin offsets the centering. */
.ww-block-button-wrap:has(.ww-size-full) { text-align: center; }

/* ─── Inline popover that appears when a button is clicked in the editor ─── */
.ww-block-button-popover {
    position: absolute;
    z-index: 50;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(20, 17, 15, 0.15);
    padding: 10px 12px;
    min-width: 280px;
    font-size: 0.85rem;
    user-select: none;
}
.ww-bbp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}
.ww-bbp-row + .ww-bbp-row {
    border-top: 1px solid var(--line-soft);
    margin-top: 4px;
    padding-top: 8px;
}
.ww-bbp-label {
    width: 56px;
    flex-shrink: 0;
    font-weight: 600;
    color: var(--ink-soft);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ww-bbp-group {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--cream-50);
}
.ww-bbp-group button {
    background: transparent;
    border: 0;
    border-right: 1px solid var(--line);
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--ink-soft);
    min-width: 36px;
    transition: background 0.12s, color 0.12s;
}
.ww-bbp-group button:last-child { border-right: 0; }
.ww-bbp-group button:hover {
    background: var(--cream-200);
    color: var(--ink);
}
.ww-bbp-group button.is-active {
    background: var(--apricot-500);
    color: #fff;
    font-weight: 600;
}
.ww-bbp-url {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--cream-50);
    font-family: inherit;
    color: var(--ink);
    min-width: 0;
}
.ww-bbp-url:focus {
    outline: none;
    border-color: var(--apricot-500);
    background: var(--paper);
}

/* Block: Table */
.ww-block-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: var(--paper);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 0 var(--line);
}
.ww-block-table th,
.ww-block-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.ww-block-table thead th {
    background: var(--cream-100);
    font-weight: 600;
    color: var(--ink);
    font-size: 0.92rem;
    border-bottom: 2px solid var(--line);
}
.ww-block-table tbody tr:last-child td { border-bottom: 0; }
.ww-block-table tbody tr:hover { background: var(--cream-50); }
@media (max-width: 600px) {
    .ww-block-table { font-size: 0.88rem; }
    .ww-block-table th, .ww-block-table td { padding: 8px 10px; }
}

/* Block: Container */
.ww-block-container {
    background: var(--cream-100);
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    margin: 1.5rem 0;
}
.ww-block-container > *:first-child { margin-top: 0; }
.ww-block-container > *:last-child  { margin-bottom: 0; }
.ww-block-container h3,
.ww-block-container h4 {
    color: var(--ink);
    margin-top: 0;
}

/* Block: Accordion */
.ww-block-accordion {
    margin: 1.5rem 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.ww-block-accordion-item {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.ww-block-accordion-item:last-child { border-bottom: 0; }
.ww-block-accordion-item-head {
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
    color: var(--ink);
    transition: background 0.12s;
}
.ww-block-accordion-item-head:hover { background: var(--cream-50); }
.ww-block-accordion-item-q { flex: 1; }
.ww-block-accordion-item-icon {
    font-size: 1.4rem;
    line-height: 1;
    color: var(--apricot-500);
    font-weight: 400;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.ww-block-accordion-item.is-open .ww-block-accordion-item-icon {
    transform: rotate(45deg);
}
.ww-block-accordion-item-body {
    padding: 0 18px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
}
.ww-block-accordion-item.is-open .ww-block-accordion-item-body {
    padding: 0 18px 16px;
    max-height: 1000px;
}
.ww-block-accordion-item-body > *:first-child { margin-top: 0; }
.ww-block-accordion-item-body > *:last-child  { margin-bottom: 0; }

/* Block: Columns (2-col, stacks on mobile) */
.ww-block-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0;
}
@media (max-width: 700px) {
    .ww-block-columns { grid-template-columns: 1fr; gap: 1rem; }
}
.ww-block-column { min-width: 0; }
.ww-block-column > *:first-child { margin-top: 0; }
.ww-block-column > *:last-child  { margin-bottom: 0; }

/* Block: Callout */
.ww-block-callout {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--apricot-50);
    border-left: 4px solid var(--apricot-500);
    border-radius: 0 14px 14px 0;
    padding: 14px 18px;
    margin: 1.5rem 0;
}
.ww-block-callout-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1.2;
}
.ww-block-callout-body { flex: 1; min-width: 0; }
.ww-block-callout-body > *:first-child { margin-top: 0; }
.ww-block-callout-body > *:last-child  { margin-bottom: 0; }
.ww-block-callout-body strong {
    display: block;
    font-weight: 600;
    color: var(--apricot-800);
    margin-bottom: 4px;
}

/* Block: Divider (decorative — not a plain <hr>) */
.ww-block-divider {
    text-align: center;
    margin: 2rem 0;
    line-height: 0;
}
.ww-block-divider span {
    display: inline-block;
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--apricot-300), transparent);
    border-radius: 2px;
}

/* Inside the editor canvas, blocks should still be hover-selectable.
   Add a subtle outline on hover so the admin can tell where blocks start/end. */
.ww-editor-canvas .ww-block-button-wrap:hover,
.ww-editor-canvas .ww-block-table:hover,
.ww-editor-canvas .ww-block-container:hover,
.ww-editor-canvas .ww-block-accordion:hover,
.ww-editor-canvas .ww-block-columns:hover,
.ww-editor-canvas .ww-block-callout:hover {
    outline: 2px dashed var(--apricot-300);
    outline-offset: 4px;
}

/* ============================================================================
   HEADER NAVIGATION — Nested submenus
   ============================================================================
   Triggered when a top-level item has a `children` array. The parent renders
   inside a .nav-has-submenu wrapper, with its <a> showing a chevron and a
   .nav-submenu dropdown that appears on hover (desktop) or tap (mobile).
*/
.nav-has-submenu {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.nav-has-submenu .nav-parent {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.nav-caret {
    font-size: 0.7rem;
    transition: transform 0.15s;
    color: var(--ink-mute);
}
.nav-has-submenu:hover .nav-caret,
.nav-has-submenu:focus-within .nav-caret {
    transform: rotate(180deg);
    color: var(--apricot-500);
}

.nav-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(20, 17, 15, 0.12);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    /* Hidden until parent is hovered or focused. transform + opacity for animation. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    z-index: 200;
}
.nav-has-submenu:hover .nav-submenu,
.nav-has-submenu:focus-within .nav-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
/* Bridge the small gap between parent and submenu so the hover doesn't drop */
.nav-submenu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.nav-submenu a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.nav-submenu a:hover { background: var(--cream-100); color: var(--apricot-700); }
.nav-submenu a.active { background: var(--apricot-50); color: var(--apricot-700); font-weight: 600; }

/* Mobile: when nav opens as a vertical list, submenu becomes a nested
   indented list rather than a floating dropdown. */
@media (max-width: 768px) {
    .nav-has-submenu { display: block; width: 100%; }
    .nav-submenu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: 0;
        border-left: 2px dashed var(--apricot-200);
        border-radius: 0;
        margin: 4px 0 4px 16px;
        padding: 4px 0 4px 12px;
        background: transparent;
        min-width: 0;
    }
    .nav-submenu::before { display: none; }
    .nav-caret { display: none; }
}

/* ============================================================================
   HEADER NAVIGATION — Mega menu (multiple groups per parent)
   ============================================================================
   When a parent has `groups`, the .nav-submenu becomes a multi-column panel.
   Each .nav-mega-col holds one group: optional heading + a list of links.
*/
.nav-submenu.nav-mega {
    display: grid;
    /* default to 1 col; data-cols on the wrapper overrides */
    grid-template-columns: 1fr;
    gap: 0;
    padding: 14px;
    min-width: 240px;
}
.nav-has-submenu[data-cols="2"] .nav-mega { grid-template-columns: repeat(2, minmax(180px, 1fr)); min-width: 420px; }
.nav-has-submenu[data-cols="3"] .nav-mega { grid-template-columns: repeat(3, minmax(180px, 1fr)); min-width: 600px; }
.nav-has-submenu[data-cols="4"] .nav-mega { grid-template-columns: repeat(4, minmax(170px, 1fr)); min-width: 760px; }

/* Position multi-column menus from the right edge if they'd overflow.
   Most nav items sit on the left side of the bar — center-align the dropdown
   so it doesn't hang off the right of the screen for items further right. */
.nav-has-submenu[data-cols="3"] .nav-mega,
.nav-has-submenu[data-cols="4"] .nav-mega {
    left: 50%;
    transform: translate(-50%, -4px);
}
.nav-has-submenu[data-cols="3"]:hover .nav-mega,
.nav-has-submenu[data-cols="3"]:focus-within .nav-mega,
.nav-has-submenu[data-cols="4"]:hover .nav-mega,
.nav-has-submenu[data-cols="4"]:focus-within .nav-mega {
    transform: translate(-50%, 0);
}

.nav-mega-col {
    padding: 0 6px;
    display: flex;
    flex-direction: column;
}
.nav-mega-col + .nav-mega-col {
    border-left: 1px solid var(--line-soft);
}
.nav-mega-heading {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-mute);
    padding: 4px 8px 6px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--line-soft);
}
.nav-mega-list {
    list-style: none;
    margin: 0;
    padding: 4px 0 0;
}
.nav-mega-list li { margin: 0; }
/* Override the generic .nav-submenu a rules for items inside the mega menu —
   the existing rules already cover hover/active styling. We just need to
   un-stretch them and reset margins. */
.nav-mega-list a { padding: 7px 10px; }

/* Mobile: collapse mega menu into a stacked indented list (one column) */
@media (max-width: 768px) {
    .nav-submenu.nav-mega,
    .nav-has-submenu[data-cols="2"] .nav-mega,
    .nav-has-submenu[data-cols="3"] .nav-mega,
    .nav-has-submenu[data-cols="4"] .nav-mega {
        grid-template-columns: 1fr !important;
        min-width: 0 !important;
        padding: 4px 0;
        left: 0;
        transform: none !important;
    }
    .nav-mega-col + .nav-mega-col {
        border-left: 0;
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px solid var(--line-soft);
    }
}

/* ============================================================================
   FOOTER NAVIGATION — Group sub-headings within a column
   ============================================================================ */
.footer-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--apricot-300);
    margin-top: 0.85rem;
    margin-bottom: 0.25rem;
}
.footer-links a.footer-sub-link {
    padding-left: 0.75rem;
    font-size: 0.86rem;
    opacity: 0.92;
}

/* Logo invert — applied to footer image when admin enables the toggle.
   `brightness(0)` collapses any colour to black, then `invert(1)` flips to white.
   Net effect: any logo (any colour, transparent or solid bg) renders pure white.
   Only useful on dark backgrounds — designed for the footer context. */
.logo-img.ww-logo-invert {
    filter: brightness(0) invert(1);
}

/* ============================================================================
   SISTER SITES — "More from weeQuesters" cross-promo strip
   ============================================================================
   Renders just above the dark footer. Treated as a distinct band — a tinted
   apricot-cream background with hairline top/bottom borders and an emoji-card
   layout that stays compact (no oversized empty hero areas).
*/
.sister-sites {
    background: var(--apricot-50);
    border-top: 1px solid color-mix(in srgb, var(--apricot-500) 18%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--apricot-500) 18%, transparent);
    padding: 2rem 0 2.25rem;
    margin-top: 2.5rem;
    position: relative;
}
/* Tiny top accent band so the section feels framed */
.sister-sites::before {
    content: '';
    position: absolute;
    top: -1px; left: 50%;
    transform: translateX(-50%);
    width: 64px; height: 3px;
    background: var(--apricot-500);
    border-radius: 0 0 4px 4px;
}
.sister-sites-head {
    text-align: center;
    margin-bottom: 1.25rem;
}
.sister-sites-head h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.25rem, 2.4vw, 1.6rem);
    color: var(--ink);
    margin: 0 0 0.25rem;
    line-height: 1.15;
}
.sister-sites-head p {
    color: var(--ink-soft);
    font-size: 0.9rem;
    margin: 0;
}

/* Card track */
.sister-sites-track {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

/* Each card — switched from vertical media-card to a horizontal compact card.
   Image/emoji on the left, text on the right. Height stays predictable. */
.sister-card {
    --site-accent: var(--apricot-500);
    display: flex;
    align-items: stretch;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: var(--ink);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    position: relative;
    min-height: 88px;
}
.sister-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 3px;
    background: var(--site-accent);
    opacity: 0;
    transition: opacity 0.18s;
}
.sister-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(20, 17, 15, 0.08);
    border-color: var(--site-accent);
}
.sister-card:hover::before { opacity: 1; }

/* Media area — fixed-width square thumbnail on the left */
.sister-card-media {
    flex: 0 0 88px;
    width: 88px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--site-accent) 14%, transparent), color-mix(in srgb, var(--site-accent) 4%, transparent));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.sister-card-media img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}
.sister-card:hover .sister-card-media img { transform: scale(1.05); }
.sister-card-emoji {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(20,17,15,0.08));
}

/* Body */
.sister-card-body {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.sister-card-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--ink);
    line-height: 1.2;
}
.sister-card-tagline {
    color: var(--ink-soft);
    font-size: 0.82rem;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.sister-card-cta {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--site-accent);
}
.sister-card-arrow {
    transition: transform 0.18s ease;
    display: inline-block;
}
.sister-card:hover .sister-card-arrow { transform: translateX(3px); }

/* Mobile: keep horizontal-card layout but allow a swipe rail for many sites */
@media (max-width: 700px) {
    .sister-sites { padding: 1.5rem 0 1.75rem; margin-top: 2rem; }
    .sister-sites-track {
        grid-template-columns: none;
        display: flex;
        gap: 10px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        margin: 0 -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .sister-card {
        flex: 0 0 86%;
        scroll-snap-align: start;
        min-height: 80px;
    }
    .sister-card-media { flex: 0 0 76px; width: 76px; }
    .sister-sites-track::-webkit-scrollbar { height: 5px; }
    .sister-sites-track::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
}

@media (prefers-reduced-motion: reduce) {
    .sister-card,
    .sister-card-media img,
    .sister-card-arrow { transition: none; }
    .sister-card:hover { transform: none; }
}

/* Sister site card — icon variant (curated SVG icon, accepts site accent colour) */
.sister-card-icon {
    width: 40px; height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 2px rgba(20,17,15,0.08));
}
.sister-card-icon svg {
    width: 100%;
    height: 100%;
}

/* ============================================================================
   TOAST NOTIFICATIONS — non-blocking user feedback (downloads, saves, etc.)
   ============================================================================
   Anchored to the bottom-right on desktop, bottom-center on mobile. Multiple
   toasts stack vertically with a small gap. Auto-dismiss with manual close X.
*/
.ww-toast-stack {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;       /* container is click-through; individual toasts re-enable */
    max-width: min(380px, calc(100vw - 2rem));
}
.ww-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 12px 12px;
    background: var(--paper, #fff);
    border: 1px solid var(--line, #e5d9c1);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(20, 17, 15, 0.16), 0 2px 6px rgba(20, 17, 15, 0.08);
    pointer-events: auto;
    font-size: 0.92rem;
    color: var(--ink, #14110F);
    line-height: 1.35;
    /* Slide-in animation */
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ww-toast.ww-toast-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.ww-toast.ww-toast-out {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition-duration: 0.16s;
}
.ww-toast-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
    color: #fff;
}
.ww-toast-msg {
    flex: 1;
    min-width: 0;
}
.ww-toast-close {
    background: transparent;
    border: 0;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--ink-mute, #8a807a);
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.12s, background 0.12s;
}
.ww-toast-close:hover {
    color: var(--ink, #14110F);
    background: var(--cream-100, #f0e8d4);
}

/* Type-specific accent colours on the icon disc */
.ww-toast-success .ww-toast-icon { background: #16a34a; }
.ww-toast-error   .ww-toast-icon { background: #dc2626; }
.ww-toast-info    .ww-toast-icon { background: var(--apricot-500, #FF8A4C); }
.ww-toast-warning .ww-toast-icon { background: #d97706; }

/* Reduced motion — skip the slide */
@media (prefers-reduced-motion: reduce) {
    .ww-toast {
        transition: opacity 0.15s linear;
        transform: none !important;
    }
}

/* Mobile — bottom-centered, full-width minus margins */
@media (max-width: 600px) {
    .ww-toast-stack {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
        max-width: none;
        align-items: stretch;
    }
}

/* ============================================================================
   HEADER SEARCH — magnifying-glass button + slide-down overlay
   ============================================================================ */

/* Trigger button — sits in nav-actions before the auth CTAs */
.header-search-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: 1.5px solid var(--line, #e5d9c1);
    color: var(--ink-soft, #5c544e);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.header-search-btn:hover {
    border-color: var(--apricot-500, #FF8A4C);
    color: var(--apricot-600, #d96a2c);
    background: var(--apricot-50, rgba(255,138,76,0.08));
}

/* Overlay — fixed full-width sheet that slides down below the sticky header.
   Backdrop dims the page slightly so the search input draws focus. */
.header-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;          /* above sticky header (z-index:100), below toasts (9500) */
    background: rgba(20, 17, 15, 0.35);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.25rem 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}
.header-search-overlay[hidden] { display: none; }
.header-search-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.header-search-panel {
    width: min(720px, 100%);
    background: var(--paper, #fff);
    border: 1px solid var(--line, #e5d9c1);
    border-radius: 18px;
    box-shadow: 0 24px 48px rgba(20, 17, 15, 0.18);
    padding: 16px;
    transform: translateY(-12px);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s;
}
.header-search-overlay.is-open .header-search-panel {
    transform: translateY(0);
    opacity: 1;
}

.header-search-form {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--cream-50, #faf6ed);
    border: 1.5px solid var(--line, #e5d9c1);
    border-radius: 999px;
    padding: 6px 8px 6px 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.header-search-form:focus-within {
    border-color: var(--apricot-500, #FF8A4C);
    box-shadow: 0 0 0 3px rgba(255, 138, 76, 0.12);
}
.header-search-form-icon {
    color: var(--ink-mute, #8a807a);
    flex-shrink: 0;
}
.header-search-input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 10px 4px;
    font-size: 1rem;
    color: var(--ink, #14110F);
    min-width: 0;       /* let it shrink inside flex */
    outline: none;
    font-family: inherit;
}
.header-search-input::placeholder {
    color: var(--ink-mute, #8a807a);
    font-style: italic;
}
.header-search-submit {
    flex-shrink: 0;
    border-radius: 999px;
}
.header-search-close {
    background: transparent;
    border: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--ink-mute, #8a807a);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.header-search-close:hover {
    background: var(--cream-100, #f0e8d4);
    color: var(--ink, #14110F);
}

.header-search-hint {
    margin: 12px 4px 0;
    font-size: 0.78rem;
    color: var(--ink-mute, #8a807a);
    text-align: center;
}
.header-search-hint kbd {
    font-family: inherit;
    background: var(--cream-100, #f0e8d4);
    border: 1px solid var(--line, #e5d9c1);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.76rem;
    color: var(--ink, #14110F);
    margin: 0 2px;
}

/* Mobile — full-width sheet, hide the close button text + bigger tap targets */
@media (max-width: 600px) {
    .header-search-overlay { padding: 0.75rem 0.75rem; align-items: stretch; }
    .header-search-panel { padding: 12px; border-radius: 14px; }
    .header-search-form { padding: 4px 6px 4px 12px; flex-wrap: wrap; }
    .header-search-input { font-size: 1rem; padding: 12px 4px; }
    .header-search-submit { padding: 8px 14px; }
    .header-search-hint { display: none; }
    /* Hide the desktop search button — mobile users use the hamburger menu entry */
    .header-search-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .header-search-overlay,
    .header-search-panel { transition: opacity 0.15s linear; transform: none !important; }
}

/* ============================================================================
   AD SLOT — sponsored label + mobile-sticky placement
   ============================================================================ */
.ad-slot-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-mute, #8a807a);
    text-align: center;
    padding: 4px 0;
    line-height: 1;
    opacity: 0.7;
}

/* Mobile sticky bottom banner — appears as a fixed bar above the footer
   on mobile devices. Only renders when the placement has an active ad. */
.ad-mobile_sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 800;            /* below header (100), modals (9000+), but above content */
    background: var(--paper, #fff);
    border-top: 1px solid var(--line, #e5d9c1);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    padding: 6px 8px 8px;
    text-align: center;
    /* Honor iPhone bottom safe area */
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.ad-mobile_sticky .ad-slot-label {
    font-size: 0.62rem;
    padding: 0 0 3px;
}
.ad-mobile_sticky img {
    max-height: 60px;
    max-width: 100%;
    height: auto;
}
/* Add bottom padding to the page so content doesn't hide behind sticky ad */
@media (max-width: 768px) {
    body:has(.ad-mobile_sticky) { padding-bottom: 80px; }
}
/* Hide on desktop entirely — sticky ads belong on mobile */
@media (min-width: 769px) {
    .ad-mobile_sticky { display: none !important; }
}

/* ============================================================================
   PICKER MODAL — shared overlay used by sister-sites, ads, and other pickers.
   The pane-specific styles (tabs, dropzone, icon tiles, emoji grid) are still
   defined inline on the sister-sites view since only that page uses them.
   ============================================================================ */
.ss-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(20, 17, 15, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.ss-picker-overlay[hidden] { display: none; }

.ss-picker {
    background: var(--paper, #fff);
    border-radius: 18px;
    width: min(680px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(20, 17, 15, 0.30);
}

.ss-picker-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line, #e5d9c1);
}
.ss-picker-head h3 { margin: 0; font-size: 1.1rem; }

.ss-picker-close {
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--ink-mute, #8a807a);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.ss-picker-close:hover {
    background: var(--cream-100, #f0e8d4);
    color: var(--ink, #14110F);
}

.ss-picker-body {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1;
}
