:root {
    color-scheme: dark;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-muted: #162133;
    --text: #f8fafc;
    --text-muted: #cbd5f5;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --border: #334155;
    --success: #22c55e;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

header.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #020617;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand-title {
    font-weight: 600;
    font-size: 1.2rem;
}

.brand-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.nav-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    border: 1px solid transparent;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    transition: border 0.2s;
}
.nav-link:hover {
    border: 1px solid var(--accent);
}

.content {
    padding: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 20px 40px rgba(8, 15, 36, 0.35);
}

.auth-card {
    max-width: 720px;
    margin: 2rem auto;
}

.claim-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.claim-form input[type="password"] {
    flex: 1;
    min-width: 260px;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card-muted);
    color: var(--text);
}

.story-card {
    position: relative;
    padding: 1.1rem 1.15rem 1.1rem 1.35rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(2, 6, 23, 0.45);
    box-shadow: 0 8px 18px rgba(2, 6, 23, 0.28);
}

.story-card::before {
    content: "";
    position: absolute;
    left: 0.55rem;
    top: 0.85rem;
    bottom: 0.85rem;
    width: 3px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.4);
}

.story-card--unread {
    border-color: rgba(56, 189, 248, 0.75);
}

.story-card--unread::before {
    background: rgba(56, 189, 248, 0.95);
}

.story-header {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
}

.story-cover {
    width: 140px;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 0.5rem;
    box-shadow: 0 10px 22px rgba(0,0,0,0.45);
}

.story-meta, .story-updated, .story-summary {
    color: var(--text-muted);
}

.story-card .story-summary {
    margin-top: 0.75rem;
    margin-bottom: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 0.65rem;
    background: rgba(15, 23, 42, 0.32);
}

.story-actions {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid;
}

.badge-primary {
    border-color: var(--accent);
    color: var(--accent);
}

.badge-muted {
    border-color: var(--border);
    color: var(--text-muted);
}

.btn {
    border-radius: 999px;
    padding: 0.5rem 1rem;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary {
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    color: #02101f;
    border: none;
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.3);
}

.btn-secondary {
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-disabled {
    border: 1px dashed var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn:hover {
    transform: translateY(-1px);
}

.chapter-card {
    padding-bottom: 3rem;
}

.chapter-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chapter-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chapter-content {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text);
}

.chapter-content p {
    margin-bottom: 1rem;
}

.chapter-footer {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

.status-pill {
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    background: var(--bg-card-muted);
    color: var(--text-muted);
}

.status-pill--done {
    border-color: var(--success);
    color: var(--success);
}

#read-sentinel {
    height: 1px;
}

.chapter-list-card {
    padding: 1rem 1.5rem;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.chapter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-card-muted);
}

.chapter-row--read {
    border-color: var(--success);
    color: var(--success);
}

.chapter-row-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: inherit;
}

.chapter-row-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.chapter-row--read .chapter-title {
    color: var(--success);
}

.chapter-number {
    font-weight: 600;
}

.chapter-title {
    color: var(--text);
}

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

.story-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.series-cluster {
    margin-bottom: 1.25rem;
    border: 1px solid rgba(148, 163, 184, 0.55);
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.55);
    padding: 0.9rem 1rem 0.6rem;
    box-shadow: none;
}

.series-cluster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.series-cluster-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.series-cluster-books {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 0.65rem;
}

.series-story {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1rem 0.95rem 1.15rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 0.85rem;
    background: rgba(2, 6, 23, 0.45);
    box-shadow: 0 8px 18px rgba(2, 6, 23, 0.28);
}

.series-story::before {
    content: "";
    position: absolute;
    left: 0.5rem;
    top: 0.7rem;
    bottom: 0.7rem;
    width: 3px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.4);
}

.series-story-main h3 {
    margin: 0;
    font-size: 1rem;
}

.series-story-kicker {
    margin: 0 0 0.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.series-story-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.series-story--unread .series-story-kicker {
    color: var(--accent);
}

.series-story--unread {
    border-color: rgba(56, 189, 248, 0.75);
}

.series-story--unread::before {
    background: rgba(56, 189, 248, 0.95);
}

.series-editor {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.series-editor h2 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
}

.series-form {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.series-form input[type="text"],
.series-form input[type="number"] {
    padding: 0.55rem 0.8rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-card-muted);
    color: var(--text);
}

.series-form input[type="text"] {
    min-width: 220px;
    flex: 1;
}

.series-form input[type="number"] {
    width: 130px;
}

@media (max-width: 768px) {
    .story-header {
        flex-direction: column-reverse;
        align-items: flex-start;
    }

    .content {
        padding: 1rem;
    }

    header.top-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .recent-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .series-story {
        flex-direction: column;
        align-items: flex-start;
    }

    .series-story-actions {
        justify-content: flex-start;
    }

    .stories-filter-controls {
        flex-direction: column;
        align-items: stretch;
    }

    #story-filter-input {
        min-width: 0;
        width: 100%;
    }

    .stories-filter-toggle,
    #story-filter-clear {
        width: fit-content;
    }
}
.follow-card {
    margin-bottom: 2rem;
}

.follow-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.follow-form input[type="url"],
.follow-form input[type="number"] {
    flex: 1;
    min-width: 250px;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card-muted);
    color: var(--text);
}

.stories-filter-card {
    margin-bottom: 1.25rem;
}

.stories-filter-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stories-filter-header h2 {
    margin: 0;
}

.stories-filter-controls {
    margin-top: 0.9rem;
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
}

#story-filter-input {
    flex: 1;
    min-width: 240px;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card-muted);
    color: var(--text);
}

#story-filter-input::placeholder {
    color: var(--text-muted);
}

.stories-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.35);
    color: var(--text);
}

.stories-filter-toggle input {
    accent-color: var(--accent);
}

.story-filter-empty {
    margin: 0.8rem 0 0;
    color: var(--text-muted);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.alert-success {
    border-color: var(--success);
    color: var(--success);
}

.alert-error {
    border-color: #f97316;
    color: #f97316;
}

.jobs-card {
    margin-bottom: 2rem;
}

.job-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.jobs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.jobs-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.job-row {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.job-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.job-row--processing {
    border-color: var(--accent);
}

.job-row--success {
    border-color: var(--success);
}

.job-row--failed {
    border-color: #f97316;
}

.job-title {
    margin: 0;
    font-weight: 600;
}

.job-meta {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sync-status-card {
    margin-bottom: 2rem;
}

.sync-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sync-status-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-chip {
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font-size: 0.82rem;
    border: 1px solid var(--border);
}

.status-chip--ok {
    border-color: var(--success);
    color: var(--success);
}

.status-chip--issues {
    border-color: #f97316;
    color: #f97316;
}

.sync-errors {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card-muted);
}

.sync-errors summary {
    cursor: pointer;
    color: var(--text);
    font-weight: 600;
}

.sync-errors-body {
    margin-top: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sync-error-row {
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    padding: 0.6rem 0.75rem;
    background: rgba(2, 6, 23, 0.25);
}

.recent-card {
    margin-bottom: 2rem;
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.recent-settings-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.recent-setting-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text);
}

.recent-threshold-input {
    width: 80px;
    padding: 0.45rem 0.55rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg-card-muted);
    color: var(--text);
}

.recent-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.recent-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card-muted);
}

.recent-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
