*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #FAFAF8; --surface: #FFFFFF; --border: #E5E3DC; --border-hover: #C8C5BB;
  --text-primary: #1A1A18; --text-secondary: #5C5B56; --text-muted: #9A9890;
  --accent: #B85C00;
  --unread-bg: #F0F7F1; --unread-border: #A8D5B0; --unread-hover: #81C784;
  --hindu-bg: #FFF3E0; --hindu-text: #BF360C;
  --ie-bg: #E3F2FD; --ie-text: #0D47A1;
  --au-bg: #E8F5E9; --au-text: #2E7D32;
  --bbc-bg: #FDECEA; --bbc-text: #C62828;
  --bhaskar-bg: #EDE7F6; --bhaskar-text: #4527A0;
  --new-bg: #E8F5E9; --new-text: #2E7D32; --new-dot: #43A047;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px;
}
body { font-family: 'IBM Plex Sans', sans-serif; background: var(--bg); color: var(--text-primary); min-height: 100vh; }

/* Header */
.header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; padding: 0 1.5rem; }
.header-top { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 0 0.75rem; gap: 12px; }
.logo { font-family: 'Playfair Display', serif; font-size: 24px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 10px; }
.auto-pill { font-size: 11px; background: #FFF8E1; color: #F57F17; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.last-updated { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.refresh-btn { display: flex; align-items: center; gap: 5px; font-size: 12px; font-family: inherit; font-weight: 500; color: var(--text-secondary); background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 12px; cursor: pointer; transition: all .15s; }
.refresh-btn:hover { background: var(--bg); border-color: var(--border-hover); }
.refresh-btn.spinning svg { animation: spin .8s linear infinite; }
.lang-toggle { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.lang-btn { font-size: 11px; font-family: inherit; font-weight: 500; padding: 4px 10px; background: none; border: none; color: var(--text-secondary); cursor: pointer; transition: all .15s; white-space: nowrap; }
.lang-btn.active { background: var(--accent); color: #fff; }
.lang-btn:hover:not(.active) { background: var(--border); }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: .7rem; }
.pill { font-size: 12px; font-family: inherit; font-weight: 500; padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); cursor: pointer; transition: all .15s; }
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Main */
.main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1.5rem 2rem; }
.section-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.section-label { font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }
.unread-pill { font-size: 11px; background: var(--new-bg); color: var(--new-text); padding: 3px 9px; border-radius: 20px; font-weight: 500; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.1rem .85rem; cursor: pointer; transition: border-color .15s, box-shadow .15s, background .2s; display: flex; flex-direction: column; animation: fadeIn .2s ease both; }
.card:hover { border-color: var(--border-hover); box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.card.unread { background: var(--unread-bg); border-color: var(--unread-border); }
.card.unread:hover { border-color: var(--unread-hover); }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: .55rem; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 4px; }
.badge-hindu { background: var(--hindu-bg); color: var(--hindu-text); }
.badge-ie { background: var(--ie-bg); color: var(--ie-text); }
.badge-au { background: var(--au-bg); color: var(--au-text); }
.badge-bbc { background: var(--bbc-bg); color: var(--bbc-text); }
.badge-bhaskar { background: var(--bhaskar-bg); color: var(--bhaskar-text); }
.badge-cat { background: #F3F3F0; color: var(--text-secondary); }
.new-badge { display: flex; align-items: center; gap: 4px; font-size: 9px; font-weight: 600; background: var(--new-bg); color: var(--new-text); padding: 2px 7px; border-radius: 4px; white-space: nowrap; flex-shrink: 0; }
.new-dot { width: 5px; height: 5px; background: var(--new-dot); border-radius: 50%; animation: pulse 1.5s ease-in-out infinite; }

.card-title { font-size: 13.5px; font-weight: 500; line-height: 1.45; color: var(--text-primary); margin-bottom: .5rem; }
.card-summary { font-size: 12.5px; line-height: 1.65; color: var(--text-secondary); flex: 1; }
.card-summary-empty { color: var(--text-muted); font-style: italic; font-size: 12px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: .75rem; padding-top: .65rem; border-top: 1px solid var(--border); }
.card-time { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.read-link { font-size: 11px; font-weight: 500; color: var(--accent); text-decoration: none; display: flex; align-items: center; gap: 3px; }
.read-link:hover { text-decoration: underline; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 1.5rem; }
.page-btn { font-size: 12px; font-family: inherit; padding: 6px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-secondary); cursor: pointer; transition: all .15s; }
.page-btn:hover:not(:disabled) { background: var(--bg); border-color: var(--border-hover); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .35; cursor: default; }
.page-ellipsis { font-size: 12px; color: var(--text-muted); padding: 0 4px; }

/* States */
.state-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 4rem 1rem; text-align: center; }
.spinner { width: 32px; height: 32px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
.state-title { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.state-sub { font-size: 13px; color: var(--text-muted); max-width: 400px; line-height: 1.6; }
.error-box { background: #FFF5F5; border: 1px solid #FECACA; border-radius: var(--radius-md); padding: 1.4rem 1.5rem; font-size: 13px; color: #991B1B; max-width: 520px; line-height: 1.8; text-align: left; }
.error-box strong { display: block; margin-bottom: 8px; font-size: 14px; }
.error-box code { font-size: 12px; background: #fff; padding: 2px 6px; border-radius: 4px; border: 1px solid #FECACA; }
.error-detail { color: #B45309; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

@media(max-width:600px){
  .header,.main { padding-left:1rem; padding-right:1rem; }
  .logo { font-size: 20px; }
  .header-right .auto-pill, .header-right .last-updated { display: none; }
  .grid { display: none; }
  .pagination { display: none; }
  .mobile-stack { display: block; }
  .footer-inner { justify-content: center; text-align: center; }
  .footer { padding: 1rem; }
}

/* Mobile card stack */
@media(min-width:601px) { .mobile-stack { display: none; } }
.mobile-stack { position: relative; padding-bottom: 28px; }
.scard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.2rem 1.2rem 1rem;
  will-change: transform; user-select: none; -webkit-user-select: none;
  position: relative; z-index: 3; display: flex; flex-direction: column;
}
.scard.unread { background: var(--unread-bg); border-color: var(--unread-border); }
.scard-behind {
  position: absolute; border: 1px solid var(--border);
  border-radius: var(--radius-lg); top: 0; pointer-events: none;
}
.scard-b1 { left: 8px; right: 8px; bottom: 10px; z-index: 2; background: var(--surface); }
.scard-b2 { left: 16px; right: 16px; bottom: 0; z-index: 1; background: var(--bg); }
.swipe-hint { text-align: center; font-size: 10px; color: var(--text-muted); margin-top: .8rem; letter-spacing: .3px; }
.stack-counter { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 10px; }

/* End-of-feed card */
.scard-done { justify-content: center; align-items: center; text-align: center; padding: 2.5rem 1.5rem; min-height: 300px; gap: .75rem; }
.done-icon { font-size: 32px; margin-bottom: .25rem; }
.done-title { font-family: 'Playfair Display', serif; font-size: 17px; font-weight: 700; color: var(--text-primary); }
.done-sub { font-size: 12.5px; color: var(--text-muted); line-height: 1.7; }
.done-refresh { margin: .75rem auto 0; }

/* Footer */
.footer { border-top: 1px solid var(--border); background: var(--surface); padding: 1.25rem 1.5rem; margin-top: 2rem; }
.footer-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-sources { font-size: 11px; color: var(--text-muted); line-height: 1.6; }
.footer-sources a { color: var(--text-secondary); text-decoration: none; font-weight: 500; }
.footer-sources a:hover { color: var(--accent); }
.footer-mii { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: .3px; }
