/* ---- Design tokens & theming ---------------------------------------- */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f3;
    --border: #d9dce1;
    --text: #1d2127;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-text: #ffffff;
    --danger: #dc2626;
    --success: #16a34a;
    --link: #2563eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --topbar-h: 52px;
    --sidebar-w: 260px;
}

:root[data-theme="dark"] {
    --bg: #15171c;
    --surface: #1d2127;
    --surface-2: #252a32;
    --border: #333a45;
    --text: #e6e8eb;
    --text-muted: #9aa3af;
    --primary: #3b82f6;
    --primary-text: #ffffff;
    --link: #60a5fa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
        --bg: #15171c;
        --surface: #1d2127;
        --surface-2: #252a32;
        --border: #333a45;
        --text: #e6e8eb;
        --text-muted: #9aa3af;
        --primary: #3b82f6;
        --link: #60a5fa;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    }
}

/* ---- Base ------------------------------------------------------------ */
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

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

/* ---- Topbar ---------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar__brand { font-weight: 700; color: var(--text); }
.topbar__search { flex: 1; max-width: 420px; }
.topbar__search input {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
}
.topbar__nav { display: flex; align-items: center; gap: 16px; }
.topbar__nav a { color: var(--text-muted); }

/* ---- Flash / alerts -------------------------------------------------- */
.flash {
    padding: 10px 16px;
    text-align: center;
    font-size: 14px;
}
.flash--success { background: var(--success); color: #fff; }
.flash--error { background: var(--danger); color: #fff; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.alert--error { background: rgba(220, 38, 38, 0.12); color: var(--danger); }

/* ---- Buttons & forms ------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
}
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn--primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.link-button {
    background: none; border: none; padding: 0;
    color: var(--text-muted); cursor: pointer; font: inherit;
}
.link-button:hover { text-decoration: underline; }
.inline { display: inline; }

.form label { display: block; margin-bottom: 14px; }
.form label span { display: block; margin-bottom: 4px; font-size: 13px; color: var(--text-muted); }
.form input, .form select, .form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

/* ---- Layout containers ----------------------------------------------- */
.auth {
    min-height: calc(100vh - 0px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.login-card h1 { margin-top: 0; font-size: 22px; }

.panel {
    max-width: 720px;
    margin: 32px auto;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel--wide { max-width: 960px; }
.panel__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel__header h1 { margin: 0; }

/* ---- App shell (sidebar + content) ----------------------------------- */
.shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - var(--topbar-h));
}
.content { flex: 1; min-width: 0; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 12px 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}
.sidebar__nav { display: flex; flex-direction: column; }
.sidebar__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 16px;
    color: var(--text);
    font-size: 14px;
}
.sidebar__item:hover { background: var(--surface-2); text-decoration: none; }
.sidebar__item.is-active { background: var(--surface-2); font-weight: 600; }
.sidebar__feed-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__feed-title em { color: var(--text-muted); font-style: normal; font-size: 12px; }
.sidebar__group { margin-top: 6px; }
.sidebar__heading {
    padding: 6px 16px 2px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.sidebar__footer { margin-top: auto; padding: 12px 16px 0; display: grid; gap: 8px; }
.sidebar__manage { font-size: 13px; color: var(--text-muted); text-align: center; }

.badge {
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    padding: 1px 8px;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}
.badge--muted { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

.btn--block { display: block; text-align: center; }

/* ---- Tables, tags, lists --------------------------------------------- */
.table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.actions { white-space: nowrap; display: flex; gap: 10px; align-items: center; }

.tag { font-size: 12px; padding: 2px 8px; border-radius: var(--radius); }
.tag--ok { background: rgba(22, 163, 74, 0.15); color: var(--success); }
.tag--error { background: rgba(220, 38, 38, 0.15); color: var(--danger); }
.tag--muted { background: var(--surface-2); color: var(--text-muted); }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.list { list-style: none; padding: 0; margin: 12px 0 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }

.checkbox { display: flex; align-items: flex-start; gap: 8px; }
.checkbox input { width: auto; margin-top: 3px; }
.checkbox span { color: var(--text); }
.feed-choices { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; }
.radio { display: flex; align-items: flex-start; gap: 8px; }
.radio input { width: auto; margin-top: 4px; }
.radio span { display: flex; flex-direction: column; color: var(--text); }
.radio small { font-size: 12px; }
.form__actions { display: flex; gap: 10px; margin-top: 8px; }
.form--inline { display: flex; gap: 8px; align-items: center; }
.form--inline input { width: auto; flex: 1; }
.link-button--danger { color: var(--danger); }

.topbar__toggle { display: none; background: none; border: none; font-size: 20px; color: var(--text); cursor: pointer; }

hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* ---- Entry list ------------------------------------------------------ */
.entries { max-width: 860px; margin: 0 auto; padding: 16px 20px 48px; }
.entries__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.entries__header h1 { font-size: 20px; margin: 0; }
.entries__empty { padding: 40px 0; text-align: center; font-size: 16px; }

.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-row {
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    position: relative;
    overflow: hidden;
}
.entry-row__inner {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 8px;
    background: var(--bg);
    touch-action: pan-y;
    will-change: transform;
}
.entry-row__swipe-hint {
    position: absolute;
    inset: 0;
    background: var(--success);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 20px;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    user-select: none;
}
.entry-row.is-selected { border-left-color: var(--primary); }
.entry-row.is-selected .entry-row__inner { background: var(--surface-2); }
.entry-row.is-read .entry-row__title { color: var(--text-muted); font-weight: 400; }
.entry-row__main { display: block; flex: 1; min-width: 0; color: inherit; }
.entry-row__main:hover { text-decoration: none; }
.entry-row__title { display: block; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.entry-row.is-unread .entry-row__title::before {
    content: ""; display: inline-block; width: 8px; height: 8px;
    background: var(--primary); border-radius: 50%; margin-right: 8px; vertical-align: middle;
}
.entry-row__meta { display: flex; gap: 10px; font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.entry-row__excerpt { display: block; font-size: 13px; color: var(--text-muted); overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.star-button {
    background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1;
    color: var(--border); padding: 2px 4px;
}
.star-button.is-on { color: #f5b301; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; }

/* ---- Reader ---------------------------------------------------------- */
.reader { max-width: 760px; margin: 0 auto; padding: 0 20px 64px; }
.reader__bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0; position: sticky; top: var(--topbar-h); background: var(--bg);
    z-index: 5; flex-wrap: wrap;
}
.reader__bar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.reader__head { margin: 12px 0 24px; }
.reader__title { font-size: 28px; line-height: 1.25; margin: 0 0 8px; }
.reader__title a { color: var(--text); }
.reader__meta { font-size: 13px; }

.reader__content { font-size: 17px; line-height: 1.7; }
.reader__content img, .reader__content video, .reader__content iframe { max-width: 100%; height: auto; border-radius: var(--radius); }
.reader__content p { margin: 0 0 1.1em; }
.reader__content h1, .reader__content h2, .reader__content h3 { line-height: 1.3; margin: 1.4em 0 0.5em; }
.reader__content pre { background: var(--surface-2); padding: 12px; border-radius: var(--radius); overflow-x: auto; }
.reader__content blockquote { margin: 0 0 1em; padding-left: 16px; border-left: 3px solid var(--border); color: var(--text-muted); }
.reader__content a { color: var(--link); }

/* ---- Shortcut help overlay ------------------------------------------- */
.help-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center; z-index: 50;
}
.help-overlay__card { background: var(--surface); border-radius: var(--radius); padding: 24px 28px; min-width: 280px; box-shadow: var(--shadow); }
.help-overlay__card h2 { margin-top: 0; }
.help-overlay__card ul { list-style: none; padding: 0; margin: 0 0 12px; }
.help-overlay__card li { padding: 4px 0; }
kbd {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px;
    padding: 1px 6px; font-family: inherit; font-size: 12px;
}

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 720px) {
    .topbar__toggle { display: block; }
    .sidebar {
        position: fixed;
        left: 0; top: var(--topbar-h);
        z-index: 15;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }
    .sidebar.is-open { transform: translateX(0); }
    .topbar__nav a { display: none; }
}

/* ---- AI summary callout ---------------------------------------------- */
.summary {
    margin: 0 0 24px;
    padding: 14px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
}
.summary.is-empty { display: none; }
.summary__label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.summary__label .muted { font-weight: 400; }
.summary__body p { margin: 0 0 6px; }
.summary__body ul { margin: 0; padding-left: 20px; }
.summary__body li { margin: 2px 0; }
.summary__body { font-size: 15px; line-height: 1.55; }
