/* キャラ紹介はチャットと共通の画像主体のプロフィールを使う。 */
#profileModal { position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; background: rgba(42, 35, 40, .4); backdrop-filter: none; }
#profileModal .profile-modal-content { width: 100%; max-width: 430px; max-height: calc(100dvh - 32px); border-radius: 12px; }
#profileModal .profile-modal-header { min-height: 0; height: min(clamp(480px, 76dvh, 720px), calc(100dvh - 32px - env(safe-area-inset-bottom, 0px))); box-sizing: border-box; }
#profileModal .profile-modal-header-info { min-width: 0; overflow-wrap: anywhere; }
#profileModal .modal-close-button { width: 44px; height: 44px; }
#profileModal .modal-close-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#profileModal .profile-modal-chat-link { display: flex; width: 100%; min-height: 44px; box-sizing: border-box; margin-top: 12px; font-size: 13px; }


#toastContainer {
    position: fixed;
    right: 18px;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 13px 16px;
    border-radius: 14px;
    color: #fff;
    font-size: 0.92rem;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.3s ease;
    box-shadow: 0 10px 26px rgba(42, 35, 40, 0.14);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: #42a85a;
}

.toast.error {
    background: #df4c59;
}


@media (max-width: 520px) {
    .novel-reader-page .novel-page-container { max-width: none; }
}
.novel-reader-header { position: sticky; top: 0; z-index: 110; background: var(--novel-surface); }
.novel-reader-header .app-header { position: static; }
.novel-reader-header #appHeaderRoot, .novel-reader-header .app-header { display: none; }
.novel-detail-navigation { position: static; }
.novel-detail-navigation-inner { display: flex; align-items: center; width: 100%; max-width: 450px; min-height: 48px; box-sizing: border-box; margin: 0 auto; padding: 2px 8px; }
.novel-detail-navigation.has-title .novel-detail-navigation-inner { background: var(--novel-surface); }
.novel-detail-scroll-title { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--novel-text); font-size: .86rem; font-weight: 800; line-height: 1.35; text-align: center; text-overflow: ellipsis; white-space: nowrap; visibility: hidden; }
.novel-detail-navigation.has-title .novel-detail-scroll-title { visibility: visible; }
.novel-detail-navigation a { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; height: 44px; color: var(--novel-text); text-decoration: none; }
.novel-detail-navigation svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.novel-page-container { width: 100%; max-width: 450px; box-sizing: border-box; margin: 0 auto; padding: 0 20px 40px; }
.novel-main-content, .novel-reading-surface { display: flex; flex-direction: column; }
.novel-main-content { gap: 8px; }
.novel-reading-surface { gap: 8px; }
.novel-reader-characters { display: flex; align-items: center; gap: 12px; min-width: 0; }
.novel-reader-characters .novel-name-control { flex: 0 1 auto; min-width: 0; margin-left: auto; }
.novel-hero { padding: 0; background: var(--novel-surface); }
.novel-hero-layout { display: flex; align-items: flex-start; gap: 16px; }
.novel-hero-titles { flex: 1; min-width: 0; }
.novel-work-title { margin: 0 0 8px; color: var(--text-primary); font-size: 20px; font-weight: 800; line-height: 1.5; overflow-wrap: anywhere; }
.novel-work-title[hidden] { display: none; }
.novel-hero-titles:has(.novel-work-title:not([hidden])) #novelTitle { font-size: 13px; font-weight: 500; line-height: 1.6; }
.novel-episode-heading { min-width: 0; }
.novel-episode-heading:has(.novel-episode-number:not([hidden])) { color: var(--text-secondary); font-size: 13px; font-weight: 500; line-height: 1.6; }
.novel-episode-heading:has(.novel-episode-number:not([hidden])) #novelTitle { display: inline; color: inherit; font: inherit; }
.novel-episode-number { display: inline; margin: 0 6px 0 0; color: inherit; font: inherit; white-space: nowrap; }
.novel-episode-number[hidden] { display: none; }
#novelTitle { flex: 1; min-width: 0; margin: 0; color: var(--text-primary); font-size: 1.35rem; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.novel-hero-cover { order: -1; flex: 0 0 72px; width: 72px; margin: 0; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 8px; background: var(--novel-control-bg); }
.novel-hero-cover-image { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.novel-hero-has-cover-image { margin: 0 -20px 6px; }
.novel-hero-has-cover-image .novel-hero-layout { position: relative; isolation: isolate; overflow: hidden; width: 100%; min-height: 560px; aspect-ratio: 3 / 5; background: #2a2328; }
.novel-hero-has-cover-image .novel-hero-cover { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; aspect-ratio: auto; border-radius: 0; }
.novel-hero-has-cover-image .novel-hero-layout::after { content: ''; position: absolute; inset: 38% 0 0; z-index: 1; background: linear-gradient(to top, rgba(12,8,11,.84) 0%, rgba(12,8,11,.48) 52%, rgba(12,8,11,0) 100%); pointer-events: none; }
.novel-hero-has-cover-image .novel-hero-titles { position: relative; align-self: flex-end; z-index: 2; }
.novel-hero-has-cover-image #novelTitle { position: relative; align-self: flex-end; z-index: 2; padding: 18px 20px 20px; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.62); }
.novel-tags { display: flex; gap: 6px; overflow-x: auto; margin: -8px -16px 16px; padding: 0 16px; scrollbar-width: none; }
.novel-tags::-webkit-scrollbar { display: none; }
.novel-tag { display: inline-flex; align-items: center; flex-shrink: 0; min-height: 44px; font-size: 11px; line-height: 1.8; color: var(--text-secondary); text-decoration: none; }
.novel-tag::before { content: '#'; }
.novel-reader-body { font-size: 16px; line-height: 2; letter-spacing: .01em; overflow-wrap: anywhere; }
.novel-reader-body p { margin: 0 0 1.55em; }
.novel-reader-body p:last-child { margin-bottom: 0; }
.novel-text-skeleton { height: 200px; background: repeating-linear-gradient(var(--novel-control-bg) 0 9px, transparent 9px 32px); border-radius: 4px; }
.novel-hero-supporting-section { flex: 1 1 0; min-width: 0; }
.novel-hero-supporting-casts { display: flex; gap: 8px; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; }
.novel-hero-supporting-casts::-webkit-scrollbar { display: none; }
.novel-hero-supporting-card { display: flex; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; font: inherit; }
.novel-hero-supporting-image { display: block; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: top; }
.novel-post-actions { display: flex; flex-direction: column; gap: 8px; padding: 0; }
.post-action-cta-card { min-width: 0; background: transparent; }
.post-action-button-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.post-action-primary, .post-action-secondary, .post-action-like-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; box-sizing: border-box; padding: 10px 14px; border: 0; border-radius: 8px; background: var(--novel-control-bg); color: var(--text-primary); font: inherit; font-size: 12px; text-decoration: none; }
.post-action-secondary { background: var(--novel-control-bg); font-size: 13px; font-weight: 700; }
.post-action-like-area { margin: 0; }
.post-action-reaction-buttons { display: flex; gap: 16px; }
.post-action-reaction-buttons .post-action-like-button { gap: 8px; padding: 10px 14px; border: 1px solid var(--border-color, #e4e0e3); background: transparent; color: var(--text-secondary); font-size: 13px; }
.post-action-reaction-buttons .post-action-like-button[aria-pressed="true"] { border-color: currentColor; background: rgba(246,87,181,.06); color: var(--primary-accent); font-weight: 700; }
.novel-like-icon { flex-shrink: 0; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.post-action-like-button[aria-pressed="true"] .novel-like-icon { fill: currentColor; }
.post-action-like-button:disabled { opacity: .5; }
.novel-section-title { margin: 0 0 12px; padding: 0; font-size: 15px; }
.novel-related-novels-section { content-visibility: auto; contain-intrinsic-size: auto 240px; }
.novel-related-novels { display: flex; gap: 12px; overflow-x: auto; padding: 0 0 8px; scrollbar-width: none; }
.novel-related-novels::-webkit-scrollbar { display: none; }
.novel-poster-card { position: relative; flex: 0 0 128px; width: 128px; min-width: 0; overflow: hidden; color: inherit; text-decoration: none; }
.novel-card-image { display: block; width: 128px; height: 170px; border-radius: 8px; object-fit: cover; }
.novel-poster-card .card-info { padding: 7px 0; }
.novel-poster-card h4 { margin: 0; padding: 0; font-size: 12px; line-height: 1.6; }
.novel-poster-card .card-info p { margin: 3px 0 0; color: var(--text-secondary); font-size: 10px; }
.novel-card-tags, .card-play-count-badge { display: none; }
.hobby-tags { display: flex; flex-wrap: wrap; gap: 5px; font-size: 10px; }
/* Chat stories use the same dark surface as prose stories. */
.novel-chat-reader .novel-reading-surface { margin: 0 -16px; padding: 0 16px 16px; background: var(--novel-surface); color: var(--text-primary); color-scheme: dark; }
.novel-chat-body { display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 450px; margin: 0 auto; }
.novel-chat-body .message-bubble { display: flex; flex-direction: column; min-width: 0; max-width: 85%; }
.novel-chat-body .cast-message { align-self: flex-start; align-items: flex-start; }
.novel-chat-body .user-message { align-self: flex-end; align-items: flex-end; }
.novel-chat-body .message-content { min-width: 0; max-width: 100%; box-sizing: border-box; padding: 8px 15px; border-radius: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.novel-chat-body .cast-message .message-content { background: var(--novel-selected-bg); }
.novel-chat-body .user-message .message-content { background: #69334f; }
.novel-chat-body .message-content p { margin: 0; color: var(--text-primary); font-size: 14px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.novel-chat-body .sender-info { display: flex; align-items: center; max-width: 100%; margin-bottom: 4px; padding-left: 5px; }
.novel-chat-body .cast-name { color: rgba(255,255,255,.92); font-size: 12px; overflow-wrap: anywhere; }
.novel-chat-body .cast-icon { flex: 0 0 32px; width: 32px; height: 32px; margin-right: 8px; border-radius: 50%; object-fit: cover; object-position: top; }
.novel-chat-body .novel-chat-initial { display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; font-size: 13px; font-weight: 700; }
.novel-chat-body .chat-narration-notice { align-self: stretch; width: 100%; max-width: none; margin: 0; color: rgba(255,255,255,.9); }
.novel-chat-body .chat-narration-notice .message-content { padding: 3px 10px; border-left: 2px solid rgba(255,255,255,.32); border-radius: 0; background: transparent; box-shadow: none; }
.novel-chat-body .chat-narration-notice .message-content p { color: inherit; font-size: 13px; font-weight: 400; }
.novel-reader-page button:focus-visible, .novel-reader-page a:focus-visible, .novel-hero-supporting-card:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.novel-related-placeholder { display: block; width: 128px; height: 170px; border-radius: 8px; background: var(--novel-control-bg); }


.novel-name-control { color: var(--text-primary); font-size: 14px; }
.novel-name-summary, .novel-name-editor { display: flex; align-items: center; gap: 4px; }
.novel-name-label { flex-shrink: 0; color: var(--text-secondary); font-size: 12px; }
.novel-chat-reader .novel-name-summary { justify-content: flex-end; }
#novelReaderNameDisplay, #novelLockedNameDisplay { min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
.novel-name-control button { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-primary); font: inherit; font-weight: 600; }
#novelEditName { flex-shrink: 1; gap: 8px; min-width: 0; max-width: 100%; padding: 8px 0; background: transparent; color: var(--text-primary); text-align: left; }
#novelEditName svg { flex-shrink: 0; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.novel-name-control button:active:not(:disabled) { background: var(--novel-control-bg); color: var(--text-primary); }
.novel-name-control button:disabled { opacity: .45; }
.novel-name-editor #novelFinishName { background: var(--text-primary); color: var(--novel-surface); }
.novel-name-summary[hidden], .novel-name-editor[hidden], #novelEditName[hidden] { display: none; }
.novel-name-control label { flex-shrink: 0; color: var(--text-secondary); font-size: 12px; }
.novel-name-control input { min-width: 0; width: 100%; min-height: 44px; box-sizing: border-box; padding: 8px 12px; border: 1px solid var(--text-secondary); border-radius: 8px; background: transparent; color: var(--text-primary); font: inherit; font-size: 16px; }
.novel-name-control input:disabled { background: transparent; color: var(--text-primary); opacity: 1; -webkit-text-fill-color: var(--text-primary); }
.novel-chapter-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.novel-chapter-controls select, .novel-chapter-controls button, .novel-continuation-section button { min-height: 44px; padding: 10px 12px; border: 0; border-radius: 8px; background: var(--novel-control-bg); color: var(--text-primary); font: inherit; font-size: 13px; }
.novel-continuation-section > button, #novelReaderSubmit { width: 100%; }
#novelContinueForm { margin: 0; padding: 16px; border-radius: 12px; background: var(--novel-surface); color: var(--text-primary); color-scheme: dark; }
#novelContinueInputs { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
#novelContinueInputs label { font-size: 13px; font-weight: 700; }
#novelReaderRequest::placeholder { color: var(--text-secondary); opacity: 1; }
#novelReaderRequest { width: 100%; min-height: 100px; box-sizing: border-box; padding: 12px; border: 0; border-radius: 8px; background: var(--novel-control-bg); color: var(--text-primary); font: inherit; font-size: 16px; }
.novel-continue-model { min-width: 0; }
#novelReaderUsage, .novel-reader-status { color: var(--text-secondary); font-size: 12px; }
#novelContinueForm #novelReaderUsage { color: var(--text-secondary); }
.novel-continuation-section button:disabled { opacity: .5; }
.novel-name-control[hidden], .novel-chapter-controls[hidden], .novel-continuation-section[hidden], #novelContinueForm[hidden], #novelStartContinuation[hidden] { display: none; }

.novel-branch-entry { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-secondary); font-size: 12px; text-decoration: none; }
.novel-branch-entry[hidden] { display: none; }

.novel-reader-models { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.novel-reader-models::-webkit-scrollbar { display: none; }
.novel-reader-models button { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; min-height: 44px; padding: 8px 12px; border: 1px solid transparent; border-radius: 999px; background: var(--novel-control-bg); color: var(--text-secondary); font: inherit; font-size: 12px; white-space: nowrap; }
.novel-reader-models button[aria-pressed="true"] { border-color: var(--button-primary-bg, #f657b5); background: var(--novel-selected-bg); color: var(--text-primary); font-weight: 700; }

.novel-reader-model-quota { flex-shrink: 0; padding: 3px 5px; border-radius: 999px; background: var(--novel-selected-bg); color: var(--text-secondary); font-size: 10px; font-weight: 500; line-height: 1.2; }
.novel-reader-model-quota[hidden] { display: none; }

/* Reading and creation share one button style; reactions sit below them. */
.novel-reader-footer { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; --novel-action-bg: var(--novel-control-bg); }
.novel-reader-footer .novel-public-chapter-navigation { margin: 0; }
.novel-reader-footer .novel-reader-action { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; box-sizing: border-box; margin: 0; padding: 10px 14px; border: 0; border-radius: 8px; background: var(--novel-action-bg); color: var(--text-primary); font: inherit; font-size: 13px; font-weight: 500; line-height: 1.5; }
.novel-action-icon { flex-shrink: 0; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.novel-reader-footer #novelStartContinuation, .novel-reader-footer #novelChatWithCast, .novel-reader-footer .post-action-secondary, .novel-reader-footer #novelReaderNext, .novel-reader-footer .novel-public-next { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; box-sizing: border-box; padding: 12px 16px; border: 0; border-radius: 8px; background: var(--novel-action-bg); color: var(--text-primary); font: inherit; font-size: 15px; font-weight: 700; line-height: 1.5; }
.novel-reader-footer #novelStartContinuation .novel-action-icon { order: 1; }
.novel-reader-footer .post-action-secondary { background: var(--novel-action-bg); }
.novel-reader-footer .post-action-secondary .novel-action-icon { order: 1; width: 16px; height: 16px; }
.novel-reader-footer .post-action-like-button { width: auto; background: transparent; color: var(--text-secondary); white-space: nowrap; }
.novel-reader-footer .post-action-reaction-buttons { justify-content: space-between; align-items: center; }
.novel-reader-footer .post-action-like-area { padding: 12px 0; }
.novel-reader-footer .post-action-like-button { margin-left: auto; }
.novel-reader-footer .novel-work-page-link { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 0; box-sizing: border-box; color: var(--text-secondary); font-size: 15px; line-height: 1.5; text-decoration: none; }
.novel-reader-footer .post-action-like-button[aria-pressed="true"] { background: transparent; color: var(--primary-accent); font-weight: 500; }
.novel-reader-footer .novel-reader-action:active:not(:disabled) { background: var(--novel-action-bg); }
/* Primary reading/creation actions match situation detail buttons. */
.novel-reader-footer :is(#novelStartContinuation, #novelChatWithCast, .post-action-secondary, #novelReaderNext, .novel-public-next),
#novelReaderSubmit { background: var(--button-primary-bg, #f657b5); color: #fff; }
.novel-reader-footer :is(#novelStartContinuation, #novelChatWithCast, .post-action-secondary, #novelReaderNext, .novel-public-next):active:not(:disabled),
#novelReaderSubmit:active:not(:disabled) { background: var(--button-primary-hover-bg, #eb45a9); }

.novel-reader-footer .novel-public-next { flex: 1 0 100%; order: -1; }
#novelChatWithCast { text-decoration: none; }
#novelChatWithCast[hidden] { display: none; }
.novel-reader-extras { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.novel-reader-extras:not(:has(.novel-continuation-section:not([hidden]), #novelChatWithCast:not([hidden]))) { display: none; }
.novel-reader-extras .novel-continuation-section:not([hidden]) { display: contents; }
.novel-reader-extras #novelStartContinuation { grid-column: 1; grid-row: 1; }
.novel-reader-extras #novelChatWithCast { grid-column: 2; grid-row: 1; }
.novel-reader-extras #novelContinueForm { grid-column: 1 / -1; grid-row: 2; }
.novel-reader-extras:has(#novelChatWithCast[hidden]) #novelStartContinuation,
.novel-reader-extras:has(.novel-continuation-section[hidden], #novelStartContinuation[hidden]) #novelChatWithCast { grid-column: 1 / -1; }
.novel-reader-footer .novel-reader-extras :is(#novelStartContinuation, #novelChatWithCast) { min-height: 44px; padding: 10px 8px; gap: 6px; font-size: 13px; font-weight: 600; }
