* { box-sizing: border-box; }
body {
  font-family: "Meiryo", "メイリオ", "Segoe UI", system-ui, sans-serif;
  margin: 0; background: #f6f7f9; color: #1a1d22;
  font-size: 15px;
}
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px; background: #0d1117; color: #fff;
  border-bottom: 3px solid #c00;
}
header h1 { margin: 0; font-size: 22px; letter-spacing: .05em; }
header .meta { display: flex; gap: 14px; align-items: center; font-size: 14px; }
header button { background: #30363d; color: #fff; border: 0; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; }
header button:hover { background: #484f58; }
.timer {
  background: #1f6feb; color: #fff; padding: 4px 12px; border-radius: 12px;
  font-size: 13px; font-weight: bold; letter-spacing: .03em;
}

nav.filters {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  padding: 12px 28px; background: #fff; border-bottom: 1px solid #e1e4e8;
  font-size: 15px;
}
nav.filters select {
  padding: 6px 10px; border: 1px solid #d0d7de; border-radius: 4px;
  font-family: inherit; font-size: 14px;
}
nav.filters input[type=search] {
  margin-left: auto; padding: 7px 12px; border: 1px solid #d0d7de; border-radius: 4px;
  min-width: 240px; font-family: inherit; font-size: 14px;
}

.sort-info {
  padding: 10px 28px; background: #fff3cd; border-bottom: 1px solid #ffe69c;
  font-size: 13px; color: #664d03;
}
.sort-info strong { color: #1a1d22; }

/* 反映バー */
.apply-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 28px; background: #eaeef2; border-bottom: 1px solid #d0d7de;
  font-size: 14px; transition: background .2s;
}
.apply-bar.active { background: #fff8dc; border-bottom-color: #e8c765; }
.apply-info { color: #1a1d22; font-weight: 500; }
.apply-info .badge-add, .apply-info .badge-rm {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 13px; font-weight: 700; margin-right: 8px;
}
.apply-info .badge-add { background: #1a7f37; color: #fff; }
.apply-info .badge-rm  { background: #cf222e; color: #fff; }
.apply-buttons { display: flex; gap: 10px; }
.apply-buttons button {
  padding: 8px 20px; border-radius: 6px; border: 1px solid #d0d7de;
  background: #fff; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600;
  color: #1a1d22;
}
.apply-buttons button:hover:not(:disabled) { background: #f6f7f9; border-color: #8b949e; }
.apply-buttons button:disabled { opacity: 0.4; cursor: not-allowed; }
.apply-buttons .apply-primary {
  background: #1a7f37; color: #fff; border-color: #156a2d;
}
.apply-buttons .apply-primary:hover:not(:disabled) { background: #156a2d; }
.apply-buttons .apply-primary:disabled { background: #8b949e; border-color: #8b949e; color: #fff; }

/* 進捗バー（watcherの導入状況） */
.progress-bar {
  padding: 0; background: #fff; border-bottom: 1px solid #e1e4e8;
  font-size: 14px; display: none;
}
.progress-bar.active { display: block; padding: 14px 28px; background: #e7f5ff; border-bottom: 2px solid #1971c2; }
.progress-bar .progress-head { display: flex; align-items: center; gap: 10px; color: #0b4da2; margin-bottom: 6px; }
.progress-bar .progress-kind { font-size: 12px; background: #0b4da2; color: #fff; padding: 2px 8px; border-radius: 10px; font-weight: 700; letter-spacing: .03em; }
.progress-bar .progress-foot { font-size: 12px; color: #57606a; margin-top: 4px; }
.progress-bar .progress-bar-outer {
  height: 8px; background: #c5dbef; border-radius: 4px; overflow: hidden;
}
.progress-bar .progress-bar-inner {
  height: 100%; background: linear-gradient(90deg, #1971c2 0%, #4dabf7 100%);
  transition: width 0.4s ease; animation: progress-pulse 1.5s ease-in-out infinite;
}
.progress-bar .progress-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid #c5dbef; border-top-color: #1971c2;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.progress-bar:not(.active) .progress-foot { padding: 8px 28px; color: #57606a; font-size: 12px; text-align: right; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progress-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

main {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 18px; padding: 22px 28px;
}
.card {
  background: #fff; border: 1px solid #d0d7de; border-radius: 8px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: border-color .2s, box-shadow .2s, opacity .2s, filter .2s, background .2s;
}
.card:hover { border-color: #8b949e; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.card .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card h3 { margin: 0; font-size: 17px; line-height: 1.4; font-weight: 700; }
.card .type {
  font-size: 11px; padding: 3px 8px; border-radius: 3px; text-transform: uppercase;
  letter-spacing: .08em; background: #eaeef2; color: #57606a; flex-shrink: 0;
  font-weight: 700;
}
.card.mcp .type { background: #ddf4ff; color: #0969da; }
.card.skill .type { background: #fff8c5; color: #9a6700; }
.card.command .type { background: #dafbe1; color: #1a7f37; }
.card.tip .type { background: #ffebe9; color: #cf222e; }

.card .summary-ja { font-size: 15px; color: #1a1d22; line-height: 1.65; }
.card .benefit {
  font-size: 14px; color: #1a7f37; line-height: 1.55;
  background: #dafbe1; border-radius: 6px; padding: 10px 12px;
  border-left: 4px solid #1a7f37;
}
.card .benefit-label {
  display: inline-block; font-weight: bold; font-size: 11px;
  background: #1a7f37; color: #fff; padding: 2px 8px; border-radius: 3px;
  margin-right: 8px; vertical-align: middle; letter-spacing: .05em;
}
.card .en-detail { font-size: 12px; color: #57606a; }
.card .en-detail summary { cursor: pointer; user-select: none; font-size: 13px; }
.card .summary-en { margin-top: 6px; line-height: 1.5; font-size: 13px; }

.card .tags { display: flex; flex-wrap: wrap; gap: 5px; }
.card .tags span { font-size: 12px; background: #f0f3f6; padding: 3px 8px; border-radius: 10px; color: #57606a; }
.card .foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: #57606a; margin-top: auto;
}
.card .foot a { color: #0969da; text-decoration: none; }
.card .foot a:hover { text-decoration: underline; }
.card .hot { color: #cf222e; font-weight: bold; }

.card label.select {
  display: flex; align-items: center; gap: 8px; font-size: 14px;
  cursor: pointer; user-select: none; font-weight: 600;
}
.card label.select input[type=checkbox] {
  width: 18px; height: 18px; accent-color: #1a7f37;
}

/* 状態バッジ（カード上部に配置） */
.state-badge {
  display: inline-block; align-self: flex-start;
  padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 700;
  letter-spacing: .03em;
}
.b-installed   { background: #1a7f37; color: #fff; }
.b-queued      { background: #e8c765; color: #3b2c00; }
.b-installing  { background: #1971c2; color: #fff; animation: badge-pulse 1.2s ease-in-out infinite; }
.b-pending-add { background: #ff8c00; color: #fff; }
.b-pending-rm  { background: #cf222e; color: #fff; }

@keyframes badge-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* 導入済み（既にGitHubに保存済み） */
.card.state-installed {
  opacity: 0.55; filter: grayscale(0.5);
  background: #f0f3f6; border-color: #b8c0c9;
}
.card.state-installed:hover { opacity: 0.85; filter: grayscale(0.2); }
.card.state-installed h3 { color: #57606a; text-decoration: line-through; text-decoration-color: #8b949e; text-decoration-thickness: 1px; }
.card.state-installed .benefit { background: #eaeef2; color: #57606a; border-left-color: #8b949e; }
.card.state-installed .benefit-label { background: #8b949e; }

/* 導入予約（未反映） */
.card.state-pending_add {
  background: #fff8dc; border-color: #ff8c00; border-width: 2px;
  box-shadow: 0 0 0 3px rgba(255,140,0,0.15);
}
.card.state-pending_add h3 { color: #b35c00; }

/* 処理待ち（GitHub保存済、watcher未処理） */
.card.state-queued {
  background: #fffbe6; border-color: #e8c765; border-width: 2px;
}
.card.state-queued h3 { color: #664d03; }

/* 処理中（watcherが今作業中） */
.card.state-installing {
  background: #e7f5ff; border-color: #1971c2; border-width: 2px;
  box-shadow: 0 0 0 3px rgba(25,113,194,0.25);
  animation: card-processing 1.5s ease-in-out infinite;
}
@keyframes card-processing {
  0%, 100% { box-shadow: 0 0 0 3px rgba(25,113,194,0.25); }
  50% { box-shadow: 0 0 0 5px rgba(25,113,194,0.45); }
}
.card.state-installing h3 { color: #0b4da2; }

/* 解除予約（未反映） */
.card.state-pending_rm {
  background: #ffebe9; border-color: #cf222e; border-width: 2px;
  box-shadow: 0 0 0 3px rgba(207,34,46,0.15);
}
.card.state-pending_rm h3 { color: #9f1824; text-decoration: line-through; }

.card.applying { opacity: .4; pointer-events: none; }

footer {
  padding: 20px 28px; font-size: 13px; color: #57606a; text-align: center;
  border-top: 1px solid #e1e4e8; line-height: 1.8; background: #fff;
}
footer b { color: #1a7f37; }

#toast {
  position: fixed; bottom: 24px; right: 24px; background: #0d1117; color: #fff;
  padding: 12px 20px; border-radius: 6px; font-size: 14px;
  opacity: 0; transform: translateY(10px); transition: all .2s;
  pointer-events: none; max-width: 400px;
}
#toast.show { opacity: 1; transform: translateY(0); }
