/* Mobile presentation, loaded after each page's component styles. */
.mobile-tabbar,
.mobile-discovery,
.hero-title-mobile { display: none; }
.menu-button .menu-close { display: none; }
.menu-button[aria-expanded="true"]>svg:first-child { display: none; }
.menu-button[aria-expanded="true"] .menu-close { display: block; }

@media screen and (max-width: 760px) {
    html { scroll-padding-top: calc(88px + env(safe-area-inset-top)); }
    body:not(.page-checkout) {
        padding: 0 0 calc(80px + env(safe-area-inset-bottom));
        background: #f6f9fc;
        font-size: 16px;
    }
    .app-shell {
        max-width: none;
        min-height: 100dvh;
        margin: 0;
        padding: 0 16px;
        border: 0;
        border-radius: 0;
        background: #fff;
        box-shadow: none;
        overflow: clip;
    }
    .app-shell .header {
        position: sticky;
        top: 0;
        z-index: 40;
        height: calc(76px + env(safe-area-inset-top));
        margin: 0 -16px;
        padding: 0 16px;
        padding-top: env(safe-area-inset-top);
        gap: 10px;
        border-bottom: 1px solid #edf2f7;
        background: rgba(255, 255, 255, .97);
    }
    .app-shell .header .brand { width: auto; min-width: 0; flex: 1; }
    .app-shell .header .brand .brand-logo { width: 154px; max-width: 100%; height: auto; }
    .header .header-actions { gap: 8px; flex-shrink: 0; }
    .header .header-actions .account {
        min-height: 44px;
        max-width: 112px;
        padding: 10px 13px;
        border-color: #dceaf5;
        border-radius: 14px;
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .header .header-search,
    .header .create-top { display: none; }
    .header .menu-button {
        display: grid;
        place-items: center;
        width: 44px;
        height: 44px;
        padding: 10px;
        border: 1px solid #dceaf5;
        border-radius: 14px;
        background: #f3f9fd;
        color: #236487;
    }
    .header .menu-button[aria-expanded="true"] { background: #e5f2fb; border-color: #8cbdd9; }
    .header .nav {
        display: none;
        position: absolute;
        inset: calc(100% + 6px) 12px auto;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 10px;
        border: 1px solid #dceaf5;
        border-radius: 20px;
        background: #fff;
        box-shadow: 0 16px 40px #23476225;
    }
    .header .nav.open { display: flex; }
    .header .nav a { min-height: 48px; padding: 12px; gap: 12px; font-size: 15px; }
    .header .nav a svg { display: block; width: 22px; height: 22px; }
    .mobile-tabbar {
        position: fixed;
        inset: auto 0 0;
        z-index: 50;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid #dfeaf2;
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 -6px 24px #25435d09;
        backdrop-filter: blur(16px);
    }
    .mobile-tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-height: 52px;
        border-radius: 14px;
        color: #64778a;
        font-size: 12px;
        line-height: 1.3;
        font-weight: 800;
    }
    .mobile-tabbar svg { width: 22px; height: 22px; }
    .mobile-tabbar a[aria-current="page"] { color: #0876a7; background: #eaf6fd; }
    .mobile-tabbar a:active { background: #edf5fa; }
    body:has(input:not([type="checkbox"]):focus, textarea:focus, select:focus) .mobile-tabbar { display: none; }
    .toast { bottom: calc(90px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }
    :focus-visible { outline: 3px solid #167bac; outline-offset: 3px; }

    /* Keep the illustration beside the action, clear of the headline. */
    .page-home .hero.school-hero {
        display: block;
        height: auto;
        min-height: 360px;
        margin: 16px 0 0;
        border: 1px solid #e4f0ec;
        border-radius: 24px;
        background: linear-gradient(130deg, #e5f6ff 0%, #f3faf0 55%, #fff4d5 100%);
        overflow: hidden;
    }
    .page-home .school-hero .hero-copy { width: 100%; margin: 0; padding: 24px 20px 26px; }
    .page-home .hero-title-desktop { display: none; }
    .page-home .hero-title-mobile { display: inline; }
    .page-home .school-hero .eyebrow {
        max-width: 260px;
        margin-bottom: 12px;
        color: #39718b;
        font-size: 10px;
        line-height: 1.55;
        letter-spacing: 1px;
    }
    .page-home .school-hero h1 { max-width: 310px; margin: 0 0 16px; font-size: 32px; line-height: 1.13; letter-spacing: -.9px; }
    .page-home .school-hero h1 em { white-space: normal; color: #d83179; }
    .page-home .school-hero p { max-width: 255px; margin-bottom: 20px; color: #496779; font-size: 15px; line-height: 1.65; }
    .page-home .school-hero p br { display: none; }
    .page-home .hero-cta.button { min-height: 48px; padding: 11px 14px; gap: 7px; font-size: 14px; line-height: 1.4; }
    .page-home .hero-cta svg { width: 18px; height: 18px; }
    .page-home .school-hero .hero-note { max-width: 175px; margin-top: 13px; color: #537586; font-size: 12px; line-height: 1.5; }
    .page-home .hero-character { inset: auto -12px -3px auto; width: 142px; height: 142px; z-index: 1; }
    .page-home .hero-character img { width: 100%; height: 100%; }
    .page-home .hero-steps { display: none; }
    .page-home .workspace { display: block; margin-top: 20px; }
    .page-home .search-box { height: 56px; padding: 5px 5px 5px 14px; gap: 10px; border: 1px solid #d4e5ef; border-radius: 17px; box-shadow: 0 4px 14px #315b7810; }
    .page-home .search-box:focus-within { border-color: #1685b8; box-shadow: 0 0 0 3px #1685b81a; }
    .page-home .search-box input { font-size: 16px; }
    .page-home .search-box input::placeholder { color: #73899a; font-size: 14px; }
    .page-home .search-box>svg { width: 20px; height: 20px; }
    .page-home .search-submit { width: 44px; height: 44px; border-radius: 12px; }
    .mobile-discovery { display: flex; gap: 8px; margin: 14px -16px 0; padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none; }
    .mobile-discovery::-webkit-scrollbar { display: none; }
    .discovery-chip { flex: none; min-height: 44px; padding: 10px 15px; border: 1px solid #dfe8ef; border-radius: 24px; background: #fff; color: #536d80; font-size: 13px; font-weight: 800; line-height: 1.4; }
    .discovery-chip[aria-pressed="true"] { border-color: #1683b2; background: #eaf7ff; color: #0d678e; }
    .page-home .section-heading.catalog-heading { display: block; padding: 20px 0 18px; }
    .page-home .catalog-heading .section-eyebrow { display: none; }
    .page-home .catalog-heading h2 { margin: 0; font-size: 25px; line-height: 1.25; letter-spacing: -.6px; }
    .page-home .catalog-heading p { max-width: 330px; margin-top: 8px; font-size: 14px; line-height: 1.6; }
    .page-home .count-badge { padding: 3px 7px; font-size: 11px; vertical-align: middle; }
    .page-home .catalog-heading>.text-link { display: none; min-height: 44px; margin-top: 8px; font-size: 14px; }
    .page-home .catalog-filtered .catalog-heading>.text-link { display: inline-flex; }

    /* Touch cards always show title and action; no hover dependency. */
    .page-home #generator-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
    .page-home #generator-grid .generator-card { display: flex; flex-direction: column; aspect-ratio: auto; padding: 0; border-radius: 18px; background: #fff; box-shadow: 0 3px 12px #264e6c09; animation: none; }
    .page-home #generator-grid .generator-card:hover,
    .page-home #generator-grid .generator-card:focus-within { transform: none; }
    .page-home #generator-grid .card-image { position: relative; inset: auto; display: block; width: 100%; height: auto; aspect-ratio: 1; flex-shrink: 0; border-radius: 17px 17px 0 0; }
    .page-home #generator-grid .tag { top: 8px; left: 8px; max-width: calc(100% - 16px); padding: 4px 7px; border-radius: 7px; font-size: 10px; line-height: 1.35; }
    .page-home #generator-grid .card-content { position: static; inset: auto; display: flex; flex: 1; flex-direction: column; gap: 0; padding: 12px 10px 10px; border-radius: 0; background: #fff; box-shadow: none; }
    .page-home #generator-grid .card-category { margin: 0 0 6px; font-size: 10px; line-height: 1.5; }
    .page-home #generator-grid .card-content h3 { min-height: 42px; margin: 0; color: #24435c; font-size: 16px; line-height: 1.3; overflow-wrap: normal; }
    .page-home #generator-grid .card-content h3 a { display: block; min-height: 44px; }
    .page-home #generator-grid .card-content p { display: none; }
    .page-home #generator-grid .card-button { display: flex; flex-shrink: 0; height: auto; min-height: 44px; max-height: none; margin: 12px 0 0; padding: 10px 6px; gap: 5px; overflow: visible; border: 1px solid var(--section-border); border-radius: 11px; opacity: 1; font-size: 12px; line-height: 1.4; }
    .page-home #generator-grid .card-button svg { width: 16px; height: 16px; }
    .page-home .empty-state { margin-top: 12px; padding: 28px 18px; }

    /* Shared forms keep a readable size and never ask for pinch-to-zoom. */
    .inner-page { padding: 22px 0 30px; }
    .button { min-height: 44px; }
    .settings-panel input,.settings-panel select,.settings-panel textarea,
    .auth-form input,.panel-form input:not([type="checkbox"]) { min-height: 48px; font-size: 16px; }
    .generator-page .studio-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .generator-page .tool-heading h1 { font-size: 27px; line-height: 1.2; }
    .generator-page .tool-heading p { font-size: 14px; }
    .generator-page .generator-status { font-size: 12px; white-space: normal; }
    .generator-page .generator-form-heading h2 { font-size: 21px; line-height: 1.3; }
    .generator-page .generator-form-heading p { font-size: 13px; }
    .generator-page .generator-fields { padding: 20px 16px; }
    .generator-page .field-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .generator-page .settings-panel label { min-width: 0; font-size: 14px; }
    .generator-page .settings-panel input,.generator-page .settings-panel select,.generator-page .settings-panel textarea { min-width: 0; width: 100%; font-size: 16px; }
    .generator-page .optional,.generator-page .form-caption,.generator-page .result-footnote { font-size: 12px; }
    .generator-page .result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .generator-page .result-actions .button { justify-content: center; min-height: 48px; font-size: 13px; }
    .generator-page .result-actions .button:last-child { grid-column: 1 / -1; }
    .generator-page .preview-empty p { font-size: 14px; }
    .auth-layout { grid-template-columns: minmax(0, 1fr); padding: 22px 4px 32px; gap: 0; }
    .auth-art { display: none; }
    .auth-form { width: 100%; max-width: 440px; margin-inline: auto; padding: 12px 0; }
    .auth-form h1 { font-size: 30px; line-height: 1.2; }
    .auth-form>p { font-size: 15px; }
    .auth-form .button { min-height: 50px; }

    .app-shell .site-footer { margin: 32px -16px 0; border-radius: 0; }
    .site-footer-main { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 18px; padding: 28px 20px 20px; }
    .site-footer-brand { grid-column: 1 / -1; }
    .site-footer-brand img { width: 170px; }
    .site-footer-brand p { max-width: 340px; font-size: 14px; }
    .site-footer h2 { margin-bottom: 6px; font-size: 11px; }
    .site-footer-links { gap: 0; }
    .site-footer-links a { display: flex; align-items: center; min-height: 44px; width: 100%; font-size: 14px; line-height: 1.5; }
    .site-footer-main>nav:last-child { grid-column: 1 / -1; }
    .site-footer-main>nav:last-child .site-footer-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
    .site-footer-bar { gap: 8px; padding: 18px 20px 24px; font-size: 12px; line-height: 1.6; }
}

@media screen and (max-width: 359px) {
    .app-shell .header .brand .brand-logo { width: 132px; }
    .header .header-actions { gap: 5px; }
    .header .header-actions .account { padding-inline: 10px; font-size: 12px; }
    .page-home .school-hero .hero-copy { padding-inline: 16px; }
    .page-home .school-hero h1 { font-size: 28px; }
    .page-home .school-hero p { max-width: 220px; }
    .page-home .hero-character { width: 116px; height: 116px; right: -17px; }
    .page-home .hero-cta.button { padding-inline: 10px; font-size: 13px; }
    .page-home .catalog-heading h2 { font-size: 23px; }
    .page-home #generator-grid { grid-template-columns: minmax(0, 1fr); }
    .page-home #generator-grid .generator-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; }
    .page-home #generator-grid .card-image { width: 100px; height: 100px; margin-left: 12px; border-radius: 12px; }
    .page-home #generator-grid .tag { display: none; }
    .page-home #generator-grid .card-content { padding: 14px 12px; }
    .page-home #generator-grid .card-content h3 { min-height: 0; font-size: 15px; }
    .page-home #generator-grid .card-content h3 a { min-height: 0; }
    .page-home #generator-grid .card-button { margin-top: 10px; }
    .generator-page .field-pair { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media screen and (min-width: 600px) and (max-width: 760px) {
    .page-home .school-hero .hero-copy { width: 72%; padding: 30px; }
    .page-home .school-hero h1 { max-width: 390px; font-size: 36px; }
    .page-home .hero-character { width: 230px; height: 230px; right: -10px; }
    .page-home #generator-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
