:root {
    --bg: #f5f7fb;
    --bg-soft: #eef2ff;
    --card: rgba(255, 255, 255, 0.88);
    --text: #172033;
    --muted: #5e6b85;
    --border: #dbe2f0;
    --accent: #4f46e5;
    --accent-strong: #3730a3;
    --accent-contrast: #ffffff;
    --shadow: 0 12px 30px rgba(35, 54, 109, 0.10);
}

html[data-theme='dark'] {
    --bg: #0b1220;
    --bg-soft: #11192c;
    --card: rgba(17, 25, 40, 0.9);
    --text: #e7ecf7;
    --muted: #9eabc7;
    --border: #24314f;
    --accent: #7c3aed;
    --accent-strong: #8b5cf6;
    --accent-contrast: #ffffff;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light dark;
}

body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg-soft), var(--bg));
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1100px, calc(100% - 24px));
    margin: 0 auto;
    padding: 16px 0 32px;
}

.site-header,
.panel,
.story,
.card,
.search-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.site-header,
.panel,
.search-form,
.card,
.story {
    padding: 16px;
}

.site-header {
    margin-bottom: 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.title-wrap h1,
.title-wrap p,
.page-title {
    margin: 0;
}

.page-title + p {
    margin-top: 8px;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 16px;
    padding: 0;
}

.nav-links a {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

button,
input,
select {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 10px 12px;
    font-size: 14px;
    background: rgba(255,255,255,0.75);
    color: var(--text);
}

html[data-theme='dark'] button,
html[data-theme='dark'] input,
html[data-theme='dark'] select {
    background: rgba(17, 25, 40, 0.95);
}

button {
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-contrast);
    border: 1px solid transparent;
    font-weight: 700;
    /* box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25); */
}

button:hover {
    background: var(--accent-strong);
}

html[data-theme='dark'] button {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 1px 2px 3px 0px rgba(124, 58, 237, 0.35);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.theme-toggle {
    width: auto;
    min-width: 120px;
}

.search-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.search-form select[multiple],
.search-form button {
    grid-column: 1 / -1;
}

select[multiple] {
    min-height: 220px;
}

.stats-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.stats-list li {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.story,
.card {
    margin-bottom: 16px;
}

.story h3,
.card h2,
.card h3 {
    margin-top: 0;
}

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

.status-banner {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}

.log-output {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 420px;
    overflow: auto;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.story-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.inline-form {
    margin: 0;
}

@media (max-width: 720px) {
    body {
        font-size: 15px;
    }

    .container {
        width: min(100%, calc(100% - 16px));
        padding: 10px 0 24px;
    }

    .site-header,
    .panel,
    .search-form,
    .card,
    .story {
        padding: 14px;
        border-radius: 14px;
    }

    .nav-links {
        flex-direction: column;
    }

    .nav-links a,
    .theme-toggle {
        width: 100%;
        text-align: center;
    }

    select[multiple] {
        min-height: 150px;
    }

    h1 {
        font-size: 1.45rem;
    }

    h2 {
        font-size: 1.2rem;
    }
}
