/* ─── 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: 900px; width: 100%; margin: 0 auto; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }

/* ─── Main ───────────────────────────────────────── */
main { max-width: 900px; 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; }

/* ─── 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; }

/* ─── Field ──────────────────────────────────────── */
.field { margin-bottom: .85rem; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex; align-items: center; gap: .35rem;
  font-size: .82rem; font-weight: 700; color: #44403c;
  margin-bottom: .3rem;
}
.field-req {
  font-size: .68rem; font-weight: 700;
  color: #dc2626; background: #fee2e2;
  padding: .1rem .35rem; border-radius: 4px;
}
.field-opt {
  font-size: .68rem; color: #a8a29e;
}
.field input[type="text"],
.field input[type="url"] {
  width: 100%;
  border: 1.5px solid #e7e5e4;
  border-radius: 9px;
  padding: .6rem .85rem;
  font-size: .9rem;
  font-family: inherit;
  color: #1c1917;
  background: #fafaf9;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: #ea580c; background: #fff; }
.field input.error { border-color: #fca5a5; background: #fff5f5; }
.field-hint {
  font-size: .72rem; color: #a8a29e; margin-top: .3rem;
  line-height: 1.4;
}
.field-hint strong { color: #78716c; }

/* ─── 2-col grid ─────────────────────────────────── */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 1rem;
}

/* ─── Presets ────────────────────────────────────── */
.presets-label { font-size: .82rem; font-weight: 700; color: #44403c; margin-bottom: .45rem; }
.presets-row {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-bottom: 1rem;
}
.preset-btn {
  padding: .3rem .75rem;
  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;
}
.preset-btn:hover  { border-color: #fb923c; color: #ea580c; }
.preset-btn.active { border-color: #ea580c; background: #ea580c; color: #fff; }

/* ─── Generate button ────────────────────────────── */
.btn-generate {
  width: 100%;
  background: #ea580c; color: #fff;
  border: none; border-radius: 10px;
  padding: .72rem;
  font-size: .97rem; font-weight: 700;
  cursor: pointer; transition: background .15s;
  font-family: inherit;
  margin-top: .25rem;
}
.btn-generate:hover { background: #c2410c; }

/* ─── Result card ────────────────────────────────── */
.result-empty {
  text-align: center;
  padding: 1.5rem;
  color: #a8a29e;
  font-size: .88rem;
  border: 2px dashed #fed7aa;
  border-radius: 10px;
}

.result-url-wrap {
  display: flex; gap: .5rem; align-items: stretch;
  margin-bottom: .85rem;
}
.result-url {
  flex: 1;
  padding: .65rem .9rem;
  background: #f8fafc;
  border: 1.5px solid #e7e5e4;
  border-radius: 9px;
  font-size: .82rem;
  color: #1d4ed8;
  word-break: break-all;
  line-height: 1.6;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
}
.btn-copy-url {
  padding: .6rem 1rem;
  background: #ea580c; color: #fff;
  border: none; border-radius: 9px;
  font-size: .85rem; font-weight: 700;
  cursor: pointer; transition: background .15s;
  white-space: nowrap; font-family: inherit;
  flex-shrink: 0;
}
.btn-copy-url:hover { background: #c2410c; }
.btn-copy-url.copied { background: #16a34a; }

/* Param breakdown */
.param-breakdown {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin-bottom: .75rem;
}
.param-tag {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .18rem .6rem;
  border-radius: 6px;
  font-size: .75rem; font-weight: 600;
}
.param-tag .p-key { opacity: .75; }
.param-tag.p-source   { background: #dbeafe; color: #1d4ed8; }
.param-tag.p-medium   { background: #ede9fe; color: #6d28d9; }
.param-tag.p-campaign { background: #dcfce7; color: #15803d; }
.param-tag.p-term     { background: #fef9c3; color: #854d0e; }
.param-tag.p-content  { background: #ffedd5; color: #c2410c; }

/* Result actions */
.result-actions {
  display: flex; gap: .5rem; flex-wrap: wrap;
}
.btn-action {
  padding: .38rem .85rem;
  border: 1.5px solid #e7e5e4;
  border-radius: 8px;
  background: #fff; font-size: .8rem; font-weight: 600;
  color: #57534e; cursor: pointer;
  transition: background .12s, border-color .12s;
  font-family: inherit; text-decoration: none;
  display: inline-flex; align-items: center;
}
.btn-action:hover { background: #f5f5f4; border-color: #d6d3d1; }

/* ─── Char-length indicator ──────────────────────── */
.url-length {
  font-size: .72rem; color: #a8a29e;
  margin-bottom: .5rem;
}
.url-length.warn { color: #d97706; }
.url-length.over { color: #dc2626; }

/* ─── History ────────────────────────────────────── */
.history-empty {
  font-size: .85rem; color: #a8a29e; text-align: center; padding: .5rem;
}
.history-list { display: flex; flex-direction: column; gap: .5rem; }
.history-item {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .65rem .8rem;
  border: 1.5px solid #e7e5e4;
  border-radius: 10px;
  background: #fafaf9;
  transition: border-color .12s;
}
.history-item:hover { border-color: #fed7aa; }
.history-info { flex: 1; min-width: 0; }
.history-url {
  font-size: .78rem; color: #1d4ed8;
  word-break: break-all;
  line-height: 1.5;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  margin-bottom: .25rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-tags { display: flex; flex-wrap: wrap; gap: .25rem; }
.history-date { font-size: .7rem; color: #a8a29e; margin-top: .2rem; }
.history-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.btn-hist-copy {
  padding: .22rem .5rem;
  border: 1.5px solid #e7e5e4; border-radius: 6px;
  background: #fff; font-size: .72rem; font-weight: 700;
  color: #57534e; cursor: pointer;
  transition: background .12s; font-family: inherit;
}
.btn-hist-copy:hover { background: #fff7ed; border-color: #fb923c; color: #ea580c; }
.btn-hist-del {
  padding: .22rem .45rem;
  border: 1.5px solid #e7e5e4; border-radius: 6px;
  background: #fff; font-size: .72rem; font-weight: 700;
  color: #a8a29e; cursor: pointer;
  transition: background .12s; font-family: inherit;
}
.btn-hist-del:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .6rem;
}
.btn-clear-hist {
  font-size: .75rem; color: #a8a29e;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 600;
  transition: color .12s;
}
.btn-clear-hist:hover { color: #dc2626; }

/* ─── Tips table ─────────────────────────────────── */
.tips-table { width: 100%; border-collapse: collapse; font-size: .83rem; margin-top: .25rem; }
.tips-table th {
  background: #fff7ed; color: #57534e; font-weight: 700;
  padding: .4rem .75rem; text-align: left;
  border-bottom: 1.5px solid #fed7aa;
  white-space: nowrap;
}
.tips-table td { padding: .38rem .75rem; border-bottom: 1px solid #f0efed; vertical-align: top; }
.tips-table tr:last-child td { border-bottom: none; }
.tips-table td:first-child { font-family: monospace; font-size: .8rem; color: #1d4ed8; font-weight: 700; white-space: nowrap; }
.tips-table td:nth-child(2) { font-weight: 600; color: #44403c; }
.tips-table td:nth-child(3) { color: #78716c; font-size: .78rem; }

/* ─── 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; }

/* ─── Toast ──────────────────────────────────────── */
#utm-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);
}
#utm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── 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: 620px) {
  .fields-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.4rem; }
  .result-url-wrap { flex-direction: column; }
  .btn-copy-url { align-self: flex-start; }
}

/* ─── Tips grid (rank-tracker 統一パターン) ──────── */
.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; }
@media (max-width: 480px) {
  .hero h1 { font-size: 1.25rem; }
  .amazon-grid { grid-template-columns: 1fr; }

  .tips-grid { grid-template-columns: 1fr; }
}

.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: #1a73e8; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }
