/* Shared components. Screen-specific rules go in screens.css. */

/* ---------- Icons ---------- */

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 1em;
  height: 1em;
}

/* ---------- Screen headers ---------- */

.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) 0 var(--s4);
}

.screen-head h1 {
  font-size: var(--text-3xl);
  font-stretch: var(--extra-wide);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.screen-head .lede {
  margin-top: var(--s2);
  color: var(--ink-muted);
}

.back-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 56px;
  margin: calc(var(--s4) * -1) calc(var(--gutter) * -1) var(--s4);
  padding: var(--s2) var(--s2);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.back-head h1 {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-lg);
  font-stretch: 105%;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 900px) {
  .back-head {
    top: var(--topbar-h);
    margin: calc(var(--s6) * -1) 0 var(--s4);
    padding: var(--s3) 0;
  }

  .screen.no-tabs .back-head {
    top: 0;
  }
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.section-head p {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 0 var(--s5);
  border: 1.5px solid transparent;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 640;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: var(--on-ink);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--ink) 88%, var(--paper));
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--field-border);
}

.btn-secondary:hover {
  border-color: var(--ink);
}

.btn-ghost:hover {
  background: var(--sunken);
}

.btn-accent {
  background: var(--accent-fill);
  color: var(--on-accent-fill);
}

.btn-accent:hover {
  background: color-mix(in srgb, var(--accent-fill) 88%, var(--ink));
}

.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--s3);
  font-size: var(--text-sm);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn[aria-busy="true"] {
  color: transparent;
  pointer-events: none;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: var(--on-ink) var(--on-ink) transparent transparent;
  animation: spin 0.7s linear infinite;
}

.btn-secondary[aria-busy="true"]::after,
.btn-ghost[aria-busy="true"]::after,
.btn-danger[aria-busy="true"]::after {
  border-color: var(--ink) var(--ink) transparent transparent;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--sunken);
}

.icon-btn .icon {
  width: 22px;
  height: 22px;
}

.icon-btn.is-on {
  color: var(--accent-ink);
}

.link-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.sticky-actions {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s2));
  z-index: 15;
  display: flex;
  gap: var(--s2);
  padding: var(--s3);
  margin: var(--s4) calc(var(--s3) * -1) 0;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--r-tile);
}

.screen.no-tabs .sticky-actions {
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s2));
}

.sticky-actions > .btn {
  flex: 1 1 0;
}

@media (min-width: 900px) {
  .sticky-actions {
    bottom: var(--s4);
  }
}

/* ---------- Chips and segmented controls ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: 36px;
  padding: 0 var(--s4);
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 560;
  white-space: nowrap;
  text-decoration: none;
}

.chip:hover {
  border-color: var(--field-border);
}

.chip[aria-pressed="true"],
.chip[aria-selected="true"],
.chip.is-selected,
input:checked + .chip {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

input:focus-visible + .chip {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.chip .count {
  font-stretch: var(--condensed);
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.chip-remove {
  margin-right: calc(var(--s2) * -1);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-control);
  background: var(--sunken);
}

.segmented > label,
.segmented > button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 var(--s4);
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segmented > label:has(input:checked),
.segmented > button[aria-pressed="true"],
.segmented > button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(28 32 66 / 0.12);
}

.segmented > label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

/* ---------- Product tiles and the label strip ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s5) var(--s3);
}

@media (min-width: 640px) {
  .tile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1000px) {
  .tile-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s6) var(--s4);
  }
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tile-link {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  border-radius: var(--r-tile);
}

.tile-link:focus-visible {
  outline-offset: 3px;
}

.media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-tile);
  background: var(--studio);
}

.media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media.is-photo img {
  object-fit: cover;
}

.media-wide {
  aspect-ratio: 4 / 3;
}

.media-tag {
  position: absolute;
  left: var(--s2);
  bottom: var(--s2);
  padding: 1px var(--s2);
  border-radius: var(--r-label);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  font-stretch: 84%;
}

.media-corner {
  position: absolute;
  top: var(--s2);
  right: var(--s2);
}

.media-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--ink-faint);
}

.media-placeholder .icon {
  width: 40%;
  height: 40%;
  stroke-width: 1.2;
}

/* The label strip reads like a shoebox end-label: text panel plus a block on the right that
   holds the one number that matters for that context (size, target price, price). */
.label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: var(--s2);
  border: 1.5px solid var(--ink);
  border-radius: var(--r-label);
  background: var(--surface);
  overflow: hidden;
}

.label-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: var(--s2) var(--s2) var(--s2) var(--s3);
}

.label-brand {
  font-size: var(--text-xs);
  font-weight: 650;
  font-stretch: var(--condensed);
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

.label-name {
  font-size: var(--text-md);
  font-weight: 680;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.label-variant {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-code {
  font-size: var(--text-xs);
  font-weight: 600;
  font-stretch: var(--condensed);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: var(--s2);
  background: var(--ink);
  color: var(--on-ink);
  text-align: center;
  line-height: 1.05;
}

.label-block-top {
  font-size: var(--text-xs);
  font-weight: 600;
  font-stretch: var(--condensed);
  opacity: 0.85;
}

.label-block-main {
  font-size: var(--text-xl);
  font-weight: 760;
  font-stretch: var(--condensed);
  font-variant-numeric: tabular-nums;
}

.label-block-main.is-long {
  font-size: var(--text-md);
}

.label-block.is-empty {
  background: var(--sunken);
  color: var(--ink-muted);
}

.label-stamps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin-top: var(--s1);
}

/* Wishlist: dashed accent outline, because it isn't yours yet. */
.label.is-wishlist {
  border-style: dashed;
  border-color: var(--accent);
}

.label.is-wishlist .label-block {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Suggestions: plain label, price in the block. */
.label.is-suggestion {
  border-color: var(--line);
}

.label.is-suggestion .label-block {
  background: var(--sunken);
  color: var(--ink);
}

.label.is-archived {
  opacity: 0.6;
}

/* ---------- Stamps and badges ---------- */

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: var(--r-label);
  font-size: var(--text-xs);
  font-weight: 620;
  font-stretch: 86%;
  line-height: 1.5;
  white-space: nowrap;
}

.stamp .icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.4;
}

.stamp-confirmed { color: var(--ink); }
.stamp-code { color: var(--ok); }
.stamp-unsure { color: var(--warn); }
.stamp-custom { color: var(--ink-muted); border-style: dashed; }
.stamp-review { color: var(--danger); }
.stamp-similar { color: var(--warn); border-style: dashed; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 0 var(--s2);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 640;
  white-space: nowrap;
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge-owned {
  background: var(--ink);
  color: var(--on-ink);
}

.badge-wish {
  border: 1.5px dashed var(--accent);
  color: var(--accent-ink);
}

.badge-demo {
  background: var(--info-soft);
  color: var(--info);
}

.badge-affiliate {
  border: 1px solid var(--field-border);
  color: var(--ink-muted);
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--sunken); color: var(--ink-muted); }

/* A long badge wraps instead of widening the page on a narrow phone, which would also push
   fixed sheets past the screen edge. */
.badge-wrap {
  max-width: 100%;
  white-space: normal;
  padding-block: 2px;
  line-height: 1.35;
}
.badge-human { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Notices and states ---------- */

.notice {
  display: flex;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-control);
  background: var(--sunken);
  color: var(--ink);
  font-size: var(--text-sm);
}

.notice > .icon {
  margin-top: 2px;
  width: 18px;
  height: 18px;
}

.notice strong {
  font-weight: 680;
}

.notice-info { background: var(--info-soft); }
.notice-info > .icon { color: var(--info); }
.notice-warn { background: var(--warn-soft); }
.notice-warn > .icon { color: var(--warn); }
.notice-danger { background: var(--danger-soft); }
.notice-danger > .icon { color: var(--danger); }
.notice-ok { background: var(--ok-soft); }
.notice-ok > .icon { color: var(--ok); }
.notice-demo { background: var(--info-soft); }
.notice-demo > .icon { color: var(--info); }

.state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s8) 0;
  max-width: 34rem;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--r-tile);
  background: var(--studio);
  color: var(--ink-muted);
}

.state-icon .icon {
  width: 28px;
  height: 28px;
}

.state h2 {
  font-size: var(--text-xl);
}

.state p {
  color: var(--ink-muted);
}

.state-danger .state-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.skeleton {
  border-radius: var(--r-tile);
  background: var(--sunken);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: var(--sunken);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-width: 0;
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 640;
}

.field-label .optional {
  color: var(--ink-muted);
  font-weight: 450;
}

.field-hint {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.field-error {
  font-size: var(--text-sm);
  color: var(--danger);
  font-weight: 560;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid var(--field-border);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-md);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868b9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-faint);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--ink);
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 0;
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-prefix {
  position: relative;
}

.input-prefix > span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.input-prefix .input {
  padding-left: 26px;
}

.search-field {
  position: relative;
}

.search-field .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.search-field .input {
  padding-left: 40px;
}

.form-grid {
  display: grid;
  gap: var(--s4);
}

@media (min-width: 640px) {
  .form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Radio and checkbox cards */
.choice {
  position: relative;
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border: 1.5px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  cursor: pointer;
}

.choice:hover {
  border-color: var(--field-border);
}

.choice input {
  margin: 3px 0 0;
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
  flex: 0 0 auto;
}

.choice:has(input:checked) {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.choice:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.choice-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.choice-title {
  font-weight: 640;
}

.choice-hint {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--ink);
}

.check:has(input:disabled) {
  color: var(--ink-muted);
  cursor: not-allowed;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  min-height: 52px;
  cursor: pointer;
}

.switch input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--field-border);
  transition: background-color 0.15s;
  cursor: pointer;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s var(--ease);
}

.switch input:checked {
  background: var(--ink);
}

.switch input:checked::after {
  transform: translateX(18px);
}

/* ---------- Lists, facts, panels ---------- */

.panel {
  padding: var(--s4);
  border-radius: var(--r-tile);
  background: var(--surface);
}

.panel-flat {
  padding: var(--s4) 0;
  border-top: 1px solid var(--line);
}

.list {
  list-style: none;
  border-radius: var(--r-tile);
  background: var(--surface);
  overflow: hidden;
}

.list > li + li {
  border-top: 1px solid var(--line);
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 56px;
  padding: var(--s3) var(--s4);
  color: inherit;
  text-decoration: none;
}

a.list-item:hover,
button.list-item:hover {
  background: var(--sunken);
}

button.list-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.list-item .grow {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.list-item .grow > :first-child {
  font-weight: 620;
}

.list-item .grow > :not(:first-child) {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.list-thumb {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: var(--studio);
}

.list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.facts {
  display: grid;
  grid-template-columns: minmax(7.5rem, auto) minmax(0, 1fr);
  gap: var(--s2) var(--s4);
  font-size: var(--text-sm);
}

.facts dt {
  color: var(--ink-muted);
}

.facts dd {
  font-weight: 560;
  overflow-wrap: anywhere;
}

.facts .unknown {
  color: var(--ink-muted);
  font-weight: 450;
  font-style: italic;
}

.facts-source {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.evidence {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  font-size: var(--text-sm);
}

.evidence li {
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
}

.evidence .icon {
  margin-top: 2px;
  width: 16px;
  height: 16px;
}

.evidence .is-support .icon { color: var(--ok); }
.evidence .is-conflict .icon { color: var(--danger); }
.evidence .is-caution .icon { color: var(--warn); }
.evidence .is-neutral .icon { color: var(--ink-muted); }

/* ---------- Offers ---------- */

.offer {
  display: grid;
  gap: var(--s2);
  padding: var(--s4);
  border-radius: var(--r-tile);
  background: var(--surface);
  border: 1.5px solid transparent;
}

.offer.is-lowest {
  border-color: var(--ink);
}

.offer.is-unavailable,
.offer.is-stale {
  background: var(--sunken);
}

.offer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
}

.offer-retailer {
  font-weight: 680;
}

.offer-price {
  font-size: var(--text-xl);
  font-weight: 760;
  font-stretch: var(--condensed);
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.1;
}

.offer-total {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-align: right;
}

.offer-lines {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px var(--s3);
  font-size: var(--text-sm);
}

.offer-lines dt {
  color: var(--ink-muted);
}

.offer-lines .unknown {
  color: var(--warn);
  font-weight: 560;
}

.disclosure {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  padding: var(--s3) var(--s4);
  border-left: 3px solid var(--field-border);
}

/* ---------- Recommendation cards ---------- */

.rec {
  display: grid;
  grid-template-columns: minmax(0, 132px) minmax(0, 1fr);
  gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-tile);
  background: var(--surface);
}

.rec .media {
  border-radius: 10px;
}

.rec .label {
  margin-top: 0;
}

.rec-body {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}

.rec-why {
  font-size: var(--text-sm);
}

.rec-related {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
}

.related-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 2px var(--s2) 2px 2px;
  border-radius: var(--r-pill);
  background: var(--sunken);
  font-size: var(--text-xs);
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.related-chip img,
.related-chip .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--studio);
  flex: 0 0 auto;
}

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

.rec-price {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.rec-price strong {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rec-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
}

@media (min-width: 640px) {
  .rec {
    grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
    gap: var(--s4);
    padding: var(--s4);
  }

  .rec-actions {
    grid-column: 2;
  }
}

.kind-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--ink-muted);
}

.kind-tag .icon {
  width: 14px;
  height: 14px;
}

/* ---------- Dialog / bottom sheet ---------- */

.sheet {
  width: 100%;
  max-width: 100%;
  max-height: min(92dvh, 760px);
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-in 0.24s var(--ease);
}

.sheet::backdrop {
  background: var(--scrim);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s2) var(--s2) var(--s5);
}

.sheet-head h2 {
  font-size: var(--text-lg);
}

.sheet-body {
  padding: 0 var(--s5) calc(var(--s6) + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

@keyframes sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

@media (min-width: 640px) {
  .sheet {
    max-width: 560px;
    margin: auto;
    border-radius: var(--r-sheet);
  }
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s3));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(calc(100% - 2 * var(--gutter)), 480px);
  pointer-events: none;
}

body.hide-tabs .toasts {
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s4));
}

@media (min-width: 900px) {
  .toasts {
    bottom: var(--s6);
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-control);
  background: var(--ink);
  color: var(--on-ink);
  font-size: var(--text-sm);
  font-weight: 560;
  box-shadow: var(--shadow-lift);
  pointer-events: auto;
  animation: sheet-in 0.2s var(--ease);
}

.toast .grow {
  min-width: 0;
}

.toast button {
  border: 0;
  background: none;
  color: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  min-height: 32px;
}

.toast-danger {
  background: var(--danger);
  color: #fff;
}

/* ---------- Progress ---------- */

.progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--sunken);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: inherit;
  transition: width 0.3s var(--ease);
}

.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.steps li {
  display: flex;
  align-items: center;
  gap: var(--s3);
  color: var(--ink-muted);
}

.steps .step-dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--field-border);
  flex: 0 0 auto;
}

.steps .step-dot .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.6;
}

.steps .is-done {
  color: var(--ink);
}

.steps .is-done .step-dot {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.steps .is-active {
  color: var(--ink);
  font-weight: 640;
}

.steps .is-active .step-dot {
  border-color: var(--ink);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}

/* ---------- In-screen tabs ---------- */

.tabs {
  display: flex;
  gap: var(--s1);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs > a,
.tabs > button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 var(--s3);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 620;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.tabs > [aria-selected="true"],
.tabs > [aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------- Tables (admin, comparisons) ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-tile);
  background: var(--surface);
}

.table {
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--s3) var(--s4);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.table th {
  font-weight: 650;
  color: var(--ink-muted);
  white-space: nowrap;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table .num {
  text-align: right;
}

/* ---------- Misc ---------- */

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
  vertical-align: -2px;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: var(--s3);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1 1 auto;
  border-top: 1px solid var(--line);
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 750;
  font-stretch: 90%;
  flex: 0 0 auto;
}

.demo-note {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--text-xs);
  color: var(--info);
  font-weight: 600;
}

.demo-note .icon {
  width: 14px;
  height: 14px;
}

/* Muted badges sit on the sunken background of stale and unavailable offers. */
.offer.is-stale .badge-muted,
.offer.is-unavailable .badge-muted {
  background: var(--surface);
}

/* One-tap helpers inside fields keep their natural width. */
.field > .chip,
.field > .link-btn {
  align-self: flex-start;
}

/* ---------- Store results (online stores through the local server) ---------- */

/* A hot-linked store image over a placeholder: if the image fails, it is hidden and the
   placeholder shows (ui/web-product.js bindRemoteImages). */
.web-img {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--ink-faint);
}

.web-img > .icon {
  width: 44%;
  height: 44%;
  stroke-width: 1.3;
}

.web-img > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--studio);
}

.web-thumb {
  width: 56px;
  height: 56px;
  color: var(--ink-muted);
}

.web-thumb > .icon {
  width: 24px;
  height: 24px;
}

.web-row {
  align-items: center;
}

.web-row-title {
  overflow-wrap: anywhere;
}

.web-row .web-row-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.web-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--s3);
}

.web-price {
  color: var(--ink);
  font-weight: 680;
  font-stretch: 84%;
  font-variant-numeric: tabular-nums;
}

.web-host,
.web-snippet {
  overflow-wrap: anywhere;
}

.web-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.web-list-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Result lists inside a panel (the match screen) need an edge of their own. */
.panel .web-lists .list {
  border: 1px solid var(--line);
}

.web-loading {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-tile);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 560;
}

.web-spinner {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  border-color: var(--ink) var(--ink) transparent transparent;
  animation: spin 0.7s linear infinite;
}

.web-preview {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--s4);
  align-items: start;
  padding: var(--s3);
  border-radius: var(--r-tile);
  background: var(--surface);
}

.web-preview-img {
  border-radius: 10px;
}

.web-preview-text {
  min-width: 0;
}

@media (min-width: 640px) {
  .web-preview {
    grid-template-columns: 120px minmax(0, 1fr);
  }
}

/* Radio chips (the save form's "What is it?"); the form's own wide gap isn't inherited. */
.web-category {
  --gap: var(--s2);
}

.chip-choice {
  position: relative;
}

.web-seen {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s1);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-control);
  background: var(--surface);
}

.web-seen p {
  overflow-wrap: anywhere;
}

.web-seen .link-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  overflow-wrap: anywhere;
}
