/* app.css — ReadFed stylesheet */

/* --- CSS variables --- */
:root {
    --accent:       #ea5c0a;
    --accent-hover: #c94e08;
    --text:         #111827;
    --muted:        #6b7280;
    --border:       #e5e7eb;
    --surface:      #f9fafb;
    --white:        #ffffff;
    --green:        #16a34a;
    --green-hover:  #15803d;
    --red:          #dc2626;
    --red-hover:    #b91c1c;
    --blue:         #2563eb;
    --radius:       6px;
    --font-ui:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif:   Georgia, "Times New Roman", Times, serif;
}

/* --- Reset & base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    background: var(--white);
    color: var(--text);
    font-family: var(--font-ui);
    line-height: 1.6;
    min-height: 100vh;
}

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

a:hover {
    text-decoration: underline;
}

/* --- Layout container --- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- Site header --- */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--white);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.site-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.site-logo:hover {
    text-decoration: none;
    color: var(--accent-hover);
}

/* --- Navigation --- */
.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.875rem;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 0.2rem 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--text);
    text-decoration: none;
}

.site-nav a.active {
    border-bottom-color: var(--accent);
    color: var(--text);
}

.nav-logout {
    margin-left: 0.5rem;
}

/* --- Feed URL bar --- */
.feed-url-bar {
    font-size: 0.8rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feed-label {
    flex-shrink: 0;
}

.feed-url {
    color: var(--muted);
    font-family: monospace;
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-url:hover {
    color: var(--accent);
}

/* --- Save form --- */
.save-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.save-form input[type="url"] {
    flex: 1;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s;
    min-width: 0;
}

.save-form input[type="url"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(234, 92, 10, 0.1);
}

.loading-indicator {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
}

.save-error {
    font-size: 0.825rem;
    color: var(--red);
    padding: 0.3rem 0;
}

/* --- Main content --- */
main.container {
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}

/* --- List header --- */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.list-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-family: var(--font-ui);
    color: var(--muted);
    background: var(--white);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    line-height: 1.4;
    white-space: nowrap;
    user-select: none;
}

.btn:hover {
    color: var(--text);
    border-color: #9ca3af;
    text-decoration: none;
    background: var(--surface);
}

.btn-primary {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    font-weight: 500;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--white);
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
}

.btn-settings {
    font-size: 0.8rem;
}

.btn-danger {
    color: var(--red);
    border-color: #fca5a5;
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: var(--red);
    color: var(--red);
}

/* --- Article list --- */
#article-list {
    margin-top: 0.25rem;
}

.article {
    border-bottom: 1px solid var(--border);
    padding: 1.1rem 0;
    transition: background 0.1s;
}

.article:last-child {
    border-bottom: none;
}

.article-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: normal;
    line-height: 1.4;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.article-title a {
    color: var(--text);
    text-decoration: none;
}

.article-title a:hover {
    color: var(--accent);
    text-decoration: none;
}

.excerpt {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 0.6rem;
    line-height: 1.55;
}

.excerpt--hidden {
    display: none;
}

/* --- Article actions bar --- */
.article-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.4rem;
}

.date {
    color: var(--muted);
    font-size: 0.78rem;
    flex-shrink: 0;
    margin-right: 0.15rem;
}

/* --- Play button --- */
.play-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    background: var(--white);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    color: var(--muted);
    user-select: none;
    white-space: nowrap;
}

.play-btn:hover {
    color: var(--green);
    border-color: var(--green);
    background: #f0fdf4;
}

.play-btn.is-playing {
    color: var(--green);
    border-color: var(--green);
    background: #f0fdf4;
}

.play-icon {
    font-size: 0.7rem;
    line-height: 1;
}

/* --- Inline progress bar (on play button) --- */
.play-progress-wrap {
    width: 50px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.play-progress-bar {
    height: 100%;
    background: var(--blue);
    border-radius: 2px;
    transition: width 0.3s linear;
}

.play-duration {
    font-size: 0.75rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

/* --- Read / original buttons --- */
.read-btn {
    color: var(--muted);
}

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

/* --- Archive / restore / delete --- */
.archive-btn {
    cursor: pointer;
}

.archive-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: #fff7f3;
}

.restore-btn {
    cursor: pointer;
}

.restore-btn:hover {
    color: var(--green);
    border-bottom-color: var(--green);
    background: #f0fdf4;
}

.perm-delete-btn {
    cursor: pointer;
}

/* --- Converting badge --- */
.converting-badge {
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
    padding: 0.25rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
    font-size: 0.925rem;
}

/* --- Settings panel --- */
.settings-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.settings-panel[hidden] {
    display: none;
}

.settings-inner {
    padding: 1.25rem 1.5rem;
    display: flex;
    gap: 2.5rem;
    flex-wrap: wrap;
}

.settings-section {
    min-width: 160px;
}

.settings-heading {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.settings-subtext {
    font-size: 0.825rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.voice-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    max-width: 360px;
}

.voice-item {
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    background: var(--white);
    color: var(--muted);
    transition: all 0.15s;
    user-select: none;
}

.voice-item:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #fff7f3;
}

.voice-item--active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.voice-item--active:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--white);
}

/* --- Toggle checkbox --- */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    cursor: pointer;
}

/* --- Auth pages --- */
.auth-page {
    background: var(--surface);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 2rem;
    min-height: 100vh;
}

.auth-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.25rem;
}

.auth-logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.auth-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: var(--red);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(234, 92, 10, 0.1);
}

.auth-footer {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

/* --- Article reader page --- */
.article-page {
    padding-top: 0;
}

.reader-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0;
}

.reader-bar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.reader-back {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    flex-shrink: 0;
    transition: color 0.15s;
}

.reader-back:hover {
    color: var(--text);
    text-decoration: none;
}

.reader-bar-title {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    min-width: 0;
}

/* --- Reader audio player --- */
.reader-player {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.reader-play-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    transition: all 0.15s;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.reader-play-btn:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent);
}

.reader-play-btn.is-playing {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
}

.reader-progress-wrap {
    width: 120px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
}

.reader-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s linear;
}

.reader-time {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* --- Article reader content --- */
.article-reader {
    max-width: 680px;
    padding-top: 2.5rem;
    padding-bottom: 4rem;
}

.article-reader-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: normal;
    line-height: 1.3;
    margin-bottom: 1.75rem;
    color: var(--text);
}

.article-body {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text);
}

.article-body p {
    margin-bottom: 1.25em;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
    font-family: var(--font-serif);
    font-weight: bold;
    line-height: 1.35;
    margin: 1.75em 0 0.6em;
    color: var(--text);
}

.article-body h1 { font-size: 1.5rem; }
.article-body h2 { font-size: 1.3rem; }
.article-body h3 { font-size: 1.15rem; }

.article-body a {
    color: var(--accent);
    text-decoration: underline;
}

.article-body blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1.25rem;
    margin: 1.25em 0;
    color: var(--muted);
    font-style: italic;
}

.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1em 0;
}

.article-body ul,
.article-body ol {
    padding-left: 1.5rem;
    margin-bottom: 1.25em;
}

.article-body li {
    margin-bottom: 0.4em;
}

.article-body pre,
.article-body code {
    font-family: "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.9rem;
}

.article-body pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1.25em;
}

.article-body code {
    background: var(--surface);
    padding: 0.15em 0.35em;
    border-radius: 3px;
    font-size: 0.875em;
}

.article-body pre code {
    background: none;
    padding: 0;
}

.article-original-link {
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
}

/* --- Stats page --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stats-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
}

.stats-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
    margin-bottom: 0.3rem;
    font-variant-numeric: tabular-nums;
}

.stats-label {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.stats-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.stats-table th {
    text-align: left;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--surface);
    white-space: nowrap;
}

.stats-table td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table tr:hover td {
    background: var(--surface);
}

.stats-title-cell {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-date {
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.8rem;
}

.stats-progress-wrap {
    width: 60px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.4rem;
}

.stats-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

.stats-pct {
    font-size: 0.78rem;
    color: var(--muted);
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-archived {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
}

/* --- Audio status bar --- */
.audio-status {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: rgba(17, 24, 39, 0.9);
    color: var(--white);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    backdrop-filter: blur(4px);
    z-index: 200;
}

.audio-status[hidden] {
    display: none;
}

/* --- Responsive: mobile --- */
@media (max-width: 600px) {
    .container {
        padding: 0 1rem;
    }

    .header-top {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .site-nav {
        gap: 0.85rem;
        flex-wrap: wrap;
    }

    .save-form {
        flex-wrap: wrap;
    }

    .save-form input[type="url"] {
        width: 100%;
    }

    .auth-card {
        padding: 1.5rem 1.25rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .settings-inner {
        flex-direction: column;
        gap: 1.25rem;
    }

    .article-reader {
        padding-top: 1.5rem;
    }

    .article-reader-title {
        font-size: 1.5rem;
    }

    .article-body {
        font-size: 1rem;
    }

    .reader-progress-wrap {
        width: 70px;
    }

    .reader-bar-title {
        display: none;
    }

    .reader-time {
        display: none;
    }
}
