.piabase-compare-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 20px 96px;
  color: #1f2937;
}

.compare-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.compare-page-header h1 {
  margin: 0 0 8px;
  color: #111827;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.35;
}

.compare-page-header p {
  margin: 0;
  color: #4b5563;
  font-size: 0.96rem;
  line-height: 1.7;
}

.compare-page-actions,
.compare-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compare-action-btn,
.compare-share-btn,
.compare-search-form button,
.compare-search-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #7d3da8;
  border-radius: 7px;
  background: #7d3da8;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.compare-action-btn.is-secondary,
.compare-share-btn {
  background: #fff;
  color: #5b287f;
}

.compare-search-add {
  border-color: #c4a1dc;
  background: #f7f0fb;
  color: #5b287f;
  box-shadow: inset 0 0 0 1px rgba(125, 61, 168, 0.08);
}

.compare-search-add:hover {
  border-color: #9d68bf;
  background: #efe1f7;
  color: #4a1f68;
}

.compare-share-btn-x {
  border-color: #111;
  background: #111;
  color: #fff;
}

.compare-share-btn-facebook {
  border-color: #1877f2;
  background: #1877f2;
  color: #fff;
}

.compare-action-btn:disabled,
.compare-search-add:disabled {
  border-color: #d1d5db;
  background: #e5e7eb;
  color: #6b7280;
  cursor: not-allowed;
}

.compare-empty {
  margin: 20px 0;
  padding: 22px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.compare-empty p {
  margin: 0 0 14px;
  color: #4b5563;
  line-height: 1.7;
}

.compare-table-wrap {
  width: 100%;
  max-width: 100%;
  margin-top: 10px;
}

.compare-table-shell {
  position: relative;
}

.compare-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.compare-scroll-hint {
  display: none;
}

.compare-section {
  margin-top: 24px;
}

.compare-section h2 {
  margin: 0 0 12px;
  padding-left: 12px;
  border-left: 4px solid #7d3da8;
  color: #111827;
  font-size: 1.18rem;
  font-weight: 800;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.compare-table th,
.compare-table td {
  padding: 12px;
  border: 1px solid #e5e7eb;
  vertical-align: top;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.65;
  word-break: break-word;
}

.compare-table th {
  background: #f8fafc;
  color: #111827;
  font-weight: 800;
  text-align: left;
}

.compare-table-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

.compare-table .compare-row-label {
  width: 150px;
}

.compare-label-mobile {
  display: none;
}

.compare-cell-max {
  background: #fff7ed;
}

.compare-max-badge {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fed7aa;
  color: #9a3412;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.compare-mobile-groups {
  display: none;
}

.compare-mobile-row {
  margin-bottom: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.compare-mobile-row h3 {
  margin: 0;
  padding: 11px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #111827;
  font-size: 0.95rem;
  font-weight: 800;
}

.compare-mobile-row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  font-size: 0.88rem;
  line-height: 1.55;
}

.compare-mobile-row-item:last-child {
  border-bottom: 0;
}

.compare-mobile-title {
  min-width: 0;
  font-weight: 800;
}

.compare-mobile-value {
  min-width: 0;
  text-align: right;
}

.compare-search-modal,
.compare-share-panel {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
}

.compare-search-modal[hidden],
.compare-share-panel[hidden] {
  display: none;
}

.compare-search-dialog,
.compare-share-panel-inner {
  width: min(680px, 100%);
  max-height: min(760px, 90vh);
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.25);
}

.compare-share-panel-inner {
  width: min(460px, 100%);
  position: relative;
}

.compare-share-panel .compare-share-actions {
  margin-top: 16px;
}

.compare-search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.compare-search-head h2,
.compare-share-panel h2 {
  margin: 0;
  color: #111827;
  font-size: 1.15rem;
  font-weight: 800;
}

.compare-search-close,
.compare-share-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  background: #fff;
  color: #374151;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}

.compare-share-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.compare-search-form {
  display: flex;
  gap: 8px;
}

.compare-search-form input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 0.95rem;
}

.compare-search-results {
  margin-top: 16px;
  max-height: min(52vh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.compare-search-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid #e5e7eb;
}

.compare-search-result-title {
  margin: 0 0 5px;
  color: #111827;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.45;
}

.compare-search-result-meta {
  margin: 0;
  color: #6b7280;
  font-size: 0.8rem;
  line-height: 1.5;
}

.compare-search-more {
  padding: 12px;
  color: #6b7280;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.piabase-compare-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10060;
  max-width: min(360px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 11px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.5;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.25);
}

.piabase-compare-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 10040;
  display: none;
  width: min(920px, calc(100vw - 28px));
  transform: translateX(-50%);
  padding: 12px 14px;
  border: 1px solid #d8b4fe;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.18);
}

.piabase-compare-bar.is-visible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.compare-bar-main {
  min-width: 0;
}

.compare-bar-count {
  margin: 0 0 5px;
  color: #111827;
  font-size: 0.9rem;
  font-weight: 800;
}

.compare-bar-hint {
  margin: 0;
  color: #6b7280;
  font-size: 0.8rem;
  line-height: 1.4;
}

.compare-bar-items {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.compare-bar-chip {
  display: inline-flex;
  align-items: center;
  max-width: 190px;
  min-height: 28px;
  padding: 4px 7px 4px 9px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f9fafb;
  color: #374151;
  font-size: 0.78rem;
  font-weight: 700;
}

.compare-bar-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compare-bar-chip button {
  margin-left: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.compare-bar-action {
  flex: 0 0 auto;
}

.piabase-compare-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #7d3da8;
  border-radius: 7px;
  background: #fff;
  color: #5b287f;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

.piabase-compare-button.is-added {
  background: #f3e8ff;
}

@media (max-width: 700px) {
  .piabase-compare-page {
    padding: 28px 10px 92px;
  }

  .compare-page-header {
    display: block;
  }

  .compare-page-actions {
    margin-top: 16px;
  }

  .compare-action-btn,
  .compare-share-btn {
    min-height: 36px;
    padding: 8px 11px;
    font-size: 0.84rem;
  }

  .compare-table-shell {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    margin-right: -10px;
    margin-left: -10px;
    box-sizing: border-box;
  }

  .compare-table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding-right: 10px;
    padding-bottom: 8px;
    padding-left: 10px;
    overflow-x: scroll;
    overflow-y: hidden;
    touch-action: pan-x pan-y;
  }

  .compare-table-shell:not(.is-scroll-hint-hidden) .compare-scroll-hint {
    position: absolute;
    top: var(--compare-scroll-hint-top, 170px);
    left: 50%;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
    pointer-events: none;
  }

  .compare-scroll-hint span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.86);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    animation: compare-scroll-hint-nudge 1.25s ease-in-out infinite;
  }

  .compare-scroll-hint span::before,
  .compare-scroll-hint span::after {
    color: #e9d5ff;
    font-size: 0.9rem;
    line-height: 1;
  }

  .compare-scroll-hint span::before {
    content: "<";
  }

  .compare-scroll-hint span::after {
    content: ">";
  }

  .compare-table-scroll .compare-section {
    width: 620px;
    min-width: 620px;
  }

  .compare-table {
    width: 100%;
    min-width: 100%;
    max-width: none;
  }

  .compare-table th,
  .compare-table td {
    padding: 9px;
    font-size: 0.78rem;
  }

  .compare-table .compare-row-label {
    width: 82px;
    white-space: nowrap;
  }

  .compare-label-desktop {
    display: none;
  }

  .compare-label-mobile {
    display: inline;
  }

  .compare-table-remove {
    min-height: 28px;
    padding: 5px 7px;
    font-size: 0.7rem;
  }

  .compare-search-dialog,
  .compare-share-panel-inner {
    padding: 16px;
  }

  .compare-search-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .compare-search-result {
    grid-template-columns: 1fr;
  }

  .compare-search-add {
    width: 100%;
  }

  .piabase-compare-bar {
    bottom: 10px;
    width: calc(100vw - 20px);
    padding: 10px;
  }

  .piabase-compare-bar.is-visible {
    align-items: stretch;
  }

  .compare-bar-items {
    display: none;
  }

  .compare-bar-action {
    align-self: center;
  }

  .piece-detail .piabase-compare-button {
    min-height: 30px;
    padding: 6px 9px;
    font-size: 0.78rem;
  }
}

@keyframes compare-scroll-hint-nudge {
  0%,
  100% {
    transform: translateX(-8px);
  }

  50% {
    transform: translateX(8px);
  }
}
