.offer-compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: .45em;
  min-height: 44px;
  margin-top: 5px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--green);
  font-size: .82rem;
  font-weight: 700;
}

.offer-compare-toggle::before {
  content: '';
  flex: none;
  width: .94rem;
  height: .94rem;
  border: 1px solid currentColor;
  border-radius: 3px;
}

.offer-compare-toggle:hover,
.offer-compare-toggle[aria-pressed='true'] {
  border-color: #9eb98e;
  background: var(--lime-light);
}

.offer-compare-toggle[aria-pressed='true']::before {
  background: var(--green);
  box-shadow: inset 0 0 0 2px var(--lime-light);
}

body:has(.compare-tray:not([hidden])) {
  --compare-safe-bottom: max(10px, env(safe-area-inset-bottom));
  padding-bottom: calc(80px + var(--compare-dock-gap, 0px) + var(--compare-safe-bottom));
}

.compare-tray {
  position: fixed;
  z-index: 5;
  inset: auto 0 calc(var(--compare-safe-bottom, 10px) + var(--compare-dock-gap, 0px));
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(37rem, calc(100% - 26px));
  margin-inline: auto;
  padding: 9px 11px 9px 15px;
  border: 1px solid #c1d1b5;
  border-radius: 13px;
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 7px 27px #142f262d;
}

#compare-selection {
  flex: 1;
  min-width: 0;
  font-size: .93rem;
  font-weight: 700;
  line-height: 1.2;
}

.compare-open,
.compare-clear,
.compare-close,
.compare-remove {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--green);
  font-size: .85rem;
  font-weight: 700;
  line-height: 1.16;
}

.compare-open {
  min-width: 85px;
  border-color: transparent;
  background: var(--green-dark);
  color: #fff;
}

.compare-open:hover:not(:disabled) { background: var(--green); }

.compare-open:disabled {
  background: #e6ece0;
  color: #4c6051;
  cursor: default;
}

.compare-clear:hover,
.compare-close:hover,
.compare-remove:hover { background: var(--lime-light); }

.compare-dialog {
  width: min(49rem, calc(100% - 30px));
  max-width: none;
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 64px #11281f52;
}

.compare-dialog::backdrop { background: #10281fbd; }
body:has(.compare-dialog[open]) { overflow: hidden; }

.compare-dialog-heading {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px clamp(12px, 3vw, 24px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.compare-dialog-heading h2 {
  color: var(--green-dark);
  font: 800 clamp(1.3rem, 3.5vw, 1.85rem)/1.1 var(--display);
  letter-spacing: -.026em;
}

.compare-close {
  display: grid;
  width: 44px;
  place-items: center;
  padding: 0;
}

.compare-content { padding: clamp(10px, 2.8vw, 22px); }
.compare-content > .compare-note { margin-block: 8px; }

.compare-table {
  width: 100%;
  overflow: hidden;
  table-layout: fixed;
  border: 1px solid var(--line);
  border-spacing: 0;
  border-radius: 12px;
  font-size: .9rem;
  line-height: 1.4;
}

.compare-table :is(th, td) {
  padding: 10px 11px;
  overflow-wrap: anywhere;
  text-align: start;
  vertical-align: top;
}

.compare-table thead th {
  background: #eff4eb;
  color: var(--green-dark);
}

.compare-table thead th:first-child { width: 20%; }
.compare-table tbody th { color: var(--green-dark); background: #f4f7ef; }
.compare-table tr + tr > *, .compare-table tbody > tr:first-child > * { border-top: 1px solid var(--line); }
.compare-table tr > * + * { border-inline-start: 1px solid var(--line); }

.compare-product { display: grid; justify-items: start; gap: 4px; }
.compare-title { font: 800 clamp(.9rem, 2.6vw, 1.1rem)/1.24 var(--display); color: var(--green-dark); }
.compare-remove { padding-inline: 7px; font-size: .8rem; }
.compare-details { color: var(--green); text-decoration: underline; text-underline-offset: .2em; font-weight: 700; }
.compare-copy, .compare-conditions { white-space: pre-wrap; }
.compare-note { color: var(--muted); font-size: .83rem; }
.compare-price { display: block; color: var(--green-dark); font-weight: 700; }

.compare-estimate { display: grid; min-width: 0; gap: 7px; }
.compare-estimate > * { min-width: 0; }
.compare-input-label, .compare-quantity-label { color: var(--green-dark); font-size: .84rem; font-weight: 700; line-height: 1.35; }
.compare-number-input, .compare-unit-select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 9px;
  border: 1px solid #b7c7ae;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.compare-number-input:focus-visible, .compare-unit-select:focus-visible { outline: 3px solid #89ad6b; outline-offset: 2px; }
.compare-number-input[aria-invalid='true'] { border-color: #a34a32; }
.compare-number-input:disabled, .compare-unit-select:disabled { background: #e9eee5; color: #687362; }
.compare-quantity-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(86px, 1fr); gap: 6px; }
.compare-input-error { color: #8e3824; font-size: .8rem; line-height: 1.35; }
.compare-estimated-total { color: var(--green-dark); font-size: .95rem; font-weight: 800; line-height: 1.4; }
.compare-unit-result { padding: 7px; border-radius: 7px; background: #edf4e7; color: var(--green-dark); font-size: .84rem; line-height: 1.4; }

.compare-state {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 6px;
  background: #eef4e8;
  color: var(--green-dark);
  font-size: .81rem;
  font-weight: 700;
}

.compare-state--warning { background: #fff1d9; color: #74501e; }

@media (max-width: 650px) {
  body:has(.mobile-group-bar:not([hidden])):has(.compare-tray:not([hidden])) {
    --compare-dock-gap: 56px;
  }
}

@media (max-width: 540px) {
  .compare-tray { gap: 6px; padding-inline: 9px; }
  #compare-selection { font-size: .82rem; }
  .compare-clear, .compare-open { padding-inline: 8px; font-size: .8rem; }
  .compare-open { min-width: 70px; }
  .compare-dialog { width: calc(100% - 16px); max-height: calc(100% - 16px); border-radius: 13px; }
  .compare-table, .compare-table :is(thead, tbody) { display: block; }
  .compare-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compare-table :is(th, td) { padding: 8px; }
  .compare-table thead th:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .compare-table thead th:nth-child(2),
  .compare-table tbody td:nth-child(2) { border-inline-start: 0; }
  .compare-table tbody > tr > th {
    grid-column: 1 / -1;
    padding-block: 5px;
    font-size: .8rem;
  }
  .compare-table tbody > tr > td { border-top: 0; }
  .compare-quantity-controls { grid-template-columns: minmax(0, 1fr); }
  .compare-estimate { gap: 6px; }
  .compare-estimate .compare-note { font-size: .78rem; line-height: 1.4; }
  .compare-estimated-total { font-size: .87rem; }
}
