* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
    line-height: 1.65;
    color: #1e293b;
    background:
        radial-gradient(ellipse 100% 60% at 50% -10%, rgba(99, 102, 241, 0.07), transparent 55%),
        linear-gradient(180deg, #faf8f5 0%, #f1f5f9 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding: 2.25rem 1.35rem 3rem;
}

.page-narrow {
    max-width: 640px;
}

.page-form {
    max-width: 560px;
}

.page-companion {
    max-width: min(96rem, calc(100vw - 2.5rem));
    padding-top: 1.5rem;
    background: #fff;
}

body:has(> .page-companion) {
    background: #fff;
}

.page-mathicon {
    max-width: min(96rem, calc(100vw - 2.5rem));
    background: #fff;
}

body:has(> .page-mathicon) {
    background: #fff;
}

.site-head {
    margin-bottom: 1.25rem;
}

.site-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem 1rem;
    max-width: 100%;
    margin: 0 auto;
}

.site-brand-logo {
    flex-shrink: 0;
}

.site-brand-text {
    text-align: left;
    min-width: 0;
}

.site-head h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 600;
    margin: 0 0 0.2rem;
    letter-spacing: 0.02em;
    color: #0f172a;
    line-height: 1.2;
}

.site-slogan {
    margin: 0 0 0.25rem;
    font-size: clamp(1.05rem, 3.2vw, 1.4rem);
    font-weight: 600;
    color: #0f766e;
    line-height: 1.35;
    letter-spacing: 0.01em;
}

.math4ai-logo-link {
    display: block;
    margin-bottom: 0;
}

.site-brand-logo .math4ai-logo {
    display: block;
    width: min(76px, 18vw);
    height: auto;
    margin: 0;
}

.tagline {
    margin: 0;
    font-size: clamp(0.78rem, 2vw, 0.9rem);
    color: #64748b;
    font-style: italic;
    line-height: 1.35;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem 1rem;
    margin-top: 0.85rem;
}

.site-nav a {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4338ca;
    text-decoration: none;
    padding: 0.45rem 0.9rem;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
}

.site-nav a:hover {
    background: #eef2ff;
    text-decoration: underline;
}

.site-nav a.nav-primary {
    color: #fff;
    background: linear-gradient(180deg, #0f766e 0%, #115e59 100%);
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(15, 118, 110, 0.22);
}

.site-nav a.nav-primary:hover {
    background: linear-gradient(180deg, #115e59 0%, #134e4a 100%);
}

.site-nav-logout {
    display: inline-flex;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

.site-nav-logout button {
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: #4338ca;
    text-decoration: none;
    padding: 0.45rem 0.9rem;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    cursor: pointer;
}

.site-nav-logout button:hover {
    background: #eef2ff;
    text-decoration: underline;
}

.site-main {
    flex: 1;
}

.site-footer {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    text-align: center;
    font-size: 0.82rem;
    color: #94a3b8;
}

.site-footer a {
    color: #64748b;
    text-decoration: none;
}

.site-footer a:hover {
    color: #4338ca;
    text-decoration: underline;
}

.site-footer .copyright-link {
    color: #64748b;
}

.site-footer .copyright-link {
    color: #64748b;
}

/* Floating book cover → Amazon */
.book-cover-float {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 900;
    width: min(11.5rem, 34vw);
    padding: 0.65rem 0.65rem 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(6px);
}

.book-cover-float-link {
    display: block;
    color: inherit;
    text-decoration: none;
    line-height: 0;
}

.book-cover-float-link img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-cover-float-link:hover img {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.book-cover-float-cta {
    display: block;
    margin-top: 0.55rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    color: #fff;
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.28);
}

.book-cover-float-link:hover .book-cover-float-cta {
    background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}

.book-cover-float-dismiss {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border: none;
    border-radius: 999px;
    font-size: 1.15rem;
    line-height: 1;
    color: #64748b;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
    cursor: pointer;
}

.book-cover-float-dismiss:hover {
    color: #0f172a;
    background: #fff;
}

.page-companion .book-cover-float {
    left: 1.25rem;
    right: auto;
}

@media (max-width: 720px) {
    .book-cover-float {
        width: min(9.5rem, 42vw);
        right: 0.75rem;
        bottom: 0.75rem;
        padding: 0.5rem 0.5rem 0.65rem;
    }

    .page-companion .book-cover-float {
        left: 0.75rem;
    }
}

.page-companion .site-head {
    margin-bottom: 1rem;
}

.page-companion .site-brand-logo .math4ai-logo {
    width: min(64px, 16vw);
}

.page-companion .site-head h1 {
    font-size: clamp(1.2rem, 4vw, 2.25rem);
}

.page-companion .site-nav a {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
}

@media (max-width: 520px) {
    .site-brand {
        gap: 0.65rem 0.75rem;
    }

    .site-brand-logo .math4ai-logo {
        width: min(60px, 16vw);
    }
}
