@import url('https://fonts.googleapis.com/css2?family=Literata:ital,wght@0,400;0,600;1,400&family=Inter:wght@400;500&display=swap');

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

:root {
    --bg:       #f4f1eb;
    --surface:  #ffffff;
    --border:   #e2ddd6;
    --text:     #1a1814;
    --text2:    #6b6760;
    --text3:    #a09d99;
    --accent:   #b85c2a;
    --radius:   10px;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── HEADER ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.logo {
    font-family: 'Literata', serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.stats {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--text3);
}

/* ── LAYOUT ── */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ── GRID ── */
.feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

/* ── CARD ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s, transform 0.15s;
    text-decoration: none;
    color: inherit;
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.10);
    transform: translateY(-2px);
}

.card-image {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    background: var(--bg);
}

.card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.card-title {
    font-family: 'Literata', serif;
    font-size: 0.97rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
}

.card-desc {
    font-size: 0.82rem;
    color: var(--text2);
    line-height: 1.5;
    flex: 1;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 4px;
}

.card-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.card-source {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.card-time {
    font-size: 0.73rem;
    color: var(--text3);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── SORT ── */
.sort-wrap {
    position: relative;
    margin-left: auto;
}

.sort-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text2);
    padding: 5px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}
.sort-btn:hover { background: var(--bg); color: var(--text); }

.sort-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    min-width: 160px;
    z-index: 100;
}
.sort-menu.open { display: block; }

.sort-item {
    padding: 9px 14px;
    font-size: 0.82rem;
    color: var(--text2);
    cursor: pointer;
    transition: background 0.1s;
}
.sort-item:hover { background: var(--bg); color: var(--text); }
.sort-item.active { color: var(--accent); font-weight: 500; }

/* ── VIEW TOGGLE ── */
.view-toggle {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.view-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text3);
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.view-btn:hover { color: var(--text2); background: var(--bg); }
.view-btn.active { color: var(--accent); border-color: var(--border); background: var(--bg); }

/* ── РЕЖИМ СПИСКА ── */
.feed.list-view {
    grid-template-columns: 1fr;
    gap: 6px;
}

.feed.list-view .card {
    flex-direction: row;
    align-items: stretch;
    border-radius: 8px;
}

.feed.list-view .card-image {
    width: 120px;
    min-height: 90px;
    aspect-ratio: unset;
    flex-shrink: 0;
    border-radius: 0;
    object-fit: cover;
}

.feed.list-view .card-body {
    padding: 10px 12px;
    gap: 4px;
    justify-content: center;
    overflow: hidden;
}

.feed.list-view .card-title {
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed.list-view .card-desc {
    font-size: 0.78rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: unset;
}

.feed.list-view .card-meta { margin-top: 0; }

/* ── EMPTY ── */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text2);
}
.empty h2 { font-family: 'Literata', serif; margin-bottom: 8px; }

/* ── MOBILE ── */
@media (max-width: 500px) {
    .feed {
        grid-template-columns: 1fr;
    }
    header { padding: 0 14px; }
    .container { padding: 14px 10px; }
}
