:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: #ffffff;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --card-hover-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
    --info: #4299e1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--primary-gradient);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2em;
}

.header h1 {
    color: white;
    font-size: 2.5em;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 1em;
}

.btn {
    padding: 0.75em 1.5em;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}

.btn-primary {
    background: white;
    color: #764ba2;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Timeline Section */
.timeline-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2em;
    margin-bottom: 2em;
    box-shadow: var(--card-shadow);
}

.timeline-section h2 {
    margin-bottom: 1em;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.timeline-controls {
    display: flex;
    gap: 1em;
    margin-bottom: 1.5em;
    flex-wrap: wrap;
}

.timeline-controls select,
.timeline-controls input {
    padding: 0.5em 1em;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95em;
}

.timeline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75em;
}

.timeline-item {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
    padding: 0.75em;
    background: #f7fafc;
    border-radius: 6px;
    border-left: 3px solid var(--info);
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Media type color variations */
.timeline-item[data-type="movie"] {
    background: #fff5f5;
    border-left-color: #e53e3e;
}

.timeline-item[data-type="movie"]:hover {
    background: #fed7d7;
}

.timeline-item[data-type="movie"] .timeline-date {
    color: #c53030;
}

.timeline-item[data-type="tv_series"] {
    background: #f0fff4;
    border-left-color: #38a169;
}

.timeline-item[data-type="tv_series"]:hover {
    background: #c6f6d5;
}

.timeline-item[data-type="tv_series"] .timeline-date {
    color: #2f855a;
}

.timeline-item[data-type="book"] {
    background: #fffaf0;
    border-left-color: #dd6b20;
}

.timeline-item[data-type="book"]:hover {
    background: #feebc8;
}

.timeline-item[data-type="book"] .timeline-date {
    color: #c05621;
}

.timeline-item[data-type="article"],
.timeline-item[data-type="youtube"],
.timeline-item[data-type="web_serial"] {
    background: #ebf8ff;
    border-left-color: #3182ce;
}

.timeline-item[data-type="article"]:hover,
.timeline-item[data-type="youtube"]:hover,
.timeline-item[data-type="web_serial"]:hover {
    background: #bee3f8;
}

.timeline-item[data-type="article"] .timeline-date,
.timeline-item[data-type="youtube"] .timeline-date,
.timeline-item[data-type="web_serial"] .timeline-date {
    color: #2c5282;
}

.timeline-item[data-type="videogame"] {
    border-left: 4px solid #9333ea;
}

.timeline-item[data-type="videogame"]:hover {
    box-shadow: 0 4px 16px rgba(147, 51, 234, 0.2);
}

.timeline-item[data-type="videogame"] .timeline-date {
    color: #9333ea;
}

.timeline-item.past-due {
    opacity: 0.8;
    background: linear-gradient(135deg, #fff 0%, #fee 100%);
}

.timeline-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.timeline-date {
    font-weight: 600;
    color: var(--info);
    font-size: 0.75em;
}

.timeline-content {
    flex: 1;
}

.timeline-title {
    font-weight: 600;
    font-size: 0.9em;
    margin-bottom: 0.2em;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.timeline-meta {
    color: var(--text-secondary);
    font-size: 0.75em;
}

.timeline-empty {
    text-align: center;
    padding: 2em;
    color: var(--text-secondary);
}

/* Stats Grid */
.stats-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5em 2em;
    margin-bottom: 2em;
    box-shadow: var(--card-shadow);
}

.stats-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2em;
    flex-wrap: wrap;
}

.stats-section h2 {
    margin: 0;
    font-size: 1.3em;
    flex-shrink: 0;
}

.stats-section select {
    padding: 0.4em 0.8em;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
    flex-shrink: 0;
}

.stats-grid {
    display: flex;
    gap: 1.5em;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.75em;
    padding: 0.5em 1em;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.stat-value {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.8em;
    color: var(--text-secondary);
    line-height: 1.3;
    white-space: nowrap;
}

/* Media Type Cards */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2em;
    margin-bottom: 2em;
}

.media-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2em;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.media-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-hover-shadow);
}

.media-card-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1em;
    color: #667eea;
}

.media-card h3 {
    font-size: 1.5em;
    margin-bottom: 0.5em;
}

.media-card-count {
    font-size: 2em;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 0.5em;
}

.media-card-label {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1em;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1.5em 2em;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5em;
}

/* Modal close button (X in header) - more specific selector */
.modal-header .modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-header .modal-close:hover {
    background: #f7fafc;
    color: var(--text-primary);
}

.modal-body {
    padding: 2em;
}

.form-group {
    margin-bottom: 1.5em;
}

.form-group label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75em;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1em;
}

.modal-footer {
    padding: 1.5em 2em;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1em;
    flex-wrap: wrap;
}

.btn-cancel {
    background: #e2e8f0;
    color: #334155;
    order: 1;
}

.btn-cancel:hover {
    background: #cbd5e0;
    color: #1e293b;
}

.btn-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    order: 2;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Hidden field container for TV shows */
#tv-fields {
    display: none;
    padding: 1em;
    background: #f7fafc;
    border-radius: 6px;
    margin-top: 1em;
}

#tv-fields.active {
    display: block;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2em;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1em;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1em;
    }

    .header h1 {
        font-size: 2em;
    }

    .stats-section .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1em;
    }

    .stats-grid {
        justify-content: flex-start;
        order: 2;
    }

    .stats-section select {
        order: 1;
        align-self: flex-end;
    }

    .stats-section h2 {
        order: 0;
    }

    .media-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .timeline-grid {
        grid-template-columns: 1fr;
    }

    .timeline-item {
        flex-direction: column;
    }

    .timeline-date {
        min-width: auto;
    }

    /* Modal button responsive styles */
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.75em;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25em 0.75em;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-want {
    background: #bee3f8;
    color: #2c5282;
}

.status-in_progress {
    background: #feebc8;
    color: #7c2d12;
}

.status-completed {
    background: #c6f6d5;
    color: #22543d;
}

.status-abandoned {
    background: #fed7d7;
    color: #742a2a;
}