:root {
    --bg-color: #fdfbf7;
    /* Warm white */
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent-color: #00c300;
    /* Line Green */
    --accent-glow: rgba(0, 195, 0, 0.15);
    --font-family: 'Inter', sans-serif;
    --border-color: rgba(0, 0, 0, 0.08);
    /* New variable for borders */
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Container adjustment */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}



.logo-image {
    max-width: 400px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* 
header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #333, #666);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
} 
*/

header p {
    color: var(--text-secondary);
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
}

/* ... existing code ... */

.ranking-item {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-out forwards;
}

.ranking-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--accent-glow);
    border-color: var(--accent-color);
}

/* ... (skipping unchanged parts) ... */

/* --- Multi-Platform Grid Layout --- */

.ranking-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.platform-column {
    background: var(--card-bg);
    /* Reverted from --glass-bg */
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* ... */


/* Platform Header Styles */
.platform-header {
    padding: 1rem;
    color: white;
    font-weight: bold;
    text-align: center;
    border-radius: 12px 12px 0 0;
    /* Rounded top corners */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: -15px -15px 15px -15px;
    /* Negative margin to fill container width */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Admin Mode: Draggable Header */
body.admin-mode .platform-header {
    cursor: default;
    /* Cursor is default, handle has grab */
    z-index: 10;
    position: relative;
    touch-action: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 1.2rem;
    user-select: none;
    padding: 0 5px;
}

.drag-handle:active {
    cursor: grabbing;
    color: #fff;
}

/* Sortable Ghost (Placeholder during drag) */
.sortable-ghost {
    opacity: 0.4;
    background: #e2e8f0;
    border: 2px dashed #94a3b8;
}

.line-header {
    background: linear-gradient(135deg, #00C300, #009900);
}

.naver-header {
    background: linear-gradient(135deg, #03C75A, #029a45);
}

.kakao-header {
    background: linear-gradient(135deg, #FEE500, #e6cf00);
    color: #3c1e1e;
    /* Dark text for yellow background */
}

.lezhin-header {
    background: linear-gradient(135deg, #EB0026, #b8001e);
}


/* Ranking List */
.ranking-list {
    flex: 1;
    overflow-y: auto;
    max-height: 620px;
    /* Approx 10 items (assuming ~60px per item) */
    padding-right: 5px;
    /* Space for scrollbar */
}

/* Scrollbar styling */
.ranking-list::-webkit-scrollbar {
    width: 6px;
}

.ranking-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.ranking-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Responsive Grid */
@media (max-width: 1024px) {
    .ranking-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .ranking-grid {
        grid-template-columns: 1fr;
    }

    .ranking-list {
        max-height: 400px;
        /* Constrain height on mobile */
    }
}

/* Link Styling */
a {
    text-decoration: none;
    color: inherit;
}

.manga-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    min-width: 0;
}

.manga-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.manga-subtext {
    font-size: 0.75rem;
    color: #999;
    font-weight: 400;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.manga-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    transition: color 0.2s;
    /* Allow wrapping if text is long */
    white-space: normal;
    overflow: hidden;
    /* text-overflow: ellipsis; not needed if wrapping */
    margin-right: 10px;
    line-height: 1.3;
}

.manga-title:hover {
    color: var(--accent-color);
}

/* Hide empty subtext only when NOT in admin mode */
body:not(.admin-mode) .manga-subtext:empty {
    display: none;
}

/* Ensure empty subtext is visible and clickable in admin mode */
body.admin-mode .manga-subtext:empty {
    display: block;
    min-height: 1.2em;
    min-width: 50px;
    background: rgba(0, 0, 0, 0.03);
    /* Subtle hint */
    border-bottom: 1px dashed #ccc;
}

/* Ensure subtext is always visible in admin mode regardless of content */
body.admin-mode .manga-subtext {
    min-height: 1.2em;
}

.manga-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: auto;
    /* Push to right */
    white-space: nowrap;
    flex-shrink: 0;
}

.rank-badge {
    display: flex;
    flex-direction: row;
    /* Horizontal: Change | Number */
    align-items: center;
    justify-content: flex-start;
    width: 85px;
    /* Increased to absorb margin for centering */
    margin-right: 0;
    flex-shrink: 0;
}

.rank-number {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-left: 0;
    flex: 1;
    /* Take available space */
    text-align: center;
    /* Center in available space */
}

.rank-change {
    font-size: 0.75rem;
    width: 25px;
    text-align: center;
}

.rank-change.up {
    color: #ff4d4d;
}

/* Korea/Japan convention: Red is Up/Hot */
.rank-change.down {
    color: #4d94ff;
}

@keyframes popUp {
    0% {
        transform: scale(1) translateY(0);
    }

    50% {
        transform: scale(1.4) translateY(-5px);
        color: #ff0000;
    }

    100% {
        transform: scale(1) translateY(0);
    }
}

.anim-pop {
    animation: popUp 0.4s ease-out;
    display: inline-block;
    /* Required for transform */
}

/* Comment Section */
.comment-section {
    display: none;
    background: #1e293b;
    padding: 1rem;
    border-top: 1px solid #334155;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.comment-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.comment-item {
    background: #0f172a;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #334155;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.comment-content {
    word-break: break-all;
}

.comment-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.comment-input {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.comment-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.comment-submit-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.comment-submit-btn:hover {
    background: #2563eb;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #1e293b;
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Bubble Icon */
.comment-bubble {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #94a3b8;
    /* Light gray */
    font-size: 0.8rem;
    margin-left: 8px;
    cursor: pointer;
    vertical-align: middle;
}

.comment-bubble:hover {
    color: #64748b;
}

.comment-count {
    font-size: 0.75rem;
    font-weight: 600;
}

.comment-icon-new {
    height: 18px;
    /* Smaller size */
    width: auto;
    margin-left: 8px;
    cursor: pointer;
    vertical-align: middle;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: #ffffff;
    /* White base */
    color: #1e293b;
    width: 90%;
    max-width: 980px;
    /* Adjusted from 950px */
    border-radius: 12px;
    /* Rounded corners */
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
}

.modal-comment-list {
    flex: 1;
    max-height: 500px;
    /* Limit height to trigger scrollbar */
    overflow-y: auto;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Scrollbar for modal */
.modal-comment-list::-webkit-scrollbar {
    width: 6px;
}

.modal-comment-list::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.modal-comment-list::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

/* Site Notice Bar */
.notice-bar {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.05);
    /* Subtle background */
    padding: 0.4rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    /* Ensure it fits container */
}

/* Dark mode adjustment if body bg is light? */
/* Actually current theme is light-ish warm tone. rgba(0,0,0,0.05) is fine. */

/* Bubble Style (Restored) */
.modal-speech-bubble {
    background: #f1f5f9;
    padding: 8px 12px;
    border-radius: 12px;
    border-top-left-radius: 0;
    /* Pointy corner for speech bubble effect */
    position: relative;
    /* Important for ::before arrow */
    color: #1e293b;
    font-size: 0.9rem;
    line-height: 1.4;
    display: inline-block;
    /* Ensure it wraps content */
    max-width: 100%;
}

/* Arrow for the bubble (Restored & Fixed) */
.modal-speech-bubble::before {
    content: "";
    position: absolute;
    right: 100%;
    /* Push to the left side of the bubble */
    top: 10px;
    /* Align near the top (text start) */
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #f1f5f9;
    /* Color matches bubble, points left */
    transform: none;
    /* Remove skew for standard arrow */
}

.notice-icon {
    font-size: 1.2rem;
    margin-right: 0.8rem;
    animation: pulse 2s infinite;
}

#notice-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.4;
    font-weight: 500;
}

/* Add padding to body in admin mode to prevent footer overlap */
body.admin-mode {
    padding-bottom: 100px;
}



/* Admin Editable style for notice and copyright */
body.admin-mode #notice-text[contenteditable="true"],
body.admin-mode #footer-copyright[contenteditable="true"] {
    border-bottom: 1px dashed #f59e0b;
    transition: all 0.2s;
    padding: 2px 5px;
    background: rgba(0, 0, 0, 0.05);
    min-width: 200px;
    cursor: text;
}

body.admin-mode #footer-copyright[contenteditable="true"]:hover {
    background: rgba(245, 158, 11, 0.1);
}

body.admin-mode #notice-text[contenteditable="true"]:focus {
    border-bottom: 2px solid #2563eb;
    outline: none;
    background: rgba(37, 99, 235, 0.1);
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* --- Restored Missing Styles --- */

.my-comment-badge {
    background-color: var(--accent-color);
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 4px;
    margin-left: 5px;
    vertical-align: middle;
    font-weight: bold;
}

.comment-edit-input {
    flex-grow: 1;
    padding: 2px 5px;
    border: 1px solid #475569;
    background: #1e293b;
    color: white;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-right: 5px;
}

#like-btn {
    transition: transform 0.1s;
    padding: 2px 6px;
    border-radius: 4px;
}

#like-btn:hover {
    background-color: #334155;
}

#like-btn:active {
    transform: scale(0.95);
}

#like-btn.liked {
    color: #ef4444;
    /* Red */
    font-weight: bold;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
    color: #94a3b8;
    opacity: 0.7;
}

.action-btn:hover {
    opacity: 1;
    color: #3b82f6;
}

.action-btn.delete:hover {
    color: #ef4444;
}

/* Modal Form Styles (Missing) */
.modal-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-top: 1px solid #e2e8f0;
    padding-top: 1rem;
}

.modal-form input {
    padding: 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #f1f5f9;
}

.modal-form input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
}

#modal-submit-btn {
    padding: 0.5rem 1rem;
    background: #b5fc77;
    /* Restored Green */
    color: #0f172a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

#modal-submit-btn:hover {
    background: #86efac;
    transform: translateY(-1px);
}

/* --------------------------- */

/* Footer Styles */
footer {
    text-align: center;
    padding: 3rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    position: relative;
    z-index: 100;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.footer-content p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .logo-image {
        max-width: 250px;
        /* Smaller logo on mobile */
    }

    .ranking-grid {
        grid-template-columns: 1fr;
        /* Single column */
        gap: 15px;
    }

    .platform-column {
        padding: 10px;
    }

    .ranking-item {
        padding: 0.5rem;
        /* Less padding */
    }

    .rank-badge {
        width: 55px;
        /* Narrower badge area */
    }

    .rank-number {
        font-size: 1.1rem;
    }

    .manga-title {
        font-size: 0.95rem;
    }

    .manga-author {
        font-size: 0.75rem;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        /* Wider modal on mobile */
        padding: 1rem;
        max-height: 85vh;
    }

    .comment-form {
        flex-direction: column;
        /* Stack inputs */
    }

    .comment-input {
        width: 100%;
        /* Full width */
        box-sizing: border-box;
    }

    #modal-submit-btn {
        width: 100%;
    }

    /* --- Comment Mobile/Card Fixes --- */
    /* Handled by Card Classes now */
}

/* --- Comment Card UI --- */
/* --- Comment Card UI --- */
.comment-card {
    background: #f8fafc;
    /* Very light background */
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
}

.comment-display-area {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
    /* Divider 1 */
}

/* --- Font Hierarchy --- */
#modal-title {
    font-size: 1.5rem !important;
    font-weight: 800;
}

.card-nick {
    font-size: 1.1rem;
    /* Increased size */
    font-weight: 700;
    color: #1e293b;
    margin-right: 5px;
}

.my-comment-badge {
    background-color: var(--accent-color);
    color: white;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.card-body {
    width: 100%;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
    /* Divider 2 */
}

/* Bubble Style override/refinement for Card - TEXT ONLY */
.modal-speech-bubble {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    position: relative;
    color: #334155;
    font-size: 0.95rem;
    /* Slightly smaller for body */
    line-height: 1.5;
    display: block;
    width: 100%;
    word-break: break-all;
}

/* Remove the old arrow */
.modal-speech-bubble::before {
    display: none;
}

/* Auto-expanding Textarea */
.auto-expand {
    min-height: 40px;
    max-height: 200px;
    overflow-y: hidden;
    resize: none;
    line-height: 1.5;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.95rem;
    font-family: inherit;
    display: block;
    width: 100%;
    box-sizing: border-box;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.card-date {
    font-size: 0.75rem;
    color: #94a3b8;
}

.card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.comment-like-btn {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* --- Edit Mode Styles --- */
.comment-edit-area {
    display: none;
    flex-direction: column;
    /* Stack vertically */
    width: 100%;
    gap: 8px;
    background: #f1f5f9;
    /* Light sophisticated bg for edit mode */
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
}

.comment-edit-input {
    min-height: 40px;
    overflow-y: hidden;
    resize: none;
    width: 100%;
    padding: 8px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    /* White input bg */
    color: #334155;
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
    font-family: inherit;
}

.edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}


.footer-links a:hover {
    color: var(--accent-color);
}

.footer-links .separator {
    color: #cbd5e1;
}

.footer-logo {
    display: block;
    height: 60px;
    width: auto;
    margin: 0 auto 1rem auto;
    opacity: 0.9;
}

/* Info Modal Specifics */
#info-modal-overlay {
    z-index: 2000;
}

.info-modal-content {
    max-width: 600px;
}

.info-modal-body {
    padding: 1rem 0;
    line-height: 1.6;
    color: #333;
    max-height: 60vh;
    overflow-y: auto;
    white-space: pre-wrap;
    /* Preserve formatting */
}

.info-textarea {
    width: 100%;
    height: 300px;
    padding: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
}

/* Character Counter */
.char-counter {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: right;
    margin-top: 4px;
    font-weight: 500;
}

.char-counter.limit-reached {
    color: #ef4444;
    /* Red color */
    font-weight: 700;
}

/* Liked State for Heart Icon */
.comment-like-btn.liked {
    color: #0ea5e9;
    /* Sky Blue */
    font-weight: bold;
}

.comment-like-btn.liked .like-count {
    color: #0ea5e9 !important;
}