/* ========== Catppuccin Mocha Palette ========== */
:root {
    /* Catppuccin Mocha Base */
    --ctp-mocha-rosewater: #dc8a78;
    --ctp-mocha-flamingo: #dd7878;
    --ctp-mocha-pink: #ea76cb;
    --ctp-mocha-mauve: #8839ef;
    --ctp-mocha-red: #d20f39;
    --ctp-mocha-maroon: #e64553;
    --ctp-mocha-peach: #fe640b;
    --ctp-mocha-yellow: #df8e1d;
    --ctp-mocha-green: #40a02b;
    --ctp-mocha-teal: #179299;
    --ctp-mocha-sky: #04a5e5;
    --ctp-mocha-sapphire: #209fb5;
    --ctp-mocha-blue: #1e66f5;
    --ctp-mocha-lavender: #7287fd;
    --ctp-mocha-text: #cdd6f4;
    --ctp-mocha-subtext1: #bac2de;
    --ctp-mocha-subtext0: #a6adc8;
    --ctp-mocha-overlay2: #9399b2;
    --ctp-mocha-overlay1: #7f849c;
    --ctp-mocha-overlay0: #6c7086;
    --ctp-mocha-surface2: #585b70;
    --ctp-mocha-surface1: #45475a;
    --ctp-mocha-surface0: #313244;
    --ctp-mocha-base: #1e1e2e;
    --ctp-mocha-mantle: #181825;
    --ctp-mocha-crust: #11111b;

    /* Semantic Mappings (Material‑like to Catppuccin) */
    --md-sys-color-background: var(--ctp-mocha-crust);
    --md-sys-color-surface: var(--ctp-mocha-base);
    --md-sys-color-primary: var(--ctp-mocha-mauve);
    --md-sys-color-on-primary: var(--ctp-mocha-crust);
    --md-sys-color-secondary: var(--ctp-mocha-teal);
    --md-sys-color-on-secondary: var(--ctp-mocha-crust);
    --md-sys-color-error: var(--ctp-mocha-red);
    --md-sys-color-on-error: var(--ctp-mocha-crust);
    --md-sys-color-surface-variant: var(--ctp-mocha-surface1);
    --md-sys-color-on-surface: var(--ctp-mocha-text);
    --md-sys-color-on-surface-variant: var(--ctp-mocha-subtext0);
    --md-sys-color-outline: var(--ctp-mocha-overlay0);

    /* Accent Colors (preserved for status/rating differentiation) */
    --color-safe: #40a02b;
    --color-questionable: #fe640b;
    --color-explicit: #d20f39;
    --color-custom: #8839ef;
    --color-deleted: #dd7878;
    --color-unknown: #45475a;
    --color-auto: #1e66f5;
    --color-exists: #fe640b;
    --color-not-found: #ea76cb;
}

/* ========== Base (used globally) ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', sans-serif;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

/* ========== App Bar (base.html) ========== */
.app-bar {
    background-color: var(--md-sys-color-surface);
    padding: 6px 24px 2px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-bar-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--md-sys-color-primary);
}
.app-bar-title img {
    height: 4rem;
    width: auto;
}
.app-bar-nav a {
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    margin-left: 24px;
    display: inline-flex;
    align-items: center;
}
.app-bar-nav a i {
    margin-right: 6px;
}
.app-bar-nav a:hover {
    color: var(--md-sys-color-primary);
}
.version-badge {
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    padding: 4px 8px;
    border-radius: 16px;
    white-space: nowrap;
}
.version-badge i {
    font-size: 0.7rem;
}
.separator {
    opacity: 0.6;
    margin: 0 2px;
}
.desktop-version { display: inline-flex; }
.mobile-version { display: none; }

@media (max-width: 700px) {
    .app-bar-nav .nav-text { display: none; }
    .desktop-version { display: none; }
    .mobile-version { display: inline-flex; }
}

/* ========== Main Container ========== */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    flex: 1;
    padding: 24px;
}
.main-content {
    width: 100%;
    flex: 1;
    padding: 24px;
}
.centered-wrapper {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    width: 25%;
}
.centered-wrapper.register { width: 45%; }
.centered-wrapper.duplicates { width: 40%; }

/* ========== Gallery Grid ========== */
.gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* default: 2 columns */
    gap: 16px;
    width: 100%;
}
/* Increase columns as screen widens */
@media (min-width: 500px) {
    .gallery { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 720px) {
    .gallery { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 960px) {
    .gallery { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1200px) {
    .gallery { grid-template-columns: repeat(6, 1fr); }
}

.gallery-tiny{
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* default: 2 columns */
    gap: 16px;
    width: 100%;
}
.gallery-item {
    background-color: var(--md-sys-color-surface);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}
.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
/* Status & Rating borders */
.gallery-item.status-matched.rating-s,
.gallery-item.rating-s {
    border: 4px solid var(--color-safe);
}
.gallery-item.status-matched.rating-q,
.gallery-item.rating-q {
    border: 4px solid var(--color-questionable);
}
.gallery-item.status-matched.rating-e,
.gallery-item.rating-e {
    border: 4px solid var(--color-explicit);
}
.gallery-item.status-custom.rating-custom-s {
    border: 4px solid var(--color-safe);
    background-color: var(--color-custom);
}
.gallery-item.status-custom.rating-custom-q {
    border: 4px solid var(--color-questionable);
    background-color: var(--color-custom);
}
.gallery-item.status-custom.rating-custom-e {
    border: 4px solid var(--color-explicit);
    background-color: var(--color-custom);
}
.gallery-item.status-unknown {
    border: 4px solid var(--color-unknown);
}
.gallery-item.status-not_found {
    border: 4px solid var(--color-not-found);
}
.gallery-item.status-deleted {
    border: 4px solid var(--color-deleted);
}

.thumbnail {
    aspect-ratio: 1 / 1;
    background-color: var(--md-sys-color-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.thumbnail img,
.thumbnail video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.filename {
    padding: 8px;
    font-size: 0.875rem;
    text-align: center;
    word-break: break-word;
}
.filesize {
    padding: 0 8px 8px 8px;
    font-size: 0.75rem;
    text-align: center;
    color: var(--ctp-mocha-text);
}
.thumbnail .library-exists,
.thumbnail .library-missing {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    pointer-events: none;
    font-size: 1.5em;
    text-shadow: 0 0 8px var(--ctp-mocha-text);
}
.thumbnail .library-exists {
    color: var(--ctp-mocha-green);
}
.thumbnail .library-missing {
    color: var(--ctp-mocha-red);
}

/* ========== Pagination ========== */
.pagination {
    margin-top: 24px;
    text-align: center;
}
.pagination a,
.pagination span {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 4px;
    background-color: var(--md-sys-color-surface);
    border-radius: 20px;
    text-decoration: none;
    color: inherit;
}
.pagination a:hover {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.current-page {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

/* ========== Gallery Controls ========== */
.gallery-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.sort-selector,
.per-page-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sort-selector select,
.per-page-selector select {
    padding: 6px 10px;
    border-radius: 20px;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline);
}
.pagination-info {
    font-size: 0.9rem;
}

/* ========== Detail View ========== */
.detail-container {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.media {
    flex: 2;
    min-width: 300px;
}
.media img,
.media video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
}
.info {
    flex: 1;
    min-width: 250px;
    background-color: var(--md-sys-color-surface);
    padding: 16px;
    border-radius: 12px;
    align-self: flex-start;
}
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--md-sys-color-on-primary);
}
.badge-safe { background-color: var(--color-safe); }
.badge-questionable { background-color: var(--color-questionable); }
.badge-explicit { background-color: var(--color-explicit); }
.badge-matched { background-color: var(--color-safe); }
.badge-not-found { background-color: var(--color-explicit); }
.badge-deleted { background-color: var(--color-explicit); }
.badge-unknown { background-color: var(--color-unknown); }
.badge-custom { background-color: var(--color-custom); }
.badge-staff { background-color: var(--md-sys-color-primary); }
.badge-admin { background-color: var(--ctp-mocha-yellow); color: var(--ctp-mocha-crust); }
.badge-custom-safe {
    background: linear-gradient(90deg, var(--color-custom) 0%, var(--color-safe) 100%);
}
.badge-custom-questionable {
    background: linear-gradient(90deg, var(--color-custom) 0%, var(--color-questionable) 100%);
}
.badge-custom-explicit {
    background: linear-gradient(90deg, var(--color-custom) 0%, var(--color-explicit) 100%);
}
.badge-optimized {
    background-color: var(--ctp-mocha-green);
}
.badge-processing {
    background-color: var(--ctp-mocha-mauve);
}
.badge-not-optimized{
    background-color: var(--ctp-mocha-lavender);
}
#past-opt-badge-container {
    display: inline-block;
}
.rating {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: bold;
}
.rating-s { background-color: var(--color-safe); color: var(--md-sys-color-on-primary); }
.rating-q { background-color: var(--color-questionable); color: var(--md-sys-color-on-primary); }
.rating-e { background-color: var(--color-explicit); color: var(--md-sys-color-on-primary); }
.download-btn,
.fuzzysearch-btn {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 24px;
    font-weight: 500;
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
    display: inline-block;
}
.download-btn:hover,
.fuzzysearch-btn:hover {
    background: var(--ctp-mocha-pink); /* lighter hover */
}
.download-btn.disabled {
    background-color: var(--md-sys-color-outline);
}
.download-btn-success,
#favorite-btn.btn-success {
background-color: var(--color-safe);
color: var(--md-sys-color-on-primary);
cursor: default;
}
.match-e621-section {
    margin-top: 16px;
}

/* Optimize Modal */
.optimize-modal-content {
    max-width: 900px;
    width: 90%;
}
.optimize-preview-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start;
}
.preview-original,
.preview-processed {
    flex: 1;
    text-align: center;
    min-width: 0;
}
.preview-original video,
.preview-original img,
.preview-processed video,
.preview-processed img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    background: var(--md-sys-color-surface-variant);
    object-fit: contain;
}
#original-preview-container,
#processed-preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}
.options-panel { margin-top: 15px; }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}
.modal-close-x {
    color: var(--md-sys-color-on-surface-variant);
    transition: color 0.2s;
}
.modal-close-x:hover {
    color: var(--md-sys-color-error);
}
.status-message {
    margin-top: 10px;
    font-style: italic;
}
.file-size {
    margin-top: 5px;
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
}
.metadata-info {
    margin-top: 5px;
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.metadata-item { display: inline-block; }
.metadata-separator {
    color: var(--md-sys-color-outline);
    user-select: none;
}
#optimize-status {
    margin: 10px 0;
    padding: 8px;
    border-radius: 4px;
    background-color: var(--md-sys-color-surface-variant);
}

/* ========== Tag Cloud & Clickable Tags ========== */
.tag-cloud {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
}
.tag-cloud .tag,
.tag.clickable {
    display: inline-block;
    background: var(--md-sys-color-surface-variant);
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 0.8rem;
    margin: 2px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
}
.tag-cloud .tag:hover,
.tag.clickable:hover {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    cursor: pointer;
}
.tag-item { cursor: pointer; }

/* ========== Sidebar ========== */
.sidebar-toggle {
    position: fixed;
    top: 70px;
    left: 16px;
    z-index: 100;
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-primary);
    border: none;
    font-size: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.sidebar-toggle:hover {
    background: var(--md-sys-color-surface-variant);
}
.sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100%;
    background: var(--md-sys-color-surface);
    border-right: 1px solid var(--md-sys-color-outline);
    transition: left 0.3s ease;
    z-index: 200;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0,0,0,0.3);
}
.sidebar-open .sidebar { left: 0; }
.sidebar-open .main-content { margin-left: 320px; }
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--md-sys-color-outline);
}
.sidebar-header h3 {
    margin: 0;
    font-weight: 500;
}
.close-sidebar {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
}
.close-sidebar:hover {
    color: var(--md-sys-color-primary);
}
.filter-section {
    margin-bottom: 24px;
}
.filter-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}
.filter-section input[type="text"],
.filter-section select {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    background: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    color: var(--md-sys-color-on-surface);
}
.filter-section button { margin-top: 8px; }

.sidebar-pool-item,
.sidebar-tag-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--md-sys-color-outline);
}
.sidebar-pool-item a,
.sidebar-tag-item a {
    flex: 1;
    margin-right: 8px;
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    word-break: break-word;
}
.sidebar-pool-item a:hover,
.sidebar-tag-item a:hover {
    color: var(--md-sys-color-primary);
}
.follow-tag-icon,
.follow-pool-icon {
    flex-shrink: 0;
    margin-left: auto;
    cursor: pointer;
    transition: color 0.2s;
}
.follow-tag-icon:hover,
.follow-pool-icon:hover {
    opacity: 0.8;
}

/* ========== Suggestions Dropdown ========== */
.suggestions-dropdown,
.tag-suggestions-dropdown {
    position: absolute;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    width: 100%;
    margin-top: 4px;
}
.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    transition: background 0.2s;
}
.suggestion-item:hover {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.tag-input-wrapper {
    position: relative;
    width: 100%;
}
.tag-search-input {
    width: 100%;
    padding: 8px;
    background: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    color: var(--md-sys-color-on-surface);
}

/* ========== Selected Tags ========== */
.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.selected-tag {
    display: inline-flex;
    background: var(--md-sys-color-surface-variant);
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface);
    gap: 4px;
    align-items: center;
}
.selected-tag .remove {
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--md-sys-color-error);
}

/* ========== Forms & Buttons ========== */
button,
 .btn {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 8px 16px;
    border-radius: 24px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}
button:hover,
.btn:hover {
    background-color: var(--ctp-mocha-pink);
}
.btn-secondary {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}
.btn-secondary:hover {
    background-color: var(--md-sys-color-outline);
}
input,
select,
textarea {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline);
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 8px;
}
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    margin-bottom: 4px;
    color: var(--md-sys-color-on-surface-variant);
}

.token-hint {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 16px;
}
.token-hint code {
    background: var(--md-sys-color-surface-variant);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--md-sys-color-on-surface);
}

/* ========== User Bar & Auth Bar ========== */
.user-bar {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1000;
}
.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}
.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.default-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.user-menu {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    width: 200px;
    display: none;
    padding-bottom: 0.2rem;
    z-index: 1001;
}
.user-menu a,
.user-info {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
}
.user-menu a.user-edit {
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
}
.user-menu a:hover {
    background: var(--md-sys-color-surface-variant);
}
.user-info {
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding: 0;
}
.logout-button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    width: 100%;
    text-align: left;
}
.logout-button:hover {
    color: var(--md-sys-color-primary);
}
.auth-bar {
    position: fixed;
    bottom: 16px;
    right: 16px;
    background: var(--md-sys-color-surface);
    padding: 8px 12px;
    border-radius: 24px;
    font-size: 0.9rem;
}
.auth-bar a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}
.auth-bar a:hover {
    text-decoration: underline;
}

/* ========== Upload Page ========== */
.dropzone {
    border: 2px dashed var(--md-sys-color-outline);
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    cursor: pointer;
    background: var(--md-sys-color-surface);
}
.dropzone.dragover {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-variant);
}
.file-list {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.file-item {
    background: var(--md-sys-color-surface);
    border-radius: 8px;
    overflow: hidden;
}
.file-item .thumbnail {
    aspect-ratio: 1;
    background: var(--md-sys-color-surface-variant);
}
.file-item .meta-btn {
    width: 100%;
    padding: 8px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    cursor: pointer;
}
.file-item .meta-btn.completed {
    background: var(--color-safe);
    color: var(--md-sys-color-on-primary);
    cursor: default;
}
.file-item .meta-btn.auto-completed {
    background: var(--color-auto);
    color: var(--md-sys-color-on-primary);
    cursor: default;
}
.file-item .meta-btn.already-exists {
    background: var(--color-exists);
    color: var(--md-sys-color-on-primary);
    cursor: default;
}
.section {
    border-top: 1px solid var(--md-sys-color-outline);
    padding-top: 1rem;
}
.section h3 {
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 500;
}

.upload-columns {
    display: flex;
    gap: 16px;
    width: 100%;
    margin-top: 1.5rem;
}
.upload-column {
    flex: 1;
    min-width: 0;
    width: 33.33%;
}
.upload-column .upload-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

/* Batch progress */
.batch-progress {
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--md-sys-color-surface);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}
.batch-progress .batch-bar {
    flex: 1;
}

/* Upload progress bar */
.upload-progress {
    padding: 8px;
}
.progress-track {
    width: 100%;
    height: 6px;
    background: var(--md-sys-color-surface-variant);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--md-sys-color-primary);
    transition: width 0.3s ease;
    width: 0%;
    border-radius: 3px;
}

/* Visual match purple button */
.file-item .meta-btn.visual-match {
    background: var(--color-custom);
    color: var(--md-sys-color-on-primary);
}

/* Visual match info in modal */
.visual-match-info {
    background: var(--md-sys-color-surface-variant);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    border-left: 4px solid var(--color-custom);
}
.visual-match-info .match-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.visual-match-info .match-thumb {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.visual-match-info .match-details {
    font-size: 0.85rem;
}
.visual-match-info .match-details strong {
    color: var(--color-custom);
}
.visual-match-info .similarity-badge {
    display: inline-block;
    background: var(--color-custom);
    color: var(--md-sys-color-on-primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}
.visual-match-group {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--md-sys-color-outline);
}
.visual-match-group .group-label {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 6px;
}
.visual-match-group .group-members {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.visual-match-group .group-member {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}
.visual-match-group .group-member:hover {
    border-color: var(--md-sys-color-primary);
}
.visual-match-group .group-member img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* iqdb results modal */
.iqdb-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}
.iqdb-match-card {
    display: flex;
    flex-direction: column;
    background: var(--md-sys-color-surface-variant);
    border-radius: 8px;
    overflow: hidden;
}
.iqdb-match-card .gallery-item {
    border-radius: 0;
}
.iqdb-match-card .iqdb-download-btn {
    width: 100%;
    padding: 6px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.iqdb-match-card .iqdb-download-btn:hover {
    background: var(--ctp-mocha-pink);
}
.iqdb-match-card .iqdb-download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.iqdb-match-card .iqdb-download-btn.downloaded {
    background: var(--color-safe);
    cursor: default;
}

/* Mobile: stack columns, 2-grid per container */
@media (max-width: 700px) {
    .upload-columns {
        flex-direction: column;
        gap: 0;
    }
    .upload-column {
        width: 100%;
    }
    .upload-column .upload-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .iqdb-results {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* ========== Modal ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal-content {
    background: var(--md-sys-color-surface);
    padding: 24px;
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}
.close {
    float: right;
    font-size: 24px;
    cursor: pointer;
}
.modal-preview {
    text-align: center;
    margin-bottom: 16px;
}
.modal-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
    background: var(--md-sys-color-surface-variant);
}

/* ========== Delete Page ========== */
.delete-container {
    max-width: 800px;
    margin: 0 auto;
}
.delete-container textarea {
    width: 100%;
    min-height: 120px;
    font-family: monospace;
}

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.folder-card {
    background: var(--md-sys-color-surface-variant);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.folder-card .folder-icon {
    font-size: 24px;
    color: var(--ctp-mocha-text);
    margin-bottom: 4px;
}
.folder-card .folder-name {
    font-weight: 600;
    font-size: 14px;
}
.folder-card .folder-count {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}
.folder-card .folder-size {
    font-size: 13px;
    margin-bottom: 8px;
}
.folder-card .btn-clear {
    background: var(--ctp-mocha-red);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 14px;
    font-size: 12px;
    cursor: pointer;
}
.folder-card .btn-clear:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.library-info {
    background: var(--md-sys-color-surface);
    border-radius: 10px;
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.6;
}

/* ========== Duplicates Page ========== */
.duplicate-set {
    background: var(--md-sys-color-surface);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.duplicate-files {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
}
.duplicate-file-item {
    width: 150px;
    position: relative;
}
.duplicate-file-item .delete-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    z-index: 1;
}
.visual-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.similarity-badge {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.7rem;
    margin-top: 4px;
    text-align: center;
}
.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.close-group-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--md-sys-color-error);
}
.threshold-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 1em 0;
}
#similarity-threshold {
width: 200px;
}
.delete-btn {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    padding: 6px 10px;
}

/* ========== Statistics Page ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}
.card {
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.log-card {
    grid-column: 1 / -1;
}
.log-container {
    background: var(--ctp-mocha-crust);
    color: var(--ctp-mocha-text);
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    padding: 12px;
    border-radius: 8px;
    height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-container pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    text-align: left;
    padding: 4px 0;
    border-bottom: 1px solid var(--md-sys-color-outline);
}
.error {
    color: var(--md-sys-color-error);
}
.badge.badge-stats{
    color: var(--ctp-mocha-text);
    background-color: var(--ctp-mocha-mauve);
}

/* ========== Avatar Picker ========== */
.avatar-option {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
}
.avatar-option.selected {
    border: 3px solid var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px rgba(var(--ctp-mocha-mauve), 0.3);
}

/* ========== Pool Cards ========== */
.pool-card {
    cursor: pointer;
}
.pool-thumbnail .loading-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-surface-variant);
}
.no-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
}
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--md-sys-color-on-surface-variant);
}

/* ========== Admin Overrides ========== */
body.django-admin {
    background: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
}
#header {
background: var(--md-sys-color-surface);
border-bottom: 1px solid var(--md-sys-color-outline);
padding: 16px 24px;
display: flex;
justify-content: space-between;
align-items: center;
}
#branding h1 a {
color: var(--md-sys-color-primary);
text-decoration: none;
font-size: 1.5rem;
font-weight: 500;
}
#user-tools {
font-size: 0.875rem;
display: flex;
gap: 12px;
align-items: center;
}
#user-tools a,
#user-tools button {
background: none;
border: none;
color: var(--md-sys-color-primary);
cursor: pointer;
font: inherit;
padding: 0;
}
#user-tools a:hover,
#user-tools button:hover {
text-decoration: underline;
}
div.breadcrumbs {
    background: var(--md-sys-color-surface-variant);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    margin: 16px 24px;
}
div.breadcrumbs a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}
.module {
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}
.module h2,
.module caption {
    background: var(--md-sys-color-surface-variant);
    padding: 12px 16px;
    font-weight: 500;
}
.module table {
    width: 100%;
    border-collapse: collapse;
}
.module th,
.module td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--md-sys-color-outline);
}
.module th {
    text-align: left;
    font-weight: 500;
    background: var(--md-sys-color-surface-variant);
}
.module tr:hover {
    background: var(--md-sys-color-surface-variant);
}
.button,
input[type="submit"],
.submit-row input {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
}
.button:hover,
input[type="submit"]:hover,
.submit-row input:hover {
    background: var(--ctp-mocha-pink);
}
a.addlink,
a.changelink,
a.deletelink {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}
.errornote {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.login #container {
    align-items: center;
    justify-content: center;
}
.login #content {
    max-width: 400px;
    margin: 40px auto;
    background: var(--md-sys-color-surface);
    padding: 24px;
    border-radius: 28px;
}
.login .form-row {
    margin-bottom: 16px;
}
.login label {
    display: block;
    margin-bottom: 4px;
}
.login input[type="text"],
.login input[type="password"] {
    width: 100%;
    padding: 8px;
    background: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    color: var(--md-sys-color-on-surface);
}

/* ========== Blacklisted follows ========== */
.gallery-item.blacklisted .thumbnail img,
.gallery-item.blacklisted .thumbnail video,
.gallery-item.blacklisted .thumbnail .no-preview { display: none; }
.gallery-item.blacklisted .thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-color-surface-variant);
}
.blacklisted-overlay {
    color: var(--ctp-mocha-red);
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    padding: 8px;
}

/* ========== HTMX ========== */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: block; }
.htmx-request.htmx-indicator { display: block; }

/* ========== Home Page ========== */
.home-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 200px;
    gap: 20px;
    align-items: stretch;
    margin-bottom: 28px;
}
.home-placeholder-text {
    color: var(--md-sys-color-on-surface-variant, #a6adc8);
    font-size: 0.85rem;
    margin: 0;
}
.home-hero {
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    padding: 24px 28px;
    text-align: center;
    border: 1px solid var(--md-sys-color-outline);
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.home-hero h1 {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    margin-bottom: 8px;
}
.home-hero p {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.95rem;
    max-width: 640px;
    margin: 0 auto 4px auto;
}
.home-hero .home-hero-sub {
    font-size: 0.85rem;
    max-width: 560px;
}
.home-hero-actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.btn-primary {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 24px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-primary:hover {
    background: var(--ctp-mocha-pink);
}
.btn-secondary {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 24px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-secondary:hover {
    background: var(--md-sys-color-outline);
}

.home-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
@media (max-width: 900px) {
    .home-layout {
        grid-template-columns: 1fr;
    }
}.stat-card {
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    border: 1px solid var(--md-sys-color-outline);
}
.stat-card i {
    font-size: 1.15rem;
    color: var(--md-sys-color-primary);
}
.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface);
}
.stat-label {
    font-size: 0.72rem;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.home-section {
    margin-bottom: 32px;
}
.home-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}
.home-section-header h2 {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}
.home-section-link {
    color: var(--md-sys-color-primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.pack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.pack-card {
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--md-sys-color-outline);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.pack-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}
.pack-card-thumb {
    aspect-ratio: 16 / 9;
    background: var(--md-sys-color-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.pack-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.pack-card-body {
    padding: 12px 16px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.pack-card-body h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}
.pack-card-author {
    font-size: 0.8rem;
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.pack-card-desc {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    flex: 1;
}
.pack-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant);
}
.pack-card-version,
.pack-card-downloads {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.how-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.how-card {
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--md-sys-color-outline);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.how-card i {
    font-size: 1.5rem;
    color: var(--md-sys-color-primary);
}
.how-card h3 {
    font-size: 1rem;
    font-weight: 500;
}
.how-card p {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.5;
}

.home-gate-note {
    background: var(--md-sys-color-surface-variant);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}
.home-gate-note i {
    color: var(--md-sys-color-primary);
    font-size: 1.2rem;
}
.home-gate-note code {
    background: var(--md-sys-color-surface);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--md-sys-color-on-surface);
}

/* ========== Account Settings ========== */
.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.account-card h2 {
    font-size: 1.05rem;
    margin-top: 0;
    margin-bottom: 8px;
}
.account-current {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 12px;
}
.account-current code {
    background: var(--md-sys-color-surface-variant);
    padding: 2px 6px;
    border-radius: 4px;
}
.avatar-preview {
    margin-bottom: 12px;
}
.avatar-preview img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--md-sys-color-outline);
}
.avatar-preview .default-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    font-size: 2.5rem;
}
.default-avatar.large {
    width: 96px;
    height: 96px;
    font-size: 2.5rem;
    border-radius: 50%;
}

/* ========== Public Profile ========== */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
}
.profile-avatar img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--md-sys-color-outline);
}
.profile-avatar .default-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    font-size: 3rem;
}
.profile-info h1 {
    margin: 0 0 4px;
}
.profile-joined {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
    margin: 0 0 12px;
}
.profile-section {
    margin-bottom: 16px;
}
.profile-section h2 {
    margin-top: 0;
    font-size: 1.05rem;
}
.profile-bio {
    line-height: 1.6;
    margin: 0;
}
.profile-bio-empty {
    color: var(--md-sys-color-on-surface-variant);
    margin: 0;
}

/* ========== Markdown ========== */
.markdown-body {
    line-height: 1.6;
    color: var(--md-sys-color-on-surface);
    overflow-wrap: break-word;
}
.markdown-body > *:first-child {
    margin-top: 0;
}
.markdown-body > *:last-child {
    margin-bottom: 0;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin: 1em 0 0.4em;
    line-height: 1.3;
}
.markdown-body h1 { font-size: 1.6rem; }
.markdown-body h2 { font-size: 1.35rem; }
.markdown-body h3 { font-size: 1.15rem; }
.markdown-body h4 { font-size: 1rem; }
.markdown-body p {
    margin: 0.5em 0;
}
.markdown-body ul,
.markdown-body ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}
.markdown-body li {
    margin: 0.15em 0;
}
.markdown-body a {
    color: var(--md-sys-color-primary);
    text-decoration: underline;
}
.markdown-body code {
    background: var(--md-sys-color-surface-variant);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}
.markdown-body pre {
    background: var(--md-sys-color-surface-variant);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.6em 0;
}
.markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
}
.markdown-body blockquote {
    border-left: 3px solid var(--md-sys-color-primary);
    margin: 0.6em 0;
    padding: 0.2em 1em;
    color: var(--md-sys-color-on-surface-variant);
}
.markdown-body table {
    border-collapse: collapse;
    margin: 0.6em 0;
    width: 100%;
}
.markdown-body th,
.markdown-body td {
    border: 1px solid var(--md-sys-color-outline);
    padding: 6px 10px;
    text-align: left;
}
.markdown-body th {
    background: var(--md-sys-color-surface-variant);
}
.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
}
.markdown-body hr {
    border: none;
    border-top: 1px solid var(--md-sys-color-outline);
    margin: 1em 0;
}
.bio-help {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    margin: 4px 0 8px;
}
.bio-actions {
    display: flex;
    gap: 8px;
}
.markdown-preview {
    margin-top: 12px;
    padding: 16px;
    background: var(--md-sys-color-surface-variant);
    border-radius: 12px;
}
.pack-card-empty {
    opacity: 0.75;
    pointer-events: none;
}
.pack-card-empty .pack-card-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-variant);
}

/* ========== UGC / Browse ========== */
.pack-card-thumb-icon {
    font-size: 3rem;
    color: var(--md-sys-color-on-surface-variant);
}
.pack-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.75rem;
    text-decoration: none;
    line-height: 1.5;
}
.tag-chip.active {
    background: rgba(255, 255, 255, 0.08);
}
.tag-chip-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 2px 5px;
    margin-left: 2px;
    border-radius: 50%;
    opacity: 0.7;
}
.tag-chip-remove:hover {
    opacity: 1;
    background: rgba(127, 127, 127, 0.25);
}
.tag-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.tag-count {
    opacity: 0.7;
    font-size: 0.7rem;
}

/* Browse layout */
.browse-header h1 {
    margin-bottom: 16px;
}
.browse-search-form {
    margin-bottom: 16px;
}
.browse-search-row {
    display: flex;
    gap: 8px;
    max-width: 560px;
}
.browse-search-input {
    flex: 1;
}
.browse-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    align-items: start;
}
.browse-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 16px;
}
.filter-card h3 {
    margin-top: 0;
    font-size: 0.95rem;
}
.filter-group-toggle {
    position: relative;
    width: 100%; display: flex; align-items: center; gap: 6px;
    background: none; border: none; color: inherit; cursor: pointer;
    font-size: 0.95rem; font-weight: 600; padding: 4px 0; text-align: left;
}
.filter-group-toggle::before {
    content: '';
    position: absolute;
    inset: 2px -16px;
    border-radius: 8px;
    background: transparent;
    pointer-events: none;
}
.filter-group-toggle:hover,
.filter-group-toggle:focus-visible {
    background: transparent;
}
.filter-group-toggle:hover::before,
.filter-group-toggle:focus-visible::before {
    background: rgba(255, 255, 255, 0.07);
}
.filter-chevron { margin-left: auto; transition: transform 0.2s ease; }
.filter-group-toggle[aria-expanded="true"] .filter-chevron { transform: rotate(180deg); }
.filter-tags.collapsed { display: none; }
.filter-category {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filter-link {
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
}
.filter-link:hover {
    background: var(--md-sys-color-surface-variant);
}
.filter-link.active {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-primary);
    font-weight: 500;
}
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.filter-empty {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.85rem;
}
.browse-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.browse-count {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
}
.browse-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 16px;
    color: var(--md-sys-color-on-surface-variant);
}
.browse-empty i {
    font-size: 3rem;
    margin-bottom: 12px;
}
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
}
.page-info {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
}

/* Project detail */
.project-header {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}
.project-avatar img {
    width: 128px;
    height: 128px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid var(--md-sys-color-outline);
}
.project-avatar .default-avatar {
    width: 128px;
    height: 128px;
    font-size: 3rem;
    border-radius: 12px;
}
.project-header-main {
    flex: 1;
}
.project-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.project-title-row h1 {
    margin: 0;
}
.category-badge {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-radius: 999px;
    padding: 2px 12px;
    font-size: 0.8rem;
    text-transform: capitalize;
}
.project-summary {
    color: var(--md-sys-color-on-surface-variant);
    margin: 8px 0;
}
.project-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface-variant);
    flex-wrap: wrap;
}
.project-owner a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
}
.project-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.project-tags {
    margin-bottom: 16px;
    padding: 12px 16px;
}
.tag-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
}
.tag-group-label {
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
    margin-right: 4px;
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    margin-bottom: 16px;
}
.tab-btn {
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    padding: 10px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.tab-btn:hover {
    color: var(--md-sys-color-on-surface);
}
.tab-btn.active {
    color: var(--md-sys-color-primary);
    border-bottom-color: var(--md-sys-color-primary);
}
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}

/* Versions */
.version-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.version-row:last-child {
    border-bottom: none;
}
.version-info {
    min-width: 120px;
}
.version-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.version-name {
    font-size: 1rem;
}
.latest-badge {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
}
.version-date {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.8rem;
}
.version-changelog {
    flex: 1;
    font-size: 0.9rem;
}
.version-changelog > *:first-child {
    margin-top: 0;
}
.version-changelog > *:last-child {
    margin-bottom: 0;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.gallery-item {
    position: relative;
    margin: 0;
    background: var(--md-sys-color-surface-variant);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 4 / 3;
}
.gallery-item img,
.gallery-item video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.gallery-item figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2;
}
.gallery-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 3;
}
.gallery-delete:hover {
    background: var(--md-sys-color-error);
}
.gallery-expand {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
    z-index: 3;
}
.gallery-item:hover .gallery-expand {
    opacity: 1;
}
.empty-hint {
    color: var(--md-sys-color-on-surface-variant);
    margin: 8px 0;
}

/* Forms */
.project-form {
    padding: 24px;
    max-width: 720px;
}
.project-form input:not([type='hidden']):not([type='file']),
.project-form select,
.project-form textarea {
    width: 100%;
}
.form-section-title {
    margin: 24px 0 8px;
}
.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}
.btn-danger {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

/* Tag editor */
.tag-editor {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tag-suggestions {
    position: absolute;
    z-index: 50;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    min-width: 220px;
}
.tag-suggestion {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
}
.tag-suggestion:hover {
    background: var(--md-sys-color-surface-variant);
}
.tag-suggestion small {
    color: var(--md-sys-color-on-surface-variant);
}

/* Contributors */
.contributor-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.contributor-input-group {
    position: relative;
    flex: 1;
    min-width: 220px;
}
.contributor-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.contributor-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.contributor-row:last-child {
    border-bottom: none;
}
.contributor-name i {
    margin-right: 8px;
}
.inline-form {
    margin: 0;
}
.user-suggestions {
    position: absolute;
    z-index: 50;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    max-height: 240px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .browse-layout {
        grid-template-columns: 1fr;
    }
    .browse-filters {
        position: static;
    }
    .project-header {
        flex-direction: column;
    }
    .version-row {
        flex-direction: column;
        gap: 8px;
    }
}

/* ========== Horizontal project form ========== */
.project-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}
.project-form-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.project-form-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-self: start;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

@media (min-width: 992px) {
    .project-form-grid {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        align-items: start;
    }
    .project-form-side {
        position: sticky;
        top: 16px;
    }
}

/* ========== Multi-upload drop zone ========== */
.drop-zone {
    border: 2px dashed var(--md-sys-color-outline);
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    color: var(--md-sys-color-on-surface-variant);
}
.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-variant);
}
.drop-zone-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    color: var(--md-sys-color-primary);
}
.drop-zone-text {
    margin: 0 0 4px;
    font-weight: 500;
}
.drop-zone-sub {
    margin: 0;
    font-size: 0.85rem;
}
.file-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.file-preview-card {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: var(--md-sys-color-surface-variant);
    aspect-ratio: 1 / 1;
}
.file-preview-card img,
.file-preview-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.file-preview-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--md-sys-color-on-surface-variant);
}
.file-preview-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.file-preview-remove:hover {
    background: var(--md-sys-color-error);
}

/* ========== Horizontal create form ========== */
.create-form {
    max-width: none;
    width: 100%;
}
.create-form input:not([type='hidden']):not([type='file']),
.create-form select,
.create-form textarea {
    width: 100%;
}
.create-form .form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.create-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    min-width: 0;
}
.create-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    align-self: start;
    min-width: 0;
}
.create-panel .form-section-title {
    margin: 0 0 4px;
    font-size: 1rem;
}

@media (min-width: 992px) {
    .create-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
    .create-panel-main { grid-row: span 2; }
}
@media (min-width: 1280px) {
    .create-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.2fr); }
}

/* ========== Upload zones ========== */
.upload-zone .drop-zone { padding: 24px 16px; }
.upload-zone .drop-zone-icon { font-size: 1.8rem; margin-bottom: 4px; }
.upload-preview { margin-top: 12px; }
.upload-preview .file-preview-card { max-width: 200px; }

.upload-batch[hidden] {
    display: none;
}
.upload-batch {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.85rem;
}

/* ========== Autosave status ========== */
.autosave-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}
.autosave-status.saved { color: var(--md-sys-color-primary); }
.autosave-status.error { color: var(--md-sys-color-error); }
.autosave-status.idle { color: var(--md-sys-color-on-surface-variant); }

/* ========== Impersonation ========== */
.impersonate-chip {
    position: absolute;
    right: 56px;                 /* 48px avatar + 8px gap */
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 4px;
    border-radius: 999px;
    background: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-on-surface);
    font-size: 0.72rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.impersonate-chip:hover {
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-primary);
}
.impersonate-chip img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}
.impersonate-chip .default-avatar.mini,
.default-avatar.mini {
    width: 22px;
    height: 22px;
    font-size: 0.65rem;
    flex: none;
}

/* Users directory */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    text-decoration: none;
    color: inherit;
}
.user-card:hover {
    border-color: var(--md-sys-color-primary);
}
.user-card-avatar {
    width: 48px;
    height: 48px;
    flex: none;
    border-radius: 50%;
    overflow: hidden;
    background: var(--md-sys-color-surface-variant);
}
.user-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.user-card-body h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}
.user-card-meta {
    margin: 0;
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}

/* ========== Project ID badge ========== */
.project-id-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.72rem;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 6px;
}

/* ========== Per-file version list ========== */
.version-downloads {
    display: inline-block;
    margin-left: 12px;
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}
.version-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.version-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-variant);
    max-width: 100%;
}
.version-file-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}
.version-file-icon {
    font-size: 1.4rem;
    color: var(--md-sys-color-on-surface-variant);
}
.version-file-name {
    font-size: 0.8rem;
    word-break: break-all;
}

/* ========== Per-file caption on media previews ========== */
.file-caption {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(100% - 44px);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.7rem;
    padding: 3px 6px;
}
.file-caption::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* ========== Category-specific (Phase 2) ========== */
.pack-format-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font-size: 0.7rem;
    font-weight: 600;
}
.pack-description {
    margin: 6px 0 0;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}

/* Guide switcher */
.guide-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding-bottom: 10px;
}
.guide-switch-btn {
    background: none;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 999px;
    color: var(--md-sys-color-on-surface-variant);
    padding: 5px 12px;
    font-size: 0.8rem;
    cursor: pointer;
}
.guide-switch-btn:hover {
    color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
.guide-switch-btn.active {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}
.guide-content {
    max-height: 70vh;
    overflow-y: auto;
}

/* Mods tab */
.mods-version {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.mods-version h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
}
.mods-source-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.7rem;
}
.mods-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}
.mods-list li {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--md-sys-color-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== Global messages banner ========== */
.messages-banner {
    margin-bottom: 16px;
}
.message {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.message-success {
    background: var(--md-sys-color-primary-container, #d8f3dc);
    color: var(--md-sys-color-on-primary-container, #1b4332);
    border-color: var(--md-sys-color-primary);
}
.message-warning {
    background: var(--md-sys-color-error-container, #fdecea);
    color: var(--md-sys-color-on-error-container, #7f1d1d);
    border-color: var(--md-sys-color-error, #b3261e);
}
.message-error {
    background: var(--md-sys-color-error-container, #fdecea);
    color: var(--md-sys-color-on-error-container, #7f1d1d);
    border-color: var(--md-sys-color-error, #b3261e);
}

/* ========== Animations tab ========== */
.animations-header h2 {
    margin: 0 0 8px;
}
.anim-pack-name {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 4px;
}
.anim-authors {
    margin: 0 0 4px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
}
.anim-description {
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
}
.anim-warning {
    margin: 10px 0 0;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--md-sys-color-error-container, #fdecea);
    color: var(--md-sys-color-on-error-container, #7f1d1d);
    font-size: 0.82rem;
}
.animations-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 14px 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--md-sys-color-surface-variant);
    font-size: 0.82rem;
    color: var(--md-sys-color-on-surface-variant);
}
.animations-summary strong {
    color: var(--md-sys-color-on-surface);
}
.anim-summary-flagged strong {
    color: var(--md-sys-color-error);
}
.anim-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.anim-card {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-low);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.anim-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.anim-name {
    font-size: 0.95rem;
}
.anim-type-badge {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    font-size: 0.68rem;
    font-weight: 600;
}
.anim-problem {
    color: var(--md-sys-color-error);
    cursor: help;
}
.anim-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.anim-actors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.actor-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--md-sys-color-surface-variant);
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface);
}
.actor-chip small {
    opacity: 0.7;
}
.injector-badge {
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--md-sys-color-secondary-container, #e8def8);
    color: var(--md-sys-color-on-secondary-container, #21005d);
    font-size: 0.68rem;
    font-weight: 600;
}
.anim-stages {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.stages-count {
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-right: 4px;
}
.stage-chip {
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--md-sys-color-surface-variant);
    font-size: 0.7rem;
    color: var(--md-sys-color-on-surface-variant);
}
.stage-chip .fa-star {
    color: var(--md-sys-color-error);
    margin-right: 2px;
}
.anim-extras {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.anim-extra {
    font-size: 0.72rem;
    color: var(--md-sys-color-on-surface-variant);
}

/* ========== Modals (gallery + model viewer) ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay[hidden] {
    display: none;
}
.modal-content {
    position: relative;
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    padding: 16px;
    width: fit-content;
    min-width: 0;
    max-width: 96vw;
    max-height: 92vh;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    z-index: 5;
}
.modal-close:hover {
    background: var(--md-sys-color-error);
    color: #fff;
}
.media-modal-content {
    padding: 8px;
    min-width: min(420px, 92vw);
}
.modal-media {
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-media img,
.modal-media video {
    display: block;
    max-width: 90vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    flex: none;
    border-radius: 8px;
}
.modal-media img {
    min-width: 320px;
    image-rendering: pixelated;
}
.modal-caption {
    text-align: center;
    margin: 10px 0 4px;
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface-variant);
}
.model-modal-content {
    width: min(720px, 94vw);
}
.model-modal-title {
    margin: 0 0 10px;
    font-size: 1rem;
}
.model-disclaimer {
    margin-top: 8px;
    color: var(--md-sys-color-on-surface-variant);
}
.model-disclaimer .fa-exclamation-triangle {
    color: var(--md-sys-color-error);
}
#model-viewer-container {
    width: 100%;
    height: 480px;
    border-radius: 10px;
    overflow: hidden;
    background: #1e1e2e;
}

/* ========== Models/Textures tab ========== */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.model-card {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-low);
}
.model-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.model-card-head strong {
    font-size: 0.9rem;
    word-break: break-all;
}
.model-meta {
    margin: 6px 0;
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant);
}
.model-textures {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.model-textures img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-variant);
}
.model-textures.strip {
    margin-top: 10px;
}
.model-textures.strip img {
    width: 32px;
    height: 32px;
}
.models-textures-title {
    margin: 18px 0 8px;
    font-size: 0.95rem;
}

/* ========== Logical tab ========== */
.logical-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.logical-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--md-sys-color-surface-variant);
    font-size: 0.8rem;
}
.logical-item img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}
.logical-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.logical-list li {
    font-size: 0.82rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--md-sys-color-surface-variant);
}
.logical-list code,
.logical-tags code {
    font-size: 0.78rem;
}
.logical-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.logical-tags code {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--md-sys-color-surface-variant);
    word-break: break-all;
}
.badge-disabled {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--md-sys-color-error-container, #fdecea);
    color: var(--md-sys-color-on-error-container, #7f1d1d);
    font-size: 0.68rem;
}

/* Full-screen Blockbench preview overlay */
.bb-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: #121418;
    display: flex;
    flex-direction: column;
}
.bb-overlay[hidden] { display: none; }
.bb-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: #1a1d24;
    color: #e6e6e6;
    border-bottom: 1px solid #2a2e38;
    flex: 0 0 auto;
}
.bb-overlay-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bb-overlay-close {
    background: none;
    border: none;
    color: #e6e6e6;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
}
.bb-overlay-close:hover { background: #2a2e38; }
.bb-overlay-status {
    position: absolute;
    top: 3.1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.8rem;
    pointer-events: none;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bb-frame {
    flex: 1 1 auto;
    width: 100%;
    border: none;
    background: #121418;
}

/* Modpack badges + Mods tab */
.modpack-badge {
    background: #1d3557;
    color: #e6f1ff;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
}
.mods-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.mods-source-badge {
    background: var(--md-sys-color-primary-container, #dbe4ff);
    color: var(--md-sys-color-on-primary-container, #001b3f);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.mods-stat {
    color: var(--md-sys-color-on-surface-variant, #555);
    font-size: 0.8rem;
}
.mods-filter {
    width: 100%;
    max-width: 420px;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline, #ccc);
    background: var(--md-sys-color-surface, #fff);
    color: inherit;
    margin-bottom: 0.75rem;
}
.mods-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.mods-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    background: var(--md-sys-color-surface-variant, #45475a);
    color: var(--md-sys-color-on-surface, #cdd6f4);
    font-size: 0.85rem;
}
.mods-item:hover { background: var(--md-sys-color-surface2, #585b70); }
.mods-name { font-weight: 600; }
.mods-file { color: var(--md-sys-color-on-surface-variant, #777); font-size: 0.78rem; }
.mods-badge {
    margin-left: auto;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
}
.mods-badge.optional { background: #fff4d6; color: #7a5c00; }
.mods-badge.client { background: #d9f2ff; color: #00567a; }
.mods-badge.server { background: #e6e0ff; color: #3a2d8f; }
.mods-link { color: inherit; text-decoration: none; opacity: 0.6; }
.mods-link:hover { opacity: 1; }

/* Model category format badges */
.model-format-badge {
    display: inline-block;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    padding: 0.1rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 0.35rem;
}
.model-tex-badge.embedded {
    display: inline-block;
    border-radius: 999px;
    background: #d1fae5;
    color: #065f46;
    padding: 0.1rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 0.35rem;
}
.model-incompatible {
    display: inline-block;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    padding: 0.15rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
}

/* Plugins tab */
.plugins-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: #fff4e0;
    border: 1px solid #f0c878;
    color: #7a4d00;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
}
.plugins-toggle {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
}
.plugins-toggle .switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.plugins-toggle .switch input { opacity: 0; width: 0; height: 0; }
.plugins-toggle .slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #cbd5e1; border-radius: 999px; transition: background 0.15s;
}
.plugins-toggle .slider:before {
    content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform 0.15s;
}
.plugins-toggle .switch input:checked + .slider { background: #059669; }
.plugins-toggle .switch input:checked + .slider:before { transform: translateX(18px); }
.plugins-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 0.25rem;
}
.plugins-list li {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.35rem 0.6rem; border-radius: 6px;
    background: var(--md-sys-color-surface-variant, #45475a);
    color: var(--md-sys-color-on-surface, #cdd6f4);
    font-size: 0.85rem;
}
.plugins-name { font-weight: 600; color: inherit; }
.plugins-badge.autoload {
    margin-left: auto;
    border-radius: 999px; background: #e0e7ff; color: #3730a3;
    padding: 0.1rem 0.5rem; font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
}
.plugins-size { color: var(--md-sys-color-on-surface-variant, #6b7280); font-size: 0.78rem; }

/* Skins tab */
.skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}
.skin-card {
    background: var(--md-sys-color-surface-variant, #45475a);
    border: 1px solid var(--md-sys-color-outline-variant, #3a3f4d);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.skin-preview {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    image-rendering: pixelated;
    background: repeating-conic-gradient(#2a2e3a 0 25%, #232732 0 50%) 0 0 / 24px 24px;
    border-radius: 6px;
}
.skin-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--md-sys-color-on-surface, #cdd6f4);
}
.skin-card-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.skin-size-badge {
    border-radius: 999px;
    background: #313244;
    color: #a6adc8;
    padding: 0.1rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    flex: 0 0 auto;
}
.skin-card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}
.skin-model-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--md-sys-color-on-surface-variant, #a6adc8);
}
.skin-model-select {
    background: var(--md-sys-color-surface, #1e1e2e);
    color: var(--md-sys-color-on-surface, #cdd6f4);
    border: 1px solid var(--md-sys-color-outline-variant, #45475a);
    border-radius: 6px;
    padding: 0.15rem 0.3rem;
    font-size: 0.75rem;
}
.skin-render-btn { width: 100%; }


/* Mod Info tab */
.mods-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: #fff4e0;
    border: 1px solid #f0c878;
    color: #7a4d00;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.9rem;
    font-size: 0.85rem;
}
.mod-card {
    background: var(--md-sys-color-surface-variant, #45475a);
    border: 1px solid var(--md-sys-color-outline-variant, #3a3f4d);
    border-radius: 10px;
    padding: 0.9rem;
    margin-bottom: 0.75rem;
}
.mod-card-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    color: var(--md-sys-color-on-surface, #cdd6f4);
    font-size: 1rem;
}
.mod-loader-badge {
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.1rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.mod-version { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.85rem; }
.mod-id { margin: 0.3rem 0 0; color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.78rem; }
.mod-desc { margin: 0.4rem 0; color: var(--md-sys-color-on-surface, #cdd6f4); font-size: 0.88rem; }
.mod-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.78rem; }
.mod-deps { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; }
.mod-deps li { color: var(--md-sys-color-on-surface-variant, #a6adc8); }
.mod-deps code { background: #313244; color: #cdd6f4; padding: 0 0.3rem; border-radius: 4px; }
.mod-dep-type { color: #8a94b0; font-size: 0.72rem; }

/* Gate page */
.gate-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 3rem 1rem;
    min-height: 60vh;
}
.gate-card {
    background: var(--md-sys-color-surface-variant, #45475a);
    border: 1px solid var(--md-sys-color-outline-variant, #3a3f4d);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
    color: var(--md-sys-color-on-surface, #cdd6f4);
}
.gate-card h1 { margin: 0.75rem 0 0.25rem; font-size: 1.4rem; }
.gate-card p { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.85rem; }
.gate-card form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.gate-card input[type="password"] {
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant, #45475a);
    background: var(--md-sys-color-surface, #1e1e2e);
    color: var(--md-sys-color-on-surface, #cdd6f4);
}
.gate-card form p {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
}
.gate-card form label {
    color: var(--md-sys-color-on-surface-variant, #a6adc8);
    font-size: 0.8rem;
}
.gate-card form input[type="text"],
.gate-card form input[type="email"],
.gate-card form input[type="password"] {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant, #45475a);
    background: var(--md-sys-color-surface, #1e1e2e);
    color: var(--md-sys-color-on-surface, #cdd6f4);
    box-sizing: border-box;
}
.gate-card form .errorlist {
    list-style: none;
    margin: 0.1rem 0 0;
    padding: 0;
    color: #f38ba8;
    font-size: 0.75rem;
}
.gate-card-alt { margin-top: 0.9rem; }
.gate-card-wide { max-width: 600px; }
.gate-card button {
    padding: 0.55rem;
    border-radius: 8px;
    border: none;
    background: var(--md-sys-color-primary, #89b4fa);
    color: #111;
    font-weight: 600;
    cursor: pointer;
}
.gate-error { color: #f38ba8 !important; font-weight: 600; margin-top: 0.5rem; }
.gate-disclaimer {
    margin: 1rem 0 0;
    color: var(--md-sys-color-on-surface-variant, #a6adc8);
    font-size: 0.8rem;
    text-align: center;
    max-width: 380px;
    line-height: 1.4;
}
.gate-disclaimer i { color: #f38ba8; margin-right: 0.3rem; }

/* Rating tab */
.rating-summary { margin-bottom: 1rem; }
.rating-percent { font-size: 1.6rem; font-weight: 700; color: var(--md-sys-color-on-surface, #cdd6f4); }
.rating-count { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.8rem; margin-left: 0.5rem; }
.rating-bar {
    display: flex; height: 10px; border-radius: 999px; overflow: hidden;
    background: var(--md-sys-color-surface, #1e1e2e); margin-top: 0.5rem; max-width: 420px;
}
.rating-bar-up { background: #40a02b; }
.rating-bar-down { background: #d20f39; }
.rating-vote { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: center; }
.rating-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.45rem 0.9rem; border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant, #45475a);
    background: var(--md-sys-color-surface, #1e1e2e);
    color: var(--md-sys-color-on-surface-variant, #a6adc8);
    cursor: pointer; font-size: 0.85rem;
}
.rating-btn.active { background: var(--md-sys-color-primary, #89b4fa); color: #111; border-color: var(--md-sys-color-primary, #89b4fa); }

/* Forum tab */
.comment-form { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem; }
.comment-form textarea, .comment-edit-form textarea {
    width: 100%; padding: 0.55rem 0.7rem; border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant, #45475a);
    background: var(--md-sys-color-surface, #1e1e2e);
    color: var(--md-sys-color-on-surface, #cdd6f4);
    font-family: inherit;
}
.comment-form button { align-self: flex-start; }
.comment-list { display: flex; flex-direction: column; gap: 0.9rem; }
.comment { padding: 0.8rem; border-radius: 10px; background: var(--md-sys-color-surface-variant, #45475a); }
.comment-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.comment-time, .comment-edited { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.75rem; }
.comment-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; }
.comment-body { margin-top: 0.4rem; }
.comment-edit-form { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.comment-edit-form[hidden] { display: none; }
.comment-edit-actions { display: flex; gap: 0.4rem; }
.link-btn { background: none; border: none; color: inherit; cursor: pointer; padding: 0; }
.inline { display: inline; }
.pack-card-rating { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.75rem; }

/* Server stats page */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.stats-grid .card { min-width: 0; }
.stats-grid h2 { margin-bottom: 0.6rem; }
.stat-table { width: 100%; border-collapse: collapse; }
.stat-table td { padding: 0.3rem 0.35rem; border-bottom: 1px solid var(--md-sys-color-outline-variant, #45475a); vertical-align: top; }
.stat-table td:first-child { color: var(--md-sys-color-on-surface-variant, #a6adc8); width: 45%; }
.stat-table tr:last-child td { border-bottom: none; }
.stat-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.85em; }
.stat-muted { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.8rem; }
.stat-bar-label { margin: 0.5rem 0 0.2rem; font-size: 0.85rem; }
.stat-bar-caption { margin: 0.15rem 0 0.5rem; color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.75rem; }
.bar-track { height: 8px; border-radius: 999px; background: var(--md-sys-color-surface-variant, #45475a); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--ctp-mocha-green); }
.bar-fill-swap { background: var(--ctp-mocha-peach); }
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.75rem; }
.stat-tile {
    background: var(--md-sys-color-surface-variant, #45475a);
    border-radius: 10px; padding: 0.6rem 0.5rem; text-align: center;
    display: flex; flex-direction: column; gap: 0.15rem;
}
.stat-tile-value { font-size: 1.15rem; font-weight: 700; }
.stat-tile-label { font-size: 0.68rem; color: var(--md-sys-color-on-surface-variant, #a6adc8); }
.stat-subhead { margin: 0.75rem 0 0.25rem; font-size: 0.9rem; }
.stat-line { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.8rem; margin: 0.25rem 0; }
.stat-chip {
    display: inline-block; background: var(--md-sys-color-surface-variant, #45475a);
    border-radius: 12px; padding: 2px 8px; margin: 2px 2px 2px 0; font-size: 0.75rem;
}
.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--md-sys-color-outline-variant, #45475a); font-size: 0.85rem; }
.stat-list li:last-child { border-bottom: none; }
.stat-excerpt { margin: 0.15rem 0 0; color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.78rem; }
.stat-up { color: var(--ctp-mocha-green); font-weight: 700; }
.stat-down { color: var(--ctp-mocha-red); font-weight: 700; }

/* Stats toolbar (auto-refresh header) */
.stats-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; flex-wrap: wrap; }
.stats-updated { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.8rem; }
.stats-error { color: var(--ctp-mocha-red); font-size: 0.8rem; }

/* Announcements */
.announce-detail { display: flex; flex-direction: column; gap: 20px; }
.home-placeholder {
    background: var(--md-sys-color-surface);
    border: 1px dashed var(--md-sys-color-outline-variant, #45475a);
    border-radius: 16px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 6px;
}
.home-placeholder h2 {
    font-size: 0.95rem;
    color: var(--md-sys-color-on-surface);
    margin: 0;
    text-align: left;
}
.home-placeholder h2 i { color: var(--md-sys-color-primary); }
.announce-panel {
    display: flex; flex-direction: column; gap: 0.3rem;
    max-height: 220px; overflow-y: auto; text-align: left;
}
.announce-item {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 0.5rem; padding: 0.22rem 0.45rem; border-radius: 6px;
    background: var(--md-sys-color-surface-variant, #45475a);
    font-size: 0.78rem; line-height: 1.3;
}
.announce-item a {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--md-sys-color-on-surface, #cdd6f4);
}
.announce-item.announce-unread a { color: var(--ctp-mocha-blue, #1e66f5); font-weight: 600; }
.announce-meta {
    color: var(--md-sys-color-on-surface-variant, #a6adc8);
    font-size: 0.68rem; white-space: nowrap; flex-shrink: 0;
}
.announce-more {
    display: inline-block; margin-top: 0.4rem; font-size: 0.75rem;
    color: var(--md-sys-color-primary, #89b4fa);
}
.announce-subhead { margin-top: 0.8rem; }
.announce-badge {
    display: inline-block; min-width: 1.1rem; text-align: center;
    background: var(--ctp-mocha-red); color: #fff; border-radius: 999px;
    font-size: 0.7rem; padding: 1px 5px; margin-left: 0.3rem;
}
.announce-actions {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem; margin-top: 0.1rem; flex-wrap: wrap;
}
.announce-actions .announce-more { margin-top: 0; }
.announce-list { display: flex; flex-direction: column; gap: 1rem; }
.announce-card h1, .announce-card h2 { margin-top: 0; }
.announce-card h2 a { color: var(--md-sys-color-on-surface, #cdd6f4); }
.announce-excerpt { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.9rem; }
.announce-admin { display: flex; gap: 0.5rem; margin-top: 1rem; }
.announce-form { max-width: 720px; }
.announce-form textarea { width: 100%; }
.announce-form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.form-input {
    width: 100%; padding: 0.55rem 0.7rem; border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant, #45475a);
    background: var(--md-sys-color-surface, #1e1e2e);
    color: var(--md-sys-color-on-surface, #cdd6f4); font-family: inherit;
}
.form-textarea {
    width: 100%; padding: 0.55rem 0.7rem; border-radius: 8px;
    border: 1px solid var(--md-sys-color-outline-variant, #45475a);
    background: var(--md-sys-color-surface, #1e1e2e);
    color: var(--md-sys-color-on-surface, #cdd6f4); font-family: inherit;
}
.notify-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.notify-item {
    padding: 0.55rem 0.6rem; border-radius: 8px; font-size: 0.85rem;
    background: var(--md-sys-color-surface-variant, #45475a);
}
.notify-item a { color: var(--md-sys-color-on-surface, #cdd6f4); }
.notify-item.notify-unread a { color: var(--ctp-mocha-blue, #1e66f5); font-weight: 600; }
.notify-new { color: var(--ctp-mocha-red); font-weight: 600; }

/* My Projects page */
.myprojects-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.myprojects-header h1 { margin: 0; }
.myprojects-layout { display: grid; grid-template-columns: 1fr 1px 1fr; gap: 24px; align-items: start; }
.myprojects-divider { background: var(--md-sys-color-outline-variant, #45475a); align-self: stretch; }
.myprojects-col h2 { margin-top: 0; font-size: 1.05rem; }
@media (max-width: 900px) {
    .myprojects-layout { grid-template-columns: 1fr; }
    .myprojects-divider { height: 1px; width: 100%; }
}
.draft-list { display: flex; flex-direction: column; gap: 0.6rem; }
.draft-card {
    background: var(--md-sys-color-surface-variant, #45475a);
    border-radius: 10px; padding: 0.7rem 0.8rem;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.draft-title { font-weight: 600; color: var(--md-sys-color-on-surface, #cdd6f4); text-decoration: none; }
.draft-meta { color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.75rem; }
.draft-actions { display: flex; gap: 0.4rem; align-items: center; }

/* Home per-category Popular/Recent sections */
.home-cat-row {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 24px;
    align-items: start;
    margin-bottom: 32px;
}
.home-cat-row-divider { background: var(--md-sys-color-outline-variant, #45475a); align-self: stretch; }
.home-cat-block { min-width: 0; }
.home-cat-block:only-child { grid-column: 1 / -1; }
.home-cat-cols {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 20px;
    align-items: start;
}
.home-cat-divider { background: var(--md-sys-color-outline-variant, #45475a); align-self: stretch; }
.home-cat-head { margin: 0 0 0.6rem; font-size: 0.95rem; }
.home-cat-head i { color: var(--md-sys-color-primary); margin-right: 0.3rem; }
.pack-row-list { display: flex; flex-direction: column; gap: 0.6rem; }
@media (max-width: 900px) {
    .home-cat-row { grid-template-columns: 1fr; }
    .home-cat-row-divider { height: 1px; width: 100%; }
    .home-cat-cols { grid-template-columns: 1fr; }
    .home-cat-divider { height: 1px; width: 100%; }
}
.pack-card-row {
    display: flex; align-items: center; gap: 0.75rem;
    background: var(--md-sys-color-surface-variant, #45475a);
    border: 1px solid var(--md-sys-color-outline-variant, #3a3f4d);
    border-radius: 10px; padding: 0.5rem 0.7rem;
    text-decoration: none; transition: border-color 0.15s;
}
.pack-card-row:hover { border-color: var(--md-sys-color-primary); }
.pack-card-row-thumb {
    width: 56px; height: 56px; flex-shrink: 0; border-radius: 8px;
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: var(--md-sys-color-surface, #1e1e2e);
}
.pack-card-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pack-card-row-thumb .pack-card-thumb-icon { font-size: 1.3rem; color: var(--md-sys-color-on-surface-variant, #a6adc8); }
.pack-card-row-body { min-width: 0; flex: 1; }
.pack-card-row-body h4 { margin: 0; font-size: 0.9rem; color: var(--md-sys-color-on-surface, #cdd6f4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-card-row-author { margin: 0.1rem 0 0; color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.72rem; }
.pack-card-row-meta { display: flex; gap: 0.6rem; margin: 0.15rem 0 0; color: var(--md-sys-color-on-surface-variant, #a6adc8); font-size: 0.72rem; flex-wrap: wrap; }
.pack-card-row-meta span { white-space: nowrap; }

/* Distinct accent button for auth-page cross links (differs from primary). */
.btn-accent {
    background: var(--ctp-mocha-blue, #1e66f5);
    color: #fff;
    border: none;
}
.btn-accent:hover {
    background: var(--ctp-mocha-sapphire, #209fb5);
    color: #fff;
}
