:root {
    --app-paper: #f4efe3;
    --app-paper-text: #302b26;
    --app-sepia: #e9ddc5;
    --app-sepia-text: #342b21;
    --app-night: #151719;
    --app-night-text: #d7d4ce;
}

::selection {
    background: #2563eb;
    color: #fff;
}

body {
    background: #f5f7fb;
}

.guest-page {
    background:
        radial-gradient(circle at 20% 20%, rgba(32, 107, 196, .12), transparent 35%),
        radial-gradient(circle at 80% 80%, rgba(130, 90, 44, .09), transparent 35%),
        #f4f6fa;
}

.app-navbar {
    background: #fff;
    box-shadow: 0 1px 0 rgba(35, 46, 60, .08);
}

.app-empty-card {
    min-height: 340px;
    justify-content: center;
}

.novel-card {
    transition: transform .16s ease, box-shadow .16s ease;
}

.novel-card:hover {
    box-shadow: 0 8px 28px rgba(35, 46, 60, .12);
    transform: translateY(-2px);
}

.novel-cover {
    align-items: center;
    background: linear-gradient(145deg, #315d8c, #1d3654);
    border-radius: .35rem .6rem .6rem .35rem;
    box-shadow: inset 4px 0 rgba(255, 255, 255, .12), 0 5px 12px rgba(35, 46, 60, .2);
    color: #fff;
    display: flex;
    flex: 0 0 70px;
    font-family: Georgia, "Noto Serif KR", serif;
    font-size: 1.75rem;
    font-weight: 700;
    height: 96px;
    justify-content: center;
}

.novel-description {
    display: -webkit-box;
    min-height: 2.7em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.novel-content-input {
    font-family: "Noto Serif KR", Georgia, serif;
    line-height: 1.8;
    resize: vertical;
}

.novel-form-heading {
    align-items: flex-end;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.novel-form-heading .page-title {
    font-size: 1.65rem;
    letter-spacing: -.035em;
}

.novel-form-eyebrow {
    color: #206bc4;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .14em;
    margin-bottom: .45rem;
}

.novel-editor-card {
    border: 0;
    box-shadow: 0 10px 35px rgba(35, 46, 60, .08), 0 1px 2px rgba(35, 46, 60, .04);
    overflow: visible;
}

.novel-form-section {
    padding: 2rem 2.25rem;
    position: relative;
}

.novel-form-section + .novel-form-section {
    border-top: 1px solid #edf0f5;
}

.novel-section-heading {
    align-items: flex-start;
    display: flex;
    gap: .9rem;
    margin-bottom: 1.5rem;
}

.novel-section-heading h3,
.novel-input-title h4 {
    color: #182433;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0;
}

.novel-section-heading p,
.novel-input-title p,
.novel-edit-notice p {
    color: var(--tblr-secondary-color);
    font-size: .82rem;
    margin: .25rem 0 0;
}

.novel-step {
    align-items: center;
    background: #206bc4;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(32, 107, 196, .24);
    color: #fff;
    display: inline-flex;
    flex: 0 0 30px;
    font-size: .78rem;
    font-weight: 700;
    height: 30px;
    justify-content: center;
}

.novel-format-control {
    height: 1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

.novel-format-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.novel-format-card {
    align-items: center;
    background: #fff;
    border: 1px solid #dfe3ea;
    border-radius: .75rem;
    cursor: pointer;
    display: flex;
    gap: 1rem;
    min-height: 104px;
    padding: 1.15rem;
    position: relative;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.novel-format-card:hover {
    border-color: #90b5df;
    box-shadow: 0 7px 20px rgba(32, 107, 196, .09);
    transform: translateY(-1px);
}

.novel-format-icon,
.novel-input-icon {
    align-items: center;
    background: #eaf3fc;
    border-radius: .65rem;
    color: #206bc4;
    display: inline-flex;
    flex: 0 0 46px;
    height: 46px;
    justify-content: center;
}

.novel-format-icon svg,
.novel-input-icon svg {
    height: 24px;
    width: 24px;
}

.novel-format-icon-series,
.novel-input-icon-paste {
    background: #f0ebfb;
    color: #7950c5;
}

.novel-format-copy {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.novel-format-copy strong {
    color: #182433;
    font-size: .98rem;
}

.novel-format-copy small {
    color: var(--tblr-secondary-color);
    line-height: 1.5;
    margin-top: .28rem;
}

.novel-format-check {
    align-items: center;
    background: #206bc4;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #206bc4;
    color: #fff;
    display: flex;
    font-size: .7rem;
    height: 20px;
    justify-content: center;
    opacity: 0;
    position: absolute;
    right: .85rem;
    top: .85rem;
    transform: scale(.7);
    transition: opacity .15s ease, transform .15s ease;
    width: 20px;
}

#format-single:checked ~ .novel-format-grid label[for="format-single"],
#format-series:checked ~ .novel-format-grid label[for="format-series"] {
    background: linear-gradient(135deg, rgba(32, 107, 196, .075), rgba(255, 255, 255, .96));
    border-color: #206bc4;
    box-shadow: 0 0 0 1px rgba(32, 107, 196, .08), 0 8px 24px rgba(32, 107, 196, .1);
}

#format-single:checked ~ .novel-format-grid label[for="format-single"] .novel-format-check,
#format-series:checked ~ .novel-format-grid label[for="format-series"] .novel-format-check {
    opacity: 1;
    transform: scale(1);
}

#format-single:focus-visible ~ .novel-format-grid label[for="format-single"],
#format-series:focus-visible ~ .novel-format-grid label[for="format-series"] {
    outline: 3px solid rgba(32, 107, 196, .24);
    outline-offset: 2px;
}

#format-series:checked ~ [data-single-content] {
    display: none !important;
}

#format-series:checked ~ [data-series-content] {
    display: block !important;
}

#format-single:checked ~ [data-series-content] {
    display: none !important;
}

.novel-format-panel {
    border-top: 1px dashed #dfe3ea;
    margin-top: 2rem;
    padding-top: 2rem;
}

.novel-content-heading {
    margin-bottom: 1.25rem;
}

.novel-input-panel {
    background: #fafbfd;
    border: 1px solid #e2e6ed;
    border-radius: .75rem;
    padding: 1.25rem;
}

.novel-input-title {
    align-items: center;
    display: flex;
    gap: .85rem;
    margin-bottom: 1rem;
}

.novel-file-zone {
    align-items: center;
    background: #fff;
    border: 1px dashed #b7c1cf;
    border-radius: .6rem;
    color: var(--tblr-secondary-color);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: .65rem;
    justify-content: center;
    min-height: 165px;
    padding: 1.25rem;
    text-align: center;
    transition: background .15s ease, border-color .15s ease;
}

.novel-file-zone:hover,
.novel-file-zone.is-selected {
    background: #f1f7fd;
    border-color: #206bc4;
}

input.visually-hidden[data-file-input]:focus-visible + .novel-file-zone {
    outline: 3px solid rgba(32, 107, 196, .24);
    outline-offset: 2px;
}

.novel-file-action {
    background: #206bc4;
    border-radius: .45rem;
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    padding: .5rem .85rem;
}

.novel-file-zone-inline {
    flex-direction: row;
    justify-content: flex-start;
    min-height: 68px;
    overflow: hidden;
    padding: .8rem;
    text-align: left;
}

.novel-file-zone-inline [data-file-name] {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.novel-content-method-panel {
    display: flex;
    flex-direction: column;
}

.novel-method-label {
    font-size: .76rem;
    margin: 1rem 0 .45rem;
}

.novel-content-method-panel .novel-content-input {
    flex: 1;
    min-height: 280px;
}

.novel-content-method-panel .novel-input-meta {
    gap: .75rem;
    margin-top: auto;
    padding-top: .7rem;
}

.novel-input-panel .novel-content-input {
    background: #fff;
    border-color: #dfe3ea;
    min-height: 165px;
    padding: 1rem;
}

.novel-input-panel .novel-content-input:focus {
    border-color: #90b5df;
    box-shadow: 0 0 0 .2rem rgba(32, 107, 196, .1);
}

.novel-input-meta {
    color: var(--tblr-secondary-color);
    display: flex;
    font-size: .72rem;
    justify-content: space-between;
    margin-top: .7rem;
}

.novel-input-meta strong {
    color: #206bc4;
    font-weight: 700;
}

.novel-series-guide {
    background: linear-gradient(135deg, #f7faff, #fbf9ff);
    border: 1px solid #dce7f4;
    border-radius: .75rem;
    margin-top: 2rem;
    padding: 1.5rem;
}

.novel-series-guide .novel-content-heading {
    margin-bottom: 1.5rem;
}

.novel-series-steps {
    align-items: center;
    display: grid;
    gap: .8rem;
    grid-template-columns: 1fr auto 1fr auto 1fr;
}

.novel-series-steps > div {
    align-items: center;
    display: grid;
    gap: .25rem .65rem;
    grid-template-columns: auto 1fr;
}

.novel-series-steps div > span {
    align-items: center;
    background: #fff;
    border: 1px solid #bdd1e8;
    border-radius: 50%;
    color: #206bc4;
    display: flex;
    font-size: .75rem;
    font-weight: 700;
    grid-row: 1 / span 2;
    height: 32px;
    justify-content: center;
    width: 32px;
}

.novel-series-steps strong {
    color: #182433;
    font-size: .82rem;
}

.novel-series-steps small {
    color: var(--tblr-secondary-color);
    line-height: 1.35;
}

.novel-series-steps > i {
    color: #9eabb9;
    font-style: normal;
}

.novel-edit-notice {
    align-items: center;
    background: #f6f9fc;
    border: 1px solid #dce5ef;
    border-radius: .75rem;
    display: flex;
    gap: 1rem;
    padding: 1.15rem;
}

.novel-edit-notice strong {
    color: #182433;
}

.novel-form-footer {
    align-items: center;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, .94);
    border-radius: 0 0 var(--tblr-card-border-radius) var(--tblr-card-border-radius);
    display: flex;
    min-height: 70px;
    padding: .85rem 2.25rem;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.episode-list-item {
    padding-bottom: 1rem;
    padding-top: 1rem;
}

.member-menu {
    min-width: 260px;
}

.reader-page {
    background: var(--app-paper);
    color: var(--app-paper-text);
    margin: 0;
    transition: background .2s ease, color .2s ease;
}

html[data-reader-theme="sepia"] .reader-page {
    background: var(--app-sepia);
    color: var(--app-sepia-text);
}

html[data-reader-theme="night"] .reader-page {
    background: var(--app-night);
    color: var(--app-night-text);
}

.reader-toolbar {
    align-items: center;
    backdrop-filter: blur(14px);
    background: rgba(244, 239, 227, .92);
    border-bottom: 1px solid rgba(48, 43, 38, .12);
    display: flex;
    gap: .75rem;
    height: 58px;
    left: 0;
    padding: max(.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left));
    position: fixed;
    right: 0;
    top: 0;
    z-index: 20;
}

html[data-reader-theme="sepia"] .reader-toolbar {
    background: rgba(233, 221, 197, .92);
}

html[data-reader-theme="night"] .reader-toolbar {
    background: rgba(21, 23, 25, .94);
    border-bottom-color: rgba(255, 255, 255, .1);
}

.reader-back,
.reader-actions a,
.reader-actions button {
    align-items: center;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: .4rem;
    color: inherit;
    display: inline-flex;
    height: 36px;
    justify-content: center;
    min-width: 36px;
    opacity: .78;
    padding: 0 .65rem;
    text-decoration: none;
}

.reader-back:hover,
.reader-actions a:hover,
.reader-actions button:hover {
    color: inherit;
    opacity: 1;
}

.reader-heading {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.reader-heading strong,
.reader-heading span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-heading span {
    font-size: .75rem;
    opacity: .65;
}

.reader-actions {
    display: flex;
    gap: .35rem;
}

.reader-progress {
    background: rgba(0, 0, 0, .08);
    height: 3px;
    left: 0;
    position: fixed;
    right: 0;
    top: 58px;
    z-index: 21;
}

.reader-progress > div {
    background: #206bc4;
    height: 100%;
    transition: width .15s linear;
}

.reader-content {
    min-height: 100vh;
    padding: 96px 20px 30vh;
}

.reader-article {
    font-family: "Noto Serif KR", "Nanum Myeongjo", Georgia, serif;
    font-size: 19px;
    line-height: 2;
    margin: 0 auto;
    max-width: 760px;
    overflow-wrap: break-word;
    word-break: keep-all;
}

.reader-title-block {
    border-bottom: 1px solid currentColor;
    margin-bottom: 4rem;
    opacity: .88;
    padding: 10vh 0 3rem;
    text-align: center;
}

.reader-title-block h1 {
    font-size: clamp(1.65em, 6vw, 2.3em);
    letter-spacing: -.04em;
    line-height: 1.35;
    margin: .5rem 0;
    overflow-wrap: anywhere;
    text-wrap: balance;
    word-break: keep-all;
}

.reader-title-block p {
    margin: 0;
    opacity: .7;
}

.reader-block {
    margin: 0 0 1.65em;
    white-space: normal;
}

.reader-block.reader-current {
    scroll-margin-top: 85px;
}

.reader-end {
    font-size: .8em;
    letter-spacing: .5em;
    opacity: .45;
    padding: 15vh 0 5vh;
    text-align: center;
}

.reader-next {
    border: 1px solid currentColor;
    border-radius: .5rem;
    color: inherit;
    display: inline-block;
    letter-spacing: 0;
    margin-top: 2rem;
    padding: .65rem 1rem;
    text-decoration: none;
}

.reader-end-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    justify-content: center;
    letter-spacing: 0;
    margin-top: 2rem;
}

.reader-end-actions .reader-next {
    margin-top: 0;
}

.reader-page-indicator {
    display: none;
}

html[data-reader-mode="page"] .reader-page {
    overflow: hidden;
}

html[data-reader-mode="page"] .reader-content {
    box-sizing: border-box;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 86px 5vw 24px;
    position: relative;
    scrollbar-width: none;
    touch-action: pan-y;
}

html[data-reader-mode="page"] .reader-content::-webkit-scrollbar {
    display: none;
}

.reader-page-trailing-space {
    display: none;
}

html[data-reader-mode="page"] .reader-page-trailing-space {
    display: block;
    height: 1px;
    pointer-events: none;
    position: absolute;
    top: 0;
}

html[data-reader-mode="page"] .reader-article {
    box-sizing: content-box;
    column-fill: auto;
    column-gap: var(--reader-column-gap, 56px);
    column-width: var(--reader-column-width, 640px);
    height: calc(100vh - 110px);
    height: calc(100dvh - 110px);
    margin: 0;
    max-width: none;
    width: var(--reader-spread-width, 640px);
}

html[data-reader-mode="page"] .reader-title-block {
    break-after: column;
    margin-bottom: 0;
    padding: 8vh 1rem 3rem;
}

html[data-reader-mode="page"] .reader-block {
    margin-bottom: 1.4em;
}

html[data-reader-mode="page"] .reader-end {
    break-inside: avoid;
    padding: 8vh 0 2vh;
}

html[data-reader-mode="page"] .reader-page-indicator {
    background: rgba(20, 22, 24, .72);
    border-radius: 999px;
    bottom: calc(.65rem + env(safe-area-inset-bottom));
    color: #fff;
    display: block;
    font-size: .72rem;
    left: 50%;
    padding: .25rem .65rem;
    position: fixed;
    transform: translateX(-50%);
    z-index: 15;
}

.reader-toast {
    background: rgba(20, 22, 24, .9);
    border-radius: 999px;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    color: #fff;
    left: 50%;
    opacity: 0;
    padding: .6rem 1rem;
    pointer-events: none;
    position: fixed;
    transform: translate(-50%, 12px);
    transition: opacity .2s ease, transform .2s ease;
    z-index: 30;
}

.reader-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 767.98px) {
    .novel-form-heading {
        align-items: flex-start;
    }

    .novel-form-heading .btn {
        font-size: 0;
        padding-left: .65rem;
        padding-right: .65rem;
    }

    .novel-form-heading .btn .icon {
        margin: 0 !important;
    }

    .novel-form-section {
        padding: 1.35rem 1.15rem;
    }

    .novel-format-grid {
        grid-template-columns: 1fr;
    }

    .novel-format-card {
        min-height: 92px;
        padding: 1rem;
    }

    .novel-series-guide {
        padding: 1.15rem;
    }

    .novel-series-steps {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .novel-series-steps > i {
        margin-left: 15px;
        transform: rotate(90deg);
        width: max-content;
    }

    .novel-form-footer {
        padding: .75rem 1rem;
    }

    .novel-form-footer .d-flex {
        width: 100%;
    }

    .novel-form-footer .btn-primary {
        flex: 1;
    }

    .reader-toolbar {
        gap: .4rem;
        padding-left: .6rem;
        padding-right: .6rem;
    }

    .reader-heading span,
    .reader-actions [data-font-down] {
        display: none;
    }

    .reader-actions button {
        font-size: .8rem;
        padding: 0 .5rem;
    }

    .reader-actions .reader-mode-button {
        min-width: 48px;
    }

    .reader-content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .reader-article {
        font-size: 18px;
        line-height: 1.95;
        word-break: normal;
    }

    .reader-title-block {
        padding-top: 5vh;
    }

    html[data-reader-mode="page"] .reader-content {
        padding-left: 18px;
        padding-right: 18px;
    }

}
