/* ========================================================
   InfoPulse — スタイルシート
   ダーク/ライト両対応、CSS変数ベース
   ======================================================== */

/* ── CSS変数（ダークモード デフォルト） ── */
:root {
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface2:   #21262d;
  --border:     #30363d;
  --accent:     #58a6ff;
  --accent-dim: #1f3a6e;
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --text-dim:   #484f58;
  --success:    #3fb950;
  --warning:    #d29922;
  --danger:     #f85149;
  --hn-color:   #ff6600;
  --reddit-color: #ff4500;
  --arxiv-color:  #b31b1b;
  --rss-color:    #ffa500;
  --radius:     8px;
  --radius-lg:  12px;
  --sidebar-w:  260px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg:         #f6f8fa;
  --surface:    #ffffff;
  --surface2:   #f0f2f5;
  --border:     #d0d7de;
  --accent:     #0969da;
  --accent-dim: #dbeafe;
  --text:       #1f2328;
  --text-muted: #656d76;
  --text-dim:   #9aa0a8;
  --shadow:     0 4px 16px rgba(0,0,0,0.1);
}

/* ── z-index 管理レイヤー (定義 + リテラル値を併用) ── */
:root {
  --z-base:       1;
  --z-sidebar:    10;
  --z-header:     20;
  --z-dropdown:   50;
  --z-shortcut:   100;
  --z-overlay:    200;
  --z-modal:      500;
  --z-toast:      900;
}

/* ── Tailwindライク ユーティリティクラス ── */
.z-1   { z-index: 1; }
.z-10  { z-index: 10; }
.z-20  { z-index: 20; }
.z-50  { z-index: 50; }
.z-100 { z-index: 100; }
.z-200 { z-index: 200; }
.z-500 { z-index: 500; }
.z-900 { z-index: 900; }

.flex-col     { display: flex; flex-direction: column; }
.flex-row     { display: flex; flex-direction: row; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.min-h-0 { min-height: 0; }
.overflow-hidden  { overflow: hidden; }
.overflow-auto    { overflow: auto; }
.overflow-y-auto  { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }

.text-xs   { font-size: 0.75rem;  line-height: 1.4; }
.text-sm   { font-size: 0.875rem; line-height: 1.5; }
.text-base { font-size: 1rem;     line-height: 1.6; }
.text-lg   { font-size: 1.125rem; line-height: 1.5; }
.text-xl   { font-size: 1.25rem;  line-height: 1.4; }
.text-2xl  { font-size: 1.5rem;   line-height: 1.3; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.tracking-tight  { letter-spacing: -0.025em; }
.tracking-normal { letter-spacing: 0; }
.tracking-wide   { letter-spacing: 0.025em; }
.leading-tight   { line-height: 1.25; }
.leading-relaxed { line-height: 1.625; }

.rounded    { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.shadow     { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08); }
.shadow-lg  { box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.divide-y > * + * { border-top: 1px solid var(--border); }
.divide-x > * + * { border-left: 1px solid var(--border); }

/* ── backdrop-blur ユーティリティ ── */
.backdrop-blur    { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.backdrop-blur-sm { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.backdrop-blur-lg { backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* ── prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── リセット / ベース ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

/* ── レイアウト ── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ── スキップリンク ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius) 0;
  text-decoration: none;
  font-weight: 600;
  z-index: var(--z-toast);
  transition: top var(--transition);
}
.skip-link:focus { top: 0; }

/* ── サイドバー ── */
#sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
  border-right: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  z-index: 10;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { font-size: 20px; }
.logo-text  {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--accent), #a5d6ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#category-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--radius);
  margin: 1px 6px;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.category-item:hover  { background: var(--surface2); }
.category-item.active { background: var(--accent-dim); color: var(--accent); }

.cat-emoji { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.cat-name  { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}
.cat-count {
  font-size: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.cat-actions {
  display: none;
  gap: 2px;
}
.category-item:hover .cat-actions { display: flex; }
.cat-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background var(--transition);
}
.cat-actions button:hover { background: var(--surface2); color: var(--text); }

.sidebar-bottom {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.last-refresh {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent), #79c0ff);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(88,166,255,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn-action:hover  { opacity: 0.9; box-shadow: 0 4px 16px rgba(88,166,255,0.4), inset 0 1px 0 rgba(255,255,255,0.2); }
.btn-action:active { transform: scale(0.97); }
.btn-action.loading .icon { display: inline-block; animation: spin 1s linear infinite; }

/* ── ボタン共通 ── */
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}
.btn-primary:hover { opacity: 0.85; }

/* ── メインエリア ── */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

#feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  box-shadow: 0 1px 0 var(--border), 0 4px 16px rgba(0,0,0,0.08);
  z-index: 20;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
#feed-title { font-size: 18px; font-weight: 700; white-space: nowrap; }

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  transition: border-color var(--transition);
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { font-size: 13px; }
#search-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  width: 200px;
}
#search-input::placeholder { color: var(--text-muted); }

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.filter-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.filter-label input { accent-color: var(--accent); }
.filter-label:hover { color: var(--text); }

.sort-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
  outline: none;
}

/* ── フィードボディ ── */
#feed-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* スクロールバー */
#feed-body::-webkit-scrollbar { width: 6px; }
#feed-body::-webkit-scrollbar-track { background: transparent; }
#feed-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#category-list::-webkit-scrollbar { width: 4px; }
#category-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── 状態ビュー（ローディング/空/エラー） ── */
.state-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 300px;
  color: var(--text-muted);
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(88,166,255,0.04) 0%, transparent 70%);
}
.empty-icon { font-size: 48px; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--text); }
.empty-sub   { font-size: 13px; max-width: 320px; }

/* コニックグラデーション スピナー */
.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0%, transparent 60%, transparent 100%);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation: spin 0.8s linear infinite;
}

/* ── 記事カード ── */
#article-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* article-card は下部の強化版を参照 */

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  text-decoration: none;
  flex: 1;
  transition: color var(--transition);
}
.card-title:hover { color: var(--accent); }

.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.article-card:hover .card-actions { opacity: 1; }
.card-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.card-btn:hover   { background: var(--surface2); color: var(--text); }
.card-btn.active  { color: #fbbf24; }

.card-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-snippet mark {
  background: rgba(88,166,255,0.25);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.source-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.source-badge.hackernews { background: rgba(255,102,0,0.15);  color: var(--hn-color); }
.source-badge.reddit     { background: rgba(255,69,0,0.15);   color: var(--reddit-color); }
.source-badge.arxiv      { background: rgba(179,27,27,0.15);  color: #f87171; }
.source-badge.rss        { background: rgba(255,165,0,0.15);  color: var(--rss-color); }
.source-badge.websearch  { background: rgba(139,92,246,0.15); color: #a78bfa; }
.source-badge.crawl      { background: rgba(6,182,212,0.15);  color: #22d3ee; }
.source-badge.github     { background: rgba(35,134,54,0.15);  color: #4ade80; }

.card-time     { font-size: 11px; color: var(--text-dim); }
.card-author   { font-size: 11px; color: var(--text-dim); }
.card-reading  { font-size: 11px; color: var(--text-dim); }
.card-score    { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.card-tag {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

/* ── モーダル ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  /* CSS transition のみ使用（WAAPI・CSS animation は廃止） */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px var(--border), inset 0 1px 0 rgba(255,255,255,0.06);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.18s ease, opacity 0.18s ease;
  opacity: 0;
}
.modal-overlay.is-open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
#modal-body { padding: 20px; overflow-y: auto; flex: 1; min-height: 200px; }

/* カテゴリフォーム */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), inset 0 0 0 1px transparent;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 0 3px rgba(88,166,255,0.2);
}
.form-input.error {
  border-color: var(--danger);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 0 3px rgba(248,81,73,0.2);
}
.form-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
}

/* ソース管理 */
.source-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.source-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.source-item-label { flex: 1; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background var(--transition);
  flex-shrink: 0;
}
.source-del-btn:hover { background: rgba(248,81,73,0.15); }

.add-source-form {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 4px;
}
.source-type-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.source-type-tab {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.source-type-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
  background: rgba(248,81,73,0.15);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-danger:hover { background: rgba(248,81,73,0.25); }

/* ── トースト ── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 900;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideInRight 0.2s ease;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ── ショートカットパネル ── */
.shortcut-panel {
  position: fixed;
  bottom: 20px;
  left: calc(var(--sidebar-w) + 20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.shortcut-panel h4 { font-size: 13px; margin-bottom: 10px; }
.shortcut-panel table { border-collapse: collapse; }
.shortcut-panel td { padding: 3px 10px 3px 0; font-size: 12px; }
kbd {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 11px;
}

/* ── 記事カード 強化 ── */
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.article-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, rgba(88,166,255,0.04), transparent 60%);
  opacity: 0;
  transition: opacity var(--transition);
}
.article-card:hover::before { opacity: 1; }
.article-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(88,166,255,0.15), inset 0 1px 0 rgba(255,255,255,0.06);
  transform: translateY(-1px);
}
.article-card.is-read { opacity: 0.55; }
.article-card.is-read:hover { opacity: 1; }

/* 未読インジケーター */
.article-card:not(.is-read)::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(180deg, var(--accent), rgba(88,166,255,0.3));
  border-radius: 0 2px 2px 0;
}
.article-card.is-read::after { display: none; }

/* ── ローディングシマー ── */
.shimmer {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ── アニメーション ── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideUp  { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse    { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes shimmer  { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes slideDown { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── 自動更新トグルボタン ── */
.btn-auto-refresh-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  box-shadow: none;
  font-weight: 500;
}
.btn-auto-refresh-toggle:hover {
  background: var(--border);
  color: var(--text);
  box-shadow: none;
  opacity: 1;
}
.btn-auto-refresh-toggle.active {
  background: linear-gradient(135deg, #1a7f3c, #3fb950);
  color: #fff;
  border-color: #3fb950;
  box-shadow: 0 2px 8px rgba(63,185,80,0.3);
}

/* ── 自動更新カウントダウン ── */
.auto-refresh-countdown {
  font-size: 11px;
  color: var(--success);
  margin-top: 5px;
  text-align: center;
}

/* ── 全て既読ボタン ── */
.btn-mark-all-read {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1.6;
}
.btn-mark-all-read:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--accent);
}

/* ── フェッチ進捗バー ── */
#fetch-progress-wrap {
  height: 3px;
  width: 100%;
  background: var(--surface2);
  overflow: hidden;
  flex-shrink: 0;
}
#fetch-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #79c0ff);
  transition: width 0.35s ease;
  border-radius: 0 2px 2px 0;
}

/* ── コンパクトモード ── */
.compact-mode .article-card {
  padding: 8px 12px;
}
.compact-mode .card-snippet { display: none; }
.compact-mode .card-tags    { display: none; }
.compact-mode #article-list { gap: 4px; }
.compact-mode .card-reading { display: none; }

/* コンパクトモードトグルボタン */
#btn-compact {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 5px 8px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1;
  white-space: nowrap;
}
#btn-compact:hover { background: var(--surface2); color: var(--text); }
#btn-compact.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── フォーカスナビゲーション ── */
.article-card.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88,166,255,0.3), 0 4px 20px rgba(88,166,255,0.15);
}

/* ── モバイルサイドバーオーバーレイ ── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9;
  animation: fadeIn 0.15s ease;
}
#sidebar-backdrop.visible { display: block; }

/* モバイルハンバーガーボタン */
#btn-sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 5px 8px;
  line-height: 1;
  transition: background var(--transition);
}
#btn-sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

/* ── レスポンシブ ── */
@media (max-width: 1200px) {
  :root { --sidebar-w: 240px; }
  #search-input { width: 160px; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 220px; }
  #search-input { width: 120px; }
  .header-right { flex-wrap: wrap; }
  .filter-group { display: none; }
  #btn-compact { display: none; }
}
@media (max-width: 600px) {
  #app { grid-template-columns: 1fr; }
  #sidebar {
    display: flex;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  #feed-header { flex-wrap: wrap; gap: 8px; }
  #btn-sidebar-toggle { display: inline-flex; align-items: center; }
}
@media (min-width: 1400px) {
  :root { --sidebar-w: 280px; }
  #article-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
}
@media (prefers-color-scheme: dark) {
  /* ダークモードシステム設定のサポート */
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #161b22;
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  #feed-header { padding: 6px 16px; }
  #feed-body   { padding: 8px 16px; }
}
