:root {
    --bg-cream: #F8EFD3;
    --accent-peach: #F4CFAE;
    --main-pink: #FF89BC;
    --dark-pink: #E8639D;
    --link-blue: #61B2E4;
    --star-yellow: #FEC501;
    --text-dark: #333333;
    --text-light: #888888;
    --panel-bg: #FFFFFF;
    --border-color: #EFEFEF;
    --badge-red: #F94646;
    --badge-yellow: #FFB300;
    --shadow-gray: #CCCCCC;
    --content-bg-light-gray: #F8F8F8;
    --icon-border-gray: #A9A9A9;
    --divider-gray: #AAAAAA;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scroll */
    font-family: 'Noto Sans SC', sans-serif;
}
#app-wrapper {
    height: 100%;
    overflow-y: auto; /* This is the new main scroll container */
    background-color: var(--bg-cream);
}
body.modal-open #app-wrapper {
    overflow: hidden;
}

/* --- START: UPDATED Notice Styles for Consistency --- */
.notice-wrapper {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 5px;
    box-sizing: border-box;
}
.usage-notice {
    background-color: var(--accent-peach);
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 10px;
}
.notice-wrapper .usage-notice:last-child {
    margin-bottom: 0;
}
.notice-wrapper .usage-notice:last-child .notice-content a {
    color: #c84c5f; 
}
.notice-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 8px;
    font-size: 13px;
    color: var(--text-dark);
    text-align: center;
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.notice-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('https://i.postimg.cc/597xms4f/1762029853049.png');
    background-size: cover;
    background-position: center;
    opacity: 0.6;
    z-index: -1;
    border-radius: 12px;
}
.notice-content p {
    margin: 4px 0;
    line-height: 1.7;
}
.notice-content a {
    color: var(--main-pink);
    font-weight: 500;
    text-decoration: none;
}
.notice-content a:hover {
    text-decoration: underline;
}
/* --- END: UPDATED Notice Styles --- */

.main-container {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 5px 120px 5px; /* Padding to ensure content can scroll above fixed buttons */
    box-sizing: border-box;
}

.panel {
    background: var(--panel-bg);
    padding: 15px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.input-container {
    flex: 1;
    min-width: 380px;
    display: flex;
    flex-direction: column;
}

.preview-container {
    flex: 2;
    min-width: 760px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
        padding-bottom: 120px;
    }
    .input-container, .preview-container {
        min-width: unset;
    }
}

h1, h2 {
    text-align: center;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 22px;
    width: 100%;
    box-sizing: border-box;
}
h1 { display: flex; align-items: center; justify-content: center; }
.help-icon { font-size: 18px; color: #ccc; margin-left: 10px; cursor: pointer; transition: color 0.3s; }
.help-icon:hover { color: var(--main-pink); }

#story-input {
    width: 100%;
    box-sizing: border-box;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
    resize: vertical;
    background-color: #fdfaf3;
    color: var(--text-dark);
    flex-grow: 1;
    min-height: 400px;
    font-family: 'Noto Sans SC', sans-serif;
}
#story-input:focus { outline: none; border-color: var(--main-pink); }

.preview-wrapper {
    width: 100%;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background-color: #fcfcfc;
}

#canvas-scaler {
    transform-origin: top left;
}

#preview-canvas {
    width: 1440px;
    background-color: var(--panel-bg);
    color: var(--text-dark);
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative; /* Added for watermark positioning */
}

[contenteditable="true"]:focus {
    outline: 2px solid var(--main-pink);
    background-color: #fff8fb;
    border-radius: 4px;
}
.description[contenteditable="true"] {
    white-space: pre-wrap; 
}
.comment-role[contenteditable="true"]:focus {
    background-color: var(--badge-yellow);
    box-shadow: 0 0 0 2px var(--main-pink) inset;
}

.preview-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 40px 50px; 
    border-bottom: 5px solid var(--main-pink); 
}
.header-title { font-size: 72px; font-weight: bold; flex-grow: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 20px; }
.header-icons-group { display: flex; align-items: center; gap: 50px; }
.header-icons-group.left { justify-content: flex-start; min-width: 250px; }
.header-icons-group.right { justify-content: flex-end; min-width: 250px; }
.icon { cursor: pointer; position: relative; display: flex; align-items: center; justify-content: center; color: #000; }
.bold-text-icon {
    text-shadow: 3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000, 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}
.icon.back-icon { font-size: 84px; }
.download-icon { flex-direction: column; }
.thick-arrow-down {
    width: 70px;
    height: 70px;
    fill: #000;
    margin-bottom: 15px;
    filter: drop-shadow(3px 0 0 black) drop-shadow(-3px 0 0 black) drop-shadow(0 3px 0 black) drop-shadow(0 -3px 0 black);
}
.download-line {
    display: block;
    width: 90px;
    height: 8px;
    background-color: #000;
    border-radius: 4px;
    box-shadow: 0 0 0 3px #000;
}
.delete-icon { font-size: 60px; }
.delete-icon .fa-trash { color: #000; }
.delete-icon .fa-xmark {
    position: absolute;
    font-size: 0.9em;
    font-weight: 900;
    color: white;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 10px));
    text-shadow: 3px 0 0 #fff, -3px 0 0 #fff, 0 3px 0 #fff, 0 -3px 0 #fff, 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
}

.main-content { padding: 60px; }
.info-section { display: flex; gap: 60px; align-items: flex-start; }
.image-placeholder { width: 480px; height: 678px; background-color: #f0f0f0; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 36px; background-size: cover; background-position: center; overflow: hidden; border-radius: 16px; flex-shrink: 0; border: 2px solid var(--border-color); }
.details-section { flex-grow: 1; display: flex; flex-direction: column; }
.title-container { display: flex; align-items: flex-start; gap: 20px; }
.details-title { font-size: 52px; font-weight: bold; line-height: 1.4; flex-grow: 1; }
.details-title span { color: var(--dark-pink); font-size: 46px; margin-left: 20px; }
.star-icon {
    width: 160px; height: 160px; border: 4px solid var(--star-yellow); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--star-yellow);
    flex-shrink: 0; margin-top: 0; box-sizing: border-box;
}
.star-icon .fa-star { font-size: 100px; }
.author-info { font-size: 52px; line-height: 1.2; }
.author-info .author { color: var(--dark-pink); }
.author-info .uploader { color: var(--link-blue); }
.author-info .stats, .author-info .category { color: #AAAAAA; }

.tags-container, .chapters-container {
    display: flex; flex-wrap: wrap; gap: 30px; margin-top: 50px;
    align-items: center;
}

.tag, .chapter { position: relative; cursor: pointer; }
.tag {
    background-color: #FBEFF4; border: 4px solid #DE688C; color: #DE688C;
    padding: 15px 35px; border-radius: 999px; font-size: 42px; font-weight: bold;
}

.add-first-item-btn {
    font-size: 42px; color: var(--text-light); border: 4px dashed #ccc; padding: 15px 45px;
    border-radius: 999px; cursor: pointer; transition: color 0.2s, border-color 0.2s;
}
.add-first-item-btn.chapter-add {
    font-size: 48px; border-radius: 16px; width: 100%; box-sizing: border-box;
    text-align: center; padding: 50px 70px;
}
.add-first-item-btn:hover { color: var(--main-pink); border-color: var(--main-pink); }

#item-action-popover {
    position: fixed;
    z-index: 1010;
    display: flex;
    gap: 8px;
    padding: 5px;
    background-color: white;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    transition: opacity 0.2s, transform 0.2s;
}
.action-btn {
    width: 20px; height: 20px; border-radius: 50%;
    background: #f0f0f0; color: #555;
    display: flex; justify-content: center; align-items: center;
    font-size: 10px; cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, color 0.2s;
}
.action-btn:hover { transform: scale(1.1); }
.action-btn.delete:hover { background-color: var(--badge-red); color: white; }
.action-btn.add:hover { background-color: var(--link-blue); color: white; }

.tag.active, .chapter.active {
    box-shadow: 0 0 0 4px var(--main-pink) inset;
}

.description { font-size: 52px; margin-top: 50px; line-height: 1.7; }

.actions-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 60px; padding: 0 120px 0 5px; box-sizing: border-box; }
.button-shadow-wrap { position: relative; display: inline-block; }
.actions-bar .button-shadow-wrap { flex-basis: 35%; display: block; }
.button-shadow-wrap::before {
    content: ""; position: absolute; border-radius: 999px; top: 0; left: 0;
    width: 101%; height: 100%; z-index: 1; background-color: #CCCCCC; transform: translate(-5px, 7px);
}
.start-button {
    position: relative; z-index: 2; width: 100%; background-color: #ED97B7; color: white;
    border: none; border-radius: 999px; font-size: 52px; font-weight: bold;
    padding: 0 20px; cursor: pointer; line-height: 1.3; text-align: center;
    height: 180px; display: flex; align-items: center; justify-content: center;
    box-sizing: border-box; box-shadow: none;
}

.icon-button { border: 5px solid var(--icon-border-gray); border-radius: 50%; width: 180px; height: 180px; position: relative; flex-shrink: 0; background-color: var(--panel-bg); }
.icon-button .icon-base, .icon-button .icon-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.icon-button .icon-base { color: var(--icon-border-gray); font-size: 100px; }
.icon-button .icon-overlay { color: white; font-size: 92px; -webkit-text-stroke: 2px var(--icon-border-gray); }
.icon-button .badge { position: absolute; top: -15px; left: calc(50% + 40px); background-color: var(--badge-red); color: white; border-radius: 999px; padding: 12px 30px; font-size: 42px; font-weight: bold; line-height: 1; }

.uploader-section { display: flex; align-items: center; gap: 35px; border-top: 2px solid var(--divider-gray); border-bottom: 2px solid var(--divider-gray); margin: 60px -60px 0 -60px; padding: 40px 60px; }
.avatar-frame { 
    width: 130px; height: 130px; border-radius: 50%; flex-shrink: 0; 
    border: 4px solid var(--main-pink); background-color: white; padding: 4px; 
    box-sizing: border-box; cursor: pointer; background-size: cover; background-position: center;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.uploader-details { font-size: 48px; }
.uploader-details .name { color: var(--link-blue); font-weight: bold; }
.uploader-details .time { color: var(--text-light); }
.uploader-details .name[contenteditable="true"] { cursor: text; }

.lower-content-background { 
    background-color: var(--content-bg-light-gray); 
    margin: 0 -60px -60px -60px; 
    padding: 60px 60px 60px 60px; 
}

.chapter { 
    position: relative; background-color: #FFFFFF; color: #555555; padding: 50px 70px;
    border-radius: 16px; font-size: 48px; border: 3px solid var(--border-color); box-shadow: none;
}
.chapter::before {
    content: ""; position: absolute; border-radius: 16px; top: 0; left: 0; width: 100%;
    height: 100%; z-index: -1; background-color: var(--shadow-gray, #CCCCCC); transform: translate(8px, 8px);
}

.also-watching-title { 
    font-size: 48px; font-weight: bold; color: #000; text-align: left; 
    margin-top: 60px; margin-bottom: 80px;
}

.comments-section { margin-top: 60px; }
.comments-header { display: flex; justify-content: space-between; align-items: center; padding: 30px 0; border-bottom: 3px solid var(--main-pink); }
.comments-header-left { display: flex; align-items: center; gap: 30px; }
.comments-header-right { display: flex; align-items: center; gap: 15px; }
.comments-header-icon { font-size: 72px; font-weight: bold; color: black; }
.comments-header-title { font-size: 64px; font-weight: bold; }
.vertical-line { width: 12px; height: 60px; background-color: #000; border-radius: 6px; }

.add-comment-btn {
    background-color: var(--link-blue); color: white; border: none; padding: 10px 20px;
    font-size: 32px; font-weight: bold; border-radius: 8px; cursor: pointer;
    margin-left: 30px; transition: background-color 0.2s;
}
.add-comment-btn:hover { background-color: #4a9fd4; }

.comment { display: flex; gap: 35px; padding: 50px 0; border-bottom: 2px solid #D9D9D9; }
.comment:last-child { border-bottom: none; }
.comment-avatar { 
    width: 170px; height: 170px; border-radius: 50%; flex-shrink: 0; border: 4px solid var(--main-pink);
    background-color: white; padding: 4px; box-sizing: border-box; cursor: pointer; 
    background-size: cover; background-position: center; display: flex; align-items: center;
    justify-content: center; overflow: hidden;
}
.comment-body { flex-grow: 1; display: flex; flex-direction: column; }
.comment-header { display: flex; justify-content: space-between; align-items: flex-start; }
.comment-user-info { display: flex; flex-direction: column; align-items: flex-start; }
.comment-user-info .name { font-size: 54px; font-weight: 500; color: var(--text-dark); }
.comment-user-info-tags { display: flex; align-items: center; gap: 20px; margin-top: 15px; }
.comment-level { color: var(--dark-pink); font-size: 48px; font-weight: bold; }
.comment-role { 
    background-color: var(--badge-yellow); color: white; border-radius: 999px; font-size: 42px; 
    padding: 10px 28px; font-weight: bold; cursor: text;
}
.comment-options { color: #CCCCCC; font-size: 48px; }

.delete-comment-btn { cursor: pointer; transition: color 0.2s ease; }
.delete-comment-btn:hover { color: var(--badge-red); }

.comment-content { font-size: 66px; line-height: 1.6; margin: 25px 0; color: var(--text-dark); }
.comment-footer { display: flex; align-items: center; justify-content: space-between; color: var(--text-light); font-size: 50px; }
.comment-meta { display: flex; align-items: center; gap: 30px; }
.comment-actions { display: flex; align-items: center; gap: 45px; font-size: 54px; color: var(--text-light); }
.comment-actions .fa-stack { font-size: 27px; vertical-align: middle; line-height: 1; margin-right: 20px; }
.comment-actions .tilted-heart { transform: rotate(20deg) translate(20px, 10px); font-size: 1.5em; }

.comment-actions .comment-quote { 
    font-family: 'Times New Roman', Times, serif; 
    font-weight: bold; 
    line-height: 1;
    color: var(--text-light); 
    position: relative;
    font-size: 2.5em;
    top: 8px;
    left: 18px;
}

.comments-input-footer { display: flex; align-items: center; gap: 30px; padding: 40px 0; border-top: 2px solid #AAAAAA; margin-top: 40px; }
.comments-input-placeholder { flex-grow: 1; color: var(--text-light); font-size: 58px; }
.comments-submit-btn {
    position: relative; z-index: 2; background-color: #ED97B7; color: white; border: none;
    border-radius: 999px; font-size: 52px; font-weight: bold; padding: 30px 70px; box-shadow: none;
}

/* --- START: Watermark CSS --- */
.watermark {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 36px;
    color: #000;
    z-index: 10;
    font-weight: 500;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}
.watermark-logo-container {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid #004b6d;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    box-sizing: border-box;
    background-color: #fff;
    flex-shrink: 0;
}
.watermark-logo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
/* --- END: Watermark CSS --- */

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px); z-index: 1000; display: flex; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; }
.modal-content { background: var(--panel-bg); padding: 25px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 20px; width: 90vw; max-width: 450px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); box-sizing: border-box; }
.modal-content h3 { margin: 0; color: var(--text-dark); width: 100%; text-align: center; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; font-size: clamp(18px, 4vw, 22px); }
.modal-buttons { display: flex; gap: 15px; width: 100%; justify-content: center; margin-top: 10px; }

#confirm-modal-message { font-size: 16px; line-height: 1.6; text-align: center; margin: 10px 0; width: 100%; box-sizing: border-box;}

.image-preview-container { width: 100%; height: auto; aspect-ratio: 480 / 678; overflow: hidden; position: relative; border: 2px solid var(--border-color); background-color: #f0f0f0; user-select: none; touch-action: none; border-radius: 8px; }
.image-preview-container.is-avatar { aspect-ratio: 1 / 1; border-radius: 50%; }
#image-preview-img { position: absolute; transform-origin: center center; cursor: grab; max-width: none; }

.help-modal-content { max-width: 650px; width: 90vw; height: auto; align-items: flex-start; text-align: left; gap: 15px; overflow-y: auto; max-height: 90vh; box-sizing: border-box; }
.help-modal-content p, .help-modal-content pre { width: 100%; box-sizing: border-box; margin: 0; }
.help-modal-content p { line-height: 1.7; font-size: 14px;}
.help-modal-content pre { background-color: #f5f5f5; padding: 15px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; font-size: 13px; line-height: 1.6; margin-top: 5px;}
.help-modal-content code { font-family: 'Courier New', Courier, monospace; color: #d63384; }

.modal-button { background-color: var(--main-pink); color: white; border: none; padding: 10px 20px; font-size: 14px; border-radius: 8px; cursor: pointer; transition: background-color 0.2s; }
.modal-button:hover { background-color: var(--dark-pink); }
.modal-button.secondary { background-color: #aaa; }
.modal-button.secondary:hover { background-color: #888; }
.modal-button.danger { background-color: var(--badge-red); }
.modal-button.danger:hover { background-color: #d43a3a; }

.floating-actions { 
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); 
    z-index: 10; width: auto; background: rgba(255, 255, 255, 0.85); 
    backdrop-filter: blur(8px); padding: 6px; border-radius: 10px; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); display: flex; gap: 6px; white-space: nowrap;
}
.floating-actions button {
    background-color: var(--main-pink); color: white; border: none; padding: 8px 16px; 
    font-size: 14px; font-weight: 500; border-radius: 5px; cursor: pointer; 
    transition: all 0.2s ease-in-out;
}
.floating-actions button:hover { transform: translateY(-2px); box-shadow: 0 2px 8px rgba(255, 137, 188, 0.5); }
.floating-actions button:disabled { background-color: #cccccc; cursor: not-allowed; transform: none; box-shadow: none; }

.hidden { display: none !important; }