/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: #fff7ed;
  color: #1c1917;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────────────── */
header {
  background: #ea580c;
  color: #fff;
  padding: 0 1rem;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(234,88,12,.35);
}
.header-inner { max-width: 960px; width: 100%; margin: 0 auto; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }

/* ─── Main ───────────────────────────────────────── */
main { max-width: 960px; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }

/* ─── Hero ───────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 1.5rem; }
.hero-icon { font-size: 3rem; margin-bottom: .5rem; }
.hero h1 { font-size: 1.75rem; font-weight: 800; color: #ea580c; margin-bottom: .5rem; }
.description { color: #57534e; font-size: .95rem; line-height: 1.7; }

/* ━━━ ヒーローバッジ ━━━ */
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.badge {
  display: inline-block;
  padding: 5px 13px;
  background: #ffedd5;
  color: #9a3412;
  border: 1.5px solid #fdba74;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ─── Card ───────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 14px;
  border: 1.5px solid #fed7aa;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(234,88,12,.07);
  margin-bottom: 1rem;
}
.card h2 { font-size: 1.05rem; font-weight: 700; color: #ea580c; margin-bottom: .85rem; }

/* ─── Setup grid (2 cols) ────────────────────────── */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* ─── Field ──────────────────────────────────────── */
.field { margin-bottom: .75rem; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block; font-size: .82rem; font-weight: 700;
  color: #44403c; margin-bottom: .3rem;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field select {
  width: 100%;
  border: 1.5px solid #e7e5e4;
  border-radius: 9px;
  padding: .55rem .8rem;
  font-size: .9rem;
  font-family: inherit;
  color: #1c1917;
  background: #fafaf9;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: #ea580c; background: #fff; }

/* ─── Buttons ────────────────────────────────────── */
.btn-primary {
  padding: .58rem 1.2rem;
  background: #ea580c; color: #fff;
  border: none; border-radius: 9px;
  font-size: .88rem; font-weight: 700;
  cursor: pointer; transition: background .15s;
  font-family: inherit; white-space: nowrap;
}
.btn-primary:hover { background: #c2410c; }

.btn-secondary {
  padding: .55rem 1rem;
  background: #fff; color: #57534e;
  border: 1.5px solid #e7e5e4; border-radius: 9px;
  font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s;
  font-family: inherit; white-space: nowrap;
}
.btn-secondary:hover { background: #f5f5f4; border-color: #d6d3d1; }

.btn-danger {
  padding: .28rem .55rem;
  background: none; color: #a8a29e;
  border: 1.5px solid #e7e5e4; border-radius: 6px;
  font-size: .75rem; font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
  font-family: inherit;
}
.btn-danger:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

.btn-icon {
  padding: .28rem .55rem;
  background: none; color: #a8a29e;
  border: 1.5px solid #e7e5e4; border-radius: 6px;
  font-size: .75rem; font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
  font-family: inherit; text-decoration: none; display: inline-flex;
  align-items: center;
}
.btn-icon:hover { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }

.btn-sm {
  padding: .3rem .7rem;
  border: 1.5px solid #e7e5e4; border-radius: 7px;
  background: #fff; font-size: .78rem; font-weight: 600;
  color: #57534e; cursor: pointer;
  transition: background .12s, border-color .12s;
  font-family: inherit; white-space: nowrap;
}
.btn-sm:hover { background: #f5f5f4; border-color: #d6d3d1; }

/* ─── Add keyword form ───────────────────────────── */
.add-form {
  display: grid;
  grid-template-columns: 1fr 100px 140px auto;
  gap: .5rem;
  align-items: end;
}

/* ─── GSC import area ────────────────────────────── */
.gsc-area {
  border: 2px dashed #fed7aa;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  background: #fffbf5;
  transition: border-color .15s, background .15s;
}
.gsc-area:hover { border-color: #ea580c; background: #fff7ed; }
.gsc-area p { font-size: .82rem; color: #78716c; margin-top: .4rem; line-height: 1.5; }
.gsc-area strong { color: #44403c; display: block; margin-bottom: .3rem; font-size: .85rem; }
.gsc-hint { font-size: .75rem; color: #a8a29e; margin-top: .6rem; line-height: 1.5; }

/* ─── Summary bar ────────────────────────────────── */
.summary-bar {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: 1rem;
}
.sum-chip {
  display: flex; align-items: center; gap: .35rem;
  padding: .3rem .85rem; border-radius: 999px;
  font-size: .82rem; font-weight: 700;
}
.sum-chip .chip-num { font-size: .9rem; font-weight: 800; }
.sum-all   { background: #f5f5f4; color: #44403c; }
.sum-top3  { background: #dcfce7; color: #15803d; }
.sum-top10 { background: #d1fae5; color: #065f46; }
.sum-top20 { background: #fef9c3; color: #854d0e; }
.sum-low   { background: #fee2e2; color: #991b1b; }
.sum-avg   { background: #ede9fe; color: #5b21b6; }

/* ─── Toolbar ────────────────────────────────────── */
.toolbar {
  display: flex; flex-wrap: wrap; gap: .5rem;
  align-items: center; margin-bottom: .75rem;
}
.filter-tabs { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1; }
.filter-tab {
  padding: .28rem .72rem;
  border: 1.5px solid #e7e5e4; border-radius: 999px;
  font-size: .78rem; font-weight: 600; color: #57534e;
  background: #fff; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  font-family: inherit;
}
.filter-tab:hover { border-color: #fb923c; }
.filter-tab.active { background: #ea580c; border-color: #ea580c; color: #fff; }
.filter-tab .fc { font-size: .72rem; opacity: .85; margin-left: .15rem; }

.toolbar-right { display: flex; gap: .4rem; align-items: center; }
.sort-select {
  padding: .3rem .6rem;
  border: 1.5px solid #e7e5e4; border-radius: 7px;
  background: #fff; font-size: .78rem; font-weight: 600;
  color: #57534e; cursor: pointer; outline: none;
  font-family: inherit;
}

/* ─── Result search ──────────────────────────────── */
.result-search-wrap {
  position: relative; margin-bottom: .75rem;
}
.result-search-wrap input {
  width: 100%; padding: .42rem .85rem .42rem 2.1rem;
  border: 1.5px solid #e7e5e4; border-radius: 8px;
  font-size: .85rem; font-family: inherit; color: #1c1917;
  background: #fafaf9; outline: none; transition: border-color .15s;
}
.result-search-wrap input:focus { border-color: #ea580c; }
.rs-icon {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  color: #a8a29e; font-size: .82rem; pointer-events: none;
}

/* ─── Table ──────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  max-height: 580px;
  overflow-y: auto;
  border-radius: 12px;
  border: 1.5px solid #fed7aa;
  box-shadow: 0 2px 8px rgba(234,88,12,.07);
}
.kw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
  min-width: 640px;
  background: #fff;
}
.kw-table thead th {
  background: #fff7ed;
  color: #57534e;
  font-weight: 700;
  padding: .5rem .75rem;
  text-align: left;
  border-bottom: 1.5px solid #fed7aa;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.kw-table tbody tr {
  border-bottom: 1px solid #f0efed;
  transition: background .1s;
}
.kw-table tbody tr:last-child { border-bottom: none; }
.kw-table tbody tr:hover { background: #fffbf5; }
.kw-table td { padding: .42rem .75rem; vertical-align: middle; }
.td-kw { font-weight: 600; word-break: break-all; }
.td-rank { text-align: center; white-space: nowrap; }
.td-change { text-align: center; white-space: nowrap; }
.td-spark { text-align: center; }
.td-date { white-space: nowrap; color: #78716c; font-size: .78rem; }
.td-action { white-space: nowrap; text-align: center; }

/* ─── Rank badge ─────────────────────────────────── */
.rank-badge {
  display: inline-block;
  font-size: .8rem; font-weight: 800;
  padding: .2rem .55rem;
  border-radius: 7px;
  min-width: 36px; text-align: center;
}
.rank-top3  { background: #dcfce7; color: #15803d; }
.rank-top10 { background: #d1fae5; color: #065f46; }
.rank-top20 { background: #fef9c3; color: #854d0e; }
.rank-top50 { background: #ffedd5; color: #c2410c; }
.rank-low   { background: #fee2e2; color: #991b1b; }
.rank-none  { background: #f4f4f5; color: #a1a1aa; }

/* ─── Change badge ───────────────────────────────── */
.chg-badge {
  display: inline-block;
  font-size: .78rem; font-weight: 700;
  padding: .18rem .45rem;
  border-radius: 6px;
}
.chg-up   { background: #dcfce7; color: #15803d; }
.chg-down { background: #fee2e2; color: #dc2626; }
.chg-same { background: #f4f4f5; color: #78716c; }
.chg-new  { background: #dbeafe; color: #1d4ed8; }

/* ─── Empty state ────────────────────────────────── */
.empty-table {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #a8a29e;
  font-size: .9rem;
  line-height: 1.8;
  background: #fff;
  border-radius: 12px;
  border: 1.5px dashed #fed7aa;
}
.empty-table strong { display: block; color: #78716c; font-size: 1rem; margin-bottom: .3rem; }

/* ─── Toast ──────────────────────────────────────── */
#rt-toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: #1c1917; color: #fff;
  padding: .6rem 1.2rem; border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  z-index: 9999; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
#rt-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Tips ───────────────────────────────────────── */
.tips-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tip-item { display: flex; gap: .65rem; }
.tip-icon { font-size: 1.4rem; flex-shrink: 0; }
.tip-text strong { display: block; font-weight: 700; margin-bottom: .15rem; font-size: .88rem; }
.tip-text p { font-size: .8rem; color: #78716c; line-height: 1.55; }

/* ━━━ 活用シーン ━━━ */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
.scene-item {
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.scene-item strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: #9a3412;
  margin-bottom: 0.3rem;
}
.scene-item p {
  font-size: 0.8rem;
  color: #78716c;
  line-height: 1.55;
  margin: 0;
}

/* ━━━ 関連ツール ━━━ */
.related-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.related-tool-item {
  display: block;
  background: #fff;
  border: 1.5px solid #fed7aa;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: #1c1917;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.related-tool-item:hover {
  border-color: #ea580c;
  box-shadow: 0 2px 8px rgba(234,88,12,0.15);
}
.related-tool-item span {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}
.related-tool-item small {
  display: block;
  font-size: 0.75rem;
  color: #78716c;
  font-weight: 400;
  margin-top: 0.25rem;
}

/* ─── Amazon ─────────────────────────────────────── */
.amazon-card h2 { margin-bottom: 0.2rem; }
.amazon-note { font-size: 0.8rem; color: #a8a29e; margin-bottom: .85rem; }
.amazon-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
.amazon-item {
  display: block; border: 1px solid #e0e0e0; border-radius: 10px;
  padding: 0.85rem; text-decoration: none; color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.amazon-item:hover {
  border-color: #FF9900; box-shadow: 0 2px 8px rgba(255,153,0,0.15);
  transform: translateY(-1px);
}
.amazon-item-icon { font-size: 1.6rem; margin-bottom: 0.3rem; }
.amazon-item-name { font-size: 0.85rem; font-weight: bold; margin-bottom: 0.18rem; }
.amazon-item-desc { font-size: 0.74rem; color: #888; line-height: 1.5; margin-bottom: 0.4rem; }
.amazon-item-link { font-size: 0.76rem; color: #FF9900; font-weight: bold; }

/* ─── Footer ─────────────────────────────────────── */
footer {
  text-align: center; padding: 1.5rem 1rem;
  font-size: .82rem; color: #a8a29e;
  border-top: 1px solid #e7e5e4; margin-top: auto;
}
footer a { color: #ea580c; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer p + p { margin-top: .3rem; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 700px) {
  .setup-grid { grid-template-columns: 1fr; }
  .add-form { grid-template-columns: 1fr 80px; }
  .add-form .field:nth-child(3),
  .add-form .field:nth-child(4) { grid-column: span 1; }
  .add-form { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.4rem; }
  .tips-grid { grid-template-columns: 1fr; }
  .scene-grid { grid-template-columns: 1fr; }
  .related-tools { grid-template-columns: 1fr; }
  .amazon-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: flex-end; }
}
@media (max-width: 480px) {
  .hero h1 { font-size: 1.25rem; }
  .add-form { grid-template-columns: 1fr; }
  .summary-bar { gap: .35rem; }
  .sum-chip { font-size: .75rem; padding: .25rem .6rem; }
}

.amazon-notice {
  font-size: 0.72rem;
  color: #bbb;
  margin-top: 0.2rem;
}

/* ━━━ FAQ ━━━ */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #ea580c; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }
