:root {
  --bg: #f7f6f2;
  --card: #ffffff;
  --text: #1d1e20;
  --sub: #5f6166;
  --muted: #8a8c92;
  --line: #e4e2dc;
  --accent: #2458d6;
  --done: #2e8b57;
  --danger: #c2410c;
  /* カテゴリの色 */
  --c-must: #c2410c;
  --c-it: #2458d6;
  --c-ai: #7c3aed;
  --c-biz: #15803d;
  --c-trend: #db2777;
  --c-run: #0e7490;
  --c-weekly: #b45309;
  --tab-h: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151618;
    --card: #1f2023;
    --text: #ececee;
    --sub: #a6a8ae;
    --muted: #7d8087;
    --line: #2e3034;
    --accent: #7aa2ff;
    --done: #5cc98a;
    --danger: #fb923c;
    --c-must: #fb923c;
    --c-it: #7aa2ff;
    --c-ai: #b794f6;
    --c-biz: #5cc98a;
    --c-trend: #f472b6;
    --c-run: #4fd1e0;
    --c-weekly: #f6ad55;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

/* ---------- ヘッダー ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h1 { font-size: 20px; margin: 0; letter-spacing: .02em; }
.streak { font-size: 12px; color: var(--muted); white-space: nowrap; }
.remaining { margin: 2px 0 6px; font-size: 13px; color: var(--sub); }
.remaining.done { color: var(--done); font-weight: 600; }
.bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
#bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.summary.done #bar-fill { background: var(--done); }
.chips {
  display: flex;
  gap: 6px;
  margin: 10px -16px 0;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  color: var(--sub);
}
.chip b { color: var(--cat); font-weight: 600; margin-left: 3px; }
.chip.all-read { opacity: .5; }

main { padding: 12px 16px; max-width: 640px; margin: 0 auto; }

/* ---------- セクション ---------- */
h2.section {
  font-size: 13px;
  color: var(--cat);
  margin: 22px 2px 8px;
  letter-spacing: .08em;
}
h2.section:first-child { margin-top: 4px; }

/* カテゴリごとの色 (--cat) */
.cat-must { --cat: var(--c-must); }
.cat-it { --cat: var(--c-it); }
.cat-ai { --cat: var(--c-ai); }
.cat-biz { --cat: var(--c-biz); }
.cat-trend { --cat: var(--c-trend); }
.cat-run { --cat: var(--c-run); }
.cat-weekly { --cat: var(--c-weekly); }

/* ---------- カード ---------- */
.swipe {
  position: relative;
  margin-bottom: 8px;
  border-radius: 14px;
  overflow: hidden;
}
.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  background: var(--muted);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 14px;
  opacity: 0;
}
.swiping .swipe-bg { opacity: 1; }
.swipe-bg.armed { background: var(--danger); }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cat);
  border-radius: 14px;
  padding: 11px 12px 10px 14px;
  touch-action: pan-y;
  transition: transform .2s;
}
.swiping .card { transition: none; }

.head { display: flex; align-items: flex-start; gap: 10px; }
.card { cursor: pointer; }
.headline {
  flex: 1;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.meta { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }
.check {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -10px -10px -6px 0;
  background: none;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.check span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
}
.check.on span { border-color: var(--done); background: var(--done); color: #fff; }

.important {
  display: flex;
  gap: 5px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger);
  font-weight: 600;
  margin: 6px 0 0;
}
.card ul { margin: 8px 0 0; padding-left: 1.1em; font-size: 14.5px; line-height: 1.55; color: var(--text); }
.card li { margin: 2px 0; }
.card li::marker { color: var(--muted); }

.foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.open-link {
  flex: none;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}
.ico-sm { flex: none; width: 14px; height: 14px; margin-top: 2px; }
.src { flex: 1; min-width: 0; font-size: 11.5px; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more {
  flex: none;
  width: 36px;
  height: 32px;
  margin-right: -6px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 18px;
  letter-spacing: 1px;
  line-height: 1;
}
.menu { display: flex; gap: 8px; margin-top: 10px; }
.menu button {
  flex: 1;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 13px;
}
.menu .dismiss { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* 読み終えた記事は1行にたたむ */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 6px;
  text-align: left;
}
.row .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.row .mark.read { background: var(--done); color: #fff; }
.row .mark.dismiss { border: 1.5px solid var(--muted); color: var(--muted); }
.row .t { flex: 1; min-width: 0; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .undo { flex: none; font-size: 12.5px; color: var(--accent); background: none; border: 0; padding: 6px 0 6px 6px; }

/* ---------- 完了・空表示 ---------- */
.finish {
  margin: 20px 0 4px;
  padding: 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--done) 12%, var(--card));
  text-align: center;
  color: var(--done);
  font-weight: 600;
}
.finish small { display: block; margin-top: 4px; color: var(--sub); font-weight: 400; font-size: 12.5px; }
.empty { color: var(--sub); text-align: center; padding: 48px 0; }
.empty strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 4px; }

/* ---------- タブ ---------- */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1;
  height: var(--tab-h);
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
}
.tabs .ico { font-size: 20px; line-height: 1; }
.tabs button.active { color: var(--accent); font-weight: 600; }
.tabs button.new::after {
  content: "";
  position: absolute;
  top: 9px; right: calc(50% - 16px);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
}

/* ---------- 設定 ---------- */
.settings section { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.settings h2 { font-size: 15px; margin: 0 0 6px; }
.settings p { font-size: 13px; color: var(--sub); margin: 0 0 10px; }
.btn {
  min-height: 44px;
  width: 100%;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn:disabled { opacity: .5; }
