:root {
    --bg: #14121f;
    --surface: #211e33;
    --surface-raised: #2c2845;
    --text: #f4f1ff;
    --text-muted: #a9a3c7;
    --accent: #4dd4ac;
    --accent-text: #0b1f19;
    --error: #ff8787;
    --radius: 14px;
    /* Native controls (audio player, select, scrollbars) in dark, matching the page. */
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

/* Classes like .btn set display and would otherwise win over the hidden attribute. */
[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    font-size: 18px;
    line-height: 1.45;
}

h1, h2, h3 {
    margin: 0 0 0.5rem;
    line-height: 1.2;
}

h2 {
    font-size: 1.2rem;
}

h1:focus, [tabindex="-1"]:focus {
    outline: none;
}

h1, .archive-title {
    overflow-wrap: anywhere;
}

button, a {
    -webkit-tap-highlight-color: transparent;
}

p {
    margin: 0 0 0.75rem;
}

a {
    color: var(--accent);
}

/* ---------- shared building blocks ---------- */

.page {
    max-width: 38rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
}

/* Small phones: less frame, more room for content (and for the audio player's own controls). */
@media (max-width: 400px) {
    .page {
        padding: 1rem 0.75rem 2rem;
    }

    .card {
        padding: 1rem;
    }
}

.btn {
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-raised);
    border: 2px solid transparent;
    border-radius: 999px;
    padding: 0.6rem 1.4rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
}

.btn:focus-visible, .input:focus-visible, .tab:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}

.btn-quiet {
    background: transparent;
    border-color: var(--surface-raised);
    color: var(--text-muted);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.input {
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 2px solid var(--surface-raised);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    width: 100%;
    min-width: 0;
}

textarea.input {
    resize: vertical;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.stacked-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* Full-width buttons on top of each other: easy to hit with the thumb, no wrapped labels. */
.button-stack {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.4rem;
}

/* Two equally wide buttons side by side, stacked on very narrow phones. */
.button-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.button-pair .btn {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
}

@media (max-width: 359px) {
    .button-pair {
        grid-template-columns: 1fr;
    }
}

/* Smaller text, but still a full finger's height to tap. */
.btn-small {
    font-size: 0.85rem;
    padding: 0.6rem 0.9rem;
}

.hint {
    color: var(--text-muted);
}

.error {
    color: var(--error);
    margin: 0.75rem 0 0;
}

/* ---------- page parts ---------- */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.top-bar h1 {
    margin: 0;
    font-size: 1.6rem;
    white-space: nowrap;
}

/* Back button on the left, title right next to it. */
.top-bar-back {
    justify-content: flex-start;
    gap: 1rem;
}

.logout {
    margin-top: 1rem;
    text-align: center;
}

.link-button {
    font: inherit;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: none;
    border: none;
    padding: 0.6rem;
    text-decoration: underline;
    cursor: pointer;
}

.tabs {
    display: flex;
    gap: 0.4rem;
    background: var(--bg);
    border-radius: 999px;
    padding: 0.25rem;
}

.tab {
    flex: 1;
    font: inherit;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 999px;
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    white-space: nowrap;
}

.tab.active {
    background: var(--surface-raised);
    color: var(--text);
}

.steps {
    margin: 0 0 0.75rem;
    padding-left: 1.4rem;
    color: var(--text-muted);
}

.steps li.current {
    color: var(--text);
    font-weight: 600;
}

.steps li.current::after {
    content: " …";
}

.steps li.done {
    color: var(--accent);
}

.steps li.done::after {
    content: " ✓";
}

.player h1 {
    font-size: 1.35rem;
}

.player audio {
    width: 100%;
    margin: 0.25rem 0 0.9rem;
}

.player .button-pair + .button-pair {
    margin-top: 0.6rem;
}

details.card summary {
    cursor: pointer;
    font-weight: 600;
}

details.card[open] summary {
    margin-bottom: 0.75rem;
}

.archive {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.archive li {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem;
}

.section-title {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0;
}

.progress {
    height: 0.6rem;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.4rem 0 0.5rem;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.6s ease;
}

.player > .btn {
    display: block;
    margin-top: 0.4rem;
}

.text-actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.text-actions .digest-status:empty {
    display: none;
}

.text-actions .digest-status {
    margin: 0;
    font-size: 0.85rem;
}

.reading article p {
    margin-bottom: 1rem;
}

.archive-title {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.archive .hint {
    font-size: 0.85rem;
}

.archive .actions {
    margin-top: 0.4rem;
    gap: 0.4rem;
    align-items: center;
}

.archive .btn-small {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* "Anhören" takes the free width; the quiet actions stay small at its side. */
.archive .actions .btn:first-child {
    flex: 1;
}
