:root {
    --font-title: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --color-primary: #FFB7C5; /* Sakura Pink */
    --color-primary-dark: #FF9EAA; /* Lavender Pink accent */
    --color-secondary: #E6E6FA; /* Lavender Purple */
    --color-bg: #FAF9F6; /* Soft warm Off-white */
    --color-card-bg: #FFFFFF;
    --color-text-main: #2F2E41; /* Soft Charcoal */
    --color-text-muted: #7A7585;
    --color-border: #F0EAE1;
    
    --radius-large: 16px;
    --radius-medium: 12px;
    --radius-small: 8px;
    
    --shadow-light: 0 4px 20px rgba(122, 117, 133, 0.04);
    --shadow-hover: 0 10px 30px rgba(122, 117, 133, 0.1);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *:before, *:after {
    font-family: var(--font-body);
    font-size: 16px;
    margin: 0;
    box-sizing: border-box;
}
a {
    text-decoration: none;
    color: #d15673;
    transition: var(--transition-smooth);
}
a:hover {
    color: #a43a53;
}
ul {
    list-style-type: none;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text-main);
}

input[type=text], input[type=date], input[type=number], input[type=password], select {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
}

input[type="checkbox"] {
    appearance: none;
    height: 1em;
    width: 1em;
    border-radius: 0.25em;
    background-color: #e0e0e0;
    cursor: pointer;
}
input[type="checkbox"]:checked {
    background-color: dodgerblue;
}

/* Flash messages */
.flash-message {
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.flash-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.flash-message.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.group-label-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
}
.group-label-checkbox-wrapper {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1em;
}
.group-label-checkbox-wrapper label {
    margin-right: 0.5em;
    cursor: pointer;
}

.main {
    max-width: 80vw;
}
@media (max-width: 600px) {
    .main {
        max-width: 100vw;
    }
}

/* --------------------------- Navigation Links ---------------------------- */
/* Top navigation bar */
header.top {
    background-color: rgba(250, 249, 246, 0.01);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}
nav.topmenu {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin: 0 auto;
    padding: 0.2em 0;
}
nav.topmenu h1 {
    margin: 0;
    font-size: 1.25rem;
    font-family: var(--font-title);
    font-weight: 800;
    display: flex;
    align-items: center;
}
nav.topmenu h1 a {
    color: var(--color-text-main) !important;
    display: flex;
    align-items: center;
    padding: 0.75em 1.2em;
}
nav.topmenu h1 a:hover {
    background-color: transparent !important;
}
nav.topmenu a {
    font-size: 0.95rem;
    font-family: var(--font-body);
    font-weight: 500;
    margin: 0;
    text-align: center;
    padding: 1em 1.2em;
    color: var(--color-text-main);
    transition: var(--transition-smooth);
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
}
nav.topmenu a:hover {
    background-color: transparent;
    color: var(--color-primary-dark);
}

/* The collapse wrapper is transparent to layout on desktop/tablet so its
   children behave as direct flex items of the nav (no visual change). */
.nav-collapse {
    display: contents;
}

/* Hamburger toggle — hidden until the mobile breakpoint */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 3em;
    height: 2.6em;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}
.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
    content: "";
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--color-text-main);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav-toggle-bar {
    position: relative;
}
.nav-toggle-bar::before {
    position: absolute;
    top: -7px;
    left: 0;
}
.nav-toggle-bar::after {
    position: absolute;
    top: 7px;
    left: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar {
    background-color: transparent;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after {
    transform: translateY(-7px) rotate(-45deg);
}

/* Content */
main.content {
    display: block;
    padding: 0 0.5em;
    margin: 3em auto;
}
main.content > * {
    margin-bottom: 1.5em;
}
main.content > section h3 {
    font-size: 2rem;
    font-weight: bolder;
}

.page-title {
    font-size: 3rem;
}

/* subtoplink */
.subtoplink {
    display: flex;
    gap: 0.5em;
    margin: 0 0 1em;
}
.subtoplink a {
    background-color: black;
    color: white;
    padding: 5px 10px;
    display: inline-block;
}

.chart-row {
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
}

.chart-row .chart {
    flex: 1 1 320px;
}

/* Fixed-height, position:relative container so Chart.js (with
   maintainAspectRatio:false) fills it and resizes cleanly with the window. */
.chart--responsive {
    position: relative;
    width: 100%;
    height: 40vh;
    min-height: 260px;
    max-height: 400px;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.92rem;
}

table.data-table th,
table.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    transition: var(--transition-smooth);
}

table.data-table th {
    background-color: #f3f0fa;
    color: #5d4694;
    font-family: var(--font-title);
    font-weight: 700;
}

table.data-table tr {
    transition: var(--transition-smooth);
}

table.data-table tbody tr:hover {
    background-color: #faf4f5;
}

table.data-table th.sorted-asc::after,
table.data-table th.sorted-desc::after {
    content: '';
    display: inline-block;
    margin-left: 6px;
    border: 4px solid transparent;
}

table.data-table th.sorted-asc::after {
    border-bottom-color: #5d4694;
}

table.data-table th.sorted-desc::after {
    border-top-color: #5d4694;
}

.tables-row {
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
    align-items: flex-start;
}

.tables-row table {
    flex: 1 1 320px;
}

a.active-menu-link {
    background-color: transparent !important;
    color: var(--color-primary-dark) !important;
    font-weight: 700;
    border-bottom: 2px solid var(--color-primary);
}

.anime-title {
    font-size: 3rem;
}

/* --------------------------------- Cards --------------------------------- */
.cards {
    display: flex;
    gap: 1.5em;
    flex-wrap: wrap;
    margin: 1.5em 0;
}
.card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-large);
    background-color: var(--color-card-bg);
    box-shadow: var(--shadow-light);
    transition: var(--transition-smooth);
    padding: 1.2em;
}
.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
}

/* --------------------------------- Animes -------------------------------- */
.animes-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: 1.5em;
    align-items: stretch;
}
.anime-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    min-height: 165px;
    height: 100%;
}
.anime-card-thumbnail {
    width: 110px;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    border-right: 1px solid var(--color-border);
}
.anime-card-thumbnail.placeholder {
    background-color: #faf4f5;
    display: flex;
    align-items: center;
    justify-content: center;
}
.anime-card-thumbnail.placeholder .placeholder-icon {
    font-size: 2.2rem;
    opacity: 0.65;
}
.anime-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: var(--transition-smooth);
}
.anime-card:hover .anime-card-thumbnail img {
    transform: scale(1.06);
}
.anime-card-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.9em 1.1em;
    min-width: 0;
}
.anime-card header {
    flex: 0 0 auto;
}
.anime-card .info {
    display: flex;
    flex-direction: column;
}
.anime-card .info h2 {
    font-family: var(--font-title);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0.25em 0;
}
.anime-card .info h2 a {
    color: var(--color-text-main);
}
.anime-card .info h2 a:hover {
    color: var(--color-primary-dark);
}
.anime-card .content {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.8em;
    margin-top: auto;
    padding-top: 0.4em;
    border-top: 1px dashed var(--color-border);
}
.anime-card .score {
    font-family: var(--font-title);
    font-size: 1.15rem;
    font-weight: 800;
    color: #a43a53;
    background-color: #faf4f5;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-primary);
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(255, 183, 197, 0.2);
}
.anime-card .other {
    flex: 1;
    min-width: 0;
}
.anime-meta-row {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin-bottom: 0.2em;
    font-size: 0.76rem;
    color: var(--color-text-muted);
}
.anime-meta-row .meta-label {
    font-size: 0.82rem;
    opacity: 0.85;
}
.anime-meta-row.anime-id-row {
    margin-bottom: 0.3em;
}
.anime-card .anime-id {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* ------------------- Animes Historical Statistics Charts ----------------- */
.animes-historical-statistics-charts-wrapper {
    display: flex;
    flex-flow: row wrap;
}
.animes-historical-statistics-charts-wrapper > div {
    flex-basis: 50%;
}

/* --------------------------------- Files --------------------------------- */
.btn-select-all-files {
    display: flex;
    align-items: center;
    justify-content: space-around;
    width: 16ch;
    color: black;
    text-align: center;
    font-weight: bold;
    padding: 0.8em;
    background-color: white;
    border: 1px solid grey;
    border-radius: 5px;
    cursor: pointer;
}
.btn-select-all-files:hover {
    background-color: #eaeaea;
}
.file-tag {
    font-size: 0.8rem;
    color: black;
    display: inline-block;
    padding: 0.2em 0.5em;
    margin: 0.1em 0;
    border: 1px solid #DDDDDD;
    border-radius: 0.5em;
    min-width: 10ch;
    text-align: center;
}
.file-tag.extension {
    color: white;
    background-color: grey;
    border: none;
}
.file-tag.mkv {
    background-color: #008800;
}
.file-tag.mp4 {
    background-color: #dd5500;
}

/* -------------------------------- Pagination ----------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 0.85rem 1.1rem;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f8f8 100%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.04);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55em 0.95em;
    border: 1px solid #d0d0d0;
    border-radius: 999px;
    color: #202124;
    background: #ffffff;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: all 0.15s ease;
}

.pagination-link:hover {
    border-color: #c0c0c0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.pagination-link.disabled {
    color: #9aa0a6;
    border-color: #e6e6e6;
    background: #f3f4f6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #5f6368;
    font-weight: 600;
}

.pagination-separator {
    color: #d0d4d9;
}

.pagination-page {
    white-space: nowrap;
}

.pagination-total {
    white-space: nowrap;
}
.file-tag.avi {
    background-color: #0088FF;
}
.btn-file-info {
    color: white;
    background-color: red;
    border: none;
}
.file-size {
    font-weight: bold;
}
.files-cards {
    flex-direction: column;
}
.file-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: 1s ease-out;
    border-left: 30px solid lightgray;
    padding: 0.5em 1em;
}
.select-file {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.select-file input {
    margin-right: 0.5em;
}
.file-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1em;
}
.file-info .file-metadata {
    flex: 0 1;
}
.file-card .file-creation {
    color: #888;
    font-size: 0.75rem;
    font-style: italic;
    overflow-wrap: anywhere;
}
.file-card .flag {
    display: inline;
    padding: 1em;
}
.file-editable-fields {
    flex: 1 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em 1em;
    min-height: 80px;
}
.file-editable-fields input {
    padding: 0.1em 0.5em;
}
.file-editable-fields label {
    display: inline-block;
    font-size: 0.75rem;
    width: 8ch;
}
.file-editable-fields .filepath, .file-editable-fields .file-anime-metadata {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}
.file-editable-fields .filepath {
    flex: 1 1;
}
.file-editable-fields .filepath input {
    min-width: 90%;
    max-width: 100%;
}

.file-delete input:checked, input#bulk-delete:checked {
    background-color: red;
}

/* BULK FILES EDIT */
#files-bulk {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin: 2em auto;
    gap: 1em;
    max-width: 900px;
    padding: 1em;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

#files-bulk-edit {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.bulk-section {
    background-color: white;
    padding: 1em;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.bulk-section h3 {
    margin: 0 0 1em 0;
    font-size: 1.1em;
    color: #333;
    border-bottom: 2px solid #2e51a2;
    padding-bottom: 0.5em;
}

.bulk-episode-controls,
.bulk-anime-controls,
.bulk-directory-controls,
.bulk-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8em;
    position: relative;
}

.bulk-episode-controls > div,
.bulk-anime-controls > div,
.bulk-directory-controls > div,
.directory-operations {
    display: flex;
    align-items: center;
    gap: 0.5em;
    flex-wrap: wrap;
}

.bulk-section label {
    font-weight: 600;
    min-width: 100px;
    color: #555;
}

.bulk-section input[type="text"],
.bulk-section input[type="number"],
.bulk-section select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.bulk-section input[type="text"]:focus,
.bulk-section input[type="number"]:focus,
.bulk-section select:focus {
    outline: none;
    border-color: #2e51a2;
    box-shadow: 0 0 0 2px rgba(46, 81, 162, 0.1);
}

#files-bulk button {
    padding: 8px 16px;
    background-color: #2e51a2;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

#files-bulk button:hover {
    background-color: #1e3a7a;
}

#files-bulk button.btn-primary {
    background-color: #28a745;
    padding: 10px 20px;
    font-size: 15px;
}

#files-bulk button.btn-primary:hover {
    background-color: #218838;
}

#files-bulk button.btn-update {
    background-color: #007bff;
    padding: 12px 24px;
    font-size: 16px;
    align-self: center;
    margin-top: 1em;
}

#files-bulk button.btn-update:hover {
    background-color: #0056b3;
}

#bulk-episode-increment,
#bulk-episode-decrement {
    padding: 6px 12px;
    background-color: #6c757d;
    min-width: 36px;
}

#bulk-episode-increment:hover,
#bulk-episode-decrement:hover {
    background-color: #545b62;
}

/* Anime search results dropdown */
.search-results {
    position: absolute;
    background-color: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: none;
    margin-top: 2px;
    min-width: 300px;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    gap: 0.5em;
    border-bottom: 1px solid #f0f0f0;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item .anime-id {
    font-weight: 600;
    color: #2e51a2;
    min-width: 50px;
}

.search-result-item .anime-title {
    color: #333;
    font-size: 1rem;
}

.no-results,
.error-msg {
    padding: 10px 12px;
    color: #6c757d;
    font-style: italic;
}

.anime-preview {
    margin-left: 0.5em;
    font-size: 14px;
}

.anime-preview a {
    color: #2e51a2;
    text-decoration: none;
}

.anime-preview a:hover {
    text-decoration: underline;
}

.bulk-summary {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    display: none;
    margin-top: 1em;
}

@media (max-width: 800px) {
    #files-bulk {
        padding: 0.5em;
    }

    .bulk-section label {
        min-width: auto;
    }

    .bulk-episode-controls > div,
    .bulk-anime-controls > div,
    .bulk-directory-controls > div {
        flex-direction: column;
        align-items: stretch;
    }
}

/* MyList Cards */
.mylist-cards {
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: stretch;
    align-content: center;
}
.mylist-card {
    flex: 1 0 300px;
    display: flex;
    flex-direction: column;
}

@media screen and (max-width: 500px) {
    .content {
        max-width: 100%;
    }
    .animes-cards {
        flex-direction: column;
        align-items: stretch;
    }
    .card {
        flex-basis: 100%;
    }
}

/* ========================================================================= */
.details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2em;
}
.details > * {
    flex-grow: 0;
    flex-basis: 240px;
    display: flex;
    flex-direction: column;
    background-color: white;
    padding: 0.2em;
}
.details .label {
    display: block;
    font-weight: bold;
    font-size: 1.2rem;
}

/* ------------------------------ Anime Info ------------------------------- */
.url {
    overflow-wrap: anywhere;
}
.start-end {
    font-style: italic;
}
.anime-id::before {
    content: "#";
}
.company {
    display: block;
    flex-wrap: wrap;
}
.company .label {
    display: block;
    font-weight: bold;
    font-size: 1.2rem;
}
.company .tags {
    display: block;
    flex-direction: column;
    flex-grow: 1;
}

/* Company */
.company a {
    display: inline-block;
    margin: 1px;
    padding: 0.25em 0.5em;
    color: white;
    background-color: #000000;
}
.company a.Studio {
    background-color: #800000;
}

.company a.Producer {
    background-color: #008000;
}

.company a.Licensor {
    background-color: #000080;
}

.anime-description {
    width: 100%;
    max-width: none;
}

/* ------------------------------ Pagination ------------------------------- */
#pagination {
    display: flex;
    justify-content: center;
    column-gap: 1em;
}
#pagination>span,
#pagination>a {
    flex-grow: 1;
    padding: 2em;
    color: black;
    background-color: #ccc;
    text-align: center;
}
#pagination a {
    color: white;
    background-color: black;
}
#pagination a:hover {
    background-color: red;
}

#pagination>button {
    flex-grow: 1;
    padding: 2em;
    color: black;
    background-color: #ccc;
    text-align: center;
}

#pagination button {
    border: none;
    background-color: #f1f1f1;
    color: black;
    padding: 8px 16px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    border-radius: 5px;
}

#pagination button.active {
    cursor: pointer;
    background-color: red;
    color: white;
}

#pagination button.active:hover {
    background-color: red;
}

#pagination-info {
    display: flex;
    justify-content: center;
    margin: 1em 0;
}
/* --------------------------------- Forms --------------------------------- */
.form-vertical fieldset {
    border: none;
}
.update-mylist form {
    text-align: center;
}
.update-mylist form input[type=file] {
    min-width: 60%;
}
.form-vertical button[type=submit] {
    background-color: dodgerblue;
    color: white;
    font-weight: bold;
    font-size: 1.25em;
    border: none;
    border-radius: 5px;
    display: block;
    margin: 10px auto;
    padding: 0.5em 3em;
}
.form-vertical button:hover {
    background-color: royalblue;
}

.success {
    background-color: rgb(130, 255, 161);
    color: green;
    padding: 20px;
}
.fail {
    background-color: rgb(252, 94, 94);
    color: red;
    padding: 20px;
}

.details .blake2 {
    font-size: 0.8rem;
}

#video_tracks, #audio_tracks, #text_tracks, #anitomy {
    display: none;
}

/* LOGIN */
.login-wrapper {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: -3em -0.5em 0;
    padding: 2em 1em;
}

.login-wrapper img {
    display: block;
    margin: 0 auto 2em;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    background-color: white;
    padding: 8px;
}

.login-form {
    display: flex;
    justify-content: center;
    width: 100%;
}

.login-form form {
    display: flex;
    flex-direction: column;
    max-width: 96%;
    width: 420px;
    background: white;
    padding: 2.5em;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-form form fieldset {
    border: none;
    padding: 0;
}

.login-form form label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5em;
    font-size: 0.95rem;
}

.login-form form input[type=text],
.login-form form input[type=password] {
    width: 100%;
    padding: 0.9em 1em;
    margin: 0 0 1.5em 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.login-form form input[type=text]:focus,
.login-form form input[type=password]:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-form .remember-me {
    display: flex;
    align-items: center;
    margin: 0.5em 0 1.5em 0;
    gap: 0.5em;
}

.login-form .remember-me label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    user-select: none;
}

.login-form .remember-me input[type="checkbox"] {
    width: 1.2em;
    height: 1.2em;
    margin: 0;
    cursor: pointer;
    border: 2px solid #e0e0e0;
}

.login-form .remember-me input[type="checkbox"]:checked {
    background-color: #667eea;
    border-color: #667eea;
}

.login-form form input[type=submit] {
    width: 100%;
    padding: 1em;
    margin: 1em 0 0 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 1.05rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.login-form form input[type=submit]:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.login-form form input[type=submit]:active {
    transform: translateY(0);
}

.login-form .error {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: -1em;
    margin-bottom: 1em;
    padding: 0.5em;
    background-color: #ffe6e6;
    border-radius: 4px;
}

@media (max-width: 600px) {
    .login-wrapper {
        margin: -3em -0.5em 0;
    }

    .login-form form {
        padding: 2em 1.5em;
        width: 100%;
    }
}

/* Push the right-hand group (search + auth link) to the far right */
nav.topmenu .navbar-search,
nav.topmenu a.login-link {
    margin-left: auto;
}

/* --------------------------- Navbar Search ------------------------------- */
.navbar-search {
    display: flex;
    align-items: center;
    gap: 0.4em;
    padding: 0 0.5em;
}

.navbar-search input[name="query"] {
    padding: 6px 12px;
    font-size: 0.88rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);
    width: 180px;
    max-width: 100%;
    background-color: var(--color-card-bg);
    color: var(--color-text-main);
    margin: 0;
}

.navbar-search input[name="query"]:focus {
    outline: none;
    border-color: var(--color-primary-dark);
}

.navbar-search select {
    padding: 6px 8px;
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);
    background-color: var(--color-card-bg);
    color: var(--color-text-main);
    max-width: 130px;
    margin: 0;
}

.navbar-search .navbar-search-desc {
    color: var(--color-text-main);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25em;
    white-space: nowrap;
    cursor: pointer;
    margin: 0;
}

.navbar-search button {
    padding: 6px 12px;
    font-size: 0.88rem;
    border: none;
    border-radius: var(--radius-small);
    cursor: pointer;
    background-color: var(--color-primary-dark);
    color: white;
    margin: 0;
    transition: var(--transition-smooth);
}

.navbar-search button:hover {
    background-color: #e08b97;
}

.navbar-search .navbar-search-help {
    font-weight: 700;
    width: 2.2em;
    background-color: var(--color-border);
    color: var(--color-text-main);
}
.navbar-search .navbar-search-help:hover {
    background-color: #e2dacf;
}

/* Below large desktops the search drops onto its own full-width row so it
   never has to fight the menu links for horizontal space. */
@media (max-width: 1300px) {
    nav.topmenu .navbar-search {
        order: 1;
        width: 100%;
        margin-left: 0;
        flex-wrap: wrap;
        padding: 0.5em 0;
    }
    .navbar-search input[name="query"] {
        flex: 1 1 220px;
        width: auto;
    }
}

/* Phones: collapse the menu behind a hamburger toggle */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
        margin-left: auto;
    }
    .nav-collapse {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        background-color: var(--color-bg);
    }
    .nav-collapse.open {
        display: flex;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }
    /* Full-width, comfortably tappable links with subtle dividers */
    nav.topmenu .nav-collapse a {
        display: block;
        width: 100%;
        text-align: left;
        padding: 0.9em 1.2em;
        border-top: 1px solid var(--color-border);
    }
    /* Search block laid out cleanly inside the open menu */
    nav.topmenu .nav-collapse .navbar-search {
        order: 0;
        width: 100%;
        margin: 0;
        flex-wrap: wrap;
        gap: 0.6em;
        padding: 0.9em 1.2em;
        border-top: 1px solid var(--color-border);
        box-sizing: border-box;
    }
    .nav-collapse .navbar-search input[name="query"] {
        flex: 1 1 100%;
        width: auto;
    }
    .nav-collapse .navbar-search select {
        flex: 1 1 auto;
        max-width: none;
    }
    /* Solid header when mobile menu is open */
    header.top:has(.nav-collapse.open) {
        background-color: var(--color-bg);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    /* Clip overflow from full-bleed sections (e.g. anime poster) */
    main.content {
        overflow-x: clip;
    }
}

/* --------------------------- Search Help Modal --------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 2em 1em;
    overflow-y: auto;
}

.modal-overlay.open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.modal-panel {
    background-color: white;
    border-radius: 6px;
    padding: 1.5em 2em;
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-panel h3 {
    margin-top: 0;
    font-size: 1.5rem;
}

.modal-close {
    position: absolute;
    top: 0.5em;
    right: 0.75em;
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: #495057;
}

.modal-close:hover {
    color: red;
}

/* Help content (rendered inside the modal) */
.modal-panel .help-content h4 {
    font-size: 1.1em;
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: #212529;
}

.modal-panel .help-content h4:first-child {
    margin-top: 0;
}

.modal-panel .help-content ul {
    list-style: none;
    padding-left: 1em;
}

.modal-panel .help-content li {
    margin: 0.5em 0;
    line-height: 1.5;
}

.modal-panel .help-content code {
    background-color: #f1f3f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384;
}

.modal-panel .help-content p {
    margin: 0.5em 0;
}

.modal-panel .syntax-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5em 0;
}

.modal-panel .syntax-table th,
.modal-panel .syntax-table td {
    border: 1px solid #dee2e6;
    padding: 6px 8px;
    text-align: left;
    font-size: 0.9em;
}

.modal-panel .syntax-table th {
    background-color: #f4f4f4;
}

/* ========================= Home Page ========================= */

.home-hero {
    padding: 2em 0 1em;
    text-align: center;
}
.home-hero .page-title {
    font-size: 3.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #ff9eaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.home-tagline {
    font-size: 1rem;
    color: #999;
    margin-top: 0.3em;
    letter-spacing: 0.03em;
}

.home-sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2em;
    margin-top: 1.5em;
    padding-bottom: 2em;
}

.home-section {
    padding: 0.6em 0;
}

.home-section-wide {
    grid-column: span 2;
}

.home-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #764ba2;
    margin-bottom: 0.8em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid #f0e8ff;
}

.home-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em;
}
.home-tags a {
    color: inherit;
}
.home-tags .anime-tag {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}
.home-tags a:hover .anime-tag {
    transform: scale(1.07);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.13);
}

@media (max-width: 768px) {
    .home-section-wide {
        grid-column: span 1;
    }
    .home-sections-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 600px) {
    .home-hero {
        padding: 1.2em 0 0.8em;
    }
    .home-hero .page-title {
        font-size: 2.5rem;
    }
}

/* Unauthenticated CTA */
.home-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 2em 1em;
}
.cta-emoji {
    font-size: 5rem;
    line-height: 1;
    margin-bottom: 0.4em;
    animation: float 3s ease-in-out infinite;
    display: block;
}
.cta-title {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #ff9eaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.2em;
    letter-spacing: 0.05em;
}
.cta-subtitle {
    font-size: 1.05rem;
    color: #999;
    margin-bottom: 2em;
    max-width: 360px;
}
.cta-login-btn {
    display: inline-block;
    padding: 0.85em 2.8em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff !important;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}
.cta-login-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 28px rgba(102, 126, 234, 0.55);
}
.cta-features {
    display: flex;
    gap: 2.5em;
    margin-top: 3em;
    flex-wrap: wrap;
    justify-content: center;
}
.cta-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35em;
    color: #aaa;
    font-size: 0.9rem;
}
.feature-icon {
    font-size: 1.8rem;
    line-height: 1;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-12px); }
}

/* ====================== Tags Management Page ====================== */

.tags-search-wrap {
    position: sticky;
    top: 0;
    z-index: 10;
    background: whitesmoke;
    padding: 0.7em 0 0.9em;
    margin-bottom: 1.5em;
}
.tags-search-input {
    width: 100%;
    max-width: 360px;
    padding: 0.55em 1.1em;
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.2s;
    margin: 0;
}
.tags-search-input:focus {
    outline: none;
    border-color: #764ba2;
}

.tags-small-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2em 3em;
    margin-bottom: 2.5em;
}
.tags-large-sections {
    display: flex;
    flex-direction: column;
    gap: 2em;
    padding-bottom: 2em;
}

.tags-mgmt-section {
    min-width: 0;
}
.tags-mgmt-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #764ba2;
    margin-bottom: 0.7em;
    padding-bottom: 0.4em;
    border-bottom: 2px solid #f0e8ff;
}
.tags-mgmt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.35em;
}

.tag-mgmt-row {
    display: flex;
    min-width: 0;
}

.tag-preview-label {
    display: flex;
    align-items: center;
    gap: 0.2em;
    width: 100%;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 0.5em;
    padding: 0.25em 0.55em;
    font-size: 0.8rem;
    color: #333;
    cursor: text;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
    box-sizing: border-box;
}
.tag-preview-label:focus-within {
    border-color: #764ba2;
    box-shadow: 0 0 0 2px rgba(118, 75, 162, 0.12);
}

@keyframes flash-ok {
    0%, 100% { border-color: #ddd;    box-shadow: none; }
    45%       { border-color: #28a745; box-shadow: 0 0 0 2px rgba(40,167,69,0.18); }
}
@keyframes flash-err {
    0%, 100% { border-color: #ddd;    box-shadow: none; }
    45%       { border-color: #dc3545; box-shadow: 0 0 0 2px rgba(220,53,69,0.18); }
}
.tag-preview-label.flash-ok  { animation: flash-ok  0.65s ease; }
.tag-preview-label.flash-err { animation: flash-err 0.65s ease; }

input.tag-emoji-input {
    flex: 0 0 1.8em;
    width: 1.8em;
    border: none;
    background: transparent;
    font-size: 1em;
    padding: 0;
    margin: 0;
    text-align: center;
    cursor: text;
    color: inherit;
}
input.tag-emoji-input:focus {
    outline: none;
}
input.tag-emoji-input::placeholder {
    color: #bbb;
}
.tag-mgmt-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .tags-small-sections {
        grid-template-columns: 1fr 1fr;
        gap: 1.5em;
    }
    .tags-mgmt-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

