:root {
    --md-sys-color-background: #fffbfe;
    --md-sys-color-on-background: #1c1b1e;
    --md-sys-color-primary: #6750a4;
    --md-sys-color-surface-variant: #e7e0ec;
}

body.dark-theme {
    --md-sys-color-background: #1c1b1e;
    --md-sys-color-on-background: #e6e1e5;
    --md-sys-color-primary: #d0bcff;
    --md-sys-color-surface-variant: #49454f;
}

body {
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    margin: 0;
    font-family: 'Segoe UI', Roboto, sans-serif;
    padding-bottom: 80px; /* Space for nav */
}

.md3-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 80px;
    background-color: var(--md-sys-color-surface-variant);
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--md-sys-color-on-background);
    text-decoration: none;
    font-size: 12px;
}

.card {
    background: var(--md-sys-color-surface-variant);
    padding: 16px;
    margin: 10px;
    border-radius: 16px;
}

/* Layout Grid 3 Kolom */
.comic-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Horizontal 3 */
    gap: 12px;
    padding: 16px;
}

/* Comic Card Style MD3 */
.comic-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.thumbnail-container {
    aspect-ratio: 2 / 3; /* Thumbnail Vertikal */
    width: 100%;
    border-radius: 12px; /* MD3 Rounded Corner */
    overflow: hidden;
    background-color: var(--md-sys-color-surface-variant);
}

.thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.comic-card:hover img {
    transform: scale(1.05);
}

.comic-title {
    margin-top: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Potong teks jika kepanjangan */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

header {
    padding: 16px;
    font-size: 22px;
    font-weight: 400;
}

/* Detail Page */
.detail-container { padding: 16px; animation: fadeIn 0.3s ease; }
.detail-header { display: flex; gap: 16px; margin-bottom: 24px; }
.detail-img { width: 120px; aspect-ratio: 2/3; border-radius: 16px; object-fit: cover; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.detail-meta { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.detail-meta h2 { margin: 0; font-size: 1.4rem; color: var(--md-sys-color-primary); }

/* MD3 Chips for Genres */
.genre-wrapper { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { 
    background: var(--md-sys-color-surface-variant); 
    padding: 6px 12px; border-radius: 8px; font-size: 11px; font-weight: 500;
}

/* Chapter List */
.chapter-card {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; background: var(--md-sys-color-surface-variant);
    border-radius: 12px; margin-bottom: 8px; text-decoration: none; color: inherit;
}
.chapter-info span { display: block; font-size: 14px; font-weight: 500; }
.chapter-date { font-size: 11px; opacity: 0.6; margin-top: 2px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.search-container { padding: 16px; position: sticky; top: 0; background: var(--md-sys-color-background); z-index: 10; }
.search-input {
    width: 100%; padding: 12px 16px; border-radius: 28px; border: none;
    background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-background);
    font-size: 14px; outline: none;
}

.filter-group { 
    display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 16px; 
    scrollbar-width: none; /* Hide scrollbar Firefox */
}
.filter-group::-webkit-scrollbar { display: none; }

.filter-select {
    padding: 8px 12px; border-radius: 8px; border: 1px solid var(--md-sys-color-surface-variant);
    background: var(--md-sys-color-background); color: var(--md-sys-color-on-background);
    font-size: 12px; min-width: 100px;
}

/* Reader Full Width Mobile */
.reader-container {
    width: 100%;
    max-width: 100vw; /* Pas layar HP */
    background: #000; /* Warna background saat loading gambar */
}

.reader-img {
    width: 100%;
    display: block; /* Menghilangkan gap antar gambar */
    height: auto;
}

.reader-nav {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    background: var(--md-sys-color-background);
}

.btn-nav {
    padding: 12px 24px;
    border-radius: 25px;
    background: var(--md-sys-color-primary);
    color: white;
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-nav.disabled {
    background: var(--md-sys-color-surface-variant);
    opacity: 0.5;
    pointer-events: none;
}

/* Top App Bar MD3 */
.md3-top-app-bar {
    height: 64px;
    background-color: var(--md-sys-color-background);
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.header-content { display: flex; align-items: center; gap: 12px; }
.app-icon { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.app-title { font-size: 20px; font-weight: 500; margin: 0; color: var(--md-sys-color-primary); }

/* Mode Sembunyi */
.hidden-ui {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

/* Reader Mobile Pas (Tanpa Jarak) */
.reader-container {
    width: 100%;
    background: #000; /* Background hitam untuk fokus */
}

.reader-img {
    width: 100%;
    display: block; /* Menghilangkan gap putih antar gambar */
    height: auto;
}

/* FAB Bookmark */
.fab-bookmark {
    position: fixed;
    bottom: 30px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--md-sys-color-primary);
    color: white;
    border: none;
    box-shadow: var(--md-sys-shadow-3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
}

.comment-section { padding: 16px; border-top: 8px solid var(--md-sys-color-surface-variant); }
.comment-card { 
    background: var(--md-sys-color-surface-variant); 
    padding: 12px; border-radius: 12px; margin-bottom: 10px; 
}
.comment-user { font-weight: bold; font-size: 12px; color: var(--md-sys-color-primary); }
.comment-text { font-size: 14px; margin-top: 4px; }

.comment-input-group { display: flex; gap: 8px; margin-bottom: 20px; }
.comment-input {
    flex: 1; padding: 12px; border-radius: 12px; border: 1px solid var(--md-sys-color-surface-variant);
    background: var(--md-sys-color-background); color: inherit;
}
.btn-send { 
    background: var(--md-sys-color-primary); color: white; border: none; 
    border-radius: 12px; padding: 0 16px; 
}

.md3-header {
    position: fixed; /* Tetap menempel */
    top: 0; left: 0; right: 0;
    height: 64px;
    background: var(--md-sys-color-background);
    z-index: 1000;
    display: flex; align-items: center; padding: 0 16px;
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

/* Beri jarak agar konten tidak tertutup header */
#app { padding-top: 64px; }

/* Hilangkan saat baca */
.header-hidden { display: none; }
#app.no-padding { padding-top: 0; }
