:root {
    color-scheme: light;
    --bg: #f6f1e8;
    --surface: #fffdf8;
    --surface-strong: #fff7e5;
    --ink: #211b18;
    --muted: #6e625c;
    --brand: #5b1f2e;
    --brand-2: #0f6b5f;
    --line: #dfd2c2;
    --shadow: 0 12px 28px rgba(37, 24, 16, .12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: max(56px, calc(16px + env(safe-area-inset-top))) 16px 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 2px 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--brand-2);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.9rem, 6vw, 3.2rem);
}

h2 {
    margin-bottom: 0;
}

.connection {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    background: var(--surface);
    color: var(--brand-2);
    font-size: .85rem;
    font-weight: 700;
}

.connection.offline {
    color: #9f2f25;
}

.now-playing,
.view-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.now-playing {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 20px;
}

.chapter-meta p {
    margin-bottom: 6px;
    color: var(--muted);
}

.chapter-meta h2 {
    font-size: clamp(2.1rem, 10vw, 5rem);
    line-height: .95;
}

.chapter-meta small {
    display: block;
    margin-top: 10px;
    color: var(--muted);
}

.quick-actions {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) 54px;
    gap: 10px;
    align-items: center;
}

.icon-button,
.primary-play,
.primary-action,
.secondary-action,
.text-button,
.segment,
.tool-button,
.book-card,
.chapter-card {
    border: 0;
    border-radius: 8px;
}

.icon-button {
    min-height: 54px;
    background: var(--surface-strong);
    color: var(--brand);
    font-size: 2.2rem;
    font-weight: 700;
}

.primary-play {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 58px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
}

.primary-play img {
    width: 28px;
    height: 28px;
}

audio {
    width: 100%;
}

.progress-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.progress-summary div,
.timer-box,
.support-box {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.progress-summary strong {
    display: block;
    color: var(--brand);
    font-size: 1.5rem;
}

.progress-summary span {
    color: var(--muted);
    font-size: .9rem;
}

.tool-strip {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0;
    padding: 8px 0;
    background: var(--bg);
}

.tool-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    font-weight: 700;
}

.tool-button.active {
    background: var(--brand);
    color: #fff;
}

.tool-button img {
    width: 24px;
    height: 24px;
}

.view-panel {
    padding: 18px;
}

.hidden {
    display: none;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-header.compact {
    margin-top: 20px;
}

.text-button,
.secondary-action {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--line);
    padding: 10px 14px;
    font-weight: 800;
}

.search-box {
    display: block;
    margin-bottom: 14px;
}

.search-box span,
.timer-box span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 700;
}

.search-box input,
.timer-box input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    color: var(--ink);
}

.segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.segment {
    min-height: 42px;
    background: var(--surface-strong);
    color: var(--ink);
    font-weight: 700;
}

.segment.active {
    background: var(--brand-2);
    color: #fff;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 8px;
}

.book-card {
    min-height: 58px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--line);
    text-align: left;
}

.book-card.active {
    outline: 3px solid rgba(15, 107, 95, .25);
    border-color: var(--brand-2);
}

.book-card strong,
.chapter-card strong {
    display: block;
}

.book-card span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .8rem;
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 8px;
}

.chapter-card {
    min-height: 46px;
    background: var(--surface-strong);
    color: var(--ink);
    font-weight: 800;
}

.chapter-card.active {
    background: var(--brand);
    color: #fff;
}

.chapter-card.heard {
    border: 2px solid var(--brand-2);
}

.reading-list {
    display: grid;
    gap: 10px;
}

.verse {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    line-height: 1.45;
}

.verse-number {
    color: var(--brand);
    font-weight: 800;
}

.verse-text {
    min-width: 0;
}

.share-verse {
    grid-column: 2;
    justify-self: start;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    background: var(--surface-strong);
    color: var(--brand);
    font-size: .85rem;
    font-weight: 800;
}

.inline-status {
    min-height: 1.2em;
    color: var(--brand-2);
    font-size: .9rem;
}

.timer-box,
.support-box {
    display: grid;
    gap: 12px;
}

.support-box {
    margin-top: 14px;
}

.support-box h3 {
    margin: 0;
    font-size: 1.1rem;
}

.primary-action {
    min-height: 48px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
}

.secondary-action {
    min-height: 44px;
}

#sleepStatus {
    margin: 0;
    color: var(--muted);
}

#supportStatus {
    margin: 0;
    color: var(--muted);
}

@media (min-width: 760px) {
    .app-shell {
        padding: max(64px, calc(24px + env(safe-area-inset-top))) 24px 24px;
    }

    .now-playing {
        grid-template-columns: minmax(0, 1fr) 360px;
        align-items: center;
    }

    .quick-actions,
    audio,
    .progress-summary {
        grid-column: 2;
    }

    .chapter-meta {
        grid-row: 1 / span 3;
    }
}
