/* Listen Over Coffee */

:root {
    --bg: #fbf8f2;
    --surface: #ffffff;
    --text: #22201c;
    --muted: #776f63;
    --border: #e7e0d3;
    --accent: #9a4f22;        /* roasted coffee */
    --accent-text: #ffffff;
    --accent-soft: #f4e6da;
    --highlight: #fff1c9;
    --danger: #b42318;
    --radius: 10px;
    --reader-size: 20px;
    --reader-font: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, Cambria, serif;
    --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

[data-theme="sepia"] {
    --bg: #f4ecd8;
    --surface: #fbf4e2;
    --text: #3b2f22;
    --muted: #7d6a54;
    --border: #e2d5b8;
    --accent-soft: #ead9bf;
    --highlight: #f0d991;
}

[data-theme="dark"] {
    --bg: #18171a;
    --surface: #222125;
    --text: #e6e1d9;
    --muted: #9b958b;
    --border: #34323a;
    --accent: #e0915a;
    --accent-text: #1a1206;
    --accent-soft: #3a2a1f;
    --highlight: #4a3b1a;
    --danger: #ff8a80;
    color-scheme: dark;
}

[data-font="times"] { --reader-font: "Times New Roman", Times, "Liberation Serif", serif; }
[data-font="book"]  { --reader-font: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--ui-font);
    transition: background-color .2s, color .2s;
}

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.25; }

.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 20px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-mark { margin-right: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent; border-radius: 999px;
    font: 600 15px/1.2 var(--ui-font);
    text-decoration: none; cursor: pointer;
    transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; padding: 12px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover, .btn-ghost.on { background: var(--accent-soft); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Flash ---------- */
.flash {
    max-width: 720px; margin: 16px auto 0; padding: 10px 16px;
    background: var(--accent-soft); border-radius: var(--radius);
    text-align: center; font-weight: 500;
}

/* ---------- Layout ---------- */
.container { max-width: 820px; margin: 0 auto; padding: 24px 20px 80px; }
.narrow { max-width: 600px; }
.page-title { font-size: 28px; margin: 8px 0 20px; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 22px; margin-bottom: 20px;
}
.tip h2 { font-size: 17px; margin: 0 0 4px; }

/* ---------- Forms ---------- */
.form label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.form input[type="text"], .form input[type="email"], .form input[type="password"],
.form input[type="url"], .form textarea {
    display: block; width: 100%; margin-top: 6px;
    padding: 11px 13px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text);
    font: 400 16px/1.4 var(--ui-font);
}
.form textarea { font-family: var(--reader-font); line-height: 1.6; resize: vertical; }
.form input:focus, .form textarea:focus, .search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.error { color: var(--danger); margin: -8px 0 12px; font-size: 14px; }
.paste { margin: 4px 0 18px; }
.paste summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.page-auth main { display: flex; justify-content: center; padding: 48px 16px; }
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 30px;
}
.auth-card h1 { margin: 0 0 4px; font-family: var(--reader-font); font-weight: 400; font-size: 30px; }
.auth-card > .muted { margin-top: 0; margin-bottom: 22px; }

/* ---------- List ---------- */
.list-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; }
.tab {
    padding: 7px 14px; border-radius: 999px;
    color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px;
}
.tab.active { background: var(--accent-soft); color: var(--text); }
.search input {
    padding: 8px 14px; min-width: 220px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text); font: 15px var(--ui-font);
}

.article-list { list-style: none; margin: 0; padding: 0; }
.article-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 18px 0; border-bottom: 1px solid var(--border);
}
.article-link { flex: 1; display: flex; gap: 16px; color: inherit; text-decoration: none; min-width: 0; }
.article-link:hover h2 { color: var(--accent); }
.thumb {
    width: 112px; height: 80px; flex-shrink: 0;
    object-fit: cover; border-radius: 8px; background: var(--border);
}
.article-text { min-width: 0; }
.article-text h2 {
    margin: 0 0 6px;
    font-family: var(--reader-font); font-weight: 600; font-size: 20px;
}
.is-read .article-text h2 { font-weight: 400; }
.meta { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.badge { background: var(--accent-soft); color: var(--text); padding: 1px 7px; border-radius: 999px; font-size: 12px; }
.excerpt { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }

.item-actions { display: flex; flex-direction: column; gap: 4px; }
.item-actions form { margin: 0; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid transparent; background: transparent;
    color: var(--muted); font-size: 16px; text-decoration: none; cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn.on { color: #d99a06; }

.empty { text-align: center; padding: 70px 0; }
.empty-title { font-family: var(--reader-font); font-size: 24px; margin-bottom: 4px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 28px; }

/* ---------- Reader ---------- */
.reader-settings { position: relative; }
.settings-panel {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 290px; padding: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}
.settings-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-row > span { width: 50px; font-size: 13px; color: var(--muted); }
.settings-panel .btn.on { background: var(--accent-soft); border-color: var(--accent); }
.font-georgia { font-family: Georgia, serif; }
.font-times { font-family: "Times New Roman", Times, serif; }
.font-book { font-family: Charter, "Sitka Text", Cambria, serif; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; }
.swatch.on { border-color: var(--accent); }
.swatch-light { background: #fbf8f2; }
.swatch-sepia { background: #f4ecd8; }
.swatch-dark { background: #18171a; }

.reader {
    max-width: 680px; margin: 0 auto; padding: 40px 22px 120px;
    font-family: var(--reader-font);
}
.reader-site {
    margin: 0 0 10px; font: 600 13px var(--ui-font);
    text-transform: uppercase; letter-spacing: .06em; color: var(--accent);
}
.reader-title { margin: 0 0 14px; font-size: calc(var(--reader-size) * 1.75); font-weight: 700; line-height: 1.18; }
.reader-meta { margin: 0 0 22px; font: 14px var(--ui-font); color: var(--muted); }
.reader-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 28px; border-bottom: 1px solid var(--border); margin-bottom: 32px; }
.reader-actions form { margin: 0; }

.reader-content {
    font-size: var(--reader-size);
    line-height: 1.72;
    letter-spacing: .003em;
    overflow-wrap: break-word;
    hyphens: auto;
}
.reader-content p { margin: 0 0 1.15em; }
.reader-content h2, .reader-content h3, .reader-content h4 { margin: 1.6em 0 .5em; line-height: 1.3; }
.reader-content h2 { font-size: 1.35em; }
.reader-content h3 { font-size: 1.18em; }
.reader-content h4 { font-size: 1.05em; }
.reader-content img { display: block; max-width: 100%; height: auto; margin: 1.4em auto; border-radius: 6px; }
.reader-content figure { margin: 1.6em 0; }
.reader-content figcaption { font: 14px/1.45 var(--ui-font); color: var(--muted); text-align: center; margin-top: -.6em; }
.reader-content blockquote {
    margin: 1.4em 0; padding: .1em 0 .1em 1.1em;
    border-left: 3px solid var(--accent); color: var(--muted); font-style: italic;
}
.reader-content ul, .reader-content ol { padding-left: 1.4em; margin: 0 0 1.15em; }
.reader-content li { margin-bottom: .4em; }
.reader-content pre {
    overflow-x: auto; padding: 14px; border-radius: 8px;
    background: var(--surface); border: 1px solid var(--border);
    font: 14px/1.5 ui-monospace, Consolas, monospace;
}
.reader-content code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.reader-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .85em; margin-bottom: 1.2em; }
.reader-content td, .reader-content th { border: 1px solid var(--border); padding: 6px 8px; }
.reader-content hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.reader-content a { text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* The paragraph being read aloud */
.reader-content .speaking, .reader-title.speaking {
    background: var(--highlight);
    border-radius: 4px;
    box-shadow: 0 0 0 6px var(--highlight);
    transition: background-color .3s;
}
.player-open .reader-content > * { cursor: pointer; }

.reader-footer {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
    margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border);
}
.reader-footer form { margin: 0; }

/* ---------- Player ---------- */
.player {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .08);
    font-family: var(--ui-font);
    padding-bottom: env(safe-area-inset-bottom);
}
.player-progress { height: 3px; background: var(--border); }
.player-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.player-inner {
    max-width: 820px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; gap: 10px;
}
.pbtn {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 50%; border: 1px solid var(--border);
    background: transparent; color: var(--text);
    font-size: 17px; cursor: pointer;
}
.pbtn:hover { background: var(--accent-soft); }
.pbtn-main { width: 56px; height: 56px; font-size: 22px; background: var(--accent); color: var(--accent-text); border: 0; }
.pbtn-main:hover { background: var(--accent); opacity: .9; }
.pbtn-close { border: 0; margin-left: auto; color: var(--muted); }
.player-info { display: flex; flex-direction: column; min-width: 90px; font-size: 14px; font-weight: 600; }
.player-info .muted { font-weight: 400; font-size: 12px; }
.player-field { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.player-field select {
    margin-top: 2px; padding: 5px 6px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
    font: 14px var(--ui-font); max-width: 220px;
}
.player-unsupported { text-align: center; margin: 0 0 10px; color: var(--danger); }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
    .topbar { padding: 8px 12px; }
    .brand-name, .btn-label { display: none; }
    .brand-mark { font-size: 22px; }
    .topbar-actions { gap: 6px; }
    .container { padding: 16px 14px 80px; }
    .search, .search input { width: 100%; min-width: 0; }
    .thumb { width: 76px; height: 60px; }
    .article-text h2 { font-size: 18px; }
    .excerpt { display: none; }
    .reader { padding: 24px 18px 140px; }
    .player-inner { flex-wrap: wrap; justify-content: center; gap: 8px 12px; }
    .player-info { order: 10; width: 100%; flex-direction: row; justify-content: center; gap: 8px; }
    .player-voice select { max-width: 150px; }
    .pbtn-close { margin-left: 0; }
}
