/* Story Platform — custom styles (Tailwind loaded via CDN in Step 1) */



body {

    font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

}



.search-suggestions a:focus-visible {

    outline: 2px solid rgb(99 102 241);

    outline-offset: 1px;

}

/* Homepage hero only */
.home-hero-chips {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.home-hero-chips::-webkit-scrollbar {
    display: none;
}

.home-hero-chip:focus-visible {
    outline: 2px solid rgb(255 255 255);
    outline-offset: 2px;
}

/* Untoldpage brand logo */
.site-logo__img--header {
    display: block;
    height: 1.8rem;
    width: auto;
    max-width: min(9.75rem, 45vw);
    object-fit: contain;
    object-position: left center;
}

.site-logo__mark {
    display: block;
    height: 1.625rem;
    width: auto;
    object-fit: contain;
}

.site-logo__wordmark {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.15;
}

.site-logo__name {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: rgb(15 23 42);
}

.site-logo__tagline {
    margin-top: 0.125rem;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgb(99 102 241);
}

.site-logo--auth .site-logo__name {
    font-size: 1rem;
}

.site-logo--auth .site-logo__mark {
    height: 1.45rem;
}

/* Homepage: content below hero (see .home-page-body in home/index.php) */
.is-homepage .home-page-body {
    box-sizing: border-box;
}

/* Featured stories — 2×2 lead-style cards */
.home-featured-quartet {
    display: grid;
    align-items: stretch;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
    .home-featured-quartet {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
}

.home-featured-quartet-item {
    display: flex;
    min-height: 0;
}

.home-featured-quartet .home-featured-lead {
    width: 100%;
}

.home-featured-quartet .home-featured-lead-cover {
    width: 6.25rem;
    align-self: stretch;
}

.home-featured-quartet .home-featured-lead-cover img,
.home-featured-quartet .home-featured-lead-cover > div[role='img'] {
    height: 100%;
    min-height: 100%;
    width: 100%;
    object-fit: cover;
}

@media (min-width: 640px) {
    .home-featured-quartet .home-featured-lead-cover {
        width: 8.75rem;
    }
}


.is-homepage main {
    width: 100%;
    max-width: 100%;
}

.home-overlay-header {
    width: 100%;
    color: rgb(255 255 255);
    border-bottom: 1px solid rgb(255 255 255 / 0.18);
    background: linear-gradient(to bottom, rgb(2 6 23 / 0.72), rgb(2 6 23 / 0.22));
    text-shadow: 0 1px 12px rgb(2 6 23 / 0.55);
}

/* Same header palette on inner pages (opaque bar over light body) */
.home-overlay-header.site-header-bar {
    background: linear-gradient(
        180deg,
        rgb(15 23 42) 0%,
        rgb(30 27 75) 52%,
        rgb(49 46 129) 100%
    );
    border-bottom-color: rgb(255 255 255 / 0.12);
    box-shadow: 0 4px 24px rgb(15 23 42 / 0.18);
}

.home-overlay-header > nav {
    width: 100%;
    max-width: 72rem;
    margin-left: auto;
    margin-right: auto;
}

.home-overlay-header > nav > a,
.home-overlay-header > nav > div > a,
.home-overlay-header > nav > div > button {
    color: rgb(255 255 255);
}

.home-overlay-header > nav > a:hover,
.home-overlay-header > nav > div > a:hover,
.home-overlay-header > nav > div > button:hover {
    color: rgb(254 240 138);
}

.home-overlay-header > nav > a:first-child {
    color: rgb(255 255 255);
    text-shadow: 0 2px 16px rgb(2 6 23 / 0.55);
}

.home-overlay-header a[href$="/register"],
.home-overlay-header a[href$="/write-story"] {
    color: rgb(255 255 255);
    border: 1px solid rgb(255 255 255 / 0.38);
    background: rgb(255 255 255 / 0.14);
    box-shadow: 0 8px 24px rgb(2 6 23 / 0.14);
    backdrop-filter: blur(8px);
}

.home-overlay-header a[href$="/register"]:hover,
.home-overlay-header a[href$="/write-story"]:hover {
    color: rgb(30 27 75);
    border-color: rgb(255 255 255);
    background: rgb(255 255 255);
}

.home-overlay-header .nav-user-details > summary {
    color: rgb(255 255 255);
    border-color: rgb(255 255 255 / 0.3);
    background: rgb(15 23 42 / 0.32);
}

.home-overlay-header .nav-user-details > summary:hover {
    border-color: rgb(255 255 255 / 0.55);
    background: rgb(15 23 42 / 0.48);
}

.home-overlay-header .nav-user-details > summary > span:nth-child(2),
.home-overlay-header .nav-user-details > summary > svg {
    color: rgb(255 255 255);
}

/* Profile menu panel stays light; do not inherit hero header link colors */
.home-overlay-header .nav-user-dropdown {
    color: rgb(51 65 85);
    text-shadow: none;
}

.home-overlay-header .nav-user-dropdown p {
    color: rgb(15 23 42);
}

.home-overlay-header .nav-user-details .nav-user-dropdown a,
.home-overlay-header .nav-user-details .nav-user-dropdown button {
    color: rgb(51 65 85) !important;
    text-shadow: none;
}

.home-overlay-header .nav-user-details .nav-user-dropdown a:hover,
.home-overlay-header .nav-user-details .nav-user-dropdown button:hover {
    color: rgb(49 46 129) !important;
    background: rgb(238 242 255);
}

.home-overlay-header [data-mobile-nav-panel] {
    position: relative;
    z-index: 110;
    color: rgb(255 255 255);
    border-color: rgb(255 255 255 / 0.14);
    background: rgb(15 23 42 / 0.96);
    box-shadow: 0 18px 38px rgb(2 6 23 / 0.3);
}

.home-overlay-header [data-mobile-nav-toggle] {
    position: relative;
    z-index: 111;
}

.home-overlay-header [data-mobile-nav-panel] a {
    color: rgb(255 255 255);
}

.home-overlay-header [data-mobile-nav-panel] a:hover {
    color: rgb(30 27 75);
    background: rgb(255 255 255);
}

.home-overlay-header [data-mobile-nav-panel] a[href$="/register"] {
    border-color: rgb(99 102 241);
    background: rgb(79 70 229);
}

.home-hero .hero-search-shell {
    min-height: 3.4rem;
}

.home-hero .hero-search-shell input,
.home-hero .hero-language-field select {
    color: rgb(15 23 42);
}

.home-hero .hero-language-field select {
    cursor: pointer;
}

.nav-user-details > summary:focus-visible,
.nav-user-dropdown a:focus-visible,
.nav-user-dropdown button:focus-visible {
    outline: 2px solid rgb(99 102 241);
    outline-offset: 2px;
}

.nav-user-details > summary {
    list-style: none;
}

.nav-user-dropdown {
    pointer-events: auto;
}

.story-tag-chip {
    border-radius: 9999px;
    border: 1px solid rgb(199 210 254);
    background: rgb(255 255 255);
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgb(51 65 85);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.story-tag-chip:hover {
    border-color: rgb(129 140 248);
    background: rgb(238 242 255);
    color: rgb(67 56 202);
}

.story-tag-chip.is-selected {
    border-color: rgb(99 102 241);
    background: rgb(224 231 255);
    color: rgb(49 46 129);
}

.story-meta-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    border: 1px solid rgb(199 210 254);
    background: rgb(255 255 255);
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgb(51 65 85);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    user-select: none;
}

.story-meta-chip:hover {
    border-color: rgb(129 140 248);
    background: rgb(238 242 255);
    color: rgb(67 56 202);
}

.story-meta-chip:has(input:checked),
.story-meta-chip.is-selected {
    border-color: rgb(99 102 241);
    background: rgb(224 231 255);
    color: rgb(49 46 129);
}

.story-meta-chip:focus-within {
    outline: 2px solid rgb(129 140 248);
    outline-offset: 2px;
}

.story-tag-selected-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 9999px;
    border: 1px solid rgb(129 140 248);
    background: rgb(238 242 255);
    padding: 0.25rem 0.35rem 0.25rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgb(49 46 129);
}

.story-tag-selected-chip button {
    display: inline-flex;
    height: 1.35rem;
    width: 1.35rem;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    border: none;
    background: transparent;
    color: rgb(79 70 229);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.story-tag-selected-chip button:hover {
    background: rgb(224 231 255);
}

.story-tag-selected-chip button:focus-visible {
    outline: 2px solid rgb(99 102 241);
    outline-offset: 1px;
}

.tag-combobox-dropdown .tag-dropdown-label {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgb(100 116 139);
}

.tag-combobox-dropdown .tag-dropdown-option {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    color: rgb(30 41 59);
    cursor: pointer;
}

.tag-combobox-dropdown .tag-dropdown-option:hover,
.tag-combobox-dropdown .tag-dropdown-option.is-active {
    background: rgb(238 242 255);
    color: rgb(49 46 129);
}

.tag-combobox-dropdown .tag-dropdown-option:focus-visible {
    outline: 2px solid rgb(99 102 241);
    outline-offset: -2px;
}

.tag-combobox-dropdown .tag-dropdown-create {
    border-top: 1px solid rgb(241 245 249);
    font-weight: 600;
    color: rgb(79 70 229);
}

.story-editor-validation-summary:focus {
    outline: 2px solid rgb(248 113 113);
    outline-offset: 2px;
}

.story-input-error {
    border-color: rgb(248 113 113) !important;
    box-shadow: 0 0 0 3px rgb(254 202 202 / 0.65) !important;
}

.story-writer-quill.story-input-error .ql-container,
.story-writer-quill.story-input-error .ql-toolbar {
    border-color: rgb(248 113 113);
}

.story-writer-layout {
    align-items: start;
}

.story-writer-sidebar-panel {
    position: relative;
    z-index: 3;
}

.story-writer-sidebar .story-meta-chip {
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
}

.story-writer-tags {
    overflow: visible;
    position: relative;
    z-index: 2;
}

.story-writer-tags-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.story-tag-selected-list:empty {
    display: none;
    margin: 0;
    min-height: 0;
}

.tag-combobox {
    position: relative;
    z-index: 5;
}

.tag-combobox-dropdown {
    z-index: 50;
}

@media (max-width: 767px) {
    .tag-combobox-dropdown {
        max-height: min(16rem, 50vh);
    }
}

.dashboard-topbar {
    isolation: isolate;
}

.dashboard-mobile-nav {
    box-shadow: 0 12px 28px rgb(15 23 42 / 0.08);
}

.dashboard-nav-toggle:focus-visible {
    outline: 2px solid rgb(99 102 241);
    outline-offset: 2px;
}

.story-writer {
    font-family: ui-sans-serif, system-ui, sans-serif;
}

.story-writer-title {
    border: 1px solid rgb(226 232 240);
    border-radius: 0.75rem;
    background: rgb(255 255 255);
    padding: 0.875rem 1rem;
    font-weight: 600;
    color: rgb(15 23 42);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.story-writer-title::placeholder {
    color: rgb(148 163 184);
    font-weight: 400;
}

.story-writer-title:placeholder-shown {
    font-weight: 400;
    color: rgb(100 116 139);
}

.story-writer-title:not(:placeholder-shown) {
    font-weight: 700;
    color: rgb(15 23 42);
}

.story-writer-title:hover {
    border-color: rgb(203 213 225);
}

.story-writer-title:focus {
    border-color: rgb(99 102 241);
    outline: none;
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.15);
}

.story-writer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.story-writer-btn:focus-visible {
    outline: 2px solid rgb(99 102 241);
    outline-offset: 2px;
}

.story-writer-btn-primary {
    border: 1px solid rgb(79 70 229);
    background: rgb(79 70 229);
    color: rgb(255 255 255);
}

.story-writer-btn-primary:hover:not(:disabled) {
    background: rgb(67 56 202);
}

.story-writer-btn-primary:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.story-writer-btn-secondary {
    border: 1px solid rgb(51 65 85);
    background: rgb(30 41 59);
    color: rgb(255 255 255);
}

.story-writer-btn-secondary:hover:not(:disabled) {
    background: rgb(15 23 42);
}

.story-writer-btn-outline {
    border: 1px solid rgb(203 213 225);
    background: rgb(255 255 255);
    color: rgb(51 65 85);
}

.story-writer-btn-outline:hover:not(:disabled) {
    background: rgb(248 250 252);
}

.image-crop-modal.flex {
    display: flex;
}

.image-crop-modal-stage {
    min-height: 14rem;
}

.image-crop-modal-stage .cropper-container {
    max-height: min(52vh, 28rem);
}

.image-crop-modal--round .cropper-view-box,
.image-crop-modal--round .cropper-face {
    border-radius: 50%;
}

.image-crop-modal--round .cropper-view-box {
    box-shadow: 0 0 0 1px rgb(255 255 255 / 0.85);
    outline: none;
}

.story-writer-cover-drop.is-dragover {
    border-color: rgb(99 102 241);
    background: rgb(238 242 255);
}

.story-writer-quill .ql-toolbar {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
    border-color: rgb(226 232 240);
    background: rgb(248 250 252);
}

.story-writer-quill .ql-container {
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
    border-color: rgb(226 232 240);
    font-size: 1.0625rem;
    line-height: 1.75;
    min-height: 360px;
}

.story-writing-surface {
    --story-writer-font: Georgia, 'Noto Serif', 'Times New Roman', serif;
}

.story-writer-localized-input,
.story-writer-localized-editor .ql-editor {
    font-family: var(--story-writer-font);
}

.story-writer-localized-input[dir='rtl'],
.story-writer-quill[dir='rtl'] .ql-editor {
    text-align: right;
}

.story-writer-quill .ql-editor {
    font-size: 1.125rem;
    line-height: 1.85;
    min-height: 22rem;
    padding: 1.15rem 1.25rem;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.story-writer-quill-shell {
    position: relative;
}

.story-typing-suggestions--floating {
    z-index: 50;
}

.story-typing-suggestions {
    position: absolute;
    z-index: 30;
    min-width: 12rem;
    max-width: min(420px, 100%);
    border-radius: 0.75rem;
    border: 1px solid rgb(199 210 254);
    background: rgb(255 255 255 / 0.98);
    padding: 0.65rem 0.75rem;
    box-shadow: 0 10px 28px rgb(15 23 42 / 0.12);
}

.story-typing-input-anchor .story-typing-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 0.35rem;
}

.story-typing-suggestion-btn,
.story-typing-suggestion-keep {
    border-radius: 9999px;
    border: 1px solid rgb(226 232 240);
    background: rgb(248 250 252);
    padding: 0.35rem 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.35;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.story-typing-suggestion-btn:hover,
.story-typing-suggestion-btn.is-selected {
    border-color: rgb(129 140 248);
    background: rgb(238 242 255);
}

.story-typing-suggestion-keep {
    font-size: 0.75rem;
    color: rgb(100 116 139);
}

.story-typing-active-status.is-active {
    border-color: rgb(199 210 254);
    background: rgb(238 242 255);
    color: rgb(67 56 202);
}

.story-typing-active-status.is-voice.is-active {
    border-color: rgb(167 243 208);
    background: rgb(236 253 245);
    color: rgb(4 120 87);
}

.story-typing-active-status.is-error {
    border-color: rgb(254 202 202);
    background: rgb(254 242 242);
    color: rgb(185 28 28);
}

#story-typing-mode[data-active-mode='transliterate'] .story-typing-mode-option:first-child,
#story-typing-mode[data-active-mode='native'] .story-typing-mode-option:nth-child(2),
#story-typing-mode[data-active-mode='voice'] .story-typing-mode-option:nth-child(3) {
    border-color: rgb(129 140 248);
    background: rgb(238 242 255);
}

@keyframes story-voice-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgb(239 68 68 / 0.35);
    }
    50% {
        box-shadow: 0 0 0 6px rgb(239 68 68 / 0);
    }
}

@media (min-width: 768px) {
    .story-writer-quill .ql-editor {
        font-size: 1.1875rem;
        min-height: 26rem;
        padding: 1.35rem 1.5rem;
    }
}

@media (max-width: 767px) {
    .story-writer-quill .ql-container {
        min-height: 280px;
    }

    .story-writer-quill .ql-editor {
        min-height: 18rem;
    }

    .story-writer-title {
        font-size: 1.375rem;
    }
}

@media (max-width: 767px) {
    .story-writer-footer {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 40;
        margin: 0;
        border-top: 1px solid rgb(226 232 240);
        background: rgb(255 255 255 / 0.96);
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0));
        box-shadow: 0 -4px 24px rgb(15 23 42 / 0.08);
    }
}

@media (max-width: 639px) {
    .home-overlay-header {
        background: linear-gradient(to bottom, rgb(2 6 23 / 0.72), rgb(2 6 23 / 0.1));
    }

    .home-hero .home-hero-bg {
        object-position: 66% center;
    }

    .home-hero .home-hero-overlay:first-of-type {
        background: linear-gradient(
            180deg,
            rgb(15 23 42 / 0.92) 0%,
            rgb(30 27 75 / 0.78) 50%,
            rgb(49 46 129 / 0.58) 100%
        );
    }

    .home-hero .home-hero-overlay:last-of-type {
        background: linear-gradient(to top, rgb(15 23 42 / 0.65), transparent 55%);
    }

    .home-hero .hero-search-shell {
        min-height: 0;
        flex-direction: column;
        gap: 0.375rem;
        padding: 0.5rem;
        border-radius: 0.75rem;
    }

    .home-hero .hero-search-shell > span {
        position: absolute;
        top: 1.35rem;
        left: 0.35rem;
        z-index: 1;
    }

    .home-hero .hero-search-shell > input {
        width: 100%;
        flex: none;
        padding-top: 0.7rem;
        padding-bottom: 0.7rem;
        padding-left: 2.75rem;
        border-bottom: 1px solid rgb(226 232 240);
    }

    .home-hero .hero-language-field {
        width: 100%;
        min-height: 2.6rem;
        border: 1px solid rgb(226 232 240);
        border-radius: 0.5rem;
    }

    .home-hero .hero-language-field select {
        width: 100%;
    }

    .home-hero .hero-search-submit {
        width: 100%;
        min-height: 2.4rem;
    }
}

/* Author profile — compact sidebar + main */
.author-page-layout .author-profile-aside {
    max-height: calc(100vh - 5.5rem);
    overflow-y: auto;
    text-align: left;
}

.author-aside-stats {
    border-top: 1px solid rgb(241 245 249);
    border-bottom: 1px solid rgb(241 245 249);
    padding: 0.625rem 0;
}

.author-aside-stat {
    padding: 0 0.375rem;
    text-align: center;
}

.author-aside-stat:not(:last-child) {
    border-right: 1px solid rgb(241 245 249);
}

.author-aside-stat dt {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgb(100 116 139);
}

.author-aside-stat dd {
    margin-top: 0.125rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgb(15 23 42);
}

.author-aside-stat dd a {
    color: inherit;
}

.author-aside-stat dd a:hover {
    color: rgb(67 56 202);
}

.author-aside-more-stats {
    border-radius: 0.5rem;
    background: rgb(248 250 252);
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    color: rgb(100 116 139);
}

.author-aside-more-stats summary {
    cursor: pointer;
    list-style: none;
    font-weight: 500;
    color: rgb(71 85 105);
}

.author-aside-more-stats summary::-webkit-details-marker {
    display: none;
}

.author-aside-more-stats summary:hover {
    color: rgb(15 23 42);
}

.author-aside-more-stats ul {
    margin: 0.5rem 0 0.125rem;
    padding: 0;
    list-style: none;
}

.author-aside-more-stats li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.2rem 0;
    border-top: 1px solid rgb(226 232 240);
}

.author-aside-more-stats li:first-child {
    border-top: none;
    padding-top: 0;
}

.author-aside-more-stats li span:last-child {
    font-weight: 600;
    color: rgb(51 65 85);
}

.author-aside-meta li {
    line-height: 1.4;
}

.author-aside-report {
    display: block;
    width: 100%;
    text-align: left;
}

.author-tab-nav {
    gap: 0.25rem;
}

.author-tab-link {
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(100 116 139);
    text-decoration: none;
}

.author-tab-link:hover {
    color: rgb(51 65 85);
}

.author-tab-link.is-active {
    border-bottom-color: rgb(79 70 229);
    color: rgb(49 46 129);
    font-weight: 600;
}

@media (min-width: 1024px) {
    .author-profile-main .story-grid-popular,
    .discovery-listing .story-grid-popular--sidebar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Explore / discovery filter capsules */
.discovery-filter-chip {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.discovery-filter-chip:focus-visible {
    outline: 2px solid rgb(99 102 241);
    outline-offset: 2px;
}

.discovery-filters section {
    display: block;
}

.discovery-filter-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-content: flex-start;
}

/* Popular stories — compact 5-column row */
@media (min-width: 1024px) {
    .story-grid-popular {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.story-book-card--compact .story-book-cover-link img,
.story-book-card--compact .story-book-cover-link > div[role='img'] {
    max-height: 10.25rem;
    width: 100%;
    object-fit: cover;
}

/* Book-style story cards */
.story-book-card-shell {
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.story-book-cover-link img,
.story-book-cover-link > div[role="img"] {
    transition: transform 0.22s ease;
}

.story-book-card:hover .story-book-card-shell,
.story-book-card:focus-within .story-book-card-shell {
    transform: translateY(-3px);
    box-shadow: 0 14px 28px -14px rgb(15 23 42 / 0.28);
}

.story-book-card:hover .story-book-cover-link img,
.story-book-card:hover .story-book-cover-link > div[role="img"],
.story-book-card:focus-within .story-book-cover-link img,
.story-book-card:focus-within .story-book-cover-link > div[role="img"] {
    transform: scale(1.02);
}

@media (prefers-reduced-motion: reduce) {
    .story-book-card-shell,
    .story-book-cover-link img,
    .story-book-cover-link > div[role="img"] {
        transition: none;
    }

    .story-book-card:hover .story-book-card-shell,
    .story-book-card:focus-within .story-book-card-shell {
        transform: none;
    }

    .story-book-card:hover .story-book-cover-link img,
    .story-book-card:hover .story-book-cover-link > div[role="img"],
    .story-book-card:focus-within .story-book-cover-link img,
    .story-book-card:focus-within .story-book-cover-link > div[role="img"] {
        transform: none;
    }
}

/* Social login — layout via Tailwind in component; normalize buttons/links */
.social-login-btn {
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    line-height: 1.25;
    text-align: center;
}

.social-login .social-login-btn[type="button"]:disabled {
    pointer-events: none;
}

/* Auth screens — allow full-page scroll on long forms (register) */
html:has(.auth-screen) {
    height: auto;
    min-height: 100%;
}

.auth-screen {
    min-height: 100dvh;
}

.auth-main {
    overflow-x: hidden;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.auth-main-inner {
    padding-bottom: 0.5rem;
}

.register-math-captcha {
    margin-top: 0.25rem;
}

.register-math-captcha__inner {
    border-radius: 0.75rem;
    border: 1px solid rgb(226 232 240);
    background: rgb(248 250 252);
    padding: 0.625rem 0.75rem;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.8);
}

.register-math-captcha__row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.register-math-captcha__badge {
    display: flex;
    height: 2.25rem;
    width: 2.25rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgb(79 70 229);
    color: rgb(255 255 255);
}

.register-math-captcha__prompt {
    display: flex;
    flex-shrink: 0;
    align-items: baseline;
    gap: 0.35rem;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1;
    color: rgb(15 23 42);
    white-space: nowrap;
}

.register-math-captcha__num {
    font-variant-numeric: tabular-nums;
}

.register-math-captcha__op {
    color: rgb(79 70 229);
}

.register-math-captcha__eq {
    color: rgb(100 116 139);
}

.register-math-captcha__input {
    box-sizing: border-box;
    width: 4.25rem;
    min-width: 4.25rem;
    flex-shrink: 0;
    margin-inline-start: auto;
    border-radius: 0.5rem;
    border: 1px solid rgb(203 213 225);
    background: rgb(255 255 255);
    padding: 0.5rem 0.375rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.0625rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: rgb(15 23 42);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.register-math-captcha__input::placeholder {
    font-weight: 600;
    color: rgb(148 163 184);
}

.register-math-captcha__input:focus {
    border-color: rgb(99 102 241);
    outline: none;
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.25);
}

.register-math-captcha__refresh {
    display: flex;
    height: 2.25rem;
    width: 2.25rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px solid rgb(226 232 240);
    background: rgb(255 255 255);
    color: rgb(79 70 229);
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.register-math-captcha__refresh:hover {
    border-color: rgb(199 210 254);
    background: rgb(238 242 255);
}

.register-math-captcha__error {
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: rgb(220 38 38);
}

.register-math-captcha__hint {
    margin: 0.375rem 0 0;
    font-size: 0.6875rem;
    line-height: 1.35;
    color: rgb(100 116 139);
}

.register-math-captcha__input::-webkit-outer-spin-button,
.register-math-captcha__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.register-math-captcha__input[type='number'] {
    -moz-appearance: textfield;
}

/* Story reader — open-book layout, paginated pages (not scrollable) */
.is-story-page {
    background: linear-gradient(165deg, #e8e4dc 0%, #f4f1ea 35%, #ebe6dd 100%);
}

.story-book-reader {
    font-family: Georgia, 'Times New Roman', Times, serif;
}

.story-reader-localized {
    font-family: inherit;
}

.story-book-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
}

@media (max-width: 1023px) {
    .story-book-sidebar {
        order: -1;
        font-family: system-ui, -apple-system, Segoe UI, sans-serif;
    }
}

@media (min-width: 1024px) {
    .story-book-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 1.25rem;
    }

    .story-book-stage {
        flex: 1 1 auto;
        min-width: 0;
    }

    .story-book-sidebar {
        flex: 0 0 17.5rem;
        width: 17.5rem;
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
        font-family: system-ui, -apple-system, Segoe UI, sans-serif;
    }
}

.story-book-sidebar-card {
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.92);
    padding: 1rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.story-book-sidebar-card + .story-book-sidebar-card,
.story-book-sidebar-card + .story-engagement-muted,
.story-engagement-muted + .story-book-sidebar-card,
.story-book-sidebar-follow + .story-book-sidebar-card,
.story-book-sidebar-card.story-engagement-muted {
    margin-top: 0.75rem;
}

.story-book-sidebar-heading {
    margin: 0 0 0.35rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #334155;
}

.story-book-sidebar-lead {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    line-height: 1.45;
    color: #64748b;
}

.story-book-sidebar-foot {
    margin: 0.75rem 0 0;
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
}

.story-book-sidebar-primary-btn {
    display: block;
    width: 100%;
    border-radius: 0.5rem;
    background: #4f46e5;
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
    padding: 0.55rem 0.75rem;
    text-decoration: none;
}

.story-book-sidebar-primary-btn:hover {
    background: #4338ca;
}

.story-book-sidebar-outline-btn {
    display: inline-block;
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
}

.story-book-sidebar-outline-btn:hover {
    background: #f8fafc;
}

.story-book-sidebar .story-engagement-muted {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.92);
    padding: 1rem;
    border-radius: 0.75rem;
}

.story-book-sidebar .story-engagement-muted #btn-like,
.story-book-sidebar .story-engagement-muted #btn-bookmark {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
}

.story-share-compact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.story-share-compact-btn {
    display: inline-flex;
    min-height: 2.5rem;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: 0.5rem;
    background: #fff;
    padding: 0.35rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #475569;
    box-shadow: inset 0 0 0 1px #e2e8f0;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.story-share-compact-btn:hover {
    background: #f8fafc;
}

.story-share-compact-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-book-stage {
    perspective: 1400px;
    padding: 0.25rem 0 1rem;
}

@media (min-width: 1024px) {
    .story-book-stage {
        padding-bottom: 0;
    }
}

.story-book-spread {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0 auto;
    max-width: 56rem;
    width: 100%;
    border-radius: 0.5rem 1.25rem 1.25rem 0.5rem;
    box-shadow:
        0 4px 6px rgba(15, 23, 42, 0.06),
        0 24px 48px rgba(15, 23, 42, 0.14),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    overflow: hidden;
    background: #faf6ef;
}

@media (min-width: 768px) {
    .story-book-spread {
        flex-direction: row;
        min-height: min(78vh, 42rem);
    }
}

@media (min-width: 1024px) {
    .story-book-spread {
        max-width: none;
        margin: 0;
    }
}

.story-book-cover-panel {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c2419 0%, #4a3f32 100%);
    padding: 1.25rem 1rem;
}

@media (min-width: 768px) {
    .story-book-cover-panel {
        width: auto;
        min-width: 10.5rem;
        max-width: 14rem;
        padding: 1.75rem 1rem 1.75rem 1.35rem;
        align-self: stretch;
    }
}

.story-book-cover-inner {
    position: relative;
    width: min(11.5rem, 46vw);
    aspect-ratio: 2 / 3;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 0 0.35rem 0.35rem 0;
    box-shadow: 8px 12px 28px rgba(0, 0, 0, 0.45);
}

@media (min-width: 768px) {
    .story-book-cover-inner {
        width: 100%;
        max-width: 12.5rem;
        margin: auto 0;
    }
}

.story-book-cover-img,
.story-book-cover-inner img,
.story-book-cover-inner > div[role='img'] {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    object-position: center;
}

.story-book-cover-inner > div[role='img'] {
    min-height: 0;
}

.story-book-spine {
    position: absolute;
    top: 4%;
    bottom: 4%;
    left: -4px;
    width: 10px;
    border-radius: 2px 0 0 2px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.25));
    pointer-events: none;
}

.story-book-page-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.04) 0, transparent 12px),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1.45rem,
            rgba(148, 163, 184, 0.07) 1.45rem,
            rgba(148, 163, 184, 0.07) calc(1.45rem + 1px)
        ),
        #fdfbf7;
    border-left: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: inset 12px 0 24px -18px rgba(15, 23, 42, 0.2);
}

.story-book-page-header {
    flex-shrink: 0;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.story-book-title {
    margin: 0;
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: clamp(1.25rem, 2.5vw, 1.65rem);
    font-weight: 700;
    line-height: 1.2;
    color: #1e293b;
}

.story-book-byline {
    margin: 0.5rem 0 0;
    font-family: system-ui, sans-serif;
    font-size: 0.8125rem;
    color: #64748b;
}

.story-book-author-link {
    font-weight: 600;
    color: #4338ca;
    text-decoration: none;
}

.story-book-author-link:hover {
    text-decoration: underline;
}

.story-book-meta-dot {
    margin: 0 0.35rem;
}

.story-book-viewport {
    flex: 1 1 auto;
    min-height: 16rem;
    max-height: min(48vh, 26rem);
    overflow: hidden;
    overscroll-behavior: none;
    padding: 1rem 1.5rem 0.5rem;
    outline: none;
}

@media (min-width: 768px) {
    .story-book-spread {
        height: min(78vh, 42rem);
        max-height: min(78vh, 42rem);
        min-height: min(78vh, 42rem);
    }

    .story-book-page-panel {
        height: 100%;
    }

    .story-book-viewport {
        flex: 1 1 auto;
        min-height: 14rem;
        max-height: none;
    }
}

.story-book-pages {
    position: relative;
    height: 100%;
    overflow: hidden;
}

.story-book-page {
    position: absolute;
    inset: 0;
    overflow: hidden;
    margin: 0;
    overflow-y: hidden;
}

.story-book-page[hidden] {
    display: none !important;
}

.story-book-page.prose {
    overflow: hidden;
}

.story-book-page p:first-child {
    margin-top: 0;
}

.story-book-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem 1.25rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    font-family: system-ui, sans-serif;
}

.story-book-nav-btn {
    flex-shrink: 0;
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.story-book-nav-btn:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #94a3b8;
}

.story-book-nav-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.story-book-progress-wrap {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.story-book-progress-track {
    height: 4px;
    margin: 0 auto 0.35rem;
    max-width: 12rem;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.story-book-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.story-book-page-label {
    margin: 0;
    font-size: 0.75rem;
    color: #64748b;
}

.story-book-source--measuring {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
    width: min(100%, 36rem);
    left: -9999px;
}

.story-book-more summary::-webkit-details-marker {
    display: none;
}

.story-book-more summary::after {
    content: ' ▾';
    font-size: 0.75rem;
    color: #94a3b8;
}

.story-book-more[open] summary::after {
    content: ' ▴';
}

.story-book-more .story-content.prose img {
    border-radius: 0.375rem;
}

@media (max-height: 720px) {
    .auth-card {
        padding: 1rem !important;
    }

    .auth-card h1 {
        margin-bottom: 0.625rem !important;
        font-size: 1.125rem !important;
    }

    .auth-card form.space-y-3 > * + *,
    .auth-card form.space-y-4 > * + * {
        margin-top: 0.625rem !important;
    }

    .auth-card input {
        padding-top: 0.375rem !important;
        padding-bottom: 0.375rem !important;
    }

    .social-login {
        margin-top: 0.5rem !important;
    }

    .social-login-grid .social-login-btn {
        padding-top: 0.375rem !important;
        padding-bottom: 0.375rem !important;
    }
}
