:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #eeece7;
  --text: #1b1c1f;
  --muted: #6a6b70;
  --line: #e2dfd8;
  --accent: #4f46e5;
  --accent-soft: #e8e7fb;
  --new: #d9480f;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .04);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "New York", "Iowan Old Style", Charter, Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316;
    --surface: #1b1d21;
    --surface-2: #25272c;
    --text: #ececee;
    --muted: #9a9ba3;
    --line: #2c2e34;
    --accent: #8b85ff;
    --accent-soft: #2a2950;
    --new: #ff8a4c;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121316;
  --surface: #1b1d21;
  --surface-2: #25272c;
  --text: #ececee;
  --muted: #9a9ba3;
  --line: #2c2e34;
  --accent: #8b85ff;
  --accent-soft: #2a2950;
  --new: #ff8a4c;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left));
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -.02em;
}
.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: url("icons/icon.svg") center / cover;
}
.updated { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { margin-left: auto; display: flex; gap: 4px; }
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .fill { fill: currentColor; stroke: none; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-row { max-width: 1280px; margin: 0 auto; padding: 4px max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left)); }
.search-row input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search-row input:focus { border-color: var(--accent); }

.tabs {
  display: flex;
  gap: 6px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 6px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab .count { margin-left: 6px; font-weight: 500; opacity: .6; font-size: 13px; }

/* ---------- feed ---------- */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card.read .title a { color: var(--muted); }
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.ph img { display: none; }
.thumb.ph::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .01em;
  color: var(--muted);
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--surface-2);
}
.thumb.ph.video::after { content: ""; }
.play {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(0, 0, 0, .15);
  cursor: pointer;
}
.play span {
  width: 68px;
  height: 48px;
  border-radius: 14px;
  background: rgba(220, 0, 0, .92);
  display: grid;
  place-items: center;
}
.play span::after { content: ""; border-left: 18px solid #fff; border-top: 11px solid transparent; border-bottom: 11px solid transparent; margin-left: 4px; }
.thumb iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 12px; flex: 1; }
.meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.src { font-weight: 650; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new { margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--new); }
.title { margin: 0; font: 650 18px/1.3 var(--font); letter-spacing: -.01em; }
.title a { text-decoration: none; display: block; }
.title a:active { opacity: .6; }
.preview {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.preview:empty { display: none; }
.foot { margin-top: auto; padding-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
a.chip:active { background: var(--accent-soft); }

.sentinel { height: 1px; }
.signin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}
.empty { grid-column: 1 / -1; padding: 60px 16px; text-align: center; color: var(--muted); }
.more { grid-column: 1 / -1; justify-self: center; min-height: 44px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; }

/* ---------- sources tab ---------- */
.sources { max-width: 760px; }
.sources h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 4px 10px; }
.sources h2:first-child { margin-top: 4px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list a, .list .row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
  text-decoration: none;
  border-top: 1px solid var(--line);
}
.list > :first-child { border-top: 0; }
.list a:active { background: var(--surface-2); }
.list .grow { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: 13px; }
.list a::after { content: "›"; color: var(--muted); font-size: 22px; line-height: 1; }
.ok { color: #2f9e44; }
.bad { color: #e03131; }
.note { color: var(--muted); font-size: 14px; margin: 10px 4px; }

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .updated { display: none; }
  .title { font-size: 17px; }
}
@media (min-width: 900px) {
  .title { font-size: 19px; }
}
