.table-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  min-height: 32px;
  margin: 0 0 12px;
  position: relative;
  z-index: 1;
}

.reset-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.reset-btn:hover,
.reset-btn:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.reset-btn[hidden] { display: none; }

.picker-table {
  width: 100%;
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  table-layout: fixed;
}

.picker-table th,
.picker-table td {
  text-align: center;
}

.picker-table th.col-layer,
.picker-table th.col-selection,
.picker-table td:first-child,
.picker-table td:nth-child(2) {
  text-align: left;
}

.picker-table thead th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 14px 20px;
  background: #f7f7f5;
}

:root[data-theme="dark"] .picker-table thead th {
  background: #1f1f1e;
}

.col-layer      { width: 26%; }
.col-selection  { width: 16%; }
.col-cost       { width: 9%; }
.col-source     { width: 8%; }
.col-complexity { width: 9%; }
.col-provider   { width: 8%; }
.col-keyspecs   { width: 12%; }
.col-website    { width: 12%; }

.picker-table td:first-child {
  white-space: nowrap;
}

.placeholder-cell {
  color: var(--muted);
  text-align: center;
}

.cost-preview {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.configure-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.configure-btn:hover,
.configure-btn:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  outline: none;
}

.picker-table td {
  padding: 18px 20px;
  vertical-align: middle;
}

.layer-name {
  font-weight: 600;
}

.layer-optional {
  margin-left: 6px;
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}

.layer-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.layer-info-btn:hover,
.layer-info-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--text);
}

.layer-info-btn:focus-visible {
  outline: 2px solid var(--accent, #6aa9ff);
  outline-offset: 2px;
}

/* Layer info reuses the .browse-detail-* product modal styles but with a
   simpler single-column body and a smaller panel. */
.browse-detail-panel.layer-info-panel {
  width: min(560px, 100%);
  height: auto;
  max-height: 80vh;
}

.browse-detail-body.layer-info-body-panel {
  display: block;
  padding: 22px;
  overflow: auto;
}

.layer-info-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
}

.selection-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.selection-list {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.selection-name-wrap {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.selection-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.selection-cell:hover .selection-add,
.selection-list:focus-within .selection-add,
.selection-add:focus-visible {
  opacity: 1;
}

.selection-add:hover,
.selection-add:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.selection-name {
  background: none;
  border: none;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.selection-name:hover,
.selection-name:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.selection-remove {
  margin-left: 0;
  width: 0;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  overflow: hidden;
  transform: translateX(-4px);
  transition: width 0.18s ease, margin-left 0.18s ease,
              opacity 0.15s ease, transform 0.18s ease,
              color 0.12s ease;
}

.selection-name-wrap:hover .selection-remove,
.selection-name-wrap:focus-within .selection-remove {
  width: 22px;
  margin-left: 6px;
  opacity: 1;
  transform: translateX(0);
}

.selection-remove:hover,
.selection-remove:focus-visible {
  color: #a3382c;
  outline: none;
}

.website-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}

.website-link:hover {
  text-decoration: underline;
}

/* ── Mobile (≤ 720px) ─────────────────────────────────────────────
   Flip the 8-column table into stacked layer cards. Each <tr> is a
   card; the layer-name <td> is its header, selection-cell is the
   prominent body, and the remaining cells become labeled key/value
   rows below (label comes from each cell's col-* class via CSS).    */
@media (max-width: 720px) {
  .picker-table,
  .picker-table tbody,
  .picker-table tr,
  .picker-table td {
    display: block;
    width: auto;
  }

  .picker-table {
    background: transparent;
    table-layout: auto;
  }

  /* Header row only makes sense for the table layout — hide visually
     in card mode but keep it accessible. */
  .picker-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .picker-table tr {
    margin: 0 0 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }

  .picker-table td {
    padding: 6px 0;
    text-align: left;
    border: 0;
    vertical-align: middle;
  }

  /* Layer name = card header, on its own row at the top */
  .picker-table td.col-layer {
    white-space: normal;
    padding: 0 0 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }

  .picker-table td.col-layer .layer-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
  }

  .picker-table td.col-layer .layer-optional {
    font-size: 11px;
    color: var(--muted);
  }

  /* Selection cell is the prominent body (no label prefix). */
  .picker-table td.col-selection {
    padding: 4px 0 10px;
    font-size: 15px;
  }

  .picker-table td.col-selection .choose-btn {
    display: inline-flex;
    padding: 8px 14px;
    font-size: 14px;
  }

  /* The remaining attribute cells: show a small label : value row.
     Empty placeholder cells are hidden so cards stay compact. */
  .picker-table td.col-cost,
  .picker-table td.col-source,
  .picker-table td.col-complexity,
  .picker-table td.col-provider,
  .picker-table td.col-keyspecs,
  .picker-table td.col-website {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    font-size: 13px;
    border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  }

  .picker-table td.placeholder-cell {
    display: none;
  }

  .picker-table td.col-cost::before,
  .picker-table td.col-source::before,
  .picker-table td.col-complexity::before,
  .picker-table td.col-provider::before,
  .picker-table td.col-keyspecs::before,
  .picker-table td.col-website::before {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }

  .picker-table td.col-cost::before      { content: "Cost"; }
  .picker-table td.col-source::before    { content: "Source"; }
  .picker-table td.col-complexity::before{ content: "Setup"; }
  .picker-table td.col-provider::before  { content: "Provider"; }
  .picker-table td.col-keyspecs::before  { content: "Key specs"; }
  .picker-table td.col-website::before   { content: "Where"; }

  .picker-table td.col-website .website-link {
    display: inline-block;
    text-align: right;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* Selection list: stack pills, wrap freely, no hover-only reveal. */
  .selection-cell {
    gap: 8px;
  }

  .selection-list {
    gap: 6px 10px;
  }

  .selection-add {
    opacity: 0.7;
  }

  .selection-name-wrap .selection-remove {
    width: 22px;
    margin-left: 6px;
    opacity: 0.7;
    transform: translateX(0);
  }

  .table-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }

  /* Match Reset to the rest of the toolbar pills on mobile. */
  .reset-btn {
    height: 34px;
    padding: 0 14px;
    border-radius: 10px;
  }
}

@media (max-width: 480px) {
  .picker-table tr { padding: 12px 14px; }
}
