:root {
    --primary-color: #2563eb;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    
    /* Source Colors */
    --dramabox-color: #ef4444;
    --melolo-color: #22c55e;
    --netshort-color: #3b82f6;

    /* Dimensions */
    --header-height: 60px;
    --bottom-nav-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    padding-bottom: calc(var(--bottom-nav-height) + 20px); /* Space for bottom nav */
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

/* Typography */
h1, h2, h3 {
    color: var(--text-primary);
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Navbar (Top) */
.navbar {
    background: var(--card-bg);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    padding: 0 15px;
    justify-content: space-between;
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5px;
}

.navbar-search {
    flex: 1;
    max-width: 400px;
    margin: 0 15px;
    position: relative;
}

.navbar-search form {
    display: flex;
}

.navbar-search input {
    width: 100%;
    padding: 8px 15px;
    padding-right: 40px; /* Space for search icon */
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.navbar-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.search-icon-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Bottom Navigation (Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background: var(--card-bg);
    box-shadow: 0 -1px 3px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.7rem;
    gap: 4px;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

/* Card Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns mobile default */
    gap: 15px;
}

@media (min-width: 640px) {
    .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
    .grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
    .grid { grid-template-columns: repeat(5, 1fr); }
}

/* Card Component */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.card:active {
    transform: scale(0.98);
}

@media(hover: hover) {
    .card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    }
}

.card-image-container {
    position: relative;
    padding-top: 140%; /* 5:7 Aspect Ratio roughly */
    width: 100%;
    background: #e2e8f0;
}

.card img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 20px;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

.badge-dramabox { 
    background-color: rgba(239, 68, 68, 0.9); 
}
.badge-melolo { 
    background-color: rgba(34, 197, 94, 0.9); 
}
.badge-netshort { 
    background-color: rgba(59, 130, 246, 0.9); 
}

.card-body {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 0.9rem;
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.6em; /* limit to 2 lines */
}

.card-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tags {
    margin-top: auto; /* Push to bottom */
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    height: 22px; /* Fixed height for 1 line of tags */
    overflow: hidden;
}

.tag {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Detail Page */
.detail-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

@media(min-width: 768px) {
    .detail-hero {
        flex-direction: row;
        align-items: start;
    }
}

.detail-cover {
    width: 100%;
    max-width: 240px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    align-self: center;
}

.detail-info h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    align-items: center;
}

.detail-meta .badge {
    padding: 6px 16px;
    border-radius: 20px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: inline-block;
}

.detail-intro {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
}

.episode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s;
}

.episode-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Player Page */
.player-container {
    background: black;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.player-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    z-index: 10;
    display: flex;
    align-items: center;
    color: white;
}

.back-icon {
    font-size: 1.2rem;
    margin-right: 15px;
    text-decoration: none;
    color: white;
    background: rgba(255,255,255,0.2);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }
.text-muted { color: var(--text-secondary); }
