.wv-compare-head,
.wv-compare-context,
.wv-compare-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.wv-compare-head { align-items: flex-start; }
.wv-compare-head h2 { text-wrap: balance; }
.wv-compare-head [data-close-compare] { flex: none; }
.wv-compare-context {
  margin-block: .75rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
}
.wv-compare-context .wv-compare-origin {
  min-width: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.wv-compare-context .wv-chat-action { flex: none; }
.wv-compare-tools { margin-block: 0 .85rem; }
.wv-aspect-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--wash);
}
.wv-aspect-toggle button {
  min-height: 36px;
  padding: .35rem .75rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.3;
}
.wv-aspect-toggle button[aria-pressed=true] {
  border-color: var(--teal-deep);
  background: var(--teal-deep);
  color: white;
}
.wv-aspect-toggle button[aria-pressed=false]:hover { color: var(--teal-deep); }
.wv-compare-tools [data-copy-comparison] { flex: none; gap: .25em; }
.wv-compare [data-copy-preview] { margin-block: .75rem; }
.wv-compare [data-comparison] { container: wahana-comparison / inline-size; }
.wv-compare-note {
  margin-block: .75rem;
  color: var(--muted);
  font-size: .875rem;
}
.wv-matrix-scroll {
  max-inline-size: 100%;
  border-radius: 12px;
  isolation: isolate;
}
.wv-matrix {
  --aspect-width: 11rem;
  --cell-block: clamp(.85rem, 1.45vw, 1.1rem);
  --cell-inline: clamp(.7rem, 1.45vw, 1.125rem);
  width: 100%;
  border-spacing: 0;
  table-layout: fixed;
  color: var(--text);
  font-size: .92rem;
  line-height: 1.5;
}
.wv-matrix :is(th, td) {
  padding: var(--cell-block) var(--cell-inline);
  border-inline-end: 1px solid var(--line);
  border-block-end: 1px solid var(--line);
  vertical-align: top;
  text-align: start;
  overflow-wrap: anywhere;
}
.wv-matrix thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  vertical-align: middle;
  border-color: #44807a;
  background: var(--teal-deep);
  color: white;
  font-weight: 600;
  line-height: 1.4;
}
.wv-matrix thead th:first-child {
  width: var(--aspect-width);
  inset-inline-start: 0;
  z-index: 3;
  border-start-start-radius: 12px;
  font-size: .81rem;
}
.wv-matrix thead th:last-child { border-start-end-radius: 12px; }
.wv-matrix tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  border-inline-start: 1px solid var(--line);
  background: var(--wash);
  color: var(--ink);
  font-size: .86rem;
  font-weight: 600;
}
.wv-matrix tbody td { background: var(--paper); }
.wv-matrix tbody tr:last-child th { border-end-start-radius: 12px; }
.wv-matrix tbody tr:last-child td:last-child { border-end-end-radius: 12px; }
.wv-matrix-choice { display: flow-root; }
.wv-matrix-choice-label { text-wrap: pretty; }
.wv-matrix-remove {
  display: grid;
  place-items: center;
  float: inline-end;
  width: 30px;
  height: 30px;
  margin: -.15rem -.25rem .1rem .35rem;
  padding: 0;
  border: 1px solid #82aaa4;
  border-radius: 50%;
  background: transparent;
  color: white;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1;
}
.wv-matrix-remove:hover { background: #ffffff20; }
.wv-matrix-remove:focus-visible { outline-color: white; outline-offset: 2px; }
.wv-matrix small {
  display: block;
  margin-block-start: .25rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.5;
}
.wv-matrix thead small { color: #e2f5ef; }
.wv-comparison-grade { display: block; font-weight: 500; }
.wv-comparison-source {
  display: block;
  width: fit-content;
  max-width: 100%;
  color: var(--teal-deep);
  font-size: .81rem;
  text-underline-offset: .16em;
}
.wv-comparison-source:not(:first-child) { margin-block-start: .35rem; }
.wv-comparison-partners {
  display: grid;
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wv-comparison-partners li + li {
  padding-block-start: .65rem;
  border-block-start: 1px solid var(--line);
}

.wv-matrix-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .25rem .65rem;
  margin-bottom: .45rem;
}
.wv-matrix-hint,
.wv-comparison-caption {
  color: var(--muted);
  font-size: .79rem;
  line-height: 1.45;
}
.wv-matrix-nav-buttons { display: flex; gap: .25rem; }
.wv-matrix-nav-buttons button {
  min-width: 38px;
  min-height: 38px;
  padding: .25rem .5rem;
  border: 1px solid #a9c0b9;
  border-radius: 7px;
  background: var(--paper);
  color: var(--teal-deep);
  font-size: .78rem;
  font-weight: 500;
}
.wv-matrix-nav-buttons button:enabled:hover { background: var(--wash); }
.wv-matrix-nav-buttons button:disabled { opacity: .55; }
.wv-comparison-caption { margin: .6rem .1rem 0; }
.wv-comparison-questions {
  margin-top: .85rem;
  border-block: 1px solid var(--line);
  color: var(--text);
}
.wv-comparison-questions summary {
  padding: .8rem .2rem;
  color: var(--teal-deep);
  font-size: .94rem;
  font-weight: 600;
  cursor: pointer;
}
.wv-comparison-questions ul {
  display: grid;
  gap: .5rem;
  margin: 0 0 .9rem;
  padding-left: 1.5rem;
  font-size: .9rem;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .wv-compare { padding: .8rem; }
  .wv-compare-head,
  .wv-compare-context,
  .wv-compare-tools { gap: .4rem; }
  .wv-compare-head {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    row-gap: .15rem;
    align-items: center;
  }
  .wv-compare-head > div { display: contents; }
  .wv-compare-head h2 { font-size: clamp(1.15rem, 5.7vw, 1.45rem); }
  .wv-compare-head [data-compare-count] { grid-column: 1 / -1; margin: 0; }
  .wv-compare-head [data-close-compare] { grid-area: 1 / 2; min-height: 38px; }
  .wv-compare-context { margin-block: .4rem .55rem; padding-bottom: .5rem; }
  .wv-compare-context .wv-chat-action { max-width: 59%; padding-inline: .55rem; font-size: .8rem; }
  .wv-compare-tools { margin-bottom: .45rem; }
  .wv-aspect-toggle button { flex: none; padding-inline: .5rem; font-size: .79rem; white-space: nowrap; }
  .wv-compare-tools [data-copy-comparison] { padding-inline: .55rem; font-size: .79rem; }
  .wv-copy-remainder { display: none; }
}

@media (max-width: 370px) {
  .wv-compare-context .wv-chat-action { max-width: 55%; }
  .wv-aspect-toggle { padding: 2px; }
  .wv-aspect-toggle button { padding-inline: .22rem; }
  .wv-compare-tools [data-copy-comparison] { padding-inline: .3rem; }
}

/* Each comparison scrolls sideways only when its own columns need the space. */
@container wahana-comparison (width < 37.25rem) {
  .wv-matrix {
    --aspect-width: 6.125rem;
    --cell-block: .75rem;
    --cell-inline: .65rem;
    font-size: .87rem;
  }
  .wv-matrix tbody th { font-size: .8rem; }
  .wv-matrix small { font-size: .75rem; }
  .wv-matrix:not([data-choice-count="1"]) {
    min-width: calc(6.125rem + 10.375rem * var(--choice-count));
  }
  .wv-matrix-scroll:has(.wv-matrix[data-choice-count="3"]) {
    overflow: auto;
    max-block-size: 72svh;
    scroll-padding-inline-start: 6.125rem;
  }
}
@container wahana-comparison (width < 26.875rem) {
  .wv-matrix-scroll:has(.wv-matrix[data-choice-count="2"]) {
    overflow: auto;
    max-block-size: 72svh;
    scroll-padding-inline-start: 6.125rem;
  }
}
