:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1a1d21;
    --muted: #6b7280;
    --border: #e3e6ea;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- Nav ---------- */
.navbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.nav-links { display: flex; gap: 8px; margin-left: 8px; }
.nav-links a {
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
}
.nav-links a:hover { background: var(--bg); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: #eef2ff; }
.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.nav-username {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.logout-form { margin: 0; }
.logout-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}
.logout-btn:hover { background: var(--bg); }

/* ---------- Layout ---------- */
.container { max-width: 720px; margin: 0 auto; padding: 20px 16px 80px; }
.page-title { font-size: 1.6rem; margin: 8px 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 20px; font-size: 0.9rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 16px; font-size: 1.1rem; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 0.9rem; }
.msg.error { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.msg.success { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field-hint { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.feed-search-field { position: relative; }
.feed-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 20;
    list-style: none;
    margin: 0;
    padding: 6px 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
}
.feed-search-item {
    padding: 8px 12px;
    cursor: pointer;
}
.feed-search-item:hover,
.feed-search-item.is-active { background: #eef2ff; }
.feed-search-item.is-subscribed { cursor: default; opacity: 0.7; }
.feed-search-item.is-subscribed:hover,
.feed-search-item.is-subscribed.is-active { background: var(--bg); }
.feed-search-url {
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.feed-search-url mark {
    background: #fef3c7;
    color: inherit;
    padding: 0;
}
.feed-search-meta {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 2px;
}
.feed-search-empty {
    padding: 10px 12px;
    color: var(--muted);
    font-size: 0.85rem;
}
input[type="text"], input[type="url"], input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

.primary-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.primary-btn:hover { background: var(--accent-dark); }
.danger-btn {
    background: transparent;
    color: var(--red);
    border: 1px solid #fecaca;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}
.danger-btn:hover { background: #fef2f2; }

/* ---------- Feed list (configuration) ---------- */
.feed-list { list-style: none; padding: 0; margin: 0; }
.feed-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.feed-row:last-child { border-bottom: none; }
.feed-meta { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.feed-name { font-weight: 600; }
.feed-url { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
.login-card .primary-btn { width: 100%; margin-top: 8px; }
.login-error { background: #fef2f2; color: var(--red); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.login-note { color: var(--muted); font-size: 0.8rem; text-align: center; margin: 18px 0 0; }
.login-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0;
    color: var(--muted);
    font-size: 0.8rem;
}
.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}
.google-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.google-btn svg { width: 18px; height: 18px; }
.google-btn:hover { background: var(--bg); }

/* ---------- Feed items ---------- */
.feed { display: flex; flex-direction: column; gap: 0; }

.day-separator {
    position: sticky;
    top: 57px;
    z-index: 5;
    margin: 18px 0 10px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg);
    padding: 6px 0;
    border-bottom: 2px solid var(--accent);
}
.hour-separator {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 10px 0 6px;
    padding-left: 2px;
    border-left: 3px solid var(--border);
    padding: 2px 0 2px 8px;
}

.article {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    touch-action: pan-y;
}
.article-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.article-time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.article-source { color: var(--accent); font-size: 0.8rem; font-weight: 600; }
.article-title { font-size: 1.1rem; font-weight: 700; margin: 4px 0 8px; line-height: 1.3; }
.article-title a { color: var(--text); }
.article-title a:hover { color: var(--accent); }
.article-body { color: #374151; font-size: 0.92rem; line-height: 1.55; }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; }
.article-body p { margin: 0 0 8px; }

.article-actions { display: flex; gap: 10px; margin-top: 14px; }
.react-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    transition: all 0.12s ease;
}
.react-btn svg { width: 18px; height: 18px; }
.react-btn.interested:hover { color: var(--green); border-color: var(--green); background: #f0fdf4; }
.react-btn.not-interested:hover { color: var(--red); border-color: var(--red); background: #fef2f2; }

/* Swipe affordance overlays (mobile) */
.swipe-hint {
    position: absolute;
    top: 0; bottom: 0;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
}
.swipe-hint.left { right: 0; color: var(--red); }
.swipe-hint.right { left: 0; color: var(--green); }

.article.removing { transition: transform 0.28s ease, opacity 0.28s ease; opacity: 0; }
.article.swiping { transition: none; }

.feed-status { text-align: center; color: var(--muted); padding: 24px 0; font-size: 0.9rem; }
.feed-status.error { color: var(--red); }

.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hide the swipe hint text on desktop; hide desktop-only hint on touch is handled in JS */
@media (hover: none) and (pointer: coarse) {
    .article-actions { display: none; }
    .hint-desktop { display: none; }
}
