:root {
  --tms-primary: #1a56db;
  --tms-border: #e5e7eb;
  --tms-muted: #6b7280;
  --tms-bg: #f9fafb;
  --tms-radius: 10px;
}

.tms-search {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.tms-search button,
.tms-search input,
.tms-search select {
  margin: 0;
  font: inherit;
}

.tms-search__header {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 1rem;
  margin: 0 0 1.25rem !important;
  padding: 0 !important;
}

.tms-search__logo {
  flex: 0 0 auto !important;
  display: block !important;
  width: 72px !important;
  height: 72px !important;
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
  border: 0 !important;
  object-fit: contain;
  vertical-align: middle;
}

.tms-search__headings {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tms-search__title {
  margin: 0 0 0.25rem !important;
  padding: 0 !important;
  float: none !important;
  clear: none !important;
  font-size: 1.5rem;
  line-height: 1.3;
}

.tms-search__subtitle {
  margin: 0 !important;
  padding: 0 !important;
  color: var(--tms-muted);
  font-size: 0.9375rem;
}

.tms-search__nav {
  flex: 0 0 auto;
  margin: 0 0 0 auto !important;
  padding: 0 !important;
  align-self: center;
}

.tms-search__nav-link {
  color: var(--tms-primary);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tms-search__nav-link:hover {
  text-decoration: underline;
}

.tms-preorder-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid #bfdbfe;
  border-radius: var(--tms-radius);
  background: #eff6ff;
  box-sizing: border-box;
}

.tms-preorder-banner__text {
  flex: 1 1 14rem;
  min-width: 0;
  margin: 0;
}

.tms-preorder-banner__title {
  margin: 0 0 0.2rem !important;
  padding: 0 !important;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  color: #1e3a8a;
}

.tms-preorder-banner__desc {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #374151;
}

.tms-btn--preorder {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tms-primary);
  color: #fff !important;
  border: 1px solid var(--tms-primary);
  text-decoration: none !important;
  font-weight: 600;
  white-space: nowrap;
}

.tms-btn--preorder:hover,
.tms-btn--preorder:focus {
  background: #1648c0;
  border-color: #1648c0;
  color: #fff !important;
}

@media (max-width: 767px) {
  .tms-preorder-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .tms-preorder-banner .tms-btn--preorder {
    width: 100%;
    text-align: center;
  }
}

/*
 * Spiel 區塊主題 page 模板：搜尋頁欄寬 flex-basis:100%，
 * 預訂頁卻常是 60.3%（左邊大片空白）。對齊搜尋頁，勿用 100vw breakout。
 */
body.tms-preorder-page main .wp-block-columns.alignwide > .wp-block-column {
  flex-basis: 100% !important;
  flex-grow: 1 !important;
  width: 100% !important;
  max-width: none !important;
}

body.tms-preorder-page main .wp-block-columns.alignwide {
  gap: 0 !important;
}

.tms-search--preorder {
  max-width: none;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.tms-search--preorder .tms-quick-actions {
  margin-top: 0.75rem;
}

.tms-sort-field {
  margin-top: 0.35rem;
}

.tms-sort-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.tms-search .tms-sort-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0;
  padding: 0.35rem 0.75rem;
  min-height: 2rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tms-search .tms-sort-pill:hover {
  border-color: #c5cad3;
  background: #f9fafb;
}

.tms-search .tms-sort-pill.is-active,
.tms-search .tms-sort-pill[aria-pressed="true"] {
  border-color: var(--tms-primary);
  background: #eff6ff;
  color: var(--tms-primary);
  box-shadow: inset 0 0 0 1px var(--tms-primary);
}

.tms-col-ship {
  width: 1%;
  max-width: 7.5em;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  white-space: nowrap;
  font-size: 0.8125rem;
  color: #374151;
  vertical-align: middle;
}

@media (max-width: 767px) {
  .tms-search__header {
    flex-wrap: wrap !important;
  }

  .tms-search__nav {
    margin: 0.25rem 0 0 !important;
    width: 100%;
  }
}

.tms-update-notice {
  margin: 0 0 1.25rem;
}

.tms-update-notice[hidden] {
  display: none !important;
}

.tms-update-notice__inner {
  position: relative;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #f5f8fc;
}

.tms-update-notice__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
}

.tms-update-notice__badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #e8eef8;
  color: var(--tms-primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tms-update-notice__date {
  font-size: 0.8125rem;
  color: var(--tms-muted);
}

.tms-search .tms-update-notice__title,
.tms-update-notice__title {
  margin: 0 0 0.2rem !important;
  padding: 0 !important;
  font-size: 0.975rem;
  font-weight: 600;
  line-height: 1.35;
  color: #111827;
}

.tms-search .tms-update-notice__body,
.tms-update-notice__body {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #374151;
}

.tms-update-notice__body br {
  line-height: 1.45;
}

.tms-update-notice__close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.tms-update-notice__close:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #111827;
}

.tms-search__bar {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.tms-search__bar input,
.tms-range input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--tms-border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  box-sizing: border-box;
}

.tms-search__bar input:focus,
.tms-range input:focus {
  outline: none;
  border-color: var(--tms-primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.tms-range input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.tms-range input[type="number"]::-webkit-outer-spin-button,
.tms-range input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tms-search__bar .tms-btn {
  flex-shrink: 0;
  padding: 0.65rem 1.1rem;
}

.tms-search__bar--compact input {
  padding: 0.45rem 0.65rem;
  font-size: 0.875rem;
}

.tms-btn--sm {
  padding: 0.45rem 0.75rem !important;
  font-size: 0.8125rem;
}

.tms-search__body {
  width: 100%;
  min-width: 0;
}

.tms-search__body > * {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.tms-quick-search {
  margin-bottom: 0.75rem;
  padding: 0;
}

.tms-quick-search__title {
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.tms-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.tms-quick-cell {
  padding: 0;
  min-width: 0;
}

.tms-quick-cell--full {
  grid-column: 1 / -1;
}

.tms-quick-cell--half {
  grid-column: span 2;
}

.tms-quick-cell__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
}

.tms-quick-field {
  display: block;
  margin: 0;
}

.tms-quick-field > span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
}

.tms-quick-filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.tms-quick-field select,
.tms-quick-field input[type="text"],
.tms-quick-field input:not([type="number"]),
.tms-typeahead input,
.tms-search .tms-select {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.3;
  background: #fff;
  color: inherit;
  box-sizing: border-box;
  font-family: inherit;
}

.tms-quick-field select:focus,
.tms-quick-field input:focus,
.tms-typeahead input:focus,
.tms-search .tms-select:focus {
  outline: none;
  border-color: var(--tms-border);
  box-shadow: none;
}

.tms-typeahead {
  position: relative;
}

.tms-typeahead__list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.tms-typeahead__item {
  padding: 0.45rem 0.65rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.tms-typeahead__item:hover,
.tms-typeahead__item.is-active,
.tms-typeahead__item:focus {
  background: #eff6ff;
  color: var(--tms-primary);
  outline: none;
}

.tms-typeahead__hint {
  padding: 0.4rem 0.65rem 0.2rem;
  font-size: 0.75rem;
  color: var(--tms-muted);
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: 0.15rem;
}

.tms-typeahead__more {
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  color: var(--tms-muted);
  border-top: 1px solid #f3f4f6;
  margin-top: 0.15rem;
}

.tms-typeahead__empty {
  padding: 0.55rem 0.65rem;
  font-size: 0.8125rem;
  color: var(--tms-muted);
}

.tms-filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.tms-filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tms-filter-label {
  flex-shrink: 0;
  width: 2.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.tms-filter-row--selects {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding-left: calc(2.5rem + 0.75rem);
}

.tms-field--inline {
  flex: 1;
  min-width: 140px;
  margin-bottom: 0;
}

.tms-field--inline span {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
}

.tms-field--inline select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
}

.tms-quick-chips {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tms-quick-chips__group {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  padding-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
}

.tms-chip {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--tms-border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.8125rem;
  cursor: pointer;
  color: #374151;
  white-space: nowrap;
}

.tms-chip.is-active {
  background: #eff6ff;
  border-color: var(--tms-primary);
  color: var(--tms-primary);
  font-weight: 600;
}

.tms-chip--sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

.tms-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.5rem;
  padding: 0;
  flex-wrap: wrap;
}

.tms-advanced__chevron {
  display: inline-block;
  margin-left: 0.15rem;
  font-size: 0.875rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

#tms-advanced-toggle[aria-expanded="true"] .tms-advanced__chevron {
  transform: rotate(180deg);
}

.tms-advanced__panel {
  margin-bottom: 0.75rem;
  padding: 0.85rem 0;
  background: var(--tms-bg);
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
}

.tms-advanced__panel[hidden] {
  display: none;
}

.tms-advanced__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 0 0.85rem;
}

.tms-quick-field--span2 {
  grid-column: 1 / -1;
}

.tms-advanced__panel .tms-quick-field input[type="text"],
.tms-advanced__panel .tms-quick-field input:not([type="number"]) {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
  box-sizing: border-box;
}

.tms-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--tms-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9375rem;
}

.tms-btn--outline {
  background: #fff;
  color: var(--tms-primary);
  border: 1px solid var(--tms-primary);
}

.tms-btn--ghost {
  background: transparent;
  color: var(--tms-muted);
  border: 1px solid var(--tms-border);
}

.tms-btn--amazon {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e47911;
  color: #fff;
  border: 1px solid #e47911;
  text-decoration: none;
  text-align: center;
  font-weight: 600;
  line-height: 1.25;
}

.tms-btn--amazon:hover,
.tms-btn--amazon:focus {
  background: #c96a0c;
  border-color: #c96a0c;
  color: #fff;
  text-decoration: none;
}

.tms-btn--amazon.tms-btn--sm {
  padding: 0.12rem 0.4rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 4px;
  min-height: 0;
}

.tms-btn--block {
  display: block;
  width: 100%;
}

.tms-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  background: var(--tms-primary);
  color: #fff;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
}

.tms-new-badge {
  display: inline-block;
  vertical-align: 0.15em;
  margin-right: 0.4em;
  padding: 0.12em 0.4em;
  border-radius: 3px;
  background: #c2410c;
  color: #fff;
  font-size: 0.68em;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
}

.tms-table__name .tms-new-badge,
.tms-single__title-zh .tms-new-badge,
.tms-card__name-zh .tms-new-badge,
.tms-related-row__name-zh .tms-new-badge {
  position: relative;
  top: -0.05em;
}

.tms-btn--outline .tms-badge-count {
  background: var(--tms-primary);
}

.tms-active-chips {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  margin-bottom: 0.75rem;
  min-height: 1.75rem;
  -webkit-overflow-scrolling: touch;
}

.tms-active-chip {
  flex-shrink: 0;
  padding: 0.25rem 0.6rem;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.tms-search__toolbar {
  margin: 0.5rem 0;
  padding: 0;
  color: var(--tms-muted);
  font-size: 0.875rem;
}

.tms-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  -webkit-overflow-scrolling: touch;
}

.tms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: #fff;
}

.tms-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tms-bg);
}

.tms-table th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid var(--tms-border);
  white-space: nowrap;
}

.tms-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--tms-border);
  vertical-align: top;
}

.tms-table__row {
  cursor: pointer;
  transition: background 0.12s;
}

.tms-table__row:hover { background: #f0f7ff; }
.tms-table tbody tr:nth-child(even) { background: #fafafa; }
.tms-table tbody tr:nth-child(even):hover { background: #f0f7ff; }

.tms-table__sku {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-weight: 600;
  white-space: nowrap;
}

.tms-table__name { min-width: 200px; }
.tms-table__link {
  color: inherit;
  text-decoration: none;
  display: block;
}
.tms-table__link:hover {
  color: var(--tms-primary);
  text-decoration: underline;
}
.tms-table__ja {
  font-size: 0.875rem;
  line-height: 1.35;
}
.tms-table__zh {
  font-size: 0.75rem;
  color: var(--tms-muted);
  margin-top: 0.15rem;
  line-height: 1.35;
}
.tms-table td.tms-loading {
  text-align: center;
  padding: 1.5rem;
  color: var(--tms-muted);
}

.tms-brand-tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tms-primary);
}

.tms-loading, .tms-empty {
  text-align: center;
  padding: 2rem;
  color: var(--tms-muted);
}

.tms-empty a {
  color: var(--tms-primary);
}

.tms-site-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--tms-border);
  font-size: 0.8125rem;
  color: var(--tms-muted);
  line-height: 1.6;
}

.tms-site-footer p {
  margin: 0 0 0.5rem;
}

.tms-site-footer p:last-child {
  margin-bottom: 0;
}

.tms-site-footer a {
  color: var(--tms-primary);
}

/* Compare */
.tms-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tms-col-amazon {
  width: 4.25rem;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}

.tms-col-amazon .tms-btn--amazon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.15;
  border-radius: 4px;
  min-height: 1.35rem;
}

.tms-col-compare {
  width: 4.5rem;
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: middle;
}

.tms-compare-check {
  width: 1.125rem;
  height: 1.125rem;
  cursor: pointer;
  accent-color: var(--tms-primary);
  vertical-align: middle;
}

.tms-compare-btn {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.tms-compare-btn.is-active {
  background: var(--tms-primary);
  border-color: var(--tms-primary);
  color: #fff;
}

.tms-compare-tray {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #fff;
  border-top: 1px solid var(--tms-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  padding: 0.75rem 1rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

.tms-compare-tray__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.tms-compare-tray__label {
  font-size: 0.875rem;
  color: #374151;
  flex-shrink: 0;
}

.tms-compare-tray__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.tms-compare-tray__chip {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--tms-border);
  border-radius: 999px;
  background: var(--tms-bg);
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
}

.tms-compare-tray__actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

body.tms-compare-tray-open .tms-site-footer {
  padding-bottom: 4rem;
}

.tms-modal__panel--wide {
  max-width: 960px;
}

.tms-compare-table-wrap {
  overflow-x: auto;
}

.tms-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.tms-compare-table th,
.tms-compare-table td {
  border: 1px solid var(--tms-border);
  padding: 0.5rem 0.65rem;
  vertical-align: top;
  text-align: left;
}

.tms-compare-table thead th {
  background: var(--tms-bg);
  font-weight: 600;
}

.tms-compare-table tbody th {
  background: #f9fafb;
  font-weight: 600;
  white-space: nowrap;
  width: 7rem;
}

.tms-compare-table__product-name {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.tms-compare-table__product-sku {
  font-size: 0.75rem;
  color: var(--tms-muted);
}

.tms-compare-table__product-link {
  color: inherit;
  text-decoration: none;
}

.tms-compare-table .tms-btn--amazon {
  display: inline-block;
  white-space: normal;
  max-width: 12rem;
  line-height: 1.25;
  font-size: 0.8125rem;
  padding: 0.4rem 0.65rem;
}

.tms-compare-table__product-link:hover {
  color: var(--tms-accent, #0b5fff);
  text-decoration: underline;
}

.tms-compare-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 0 5rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.tms-compare-page__header {
  margin-bottom: 1.25rem;
}

.tms-compare-page__title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  line-height: 1.3;
}

.tms-compare-page__lead {
  margin: 0 0 0.75rem;
  color: var(--tms-muted);
  font-size: 0.925rem;
}

.tms-compare-page__actions {
  margin: 0;
}

.tms-compare-page__body {
  margin-top: 0.5rem;
}

.tms-search__more {
  text-align: center;
  margin-top: 1.25rem;
}

.tms-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.tms-page-numbers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.tms-page-btn,
.tms-page-num {
  min-width: 2.25rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 0.875rem;
  cursor: pointer;
}

.tms-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tms-page-num.is-active {
  background: var(--tms-primary);
  border-color: var(--tms-primary);
  color: #fff;
  font-weight: 600;
}

.tms-page-ellipsis {
  padding: 0 0.25rem;
  color: var(--tms-muted);
}

.tms-page-jump {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: #374151;
}

.tms-page-jump input {
  width: 4rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  font-size: 0.875rem;
}

/* Modal */
.tms-modal[hidden] { display: none !important; }

.tms-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.tms-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.tms-modal__panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  overflow: auto;
}

#tms-detail-body.tms-modal__panel {
  max-width: 640px;
  padding: 1.25rem 1.25rem 1.5rem;
}

.tms-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--tms-border);
}

.tms-modal__header h3 { margin: 0; font-size: 1.125rem; }

.tms-modal__close {
  border: none;
  background: var(--tms-bg);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.tms-modal__body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.tms-modal__footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--tms-border);
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.tms-field {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.tms-field span, .tms-field legend {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.tms-field select,
.tms-field input[type="text"],
.tms-field input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  font-size: 0.9375rem;
}

.tms-field fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.tms-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.tms-range > span {
  flex-shrink: 0;
  color: var(--tms-muted);
  font-size: 0.9375rem;
  user-select: none;
}

.tms-price-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

body.tms-modal-open { overflow: hidden; }

/* 型號 + 品牌快選 */
.tms-quick-brand-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 0.75rem;
  align-items: end;
}

.tms-quick-field--brands {
  min-width: 0;
}

/* 與「型號」標籤同一套字級／間距（覆蓋主題對 div>span 的樣式） */
.tms-search .tms-quick-field--brands > span,
.tms-search .tms-quick-brand-row .tms-quick-field > span {
  display: block;
  margin: 0 0 0.35rem;
  padding: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25;
  color: #374151;
}

.tms-brand-pills {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  align-items: stretch;
}

.tms-search .tms-brand-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 3.25rem;
  height: auto;
  margin: 0;
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--tms-border);
  border-radius: 6px;
  background-color: #fff;
  color: #374151;
  font-size: 0.75rem;
  font-weight: 400;
  font-family: inherit;
  line-height: 1;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-align: center;
  overflow: hidden;
}

/* Logo 按鈕：用 background-size:contain，避開主題對 img 的覆蓋樣式 */
.tms-search .tms-brand-pill--logo {
  min-width: 0;
  height: 3.5rem;
  min-height: 3.5rem;
  padding: 0.4rem 0.35rem;
  background-color: #fff;
  background-image: var(--tms-brand-logo);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.tms-search .tms-brand-pill--logo > * {
  display: none; /* 隱藏殘留 img，改以背景圖顯示 */
}

.tms-search .tms-brand-pill:hover {
  border-color: #c5cad3;
  background-color: #f9fafb;
}

.tms-search .tms-brand-pill--logo:hover {
  background-color: #f9fafb;
  background-image: var(--tms-brand-logo);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.tms-search .tms-brand-pill.is-active,
.tms-search .tms-brand-pill[aria-pressed="true"] {
  border-color: var(--tms-primary);
  background-color: #eff6ff;
  box-shadow: inset 0 0 0 1px var(--tms-primary);
}

.tms-search .tms-brand-pill--logo.is-active,
.tms-search .tms-brand-pill--logo[aria-pressed="true"] {
  background-color: #eff6ff;
  background-image: var(--tms-brand-logo);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.tms-search .tms-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1.4.6L6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 10px 7px;
  padding-right: 1.75rem;
}

/* Results grid cards */
.tms-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 0.75rem 0 1.25rem;
}

.tms-result-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tms-result-card:hover,
.tms-result-card:focus-visible {
  border-color: var(--tms-primary);
  box-shadow: 0 4px 14px rgba(26, 86, 219, 0.12);
  outline: none;
}

.tms-result-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tms-result-card__compare {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--tms-muted);
  cursor: pointer;
  user-select: none;
}

.tms-result-card__sku {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  font-weight: 600;
}

.tms-result-card__link {
  color: inherit;
  text-decoration: none;
  display: block;
}

.tms-result-card__link:hover {
  text-decoration: underline;
  color: var(--tms-primary);
}

.tms-result-card__name-ja {
  font-size: 0.95rem;
  line-height: 1.35;
}

.tms-result-card__name-zh {
  font-size: 0.75rem;
  color: var(--tms-muted);
  line-height: 1.35;
  margin-top: 0.1rem;
}

.tms-result-card__price {
  margin-top: auto;
  padding-top: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--tms-primary);
}

.tms-results-grid > .tms-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--tms-muted);
}

/* Cards for single/related - keep minimal */
.tms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.tms-card {
  display: block;
  background: #fff;
  border: 1px solid var(--tms-border);
  border-radius: var(--tms-radius);
  padding: 1rem;
  text-decoration: none;
  color: inherit;
}

@media (max-width: 768px) {
  .tms-search__header { gap: 0.75rem; }
  .tms-search__logo { width: 56px !important; height: 56px !important; }
  .tms-search__title { font-size: 1.125rem; }
  .tms-col-hide-mobile { display: none; }

  .tms-quick-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tms-quick-cell--full {
    grid-column: 1 / -1;
  }

  .tms-quick-cell--half {
    grid-column: span 1;
  }

  .tms-quick-cell--half:last-of-type {
    grid-column: 1 / -1;
  }

  .tms-quick-brand-row {
    grid-template-columns: 1fr;
  }

  .tms-brand-pills {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tms-quick-filters {
    grid-template-columns: 1fr;
  }

  .tms-advanced__grid {
    grid-template-columns: 1fr;
  }

  .tms-modal {
    padding: 0;
    align-items: flex-end;
  }

  .tms-modal__panel {
    max-width: none;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
}
