:root {
    --primary-color: #4A90E2;
    --accent-color: #50E3C2;
    --background-color: #F4F7F9;
    --text-color: #333333;
    --light-text-color: #FFFFFF;
    --border-color: #E0E6ED;
    --nyancoin-bubble-bg: #FFFFFF;
    --inusarium-bubble-bg: #D8F3E1;
    --sidebar-bg: #FFFFFF;
    --active-chapter-bg: #E7F0FE;
    --sidebar-width: 300px;
    --header-height: 60px;
    --shadow-light: 0 2px 5px rgba(0, 0, 0, 0.05); /* Lighter shadow for general use */
    --shadow-medium: 0 5px 15px rgba(0, 0, 0, 0.08); /* Medium shadow for sidebar */
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.7;
}

.app-container {
    display: flex;
    height: 100vh;
}


/* --- Left Sidebar (Mobile First) --- */
#nav-sidebar {
    background-color: var(--sidebar-bg);
    /* Removed: border-right: 1px solid var(--border-color); */
    box-shadow: var(--shadow-medium); /* Added shadow */
    padding: 1.5rem;
    overflow-y: scroll;
    /* Mobile styles: hidden off-screen */
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--sidebar-width);
    max-width: 85%; /* Ensure it doesn't cover the whole screen */
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-sizing: border-box;
}

#nav-sidebar.is-open {
    transform: translateX(0);
}

.sidebar-header {
    padding-bottom: 1rem; /* Added padding */
    border-bottom: 1px solid var(--border-color); /* Added border for separation */
    margin-bottom: 1.5rem; /* Adjusted margin */
}

.sidebar-header h1 {
    margin: 0; /* Adjusted margin */
    font-size: 1.8rem;
    color: var(--text-color);
    line-height: 1.4;
}

#chapter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-item {
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 3.5rem; /* Changed from height to min-height */
    display: flex; /* Use flexbox for vertical centering */
    align-items: center; /* Vertically center content */
    box-sizing: border-box; /* Ensure padding is included in height */
    will-change: transform, background-color, box-shadow; /* Hint for optimization */
}

.chapter-item:hover {
    background-color: var(--background-color);
    transform: translateY(-2px); /* Slight lift */
    box-shadow: var(--shadow-light); /* Subtle shadow on hover */
}

.chapter-item.active {
    background-color: var(--active-chapter-bg);
    color: var(--primary-color);
    border-left: 4px solid var(--primary-color); /* Added left border for emphasis */
    padding-left: calc(1rem - 4px); /* Adjust padding to keep text aligned */
}

/* --- Main Content (Mobile First) --- */
#main-content {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 0 1rem;
}

.main-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

#chapter-title-main {
    margin: 0;
    font-size: 1.2rem;
    flex-grow: 1;
    text-align: center;
}

#dialogue-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

/* --- Hamburger Menu Button --- */
#menu-toggle {
    display: block;
    position: relative;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

#menu-toggle span {
    display: block;
    position: absolute;
    height: 3px;
    width: 100%;
    background: var(--text-color);
    border-radius: 3px;
    opacity: 1;
    left: 0;
    transition: 0.25s ease-in-out, background 0.2s ease, transform 0.2s ease;
}

#menu-toggle:hover span {
    background: var(--primary-color);
    transform: scale(1.1);
}

#menu-toggle span:nth-child(1) { top: 0px; }
#menu-toggle span:nth-child(2) { top: 10px; }
#menu-toggle span:nth-child(3) { top: 20px; }


/* --- Chat Bubbles --- */
.chat-bubble {
    display: flex;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.chat-bubble.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.bubble-content {
    max-width: 80%;
    padding: 0.8rem 1.2rem;
    border-radius: 20px;
}

.character-name {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

.nyancoin-bubble .avatar { margin-right: 0.75rem; }
.nyancoin-bubble .bubble-content {
    background-color: var(--nyancoin-bubble-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 5px;
}

.inusarium-bubble { flex-direction: row-reverse; }
.inusarium-bubble .avatar { margin-left: 0.75rem; }
.inusarium-bubble .bubble-content {
    background-color: var(--inusarium-bubble-bg);
    border: 1px solid var(--border-color);
    border-bottom-right-radius: 5px;
}
.inusarium-bubble .character-name { color: #008a6e; }


/* --- Tablet & Desktop Styles --- */
@media (min-width: 768px) {
    .app-container {
        display: flex;
    }

    #nav-sidebar {
        position: static; /* Revert from fixed */
        transform: translateX(0); /* Always visible */
        width: var(--sidebar-width);
        max-width: none;
        box-shadow: var(--shadow-medium); /* Apply shadow on desktop too */
    }

    .sidebar-header {
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1.5rem;
    }

    .sidebar-header h1 {
        margin: 0;
    }

    #main-content {
        flex-grow: 1;
        width: auto; /* Let it grow */
        padding: 2rem 3rem;
    }

    .main-header {
        display: block; /* Revert to simple block */
        height: auto;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 1rem;
        margin-bottom: 2rem;
    }

    #chapter-title-main {
        font-size: 2rem;
        text-align: left;
    }

    #menu-toggle {
        display: none; /* Hide hamburger on large screens */
    }

    .avatar {
        width: 50px;
        height: 50px;
    }
}