/* 履歴ページ：スマホ優先 + PC は表形式グリッド */

.history-page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
}

.history-page .page-main {
  flex: 1 0 auto;
}

.site-header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.site-header-nav a,
.site-header-user a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
}

.site-header-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
  max-width: 100%;
}

.site-header-email {
  font-size: 0.75rem;
  max-width: min(100%, 12rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-title {
  margin: 0 0 4px;
  font-size: clamp(1.125rem, 4vw, 1.5rem);
  line-height: 1.35;
  word-break: break-word;
}

.page-lead {
  margin: 0 0 16px;
}

.breadcrumb {
  margin: 0 0 12px;
  font-size: 0.9375rem;
}

.breadcrumb a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.section-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.history-list-card {
  padding: 12px 16px;
}

.history-list-head {
  display: none;
}

/* 履歴一覧（スマホ：縦積みカード） */
.history-cards {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid #e4e4e7;
}

.history-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.history-card:first-child {
  padding-top: 0;
}

.history-card-thumb {
  display: block;
  line-height: 0;
  width: fit-content;
}

img.thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.history-card-main {
  min-width: 0;
}

.history-card-date {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.history-card-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.history-card-title a {
  color: #18181b;
  text-decoration: none;
}

.history-card-title a:hover {
  color: #2563eb;
}

.history-card-brand {
  margin: 0;
  font-size: 0.8125rem;
}

.history-card-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.history-card-price {
  font-size: 0.875rem;
  word-break: break-word;
}

.history-list-chips {
  margin-top: 6px;
  gap: 4px;
}

.history-list-chips .chip {
  font-size: 0.75rem;
  padding: 4px 8px;
}

.history-card-kw-text {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  word-break: break-word;
}

.history-card-kw-text a,
.history-card-price a {
  color: #2563eb;
}

.history-card-price-src {
  font-size: 0.8125rem;
}

.history-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.history-card-actions .btn.outline {
  flex: 1 1 auto;
  min-width: 5rem;
  text-align: center;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #2563eb;
  color: #2563eb;
  background: #fff;
}

.history-delete-form {
  margin: 0;
  flex: 0 0 auto;
}

/* 詳細（送信画像は最大 640px までそのまま表示） */
.detail-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-photo-card {
  padding: 12px;
  text-align: center;
  max-height: min(42vh, 320px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

img.photo {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: min(42vh, 320px);
  margin: 0 auto;
  border-radius: 8px;
  object-fit: contain;
}

.market-warnings {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.market-warnings li {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  font-size: 0.875rem;
  line-height: 1.45;
}

.price-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.price-list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid #e4e4e7;
}

.price-list-item:last-child {
  border-bottom: none;
}

.price-list-source {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #71717a;
}

.price-list-value {
  font-size: 0.9375rem;
  font-weight: 600;
  word-break: break-word;
}

.price-list-value a {
  color: #2563eb;
}

.price-list-note {
  display: block;
  font-size: 0.8125rem;
  font-weight: 400;
  margin-top: 2px;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-actions .btn.primary {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px 16px;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
}

.btn-danger {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  width: 100%;
  box-sizing: border-box;
}

.history-page .link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.history-page .link-list a {
  flex: 1 1 calc(50% - 4px);
  min-width: 8rem;
  text-align: center;
  box-sizing: border-box;
  padding: 10px 8px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  color: #2563eb;
  text-decoration: none;
  font-size: 0.8125rem;
}

.history-page .chips {
  margin-top: 12px;
}

.keyword-select-hint {
  margin: 0 0 8px;
  font-size: 0.8125rem;
}

.chips-selectable {
  margin-top: 0;
}

.chip-selectable {
  cursor: pointer;
  border: 1px solid #bfdbfe;
  font: inherit;
  line-height: 1.3;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip-selectable:hover {
  border-color: #2563eb;
}

.chip-selectable:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.chip-selectable.chip--selected {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.keyword-google-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e4e4e7;
}

.keyword-google-box.hidden {
  display: none;
}

.keyword-google-label {
  margin: 0 0 4px;
  font-size: 0.75rem;
}

.keyword-google-term {
  margin: 0 0 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  word-break: break-word;
}

.keyword-google-link {
  display: inline-block;
  padding: 10px 14px;
  border: 1px solid #2563eb;
  border-radius: 10px;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}

.keyword-google-link:hover {
  background: #eff6ff;
}

/* タブレット以上：一覧グリッド + 詳細は送信画像を原寸表示（項目は画像の下） */
@media (min-width: 640px) {
  .detail-photo-card {
    max-height: none;
    overflow: visible;
    padding: 16px;
  }

  img.photo {
    max-width: 640px;
    max-height: none;
    width: auto;
    height: auto;
  }

  .history-card {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px 16px;
    align-items: start;
  }

  .history-card-thumb {
    grid-row: 1 / span 2;
  }

  .history-card-main {
    grid-column: 2;
  }

  .history-card-price {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
  }

  .history-card-price .history-card-label {
    display: none;
  }

  .history-card-actions {
    grid-column: 3;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 7rem;
  }

  .history-card-actions .btn.outline,
  .history-delete-form .btn-danger {
    width: auto;
    flex: 0 0 auto;
    min-width: 4.5rem;
    padding: 8px 12px;
  }

  .price-list-item {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
  }

  .price-list-source {
    flex: 0 0 35%;
    font-size: 0.875rem;
  }

  .price-list-value {
    flex: 1 1 auto;
    text-align: right;
    font-size: 1rem;
  }

  .detail-actions {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .detail-actions .btn.primary {
    width: auto;
    flex: 0 0 auto;
    min-width: 10rem;
  }

  .detail-actions .btn-danger {
    width: auto;
    min-width: 10rem;
  }

  .history-page .link-list a {
    flex: 0 1 auto;
    min-width: 0;
  }

  .history-page .result-dl {
    display: grid;
    grid-template-columns: 7em 1fr;
    gap: 4px 16px;
  }

  .history-page .result-dl dt {
    margin-top: 0;
  }
}
