/* ReadToMe — dark reader-friendly stylesheet */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg:         #1a1a2e;
    --surface:    #16213e;
    --surface2:   #0f3460;
    --accent:     #e94560;
    --accent2:    #53c0f0;
    --text:       #e0e0e0;
    --text-muted: #8a8a9a;
    --border:     #2a2a4a;
    --success:    #4caf79;
    --error-bg:   #2d1a1a;
    --error-text: #ff6b6b;
    --radius:     8px;
    --font:       system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 120px; /* space for player bar */
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.site-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.add-form {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 240px;
}

.url-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.2s;
}

.url-input:focus {
    border-color: var(--accent2);
}

.url-input::placeholder {
    color: var(--text-muted);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */

.btn {
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 8px 14px;
    transition: opacity 0.15s, background 0.15s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.85;
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
}

.btn-secondary:hover {
    opacity: 0.85;
}

.btn-play {
    background: var(--accent2);
    color: var(--bg);
}

.btn-play:hover {
    opacity: 0.85;
}

.btn-play.playing {
    background: var(--success);
}

.btn-retry {
    background: var(--surface2);
    color: var(--accent2);
}

.btn-delete {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 10px;
}

.btn-delete:hover {
    border-color: var(--error-text);
    color: var(--error-text);
}

/* ── Main content ─────────────────────────────────────────────────────────────── */

.main-content {
    max-width: 760px;
    margin: 20px auto;
    padding: 0 16px;
}

/* ── Status message ───────────────────────────────────────────────────────────── */

.status-message {
    background: var(--surface2);
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 16px;
    padding: 10px 14px;
}

.status-message.status-success {
    background: #1a3a28;
    color: var(--success);
}

.status-message.status-error {
    background: var(--error-bg);
    color: var(--error-text);
}

/* ── Article cards ────────────────────────────────────────────────────────────── */

.article-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--surface2);
}

.card.status-complete {
    border-left: 3px solid var(--success);
}

.card.status-error {
    border-left: 3px solid var(--error-text);
}

.card.status-pending,
.card.status-extracting,
.card.status-converting {
    border-left: 3px solid var(--accent2);
}

.card-body {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-meta {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-error {
    background: var(--error-bg);
    border-radius: 4px;
    color: var(--error-text);
    font-size: 0.8rem;
    margin-top: 6px;
    padding: 4px 8px;
}

.card-actions {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    gap: 8px;
}

.status-badge {
    color: var(--text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* ── Empty / loading states ───────────────────────────────────────────────────── */

.empty-state,
.loading-state,
.error-state {
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 40px 0;
    text-align: center;
}

.empty-state a {
    color: var(--accent2);
}

/* ── Sticky audio player ──────────────────────────────────────────────────────── */

.player-bar {
    background: var(--surface);
    border-top: 1px solid var(--border);
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    left: 0;
    padding: 10px 16px;
    position: fixed;
    right: 0;
    z-index: 200;
}

.player-info {
    flex: 1;
    min-width: 0;
}

.player-title {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-controls {
    flex-shrink: 0;
}

#audio-player {
    height: 36px;
    width: min(380px, 50vw);
}

.player-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 4px 8px;
}

.player-close:hover {
    color: var(--text);
}

/* ── Bookmarklet modal ────────────────────────────────────────────────────────── */

.modal-overlay {
    background: rgba(0, 0, 0, 0.6);
    bottom: 0;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 300;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    left: 50%;
    max-width: 480px;
    padding: 24px;
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 32px);
    z-index: 301;
}

.modal h2 {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.modal p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.bookmarklet-drag {
    background: var(--accent);
    border-radius: var(--radius);
    color: #fff;
    cursor: grab;
    display: inline-block;
    font-weight: 700;
    padding: 10px 18px;
    text-decoration: none;
    user-select: none;
}

.bookmarklet-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 10px;
}

/* ── Login page ──────────────────────────────────────────────────────────────── */

.login-wrap {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 360px;
    padding: 32px 28px;
    width: 100%;
}

.login-title {
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
}

.login-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.login-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.login-input:focus {
    border-color: var(--accent2);
}

.login-error {
    background: var(--error-bg);
    border-radius: var(--radius);
    color: var(--error-text);
    font-size: 0.88rem;
    padding: 8px 12px;
}

.login-btn {
    font-size: 1rem;
    margin-top: 4px;
    padding: 11px;
    width: 100%;
}

/* ── Sign-out link ────────────────────────────────────────────────────────────── */

.btn-logout {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
    text-decoration: none;
    white-space: nowrap;
}

.btn-logout:hover {
    color: var(--text);
}

/* ── Mobile tweaks ────────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
    .header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .site-title {
        text-align: center;
    }

    .card {
        flex-direction: column;
    }

    .card-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .card-title,
    .card-meta {
        white-space: normal;
        overflow-wrap: break-word;
        word-break: break-all;
    }

    .player-bar {
        flex-wrap: wrap;
    }

    #audio-player {
        width: 100%;
    }
}
