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

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    background: var(--page-canvas);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header,
.landing-header {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(16px);
    background: var(--header-surface);
    border-bottom: 1px solid var(--header-divider);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem clamp(1.5rem, 4vw, 5rem);
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(140deg, var(--brand-mark-start), var(--brand-mark-end));
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
}

.brand-tagline {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.nav-links a {
    transition: color 0.2s ease, opacity 0.2s ease;
}

.nav-links a:hover {
    color: var(--text-primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.mobile-toggle {
    margin-left: auto;
}

.user-menu {
    position: relative;
}

.menu-dropdown {
    position: relative;
}

.menu-toggle {
    border: none;
    cursor: pointer;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--glass-whisper);
    color: var(--text-primary);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.menu-toggle:focus-visible {
    outline: 2px solid var(--accent-ring);
    outline-offset: 3px;
}

.nav-link-dropdown .menu-toggle {
    padding: 0;
    border-radius: 0;
    background: var(--clear-fill);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link-dropdown .menu-toggle:hover {
    color: var(--text-primary);
}

.nav-link-dropdown .menu-toggle:focus-visible {
    border-radius: 8px;
    padding: 0.15rem 0.3rem;
    outline-offset: 2px;
}

.nav-link-dropdown .menu-panel {
    top: calc(100% + 0.9rem);
    right: auto;
    left: 0;
}

.menu-toggle .caret {
    width: 0;
    height: 0;
    border-left: 5px solid var(--clear-fill);
    border-right: 5px solid var(--clear-fill);
    border-top: 6px solid var(--text-primary);
    transition: transform 0.2s ease;
}

.menu-dropdown.open .menu-toggle .caret {
    transform: rotate(180deg);
}

.nav-link-dropdown.open .menu-toggle .caret {
    border-top-color: var(--text-primary);
}

.user-toggle {
    border: none;
    cursor: pointer;
    border-radius: 999px;
    padding: 0.4rem 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--glass-whisper);
    color: var(--text-primary);
    transition: background 0.2s ease, color 0.2s ease;
}

.user-toggle:focus-visible {
    outline: 2px solid var(--accent-ring);
    outline-offset: 3px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-avatar img {
    width: 28px;
    height: 28px;
    display: block;
}

.user-toggle .caret {
    width: 0;
    height: 0;
    border-left: 5px solid var(--clear-fill);
    border-right: 5px solid var(--clear-fill);
    border-top: 6px solid var(--text-primary);
    transition: transform 0.2s ease;
}

.user-menu.open .caret {
    transform: rotate(180deg);
}

.menu-panel {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    background: var(--menu-panel-surface);
    border: 1px solid var(--glass-fill);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 180px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.user-dropdown {
    min-width: 180px;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.menu-dropdown.open .menu-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.books-dropdown {
    min-width: 260px;
}

.books-dropdown a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.menu-item-active {
    color: var(--text-primary) !important;
    background: var(--glass-lift);
}

.menu-item-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--copy-solid);
    background: var(--support-pill);
}

.menu-empty {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.user-dropdown-header {
    padding: 0.25rem 0.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.user-dropdown-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.user-dropdown-details {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-dropdown-separator {
    height: 1px;
    background: var(--glass-fill);
    margin: 0.35rem 0;
}

.user-dropdown a {
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.user-dropdown a:hover {
    background: var(--glass-panel);
    color: var(--text-primary);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.btn {
    border: none;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.03em;
    border-radius: 999px;
    padding: 0.65rem 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, var(--accent-start) 0%, var(--accent-mid) 55%, var(--accent-end) 100%);
    color: var(--copy-on-accent);
    box-shadow: 0 14px 28px var(--accent-shadow), inset 0 1px 0 var(--edge-spotlight);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, var(--primary-button-gloss-top) 0%, var(--primary-button-gloss-bottom) 100%);
    mix-blend-mode: screen;
    opacity: var(--primary-button-gloss-opacity);
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.btn:hover::after {
    opacity: var(--primary-button-gloss-opacity-hover);
}

.btn.is-loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: var(--clear-fill);
    display: inline-block;
    animation: readsme-spin 0.75s linear infinite;
}

@keyframes readsme-spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-outline {
    color: var(--secondary-button-text);
    border: 1px solid var(--support-shell-edge);
    background: linear-gradient(180deg, var(--secondary-button-start) 0%, var(--secondary-button-mid) 58%, var(--secondary-button-end) 100%);
    box-shadow: 0 16px 30px var(--secondary-button-shadow), inset 0 1px 0 var(--edge-strong);
}

.btn-outline::after {
    background: linear-gradient(180deg, var(--secondary-button-gloss-top) 0%, var(--secondary-button-gloss-mid) 52%, var(--secondary-button-gloss-bottom) 100%);
    mix-blend-mode: normal;
    opacity: var(--secondary-button-gloss-opacity);
}

.btn-outline:hover {
    border-color: var(--support-focus);
    box-shadow: 0 20px 36px var(--secondary-button-shadow-hover), inset 0 1px 0 var(--edge-focus-soft);
}

.btn-icon {
    padding: 0.45rem;
    min-width: 40px;
    justify-content: center;
}

.btn-icon__svg {
    width: 18px;
    height: 18px;
    display: block;
}

.btn-icon-circle {
    width: 44px;
    height: 44px;
    padding: 0;
    min-width: 44px;
    justify-content: center;
}

.btn-accent {
    color: var(--copy-on-accent);
    background: linear-gradient(135deg, var(--accent-start-strong) 0%, var(--primary-button-mid) 35%, var(--primary-button-end) 70%, var(--accent-end-max) 100%);
    box-shadow: 0 24px 40px var(--primary-button-shadow), inset 0 0 1px var(--copy-quiet);
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 28px 46px var(--primary-button-shadow-hover), inset 0 1px 0 var(--copy-subtle);
}

.mobile-toggle {
    display: none;
    flex-direction: column;
    gap: 6px;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
}

.mobile-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
}

.mobile-menu {
    display: none;
    flex-direction: column;
    padding: 0 1.5rem 1.5rem;
    gap: 0.75rem;
    color: var(--text-muted);
}

.mobile-menu.open {
    display: flex;
}

.content {
    flex: 1;
    padding: clamp(2rem, 5vw, 4.5rem) clamp(1.5rem, 5vw, 5rem);
    background: var(--page-glow-start);
}

.book-shell,
.dashboard-shell,
.conversations-shell {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.book-hero,
.book-form-wrap,
.dashboard-hero,
.dashboard-card,
.conversations-hero,
.conversations-card {
    border-radius: 28px;
    padding: var(--surface-padding, clamp(1.5rem, 4vw, 2.5rem));
    background: var(--surface-card);
    border: 1px solid var(--surface-card-edge);
    box-shadow: 0 40px 90px var(--surface-card-shadow);
}

.book-hero,
.dashboard-hero,
.conversations-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.book-hero h1,
.book-form-wrap h1,
.dashboard-hero h1,
.conversations-hero h1 {
    margin: 0;
}

.book-hero__meta,
.dashboard-hero__meta,
.conversations-hero__meta {
    color: var(--copy-soft);
}

.messages {
    margin-bottom: 1.5rem;
    border-radius: 18px;
    padding: 1rem 1.25rem;
    background: var(--accent-wash-subtle);
    border: 1px solid var(--accent-glow);
    color: var(--text-primary);
}

.messages.error {
    background: var(--base-notice-error-surface);
    border-color: var(--base-notice-error-edge);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 0.75rem;
    margin: 0 0 0.4rem;
    color: var(--copy-quiet);
}

.chip-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chip {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid var(--edge-soft);
    background: var(--glass-fill);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: var(--support-wash-soft);
    color: var(--copy-strong);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.empty-state {
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px dashed var(--edge-soft);
    text-align: center;
    color: var(--copy-reading);
}

.story-author__avatar,
.suggested-edit__avatar {
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid var(--glass-strong);
    background: var(--header-divider);
}

.simple-footer {
    margin-top: auto;
    padding: 1.25rem clamp(1.5rem, 4vw, 5rem);
    border-top: 1px solid var(--glass-fill);
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--simple-footer-surface);
}

.site-footer {
    margin-top: auto;
    padding: clamp(2.5rem, 5vw, 4rem) clamp(1.5rem, 5vw, 5rem);
    background: linear-gradient(180deg, var(--footer-surface-start), var(--footer-surface-end));
    border-top: 1px solid var(--glass-fill);
    position: relative;
    overflow: hidden;
}

.site-footer::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, var(--page-glow-start), var(--clear-fill) 45%),
        radial-gradient(circle at 78% 5%, var(--support-wash-soft), var(--clear-fill) 52%);
    opacity: 0.8;
    pointer-events: none;
}

.site-footer-content {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 2rem;
    z-index: 2;
}

.confetti-container {
    pointer-events: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 120;
}

.confetti-piece {
    position: absolute;
    top: 0;
    width: 8px;
    height: 18px;
    border-radius: 4px;
    opacity: 0;
    background: var(--confetti-color, var(--accent-confetti));
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translate3d(0, -15vh, 0) rotate(var(--confetti-rotate-start, 0deg));
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    100% {
        transform: translate3d(
            var(--confetti-drift, 0px),
            var(--confetti-translate, 70vh),
            0
        ) rotate(var(--confetti-rotate-end, 720deg));
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .confetti-piece {
        animation: none;
        display: none;
    }
}

.footer-brand {
    max-width: 320px;
}

.footer-brand h3 {
    margin: 0;
    font-size: 1.75rem;
}

.footer-brand p {
    margin-top: 0.5rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.footer-cta {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.footer-column h4 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.footer-column a,
.footer-column span {
    display: block;
    color: var(--text-primary);
    opacity: 0.85;
    margin: 0.35rem 0;
    font-size: 0.95rem;
}

.footer-column a:hover {
    opacity: 1;
}

.footer-bottom {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--glass-fill);
    margin-top: 3rem;
    padding-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    gap: 1rem;
}

.social-links {
    display: flex;
    gap: 0.85rem;
}

.social-links a {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--edge-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-primary);
    opacity: 0.8;
    transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.social-links a:hover {
    opacity: 1;
    transform: translateY(-2px);
    border-color: var(--edge-focus-strong);
}

@media (max-width: 900px) {
    .nav-links,
    .nav-actions {
        display: none;
    }

    .mobile-toggle {
        display: flex;
    }

}

@media (max-width: 640px) {
    .book-hero,
    .book-form-wrap,
    .dashboard-hero,
    .dashboard-card,
    .conversations-hero,
    .conversations-card {
        border-radius: 18px;
        padding: 1.15rem;
    }
}

@media (max-width: 720px) {
    .footer-cta {
        flex-direction: column;
    }
}
