*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #fff;
    --fg: #111;
    --muted: #666;
    --border: #ddd;
    --accent: #0066cc;
    --danger: #cc3333;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111;
        --fg: #eee;
        --muted: #999;
        --border: #333;
        --accent: #4da6ff;
        --danger: #ff6666;
    }
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
    background: var(--bg);
    color: var(--fg);
}

a { color: var(--accent); }

/* Navigation */
header nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
    color: var(--fg);
}

.search { flex: 1; }
.search input {
    width: 100%;
    max-width: 300px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
}

.btn {
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

.btn:hover { opacity: 0.9; }

/* Hero */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h1 { margin-bottom: 0.5rem; font-size: 2.5rem; }
.tagline { color: var(--muted); font-size: 1.1rem; }

.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}

.stat {
    text-align: center;
    text-decoration: none;
    color: var(--fg);
    padding: 1rem 2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.stat:hover { border-color: var(--accent); }

.stat .num {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
}

.stat .label {
    color: var(--muted);
}

/* API Example */
.api-example {
    background: var(--border);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.api-example h2 { margin-top: 0; font-size: 1rem; }

pre {
    overflow-x: auto;
    background: var(--bg);
    padding: 1rem;
    border-radius: 4px;
    margin: 0.5rem 0;
}

code {
    font-family: ui-monospace, monospace;
    font-size: 0.875rem;
}

/* Filters */
.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filters input, .filters select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
}

.filters button {
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Title List */
.title-list {
    list-style: none;
    padding: 0;
}

.title-list li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.title-list .thumb {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.title-list .info { flex: 1; }
.title-list .year { color: var(--muted); margin-left: 0.5rem; }

.type-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    text-transform: uppercase;
}

.type-badge.movie { background: #2563eb; color: white; }
.type-badge.show { background: #7c3aed; color: white; }

/* Detail Page */
.detail header {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail .poster {
    width: 150px;
    height: auto;
    border-radius: 8px;
}

.detail h1 { margin: 0; }
.detail .year { color: var(--muted); margin: 0.5rem 0; }

.meta {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
}

.meta dl {
    flex: 1;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    margin: 0;
}

.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.btn-edit {
    padding: 0.5rem 1rem;
    background: var(--border);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--fg);
}

/* Edit Form */
.edit-form {
    background: var(--border);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.edit-form h3 { margin-top: 0; }

.edit-form label {
    display: block;
    margin-bottom: 1rem;
}

.edit-form input {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
}

.edit-form .actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.edit-form button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.edit-form button[type="submit"] {
    background: var(--accent);
    color: white;
}

.edit-form button.danger {
    background: var(--danger);
    color: white;
}

/* Seasons & Episodes */
.seasons h2 {
    margin-bottom: 1rem;
}

.season {
    background: var(--border);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.season h3 {
    margin: 0 0 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.episode-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.episode-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--bg);
}

.episode-list li:last-child { border-bottom: none; }

.ep-num {
    font-weight: 600;
    color: var(--muted);
    min-width: 2.5rem;
}

.ep-title { flex: 1; }

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--fg);
}

.btn-small:hover { background: var(--border); }

.add-episode-form {
    display: flex;
    gap: 0.5rem;
}

.add-episode-form input {
    padding: 0.5rem;
    border: 1px solid var(--bg);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
}

.add-episode-form button {
    padding: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.add-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.add-form input {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
    width: 100px;
}

.add-form button {
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Add Title Form */
.add-title-form {
    max-width: 500px;
}

.add-title-form label {
    display: block;
    margin-bottom: 1rem;
}

.add-title-form input,
.add-title-form select {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--fg);
}

.add-title-form button {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

/* API Link */
.api-link {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--border);
    border-radius: 4px;
}

/* API Docs */
.api-docs {
    max-width: 800px;
}

.api-docs .intro {
    font-size: 1.1rem;
    color: var(--muted);
    margin-bottom: 2rem;
}

.api-docs .toc {
    background: var(--border);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 2rem;
}

.api-docs .toc a {
    margin: 0 0.25rem;
}

.api-docs section {
    margin-bottom: 3rem;
}

.api-docs h2 {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.api-docs h3 {
    font-family: ui-monospace, monospace;
    background: var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin: 1.5rem 0 0.75rem;
}

.api-docs table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.api-docs th, .api-docs td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.api-docs th {
    background: var(--border);
}

.api-docs pre {
    border: 1px solid var(--border);
}

.api-docs ul {
    padding-left: 1.5rem;
}

.api-docs li {
    margin-bottom: 0.5rem;
}

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.875rem;
}
