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

/* ═══════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════ */

:root {
  /* === Brand === */
  --primary: #e74c3c;
  --primary-light: #fdf2f2;
  /* === Accent (legacy) === */
  --accent: #405de6;
  --accent2: #833ab4;
  --ig-grad: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  /* === Surfaces === */
  --surface: #ffffff;
  --bg-card: #ffffff;
  --surface2: #f5f6f8;
  --bg-page: #f5f6f8;
  /* === Border === */
  --border: #e8eaed;
  /* === Text === */
  --text-primary: #1a1a2e;
  --text-secondary: #555555;
  --text-muted: #888888;
  /* === Shadows === */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.12);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.12);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.16);
  /* === Radius === */
  --radius-card: 12px;
  --radius: 12px;
  --radius-sm: 10px;
}

body {
  font-family: system-ui, -apple-system, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  font-size: 0.95rem;
  line-height: 1.7;
  background: var(--surface2);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════
   LAYOUT: HEADER
   ═══════════════════════════════════ */
header {
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
header .inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; width: 100%; }
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 8px; overflow: hidden; }

/* ロゴリンク */
.header-logo-link {
  text-decoration: none; color: inherit; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.header-logo-link:hover h1 { opacity: .8; }

/* 右サイドエリア */
.header-right {
  display: flex; align-items: center; gap: 12px;
  overflow: hidden; min-width: 0;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}
header p { color: var(--text-muted); font-size: .75rem; margin-top: 1px; font-weight: 400; }

/* マイページリンク */
.mypage-link-btn {
  color: #737373; font-size: .85rem; text-decoration: none;
  white-space: nowrap; position: relative; flex-shrink: 0;
}
.mypage-link-btn:hover { color: var(--text-primary); }
@media (max-width: 480px) { .mypage-label { display: none; } }

/* 天気ウィジェット */
.weather-widget {
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  flex-shrink: 0;
}
.weather-city { font-size: .65rem; color: var(--text-muted); }
.weather-desc { font-size: .8rem; color: var(--text-secondary); white-space: nowrap; }
.weather-temp { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
@media (max-width: 600px) { .weather-widget { display: none; } }

/* ===== SEARCH ROW ===== */
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.search-row .search-bar { flex: 1; margin-bottom: 0; }
.catchup-icon-btn {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
  opacity: 0.7;
  padding: 6px;
  border-radius: 50%;
  transition: opacity .15s, background .15s;
}
.catchup-icon-btn:hover { opacity: 1; background: var(--surface2); }

/* ===== SEARCH ===== */
.search-bar { margin-bottom: 12px; }
.search-bar input {
  width: 100%;
  padding: 11px 20px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.search-bar input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(231,76,60,0.12);
}
.search-bar input::placeholder { color: var(--text-muted); }

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .82rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  transition: color .15s;
}
.back-link:hover { color: var(--text-primary); }

/* ═══════════════════════════════════
   LAYOUT: CONTAINER
   ═══════════════════════════════════ */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
main.container { padding-top: 22px; padding-bottom: 56px; }

/* ===== FILTER TABS (X-style) ===== */
.filter-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.genre-tabs { border-bottom: none; margin-bottom: 8px; }

/* keep .filter-bar as alias for old code elsewhere */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.filter-btn {
  flex-shrink: 0;
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.filter-btn:hover { color: var(--text-primary); }
.filter-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* ===== LAST UPDATED ===== */
.last-updated { font-size: .75rem; color: var(--text-muted); margin: 10px 0 14px; font-weight: 400; }

/* ═══════════════════════════════════
   LAYOUT: GRID
   ═══════════════════════════════════ */
.topics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 768px) {
  .topics-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}
@media (min-width: 1024px) {
  .topics-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ═══════════════════════════════════
   COMPONENT: TOPIC CARD
   ═══════════════════════════════════ */
.topic-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: transform .2s cubic-bezier(.25,.46,.45,.94), box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.topic-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  border-radius: 3px 0 0 3px;
  transition: background .15s;
}
.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.topic-card.rising::before    { background: #ef4444; }
.topic-card.peak::before      { background: #f59e0b; }
.topic-card.declining::before { background: #d1d5db; }

/* サムネイル */
.card-thumb {
  flex: 0 0 88px;
  width: 88px; height: 88px;
  border-radius: 12px;
  overflow: hidden;
  background: #f3f4f6;
}
.card-thumb-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.card-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  border-radius: 12px;
}
.card-thumb-placeholder.rising    { background: #fef2f2; }
.card-thumb-placeholder.peak      { background: #fffbeb; }
.card-thumb-placeholder.declining { background: #f8fafc; }

.card-body { flex: 1; min-width: 0; }

.topic-status {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: .04em;
  border-radius: 20px;
  padding: 2px 8px;
  text-transform: uppercase;
}
.topic-status.rising    { color: #dc2626; background: #fef2f2; }
.topic-status.peak      { color: #b45309; background: #fffbeb; }
.topic-status.new       { color: #1d4ed8; background: #eff6ff; }
.topic-status.declining { color: var(--text-muted); background: #f3f4f6; }

.topic-card h3 {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -.01em;
}

.card-summary {
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  color: var(--text-muted);
}
.article-count {
  font-size: .72rem;
  font-weight: 500;
  color: var(--text-muted);
}
.card-attribution {
  font-size: .62rem;
  color: var(--text-muted);
  opacity: 0.55;
  margin-top: 4px;
}
/* ═══════════════════════════════════
   COMPONENT: BADGES
   ═══════════════════════════════════ */
.reliability-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.src-count-label {
  font-size: .68rem;
  color: var(--text-muted);
}
.src-count-label.src-single {
  color: var(--text-muted);
  opacity: 0.65;
}
.reliability-badge {
  font-size: .7rem;
  color: #b45309;
  background: rgba(180,83,9,0.08);
  border: 1px solid rgba(180,83,9,0.2);
  border-radius: 20px;
  padding: 2px 8px;
  font-weight: 500;
}
.conflict-badge {
  font-size: .7rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
}
.genre-tag {
  font-size: .7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
}

/* ═══════════════════════════════════
   STATE: LOADING / EMPTY
   ═══════════════════════════════════ */
.loading {
  text-align: center;
  padding: 80px 0;
  color: var(--text-muted);
  grid-column: 1 / -1;
  font-size: .9rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid #e5e7eb;
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== DETAIL PAGE ===== */
.status-badge {
  display: inline-block;
  padding: 5px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .82rem;
  margin: 20px 0;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.status-badge.rising    { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.status-badge.peak      { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.status-badge.new       { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status-badge.declining { background: #f3f4f6; color: var(--text-muted); border: 1px solid #e5e7eb; }

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card h2 {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

#timeline-chart { max-height: 280px; }

/* ===== ARTICLE LIST ===== */
.article-item { padding: 12px 0; border-bottom: 1px solid var(--surface2); }
.article-item:last-child { border-bottom: none; }
.article-item a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.55;
}
.article-item a:hover { color: var(--accent); }
.article-meta { font-size: .73rem; color: var(--text-muted); margin-top: 3px; }

/* ===== VERTICAL TIMELINE ===== */
.article-total-count {
  font-size: .8rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--surface2);
}

.story-timeline-wrap {
  position: relative;
  padding-left: 8px;
}
.story-timeline-wrap::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 6px;
  bottom: 6px;
  width: 1.5px;
  background: #e5e7eb;
  border-radius: 1px;
}

.timeline-item {
  display: flex;
  flex-direction: row;
  gap: 12px;
  position: relative;
  padding-bottom: 20px;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
  margin-top: 5px;
  position: relative;
  z-index: 1;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #3b82f6;
}
.timeline-item:first-child .timeline-dot {
  background: #f43f5e;
  box-shadow: 0 0 0 2px #f43f5e;
}

.timeline-content { flex: 1; min-width: 0; }
.timeline-time {
  font-size: .73rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}
.timeline-item:first-child .timeline-time { color: #f43f5e; }

.timeline-article { margin-bottom: 8px; }
.timeline-article:last-child { margin-bottom: 0; }
.timeline-article-link {
  display: block;
  color: var(--text-primary);
  text-decoration: none;
  font-size: .88rem;
  line-height: 1.55;
  font-weight: 500;
  transition: color .15s;
}
.timeline-article-link:hover { color: var(--accent); }

.timeline-source {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== ADS ===== */
.ad-slot {
  background: var(--surface2);
  border: 1.5px dashed #e5e7eb;
  border-radius: var(--radius-sm);
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: .78rem;
  margin-bottom: 14px;
}
.ad-card-wrapper { width: 100%; }
.ad-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.ad-label {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.7rem;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

/* ===== SITE FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 16px;
  text-align: center;
  margin-top: 48px;
  color: var(--text-muted);
  font-size: .8rem;
  line-height: 1.6;
}
.site-footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 8px;
}
.site-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.site-footer-links a:hover { color: var(--text-secondary); }
.site-footer-copy { font-size: .75rem; color: var(--text-muted); opacity: .7; }

/* ═══════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════ */
@media (max-width: 600px) {
  header h1 { font-size: 1.15rem; }
  .card-thumb { flex: 0 0 76px; width: 76px; height: 76px; }
}
@media (max-width: 480px) {
  .container { padding-left: 12px; padding-right: 12px; }
  main.container { padding-left: 12px; padding-right: 12px; }
  .weather-widget { display: none; }
  .auth-btn-text { display: none; }
}

/* ===== GENRE FILTER ===== */
.genre-bar { margin-top: 0; }
#genre-badge {
  display: none; margin-left: 8px;
  font-size: .78rem; background: var(--surface2); color: var(--text-secondary);
  border-radius: 6px; padding: 3px 10px; font-weight: 600;
  border: 1px solid var(--border);
}

/* ===== STORY TIMELINE ===== */
.score-note { font-size: .73rem; color: var(--text-muted); margin-top: 8px; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.chart-header h2 { margin-bottom: 0; }
.timerange-btns { display: flex; flex-wrap: wrap; gap: 5px; }
.tr-btn {
  padding: 3px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: .76rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all .15s;
}
.tr-btn.active, .tr-btn:hover {
  border-color: var(--text-primary);
  background: var(--text-primary);
  color: #fff;
}

/* ===== NEW BADGE ===== */
.new-badge {
  display: inline-block;
  background: #f43f5e;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  vertical-align: middle;
  margin-left: 6px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ===== SORT TOGGLE ===== */
.sort-toggle { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.sort-label { font-size: .78rem; color: var(--text-secondary); }
.sort-btn {
  padding: 2px 10px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  font-size: .76rem;
  font-weight: 500;
  font-family: inherit;
  transition: all .15s;
}
.sort-btn.active, .sort-btn:hover {
  border-color: var(--text-primary);
  background: var(--text-primary);
  color: #fff;
}
.timeline-window-note { font-size: .76rem; color: var(--text-muted); margin-bottom: 12px; }

/* ===== TIMELINE DAY GROUPS ===== */
.day-articles { display: flex; flex-direction: column; gap: 0; }
.day-more-details { margin-top: 4px; }
.day-more-btn {
  font-size: .76rem; color: var(--accent); cursor: pointer;
  padding: 4px 0; list-style: none; user-select: none;
}
.day-more-btn::-webkit-details-marker { display: none; }
.day-more-btn::before { content: '▶ '; font-size: .7rem; }
details[open] .day-more-btn::before { content: '▼ '; }
.timeline-show-all-btn {
  display: block; width: 100%; margin-top: 12px;
  padding: 10px; border: 1.5px dashed var(--border);
  border-radius: 8px; background: none; color: var(--text-secondary);
  font-size: .82rem; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.timeline-show-all-btn:hover { border-color: var(--accent); color: var(--accent); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.metrics-grid .card { margin-bottom: 0; }

.story-item {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--surface2); position: relative;
}
.story-item:last-child { border-bottom: none; }
.story-item.latest .story-left { border-color: #f43f5e; }

.story-left {
  flex: 0 0 100px; text-align: right;
  padding-right: 16px; border-right: 1.5px solid #e5e7eb;
  padding-top: 2px;
}
.story-time { font-size: .73rem; color: var(--text-secondary); font-weight: 600; line-height: 1.4; }
.story-badges { display: flex; gap: 4px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.story-count { font-size: .68rem; background: var(--surface2); color: var(--text-secondary); border-radius: 4px; padding: 1px 6px; border: 1px solid var(--border); }
.story-latest { font-size: .68rem; color: #f43f5e; font-weight: 700; }

.story-right { flex: 1; min-width: 0; }
.story-empty { font-size: .8rem; color: #d1d5db; }
.summary-placeholder { font-size: .86rem; color: var(--text-muted); padding: 8px 0; }

.headline-item {
  padding: 6px 0; border-bottom: 1px solid var(--surface2);
  display: flex; gap: 8px; align-items: flex-start;
}
.headline-item:last-child { border-bottom: none; }
.headline-item a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: .86rem;
  line-height: 1.55;
  font-weight: 500;
}
.headline-item a:hover { color: var(--accent); }
.headline-source-badge {
  flex-shrink: 0;
  font-size: .64rem; font-weight: 700; color: var(--text-muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 6px;
  white-space: nowrap; display: flex; align-items: center; gap: 3px; margin-top: 2px;
}
.source-favicon { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }

/* AI要約 */
.summary-text { font-size: .88rem; line-height: 1.75; color: var(--text-secondary); padding: 4px 0; }

/* ===== DUAL CHART ROW ===== */
.charts-row {
  display: flex;
  flex-direction: row;
  gap: 14px;
  margin-top: 12px;
}
.chart-col { flex: 1; min-width: 0; }
.chart-col-title {
  font-size: .73rem; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 6px; text-align: center;
}
.chart-col canvas {
  display: block;
  width: 100% !important;
  height: 220px !important;
}
@media (max-width: 600px) {
  .charts-row { flex-direction: column; }
}

/* ═══════════════════════════════════
   COMPONENT: COMMENTS
   ═══════════════════════════════════ */
.comments-card { margin-top: 16px; }

.comment-form { margin-bottom: 24px; }
.comment-form-row { margin-bottom: 10px; }

.comment-nickname-input {
  width: 180px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .86rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--surface2);
}
.comment-nickname-input:focus {
  border-color: #a8a8a8;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.comment-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--surface2);
  line-height: 1.65;
}
.comment-textarea:focus {
  border-color: #a8a8a8;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.comment-char-count { text-align: right; font-size: .72rem; color: var(--text-muted); margin-top: 4px; }
.comment-char-warn .comment-char-count { color: #f59e0b; font-weight: 700; }

.comment-form-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.comment-error   { font-size: .8rem; color: #f43f5e; flex: 1; }
.comment-success { font-size: .8rem; color: #10b981; font-weight: 600; flex: 1; }

.comment-submit-btn {
  padding: 9px 22px;
  background: var(--text-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .86rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.comment-submit-btn:hover:not(:disabled) { opacity: .85; transform: translateY(-1px); }
.comment-submit-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.comments-list { display: flex; flex-direction: column; gap: 0; }
.comment-item { padding: 14px 0; border-bottom: 1px solid var(--surface2); }
.comment-item:last-child { border-bottom: none; }

.comment-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.comment-nick { font-size: .8rem; font-weight: 700; color: var(--text-primary); }
.comment-time { font-size: .7rem; color: var(--text-muted); }
.comment-delete-btn {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: .75rem; color: var(--text-muted); opacity: .5; padding: 2px 6px;
  border-radius: 4px; transition: opacity .15s, color .15s;
}
.comment-delete-btn:hover { opacity: 1; color: #e53935; }
.comment-body {
  font-size: .88rem; color: var(--text-secondary); line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.comments-empty, .comments-loading {
  text-align: center; padding: 32px 0;
  font-size: .86rem; color: var(--text-muted);
}
@media (max-width: 600px) {
  .comment-form-actions { flex-direction: column; align-items: stretch; }
  .comment-submit-btn  { width: 100%; }
  .comment-error, .comment-success { text-align: center; }
}

/* ═══════════════════════════════════
   COMPONENT: COMMENTS (X-style)
   ═══════════════════════════════════ */
/* コメント投稿エリア（X風） */
.cx-post-area {
  display: flex;
  gap: 12px;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.cx-post-avatar-col { flex-shrink: 0; }
.cx-post-right { flex: 1; min-width: 0; position: relative; }
.cx-post-handle {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

/* 投稿フォームのアバター（小）*/
.cx-post-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #e5e7eb;
}
.cx-post-avatar-init {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #334155;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* @メンションサジェスト */
.mention-suggest {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  min-width: 180px;
  max-width: 260px;
  overflow: hidden;
}
.mention-item {
  padding: 10px 14px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .1s;
}
.mention-item:hover { background: var(--surface2); }

/* コメント一覧（X風） */
.cx-comment {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.cx-comment:last-child { border-bottom: none; }
.cx-avatar-col { flex-shrink: 0; }

/* アバター画像 or 頭文字 */
.cx-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.cx-avatar-init {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #334155;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.cx-content { flex: 1; min-width: 0; }
.cx-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}
.cx-name {
  font-size: .86rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.cx-handle {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.cx-dot {
  font-size: .78rem;
  color: var(--text-muted);
}
.cx-time {
  font-size: .74rem;
  color: var(--text-muted);
}
.cx-delete-btn {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  font-size: .74rem; color: var(--text-muted);
  opacity: .5; padding: 2px 6px;
  border-radius: 4px; transition: opacity .15s, color .15s;
}
.cx-delete-btn:hover { opacity: 1; color: #e53935; }

.cx-body {
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 8px;
}
.cx-mention {
  color: #2563eb;
  font-weight: 600;
  cursor: default;
}

/* いいね・保存・返信ボタン行 */
.cx-actions {
  display: flex;
  gap: 18px;
  align-items: center;
}
.cx-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .78rem;
  color: var(--text-muted);
  padding: 3px 0;
  border-radius: 4px;
  transition: color .15s, transform .1s;
  font-family: inherit;
}
.cx-action-btn:hover { color: var(--text-primary); }
.cx-action-btn:active { transform: scale(.93); }

/* いいねボタン */
.cx-like-btn .cx-like-icon { font-size: .9rem; line-height: 1; }
.cx-like-btn.liked { color: #f43f5e; }
.cx-like-btn.liked .cx-like-icon { animation: cx-pop .2s ease; }
.cx-like-count { font-size: .78rem; font-weight: 600; }

/* 保存ボタン */
.cx-save-btn.saved { color: #2563eb; }

/* いいねアニメーション */
@keyframes cx-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* プロフィール設定モーダル（mypage） */
.profile-setup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.profile-setup-overlay.open { display: flex; }
.profile-setup-modal {
  background: var(--surface);
  border-radius: 18px;
  padding: 32px 28px 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
}
.profile-setup-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.profile-setup-desc {
  font-size: .84rem;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.6;
}
.profile-setup-field { margin-bottom: 16px; }
.profile-setup-label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.profile-setup-input,
.profile-setup-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .92rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface2);
  outline: none;
  transition: border-color .15s;
}
.profile-setup-input:focus,
.profile-setup-select:focus { border-color: #6366f1; }
.profile-setup-hint {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.profile-setup-error {
  font-size: .78rem;
  color: #f43f5e;
  margin-top: 4px;
  min-height: 18px;
}
.profile-setup-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.profile-setup-skip {
  flex: 1;
  padding: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.profile-setup-skip:hover { background: var(--border); }
.profile-setup-save {
  flex: 2;
  padding: 11px;
  background: #0f172a;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity .15s;
}
.profile-setup-save:hover { opacity: .88; }

/* モバイル最適化 */
@media (max-width: 600px) {
  .cx-avatar     { width: 34px; height: 34px; }
  .cx-avatar-init { width: 34px; height: 34px; font-size: .85rem; }
  .cx-post-avatar { width: 32px; height: 32px; }
  .cx-post-avatar-init { width: 32px; height: 32px; font-size: .8rem; }
  .cx-comment    { gap: 9px; }
  .cx-actions    { gap: 14px; }
}

/* ===== AUTH AREA ===== */
.auth-area { display: flex; align-items: center; gap: 10px; }

/* ===== TOPIC CARD WRAPPER ===== */
.topic-card-wrapper { position: relative; }

/* ===== FAV BUTTON ===== */
.fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background .15s, transform .15s;
  z-index: 1;
  line-height: 1;
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}
.fav-btn:hover { background: #fff; transform: scale(1.18); }
.fav-active { color: #f43f5e; }

/* ===== FAV TOGGLE (search row icon) ===== */
.fav-toggle-btn.icon-only {
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  color: #ccc;
  line-height: 1;
  transition: color .15s, background .15s;
  font-family: inherit;
}
.fav-toggle-btn.icon-only:hover { background: var(--surface2); }
.fav-toggle-btn.icon-only.active { color: #f5c518; }

/* ===== COMMENT LOGIN PROMPT ===== */
.comment-login-prompt {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: .88rem;
  margin-bottom: 24px;
  background: var(--surface2);
}
.comment-login-prompt a { color: var(--accent); font-weight: 600; text-decoration: none; }
.comment-login-prompt a:hover { text-decoration: underline; }

/* ===== TRENDING BANNER ===== */
.trending-banner {
  background: var(--ig-grad);
  color: white;
  padding: 10px 16px;
  text-align: center;
  font-size: .82rem;
  font-weight: 600;
}
.trending-banner a { color: white; text-decoration: underline; }

/* ===== GENRE BORDER COLORS ===== */
.topic-card.genre-politics::before      { background: #3b82f6; }
.topic-card.genre-economy::before       { background: #10b981; }
.topic-card.genre-tech::before          { background: #8b5cf6; }
.topic-card.genre-entertainment::before { background: var(--ig-grad); }
.topic-card.genre-world::before         { background: #f97316; }
.topic-card.genre-other::before         { background: #94a3b8; }

/* ===== ARTICLE COUNT / READING TIME BADGE ===== */
.topic-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== PULSE ANIMATION ===== */
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: .8; }
}

/* ===== STICKY SEARCH ===== */
.search-wrapper-sticky {
  position: sticky;
  top: 56px;
  z-index: 90;
  background: rgba(250,250,250,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 0 4px;
}

/* ===== LOAD MORE BUTTON ===== */
#load-more-container {
  text-align: center;
  margin-top: 28px;
  padding-bottom: 4px;
}
#load-more-container button {
  width: 100%;
  max-width: 480px;
  padding: 13px 24px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
#load-more-container button:hover {
  background: var(--text-primary);
  color: #fff;
  border-color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
#load-more-container button:active { transform: translateY(0); }

/* ===== SKELETON CARD ===== */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  overflow: hidden;
}
.skeleton-card .sk-thumb {
  flex: 0 0 88px;
  width: 88px; height: 88px;
  border-radius: 12px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e9eaec 50%, #f3f4f6 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skeleton-card .sk-body { flex: 1; min-width: 0; }
.skeleton-card .sk-line {
  height: 11px;
  border-radius: 6px;
  margin-bottom: 9px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e9eaec 50%, #f3f4f6 75%);
  background-size: 1200px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skeleton-card .sk-line.sk-title  { width: 88%; height: 13px; }
.skeleton-card .sk-line.sk-short  { width: 60%; }
.skeleton-card .sk-line.sk-tiny   { width: 38%; height: 9px; margin-bottom: 0; }

/* ===== 急上昇キーワードストリップ ===== */
.keyword-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 8px;
  overflow: hidden;
}
.keyword-strip-label { font-size: .95rem; flex-shrink: 0; }
.keyword-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}
.keyword-chips::-webkit-scrollbar { display: none; }
.keyword-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: .76rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.keyword-chip:hover { background: var(--surface2); border-color: #a8a8a8; color: var(--text-primary); }
.keyword-chip.active { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }

/* ===== 関連トピック ===== */
.related-topic-item {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  transition: background .15s, border-color .15s, transform .1s;
}
.related-topic-item:hover {
  background: var(--surface2);
  border-color: #a8a8a8;
  transform: translateX(3px);
}
.related-topic-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.related-topic-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.entity-tag {
  font-size: .68rem;
  color: var(--accent);
  background: rgba(64,93,230,0.08);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 500;
}

/* ===== ストーリーマップボタン ===== */
.storymap-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--text-primary);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  margin: 8px 0 4px;
  transition: opacity .2s, transform .15s;
}
.storymap-btn:hover { opacity: .85; transform: translateY(-1px); }

/* ===== Discovery (関連する話題) ===== */
#discovery-section { margin-bottom: 16px; }
.disc-card-wrapper h2 { margin-bottom: 4px; }
.disc-header-sub { font-size: .72rem; color: var(--text-muted); margin: 0 0 14px; }
.disc-col-body { display: flex; flex-direction: column; gap: 8px; }

.disc-card {
  display: block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-decoration: none;
  transition: all .15s;
}
.disc-card:hover {
  background: #fff;
  border-color: #a8a8a8;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.disc-card-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.disc-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.disc-card-meta { font-size: .68rem; color: var(--text-muted); }

.disc-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 8px;
  margin-bottom: 5px;
}
.disc-badge-parent { background: #fef3c7; color: #92400e; }
.disc-badge-child  { background: #dcfce7; color: #166534; }

.disc-see-all {
  display: block;
  margin-top: 10px;
  font-size: .73rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  text-align: right;
}
.disc-see-all:hover { text-decoration: underline; }

/* タイムライン日付カウント */
.day-article-count { color: var(--text-muted); font-weight: 400; }

/* ═══════════════════════════════════
   COMPONENT: HOT STRIP
   ═══════════════════════════════════ */
.hot-strip { margin-bottom: 14px; }
.hot-strip-header {
  font-size: .76rem;
  font-weight: 700;
  color: #ef4444;
  margin-bottom: 8px;
  letter-spacing: .03em;
}
.hot-strip-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}
.hot-strip-chips::-webkit-scrollbar { display: none; }
.hot-chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid #fecaca;
  background: #fff5f5;
  color: #dc2626;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
  transition: all 0.15s;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hot-chip:hover {
  background: #fee2e2;
  border-color: #ef4444;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(239,68,68,0.25);
}

/* COMPONENT: BADGES (continued) — カードNEWバッジ */
@keyframes new-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.card-new-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #f43f5e;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  z-index: 2;
  letter-spacing: .04em;
  text-transform: uppercase;
  box-shadow: 0 1px 6px rgba(244,63,94,0.35);
  pointer-events: none;
  animation: new-pulse 2s ease-in-out infinite;
}

/* ═══════════════════════════════════
   DARK MODE
   ═══════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #ff6b5b;
    --primary-light: rgba(231,76,60,0.12);
    --surface: #1c1c1e;
    --bg-card: #1c1c1e;
    --surface2: #0a0a0a;
    --bg-page: #0a0a0a;
    --border: rgba(255,255,255,0.1);
    --text-primary: #f5f5f5;
    --text-secondary: #a8a8a8;
    --text-muted: #666666;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
    --shadow: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.5);
    --shadow-hover: 0 6px 20px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
  }

  body { background: #0a0a0a; }

  header {
    background: rgba(0,0,0,0.88);
    border-bottom-color: rgba(255,255,255,0.08);
  }

  .search-bar input {
    background: #1c1c1e;
    color: #f5f5f5;
    border-color: rgba(255,255,255,0.12);
  }
  .search-bar input::placeholder { color: #666; }
  .search-bar input:focus {
    background: #2c2c2e;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255,107,91,0.15);
  }

  .site-footer {
    background: #1c1c1e;
    border-top-color: rgba(255,255,255,0.08);
  }

  .search-wrapper-sticky {
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .topic-card {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.08);
  }
  .topic-card:hover { box-shadow: 0 4px 24px rgba(0,0,0,0.6); }

  .card-thumb-placeholder.rising    { background: linear-gradient(135deg, #3a1010, #4a1515); }
  .card-thumb-placeholder.peak      { background: linear-gradient(135deg, #3a2a00, #4a3500); }
  .card-thumb-placeholder.declining { background: linear-gradient(135deg, #0a1a2e, #0f2040); }

  .filter-tabs { border-bottom-color: rgba(255,255,255,0.1); }
  .filter-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #666;
  }
  .filter-btn:hover { color: #f5f5f5; }
  .filter-btn.active { color: #f5f5f5; border-bottom-color: var(--primary); }

  .ad-card {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.08);
  }
  .ad-label { color: #555; }

  .fav-toggle-btn.icon-only { color: #888; }
  .fav-toggle-btn.icon-only.active { color: #f5c518; }

  .keyword-chip {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.1);
    color: #a8a8a8;
  }
  .keyword-chip:hover { background: #2c2c2e; border-color: rgba(255,255,255,0.2); color: #f5f5f5; }
  .keyword-chip.active { background: #f5f5f5; color: #000; border-color: #f5f5f5; }

  .card {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.08);
  }

  .skeleton-card {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.06);
  }
  .skeleton-card .sk-thumb,
  .skeleton-card .sk-line {
    background: linear-gradient(90deg, #2c2c2e 25%, #3a3a3c 50%, #2c2c2e 75%);
    background-size: 1200px 100%;
  }

  .topic-status.declining { color: #a8a8a8; background: #2c2c2e; }

  .genre-tag { background: #2c2c2e; border-color: rgba(255,255,255,0.08); }
  .topic-meta-badge { background: #2c2c2e; border-color: rgba(255,255,255,0.08); }

  .headline-source-badge {
    background: #2c2c2e;
    border-color: rgba(255,255,255,0.08);
    color: #a8a8a8;
  }

  .comment-nickname-input,
  .comment-textarea {
    background: #2c2c2e;
    border-color: rgba(255,255,255,0.1);
    color: #f5f5f5;
  }
  .comment-nickname-input:focus,
  .comment-textarea:focus {
    background: #3a3a3c;
    border-color: rgba(255,255,255,0.3);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.05);
  }

  .comment-submit-btn {
    background: #f5f5f5;
    color: #000;
  }
  .comment-submit-btn:hover:not(:disabled) { opacity: .85; }

  .comment-login-prompt {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.1);
  }

  .ad-slot {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.08);
  }

  .related-topic-item {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.08);
  }
  .related-topic-item:hover {
    background: #2c2c2e;
    border-color: rgba(255,255,255,0.2);
  }

  .disc-card {
    background: #2c2c2e;
    border-color: rgba(255,255,255,0.08);
  }
  .disc-card:hover {
    background: #3a3a3c;
    border-color: rgba(255,255,255,0.2);
  }

  .discovery-col {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.08);
  }

  .fav-btn {
    background: rgba(28,28,30,0.85);
  }
  .fav-btn:hover { background: #2c2c2e; }

  #load-more-container button {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.12);
    color: #a8a8a8;
  }
  #load-more-container button:hover {
    background: #f5f5f5;
    border-color: #f5f5f5;
    color: #000;
  }

  .tr-btn { background: #1c1c1e; border-color: rgba(255,255,255,0.12); color: #a8a8a8; }
  .tr-btn.active, .tr-btn:hover { background: #f5f5f5; border-color: #f5f5f5; color: #000; }

  .sort-btn { background: #1c1c1e; border-color: rgba(255,255,255,0.12); }
  .sort-btn.active, .sort-btn:hover { background: #f5f5f5; border-color: #f5f5f5; color: #000; }

  .story-left { border-right-color: rgba(255,255,255,0.1); }
  .story-count { background: #2c2c2e; border-color: rgba(255,255,255,0.08); }

  .storymap-btn { background: #f5f5f5; color: #000; }
  .storymap-btn:hover { opacity: .85; }

  .disc-badge-parent { background: #3a2a00; color: #fde68a; }
  .disc-badge-child  { background: #0a2e18; color: #86efac; }
  .disc-card { background: #2a2a2e; border-color: rgba(255,255,255,.09); }
  .disc-card:hover { background: #3a3a3e; border-color: rgba(255,255,255,.2); }

  .entity-tag { background: rgba(64,93,230,0.15); }

  .hot-chip {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
    color: #fca5a5;
  }
  .hot-chip:hover {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.5);
  }
}

/* ═══════════════════════════════════
   [data-theme="dark"] — 明示的ダークモード
   (システム設定と独立してトグルできる)
   ═══════════════════════════════════ */
[data-theme="dark"] {
  --primary: #ff6b5b;
  --primary-light: rgba(231,76,60,0.12);
  --surface: #1c1c1e; --bg-card: #1c1c1e;
  --surface2: #0a0a0a; --bg-page: #0a0a0a;
  --border: rgba(255,255,255,0.1);
  --text-primary: #f5f5f5; --text-secondary: #a8a8a8; --text-muted: #666666;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.5);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}
[data-theme="dark"] body { background: #0a0a0a; }
[data-theme="dark"] header { background: rgba(0,0,0,0.88); border-bottom-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .search-bar input { background: #1c1c1e; color: #f5f5f5; border-color: rgba(255,255,255,0.12); }
[data-theme="dark"] .search-bar input::placeholder { color: #666; }
[data-theme="dark"] .topic-card { background: #1c1c1e; border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .card { background: #1c1c1e; border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .filter-tabs { border-bottom-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .filter-btn { color: #666; border-bottom-color: transparent; }
[data-theme="dark"] .filter-btn.active { color: #f5f5f5; border-bottom-color: var(--primary); }
[data-theme="dark"] .site-footer { background: #1c1c1e; border-top-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .ad-card { background: #1c1c1e; border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .genre-tag { background: #2c2c2e; }
[data-theme="dark"] .cx-comment { background: #1c1c1e; border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .cx-comment-textarea { background: #2c2c2e; color: #f5f5f5; border-color: rgba(255,255,255,0.1); }
[data-theme="dark"] .hist-card { background: #1c1c1e; border-color: rgba(255,255,255,0.08); }
[data-theme="dark"] .hist-quoted { background: #2c2c2e; border-left-color: rgba(255,255,255,0.15); }

/* [data-theme="light"] — システムがダークでも強制ライト */
[data-theme="light"] {
  --primary: #e74c3c; --primary-light: #fdf2f2;
  --surface: #ffffff; --bg-card: #ffffff;
  --surface2: #f5f6f8; --bg-page: #f5f6f8;
  --border: #e8eaed;
  --text-primary: #1a1a2e; --text-secondary: #555555; --text-muted: #888888;
}
[data-theme="light"] body { background: #f5f6f8; }
[data-theme="light"] header { background: rgba(255,255,255,0.96); }

/* ═══════════════════════════════════
   キーワードストリップ
   ═══════════════════════════════════ */
.keyword-strip {
  display: flex; align-items: center; gap: 8px;
  overflow-x: auto; padding: 6px 0 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.keyword-strip::-webkit-scrollbar { display: none; }
.keyword-strip-label {
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
}
.kw-chip {
  flex-shrink: 0; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); font-size: .78rem; cursor: pointer;
  white-space: nowrap; transition: background .15s, color .15s;
}
.kw-chip:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ═══════════════════════════════════
   コメント: 引用 / バッド
   ═══════════════════════════════════ */
.cx-quoted-block {
  background: var(--surface2); border-left: 3px solid var(--border);
  border-radius: 4px; padding: 8px 10px; margin: 4px 0 8px;
  font-size: .82rem; color: var(--text-muted);
}
.cx-quoted-handle { font-weight: 700; color: var(--primary); }
.cx-action-dislike { color: #64748b; }
.cx-action-dislike.cx-bad-active { color: #6366f1; }
.cx-quote-preview-block { display: flex; align-items: flex-start; gap: 8px; }
.cx-quote-cancel-btn {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: #94a3b8; font-size: 1rem; line-height: 1; padding: 0 2px;
  flex-shrink: 0;
}
.cx-quote-cancel-btn:hover { color: #ef4444; }

/* ═══════════════════════════════════
   認証モーダル（Google / Apple 将来対応）
   ═══════════════════════════════════ */
.auth-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.auth-modal-inner {
  background: var(--surface, #fff); border-radius: 20px;
  padding: 32px 28px; width: 100%; max-width: 360px;
  position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.auth-modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 1.3rem; cursor: pointer;
  color: var(--text-muted, #888); line-height: 1;
}
.auth-modal-close:hover { color: var(--text-primary, #111); }
.auth-modal-logo { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.auth-modal-title { font-size: 1.15rem; font-weight: 700; margin: 0 0 8px; color: var(--text-primary, #1a1a1a); }
.auth-modal-desc { font-size: .82rem; color: var(--text-muted, #64748b); margin: 0 0 24px; line-height: 1.6; }
.auth-modal-provider-wrap { display: flex; justify-content: center; margin-bottom: 16px; min-height: 44px; }

/* ── divider ── */
.auth-modal-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 14px; color: var(--text-muted, #94a3b8); font-size: .78rem;
}
.auth-modal-divider::before, .auth-modal-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border, #e2e8f0);
}

/* ── Apple ラッパー（ボタン + 近日公開バッジ） ── */
.auth-modal-apple-wrap {
  position: relative; margin-bottom: 20px;
}
.auth-modal-apple-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 16px; border-radius: 8px;
  border: 1.5px solid #1d1d1f;
  background: #1d1d1f; color: #fff;
  font-size: .9rem; font-weight: 600; font-family: inherit;
  cursor: not-allowed; opacity: .45;
  transition: opacity .15s;
}
.auth-modal-apple-btn .apple-icon { width: 17px; height: 17px; flex-shrink: 0; }

/* ダークモードではAppleボタンを白背景に反転 */
@media (prefers-color-scheme: dark) {
  .auth-modal-apple-btn { background: #fff; color: #1d1d1f; border-color: #fff; }
}
[data-theme="dark"] .auth-modal-apple-btn { background: #fff; color: #1d1d1f; border-color: #fff; }
[data-theme="light"] .auth-modal-apple-btn { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }

.auth-coming-soon {
  position: absolute; top: -9px; right: 14px;
  background: #3b82f6; color: #fff;
  font-size: .65rem; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px;
  pointer-events: none;
}

/* ── 利用規約リンク ── */
.auth-modal-terms {
  font-size: .72rem; color: var(--text-muted, #94a3b8);
  margin: 0; line-height: 1.6;
}
.auth-modal-terms a { color: var(--text-muted, #94a3b8); text-decoration: underline; }

/* ═══════════════════════════════════
   [data-theme="light"] — 明示的ライトモード（システムダーク時に強制上書き）
   ═══════════════════════════════════ */
[data-theme="light"] {
  --primary: #e74c3c; --primary-light: #fdf2f2;
  --surface: #ffffff; --bg-card: #ffffff;
  --surface2: #f5f6f8; --bg-page: #f5f6f8;
  --border: #e8eaed;
  --text-primary: #1a1a2e; --text-secondary: #555555; --text-muted: #888888;
  --shadow-sm: 0 2px 6px rgba(0,0,0,.08);
  --shadow: 0 2px 8px rgba(0,0,0,.1);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}
[data-theme="light"] body         { background: #f5f6f8; color: #1a1a2e; }
[data-theme="light"] header       { background: rgba(255,255,255,.96); border-bottom: 1px solid #e8eaed; }
[data-theme="light"] .topic-card  { background: #fff; border-color: #e8eaed; color: #1a1a2e; }
[data-theme="light"] .card        { background: #fff; border-color: #e8eaed; }
[data-theme="light"] .search-bar input { background: #fff; color: #1a1a2e; border-color: #e2e8f0; }
[data-theme="light"] .filter-tabs { border-bottom-color: #e2e8f0; }
[data-theme="light"] .filter-btn  { color: #64748b; }
[data-theme="light"] .filter-btn.active { color: #1a1a2e; border-bottom-color: var(--primary); }
[data-theme="light"] .site-footer { background: #fff; border-top-color: #e2e8f0; }
[data-theme="light"] .kw-chip     { background: rgba(231,76,60,.08); color: #e74c3c; }
[data-theme="light"] .cx-comment  { background: #fff; border-color: #e8eaed; }
[data-theme="light"] .genre-tag   { background: #f1f5f9; }
[data-theme="light"] .ad-card     { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="light"] .load-more-btn { background: #fff; color: #475569; border-color: #cbd5e1; }
[data-theme="light"] .keyword-strip { background: transparent; }

/* ダークモード補足（data-theme="dark"でも不足している要素） */
[data-theme="dark"] .kw-chip     { background: rgba(255,107,91,.15); color: #ff9a90; border-color: rgba(255,107,91,.3); }
[data-theme="dark"] .hot-chip    { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.3); }
[data-theme="dark"] .load-more-btn { background: #1c1c1e; color: #a8a8a8; border-color: rgba(255,255,255,.12); }
[data-theme="dark"] .auth-modal-inner { background: #1c1c1e; }
[data-theme="dark"] .fav-btn     { background: rgba(0,0,0,.5); }
[data-theme="dark"] .search-bar input:focus { background: #2c2c2e; }
[data-theme="dark"] .cx-quoted-block { background: #2c2c2e; }
[data-theme="dark"] .comment-textarea { background: #2c2c2e; color: #f5f5f5; }
