body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

/* === 24-COLUMN GRID SYSTEM === */
.row {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col-13, .col-14, .col-15, .col-16, .col-17, .col-18, .col-19, .col-20, .col-21, .col-22, .col-23, .col-24 {
    padding: 0 10px; /* Gutter padding */
    box-sizing: border-box;
}

.col-1 { flex-basis: 4.16666667%; }
.col-2 { flex-basis: 8.33333333%; }
.col-3 { flex-basis: 12.5%; }
.col-4 { flex-basis: 16.66666667%; }
.col-5 { flex-basis: 20.83333333%; }
.col-6 { flex-basis: 25%; }
.col-7 { flex-basis: 29.16666667%; }
.col-8 { flex-basis: 33.33333333%; }
.col-9 { flex-basis: 37.5%; }
.col-10 { flex-basis: 41.66666667%; }
.col-11 { flex-basis: 45.83333333%; }
.col-12 { flex-basis: 50%; }
.col-13 { flex-basis: 54.16666667%; }
.col-14 { flex-basis: 58.33333333%; }
.col-15 { flex-basis: 62.5%; }
.col-16 { flex-basis: 66.66666667%; }
.col-17 { flex-basis: 70.83333333%; }
.col-18 { flex-basis: 75%; }
.col-19 { flex-basis: 79.16666667%; }
.col-20 { flex-basis: 83.33333333%; }
.col-21 { flex-basis: 87.5%; }
.col-22 { flex-basis: 91.66666667%; }
.col-23 { flex-basis: 95.83333333%; }
.col-24 { flex-basis: 100%; }
/* ============================ */

.container {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

h1, h2 {
    text-align: center;
}

.anime-list {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
    width: 100%;
}

/* === Anime Item Layout (3-column) === */
.anime-item {
    display: flex;
    align-items: stretch; /* Make columns equal height */
    margin-bottom: 15px;
    background-color: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 8px;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden; /* Prevent content from spilling out */
}

.anime-item__column {
    flex: 1; /* Each column takes up 1/3 of the space */
    padding: 0 10px;
    box-sizing: border-box;
    min-width: 0; /* Allow columns to shrink */
    display: flex;
    flex-direction: column;
}

.anime-item__column--image {
    justify-content: center; /* Center image vertically if it's smaller */
}

.thumbnail-base {
    width: 100%;
    height: auto; /* Maintain aspect ratio based on width */
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.anime-title {
    font-weight: bold;
    color: #34495e;
    font-size: 1.2em;
    margin-bottom: 8px;
}

.anime-id {
    color: #7f8c8d;
    font-size: 0.9em;
    margin-bottom: 8px;
}

.anime-item__column span {
    color: #555;
    font-size: 0.95em;
    margin-bottom: 4px;
}

.sidebar {
    background-color: #ffffff;
    border-radius: 10px;
    padding: 20px;
    /* Sticky Sidebar Settings */
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 20px; /* Space from top */
    height: auto; /* Allow auto height up to max */
    max-height: calc(100vh - 40px); /* Limit height to viewport - margins */
    overflow-y: auto; /* Scroll inside sidebar if too long */
    
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    /* text-align: center; Remove default center align for better list look */
    color: #333; /* Change color for better readability */
    box-sizing: border-box;
}

.sidebar h3 {
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    font-size: 1.2em;
    color: #555;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.sidebar-nav li {
    margin-bottom: 0;
    border-bottom: 1px solid #eee; /* Add separator line */
}

.sidebar-nav li:last-child {
    border-bottom: none;
}

.sidebar-nav a {
    display: block;
    padding: 12px 10px;
    background-color: transparent; /* Remove default background */
    color: #333;
    text-decoration: none;
    border-radius: 0; /* Remove rounded corners */
    transition: background-color 0.2s;
}

.sidebar-nav a:hover {
    background-color: #f5f5f5; /* Light grey on hover */
    /* Removed padding-left shift for simpler look */
}


/* === GRID DEBUG MODE === */
/* Add "debug-grid" class to body to enable */

/* Page-level 24-column grid */
body.debug-grid [class*="col-"] {
    background-color: rgba(128, 0, 128, 0.1); /* Light purple */
    box-shadow: inset 0 0 0 1px rgba(128, 0, 128, 0.3);
}

/* Anime-item internal 3-column grid */
body.debug-grid .anime-item__column {
    background-color: rgba(0, 128, 0, 0.1); /* Light green */
    box-shadow: inset 0 0 0 1px rgba(0, 128, 0, 0.3);
}

/* === BUTTONS === */
.button-primary {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.button-primary:hover {
    background-color: #2980b9;
}

.button-danger {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.button-danger:hover {
    background-color: #c0392b;
}

/* === RESPONSIVE DESIGN (Mobile Optimization) === */
@media (max-width: 768px) {
    body {
        padding: 10px; /* Reduce body padding on mobile */
    }

    /* Stack all columns */
    [class*="col-"] {
        flex-basis: 100% !important;
        max-width: 100% !important;
        padding: 0; /* Remove horizontal gutter */
        margin-bottom: 20px; /* Add vertical spacing between stacked columns */
    }

    /* Hide spacers if marked */
    .spacer-column {
        display: none;
    }

    /* Adjust container padding */
    .container {
        padding: 15px;
    }

    /* Reorder layout: Main Content (1) -> Sidebar Left (2) -> Sidebar Right (3) */
    .row {
        flex-direction: column;
    }
    
    .main-column {
        order: 1;
    }
    
    .sidebar-column-left {
        order: 2;
    }
    
    .sidebar-column-right {
        order: 3;
    }

    /* Sidebar styling for mobile */
    .sidebar {
        padding: 15px;
        height: auto; /* Remove fixed height */
        /* Reset sticky behavior for mobile */
        position: static;
        top: auto;
        max-height: none;
        overflow-y: visible;
    }
    .sidebar h3 {
        font-size: 1.1em;
        padding-bottom: 5px;
        margin-bottom: 10px;
    }
    /* sidebar-nav styles removed as they are now shared with PC default */

    /* Card-style layout for anime items */
    .anime-item {
        flex-direction: column;
        padding: 15px;
    }

    .anime-item__column {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ecf0f1; /* Light separator */
        padding: 10px 0;
        margin-bottom: 5px;
    }
    
    .anime-item__column:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    /* Specific adjustments for image column */
    .anime-item__column--image {
        padding-top: 0;
    }

    /* Modal responsiveness */
    .modal-content {
        width: 90%;
        margin: 20px auto;
        padding: 20px;
    }

    /* Typography adjustments */
    h1 { font-size: 1.5em; }
    h2 { font-size: 1.3em; }
    
    .anime-title {
        font-size: 1.1em;
    }

    /* Hide less important info on mobile if needed, or just stack nicely */
    
    /* Ensure tables scroll if too wide */
    .status-table-container, .container {
        overflow-x: auto;
    }
}
