:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #d1d5db;
    --text: #1f2937;
    --text-muted: #6b7280;
    --primary: #b91c1c;
    --primary-hover: #991b1b;
    --primary-light: #fef2f2;
    --link: #1d4ed8;
    --link-hover: #1e40af;
    --code-bg: #f3f4f6;
    --warning-bg: #fffbeb;
    --warning-border: #f59e0b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

header {
    background: var(--primary);
    color: white;
    padding: 0;
    border-bottom: 3px solid var(--primary-hover);
}

header .header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

header h1 a { color: white; text-decoration: none; }
header h1 a:hover { text-decoration: none; opacity: 0.9; }

header .tagline {
    font-size: 0.8rem;
    opacity: 0.85;
    font-weight: 400;
}

header nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

header nav a {
    color: rgba(255,255,255,0.9);
    font-size: 0.82rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
    white-space: nowrap;
}

header nav a:hover {
    background: rgba(255,255,255,0.15);
    color: white;
    text-decoration: none;
}

.search-box {
    display: flex;
}

.search-box input {
    font-size: 0.85rem;
    padding: 5px 10px;
    border: none;
    border-radius: 4px 0 0 4px;
    outline: none;
    width: 160px;
}

.search-box button {
    font-size: 0.85rem;
    padding: 5px 10px;
    border: none;
    border-radius: 0 4px 4px 0;
    background: var(--primary-hover);
    color: white;
    cursor: pointer;
}

main {
    max-width: 960px;
    margin: 24px auto;
    padding: 0 20px;
}

/* Stats bar */
.stats-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.stats-bar .stats {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stats-bar .stats strong {
    color: var(--text);
}

.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-tabs a {
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px solid transparent;
    text-decoration: none;
}

.filter-tabs a:hover {
    background: var(--bg);
    text-decoration: none;
}

.filter-tabs a.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
    font-weight: 600;
}

/* Index page */
.comic-list {
    list-style: none;
}

.comic-list li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: box-shadow 0.15s;
}

.comic-list li.unexplained {
    border-left: 3px solid var(--warning-border);
}

.comic-list li:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.comic-list a.comic-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    gap: 16px;
}

.comic-list a.comic-link:hover { text-decoration: none; }

.comic-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 60px;
    overflow: hidden;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #f9f9f9;
}

.comic-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.comic-info {
    flex: 1;
    min-width: 0;
}

.comic-list .comic-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--link);
}

.comic-list .comic-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.needs-explanation {
    color: var(--warning-border);
    font-weight: 600;
}

.comic-list .comic-excerpt {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    padding: 16px 0;
}

.page-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Comic detail page */
.comic-header {
    margin-bottom: 20px;
}

.comic-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.comic-header .meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.comic-header .meta a { font-size: 0.85rem; }

.comic-image-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
}

.comic-image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.comic-image-container .votey-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.comic-image-container .votey-toggle {
    background: var(--primary);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.comic-image-container .votey-toggle:hover {
    background: var(--primary-hover);
}

.votey-img {
    display: none;
    margin-top: 10px;
}

.explanation-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 20px;
}

.needs-explanation-box {
    border-color: var(--warning-border);
    background: var(--warning-bg);
}

.explanation-box h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    color: var(--primary);
}

.article-warning {
    background: #fff8e1;
    border: 1px solid #ffcc02;
    border-radius: 6px;
    padding: 14px 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.article-warning .warning-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.article-warning .warning-text {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #5d4e00;
}

.article-warning .warning-text a {
    font-weight: 600;
}

.explanation-content {
    font-size: 0.95rem;
    line-height: 1.75;
}

.explanation-content p { margin-bottom: 12px; }
.explanation-content ul, .explanation-content ol { margin-bottom: 12px; padding-left: 24px; }
.explanation-content li { margin-bottom: 4px; }
.explanation-content h1, .explanation-content h2, .explanation-content h3,
.explanation-content h4 { margin: 16px 0 8px; }
.explanation-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.explanation-content code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.comic-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
}

.btn:hover { text-decoration: none; background: var(--bg); }

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

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

.old-revision-banner {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* Edit page */
.edit-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
}

.form-group textarea {
    min-height: 400px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
    resize: vertical;
}

.form-group .help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* History page */
.history-list {
    list-style: none;
}

.history-list li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.history-list .rev-info {
    font-size: 0.85rem;
}

.history-list .rev-info .rev-editor {
    font-weight: 600;
}

.history-list .rev-info .rev-summary {
    color: var(--text-muted);
    font-style: italic;
}

.history-list .rev-info .rev-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 { margin-bottom: 8px; color: var(--text); }

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.error-msg {
    background: #fef2f2;
    color: var(--primary);
    border: 1px solid #fecaca;
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

footer {
    max-width: 960px;
    margin: 40px auto;
    padding: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

footer a { color: var(--text-muted); }

/* About page */
.about-page .about-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.about-page .about-section h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.about-page .about-section p {
    font-size: 0.9rem;
    margin-bottom: 8px;
    line-height: 1.7;
}

.about-page .about-section p:last-child {
    margin-bottom: 0;
}

.form-group input[type="password"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

@media (max-width: 640px) {
    header .header-inner {
        flex-direction: column;
        text-align: center;
    }
    .search-box input { width: 140px; }
    .stats-bar { flex-direction: column; text-align: center; }
    .comic-thumb { display: none; }
}
