:root {
  --background: #f4f5f1;
  --surface: #fffdf4;
  --surface-soft: #f7f4e8;
  --text: #1f2924;
  --muted: #667269;
  --border: #cfc8ad;
  --accent: #476f56;
  --accent-strong: #31513e;
  --positive: #dceee2;
  --positive-text: #245337;
  --missing: #fff3ce;
  --missing-text: #6a4d12;
  --contradiction: #f7d8d5;
  --contradiction-text: #7b2d28;
  --focus: #1f6feb;
  --shadow: 0 8px 18px rgba(74, 63, 42, 0.12);
  --font-body: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: Georgia, "Times New Roman", Times, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
.choice,
.comparison-differing-toggle,
.dot-picker-dropdown summary,
.single-picker-dropdown summary,
.multi-text-picker-dropdown summary {
  -webkit-user-select: none;
  user-select: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  width: min(1410px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fbfcf8 0%, var(--background) 100%);
}

.header-content {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 160px;
  column-gap: 16px;
  row-gap: 4px;
  align-items: center;
  text-align: center;
}

.eyebrow {
  justify-self: start;
  margin: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-save-button {
  grid-column: 3;
  justify-self: end;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.15;
}

h1 {
  grid-column: 2;
  max-width: none;
  margin: 0 auto;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  white-space: nowrap;
}

h2 {
  font-size: 1.25rem;
}

#mushroom-heading {
  font-size: 1.42rem;
}

h3 {
  font-size: 1rem;
}

.intro {
  grid-column: 2;
  max-width: 740px;
  margin: 2px auto 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.source-note {
  grid-column: 3;
  justify-self: end;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.source-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inline-info-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sources-dialog {
  width: min(640px, calc(100% - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.sources-dialog::backdrop {
  background: rgba(31, 41, 36, 0.34);
}

.sources-dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.sources-dialog p {
  margin: 6px 0;
}

.dialog-close-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
}

.source-reference {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 12px;
}

.source-reference h3 {
  margin-bottom: 6px;
}

.app-shell {
  --top-card-height: min(84vh, 800px);
  display: grid;
  grid-template-columns: minmax(400px, 640px) minmax(240px, 280px) minmax(280px, 1fr);
  gap: 24px;
  align-items: stretch;
  padding: 24px 0 42px;
}

.panel.mushroom-panel {
  align-self: start;
  margin-top: 0;
  padding: 12px;
  max-height: var(--top-card-height);
  overflow: auto;
}

.mushroom-panel .section-head {
  margin-bottom: 4px;
}

.mushroom-panel .observation-heading {
  flex-direction: row;
  align-items: center;
}

.observation-reset-button,
.observation-view-toggle {
  flex: 0 0 auto;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
}

.observation-reset-button:hover,
.observation-view-toggle:hover {
  border-color: var(--accent-strong);
}

.observation-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  margin-left: auto;
}

#mushroom-image {
  overflow-x: auto;
}

#mushroom-color-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 6px;
}

.mushroom-options-dialog {
  width: fit-content;
  max-width: min(640px, calc(100% - 32px));
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(74, 63, 42, 0.24);
}

.mushroom-clear-button {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #777;
  font-size: 1.2rem;
  line-height: 1;
}

.mushroom-clear-button:hover {
  color: #333;
  text-shadow: 0.4px 0 currentColor, -0.4px 0 currentColor;
}

.mushroom-extra-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0;
  margin-top: 4px;
}

.mushroom-filter-button {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  padding: 4px 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.8rem;
  white-space: nowrap;
}

.mushroom-filter-button > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mushroom-filter-button.is-active {
  border-color: var(--accent);
  background: #e4eee7;
}

.mushroom-filter-button:hover {
  border-color: var(--accent-strong);
}

.mushroom-filter-value {
  font-weight: 600;
}


.app-shell > *,
.panel,
.sticky-results,
.sticky-details {
  min-width: 0;
}

.panel,
.sticky-results {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel,
.sticky-results,
.details-panel {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(246, 241, 222, 0.18));
}

.panel {
  padding: 22px;
}


.sticky-results,
.sticky-details {
  position: sticky;
  top: 16px;
}

.sticky-details {
  position: static;
  top: auto;
}

.sticky-results {
  max-height: var(--top-card-height);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.details-panel {
  max-height: var(--top-card-height);
  overflow: hidden;
  padding: 18px;
}

.details-panel.is-empty {
  align-self: start;
  max-height: none;
  overflow: visible;
}

.sticky-details {
  max-height: calc(var(--top-card-height) - 36px);
  overflow: auto;
}

.details-panel.is-empty .sticky-details {
  max-height: none;
  overflow: visible;
}

.details-panel.is-empty .species-details {
  min-height: 0;
}


.comparison-panel,
.all-species-panel {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-head p,
.muted {
  margin: 6px 0 0;
  color: var(--muted);
}

.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.section-toggle::before {
  content: "";
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  margin: 0 3px;
  border-right: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: rotate(45deg) translateY(-2px);
}

.section-toggle[aria-expanded="false"]::before {
  transform: rotate(-45deg);
}

.collapsible-section.is-collapsed .collapsible-content {
  display: none;
}

.collapsible-section.is-collapsed {
  align-self: start;
  max-height: none;
}

.collapsible-section.is-collapsed .section-head {
  margin-bottom: 0;
}

.details-panel > .sticky-details {
  max-height: calc(var(--top-card-height) - 90px);
}

.secondary-button,
.reset-group,
.species-button {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
}

.secondary-button,
.reset-group {
  min-height: 40px;
  padding: 8px 12px;
  white-space: nowrap;
}

.secondary-button:hover,
.reset-group:hover,
.species-button:hover {
  border-color: var(--accent);
}

.filter-form {
  display: grid;
  gap: 7px;
}

.filter-group {
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: start;
  min-width: 0;
  min-inline-size: 0;
  margin: 0;
  padding: 2px 0 9px;
  border: 0;
  border-bottom: 1px solid var(--border);
}

.filter-group:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.filter-group legend {
  padding: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.filter-title {
  grid-column: 1;
  padding-top: 5px;
}

.options-grid {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  min-width: 0;
}

.filter-group .reset-group {
  grid-column: 3;
  justify-self: end;
  min-width: 28px;
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 1px;
  font-size: 1rem;
  line-height: 1;
}

@media (max-width: 1280px) {
  .filter-group {
    grid-template-columns: minmax(125px, 165px) minmax(0, 1fr) auto;
  }
}

.choice {
  position: relative;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice > span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--surface-soft);
  font-size: 0.92rem;
}

.choice-with-swatch > span {
  min-width: 28px;
  min-height: 28px;
  justify-content: center;
  border-color: color-mix(in srgb, var(--choice-color) 72%, #4a3f2a);
  border-radius: 999px;
  padding: 3px 6px;
  background: color-mix(in srgb, var(--choice-color) 84%, var(--surface));
  color: var(--choice-text-color);
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.45), inset 0 -1px 2px rgba(74, 63, 42, 0.12);
  filter: saturate(1.08);
  opacity: 0.96;
}

.choice input:checked + span {
  border-color: var(--accent);
  background: #e4eee7;
  color: var(--accent-strong);
  font-weight: 700;
}

.choice-with-swatch input:checked + span {
  border-color: rgba(74, 63, 42, 0.82);
  background: var(--choice-color);
  color: var(--choice-text-color);
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px rgba(40, 34, 22, 0.72), inset 0 1px 2px rgba(255, 255, 255, 0.38), inset 0 -1px 2px rgba(74, 63, 42, 0.2);
  filter: none;
  opacity: 1;
}

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

.error-message {
  margin-bottom: 16px;
  border: 1px solid var(--contradiction-text);
  border-radius: 8px;
  padding: 12px;
  background: var(--contradiction);
  color: var(--contradiction-text);
}

.result-counts {
  margin: 12px 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-weight: 650;
  text-align: center;
}

.result-counts strong {
  display: block;
  color: var(--text);
  font-size: 1.35rem;
}

.search-label {
  margin-bottom: 6px;
  font-weight: 700;
}

.name-search-wrap {
  position: relative;
}

#name-search {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.result-sort-row {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.sort-name-button {
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  background: #d9f2e4;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
}

.sort-name-button:hover {
  border-color: var(--accent);
  background: #c8ecd7;
}

.compact-results {
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.species-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  margin-bottom: 5px;
  padding: 7px 8px;
  text-align: left;
}

.species-button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.compact-result-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
}

.compact-result-row .species-button {
  margin-bottom: 0;
}

.comparison .species-exclusion-cell {
  width: 1%;
  padding: 5px 3px;
  white-space: nowrap;
  text-align: center;
}

.species-exclusion-button {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #59635c;
  font-size: 17px;
  line-height: 1;
}

.species-exclusion-button:hover {
  background: var(--surface-soft);
  border-color: var(--border);
}

.species-exclusion-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.comparison tr.is-manually-excluded > td,
.compact-result-row.is-manually-excluded .species-button {
  background: #f0f0eb;
  color: #59635c;
}

.is-manually-excluded .cell-values,
.is-manually-excluded .scientific-cell,
.is-manually-excluded .scientific-name {
  color: #59635c;
}

.is-manually-excluded .species-name,
.is-manually-excluded .compact-status-cell,
.is-manually-excluded .comparison-cell,
.is-manually-excluded .status-badge {
  font-weight: 400;
}

.comparison .excluded-group-start > td {
  border-top: 2px solid var(--border);
}

.compact-result-row.excluded-group-start {
  border-top: 2px solid var(--border);
  padding-top: 6px;
  margin-top: 6px;
}

.species-name {
  display: block;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 800;
}

.scientific-name {
  display: block;
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  font-family: var(--font-display);
  color: var(--muted);
  font-style: italic;
}

.scientific-cell {
  font-family: var(--font-display);
  color: var(--muted);
  font-style: italic;
}

.status-badge {
  display: inline-flex;
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  justify-self: end;
  margin-top: 0;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-full,
.cell-match {
  background: var(--positive);
  color: var(--positive-text);
}

.status-possible,
.cell-missing {
  background: var(--missing);
  color: var(--missing-text);
}

.cell-contradiction {
  background: var(--contradiction);
  color: var(--contradiction-text);
}

.comparison {
  overflow-x: auto;
}

.comparison table {
  min-width: 620px;
  font-size: 0.86rem;
}

.comparison th,
.comparison td {
  padding: 5px 7px;
}

.comparison-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.custom-comparison-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px 12px;
  max-width: 460px;
  margin-bottom: 16px;
}

.custom-comparison-search > label {
  white-space: nowrap;
}

.custom-comparison-search > .lookalike-suggestions,
.custom-comparison-search > p {
  grid-column: 2;
}

.custom-comparison-search input {
  width: 100%;
  min-width: 0;
}

.custom-comparison-search p:empty {
  display: none;
}

.comparison-remove-cell {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
  white-space: nowrap;
  text-align: center;
}

th.comparison-remove-cell {
  background: var(--surface-soft);
}

.comparison-remove {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #b42318;
  font-size: 1.5rem;
  cursor: pointer;
}

.comparison-remove:hover {
  color: #861b12;
}

.comparison-differing-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.88rem;
}

tr.clickable-row {
  cursor: pointer;
}

tr.clickable-row:hover {
  background: var(--surface-soft);
}

.comparison-cell {
  border-radius: 6px;
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  padding: 2px 5px;
  font-weight: 700;
}

.cell-values {
  display: inline;
  margin-top: 0;
  color: var(--text);
  font-weight: 400;
}

.compact-status-cell {
  font-weight: 800;
}

.all-species-table {
  max-height: 1080px;
  overflow: auto;
}

.species-directory-table {
  min-width: 820px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.species-directory-table th,
.species-directory-table td {
  border-right: 1px solid var(--border);
  padding: 7px 9px;
}

.species-directory-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.species-directory-table thead tr:first-child th {
  top: 0;
}

.species-directory-table thead tr:nth-child(2) th {
  top: 35px;
}

.species-directory-table th:last-child,
.species-directory-table td:last-child {
  border-right: 0;
}

.blank-group-heading {
  background: var(--surface);
}

.koh-group-heading {
  text-align: center;
  color: var(--text);
  font-size: 1.05rem;
}

.sort-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
  text-align: left;
}

.center-heading .sort-button {
  justify-content: center;
  text-align: center;
}

.sort-button::after {
  content: "↕";
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.sort-button[data-direction="asc"]::after {
  content: "↑";
}

.sort-button[data-direction="desc"]::after {
  content: "↓";
}

.marker-cell {
  text-align: center;
}

.value-markers {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.value-marker,
.unknown-marker {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(31, 41, 36, 0.62);
  border-radius: 50%;
  background: var(--marker-color, var(--surface-soft));
}

.no-reaction-marker {
  position: relative;
  background: #d7d8d4;
}

.no-reaction-marker::before,
.no-reaction-marker::after {
  position: absolute;
  width: 13px;
  height: 2px;
  border-radius: 999px;
  background: rgba(102, 114, 105, 0.85);
  content: "";
}

.no-reaction-marker::before {
  transform: rotate(45deg);
}

.no-reaction-marker::after {
  transform: rotate(-45deg);
}

.unknown-marker {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 900;
}

.question-marker {
  background: #eef0ea;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 10px;
}

.details-grid div {
  display: grid;
  grid-template-columns: minmax(94px, 42%) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding: 6px 0;
}

.details-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.details-grid dd {
  margin: 0;
  min-width: 0;
  font-size: 0.9rem;
}

.detail-list {
  margin: 6px 0 10px;
  padding-left: 18px;
  font-size: 0.9rem;
}

.species-details h3 {
  margin-top: 12px;
  font-size: 0.98rem;
}

.species-details > h3:first-child {
  margin-top: 10px;
}

.species-details .scientific-name {
  margin: 2px 0 6px;
}

.species-edit-form {
  display: grid;
  gap: 5px;
}

.species-compact-view {
  display: grid;
  gap: 8px;
}

.empty-details-heading {
  margin-bottom: 8px;
}

.species-edit-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px 14px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.species-name-text {
  grid-column: 1;
  display: grid;
  justify-items: start;
  gap: 2px;
}

.species-name-text strong {
  grid-row: 1;
}

.species-name-text .scientific-name {
  grid-row: 2;
}

.species-edit-name-row strong {
  font-family: var(--font-display);
  font-size: 0.98rem;
}

.species-edit-name-row .scientific-name {
  margin: 0;
  font-size: 0.9rem;
}

.species-compact-name-row {
  margin-bottom: 2px;
}

.compact-section {
  display: grid;
  gap: 5px;
  padding-top: 3px;
}

.compact-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.compact-field-grid {
  display: grid;
  gap: 6px;
}

.compact-field-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-field-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-field {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  border: 1px solid rgba(210, 199, 175, 0.56);
  border-radius: 6px;
  padding: 5px 6px;
  background: rgba(255, 252, 242, 0.54);
}

.compact-field-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-field-value {
  min-width: 0;
  min-height: 18px;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.22;
}

.compact-field-value .value-markers {
  min-height: 18px;
}

.compact-field-value .unknown-marker {
  opacity: 0;
}

.compact-field-description {
  margin: 1px 0 0;
  min-height: 0.82rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.18;
}

.compact-field-with-description .compact-field-value {
  margin-bottom: 1px;
}

.compact-section .detail-list {
  margin: 0;
  font-size: 0.78rem;
}

.editable-compact-section .detail-edit-row-compact {
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  min-width: 0;
  border: 1px solid rgba(210, 199, 175, 0.56);
  border-radius: 6px;
  padding: 5px 6px;
  background: rgba(255, 252, 242, 0.54);
}

.editable-compact-section .detail-edit-row-compact label,
.editable-compact-section .detail-edit-row-compact .detail-control {
  grid-column: 1;
}

.editable-compact-section .detail-edit-row-compact label {
  padding-top: 0;
  overflow: hidden;
  font-size: 0.68rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editable-compact-section .detail-control {
  gap: 2px;
}

.editable-compact-section .dot-picker,
.editable-compact-section .single-picker,
.editable-compact-section .multi-text-picker {
  min-width: 0;
}

.editable-compact-section .dot-picker-with-description {
  grid-template-columns: minmax(0, 1fr) auto;
}

.editable-compact-section .dot-picker-with-description .dot-picker-selected {
  grid-column: 1;
  min-width: 0;
}

.editable-compact-section .dot-picker-with-description .color-description-input {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 24px;
}

.editable-compact-section .dot-picker-with-description .dot-picker-dropdown {
  grid-column: 2;
  grid-row: 1;
}

.compact-images-section {
  padding-top: 8px;
}

.compact-images-section .image-grid {
  margin-top: 0;
}

.compact-empty-images {
  min-height: 96px;
}

.redlist-badge {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 22px;
  border: 1px solid rgba(75, 53, 32, 0.18);
  border-radius: 3px;
  padding: 2px 6px;
  color: #211913;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.redlist-badge-cr {
  background: #b84b4a;
  color: #fff8ef;
}

.redlist-badge-en {
  background: #c95370;
  color: #fff8ef;
}

.redlist-badge-vu {
  background: #d9855f;
  color: #fff8ef;
}

.redlist-badge-nt {
  background: #d9aaa8;
}

.redlist-badge-lc {
  background: #b3c746;
}

.redlist-badge-dd,
.redlist-badge-ne {
  background: #c8c6be;
}

.species-empty-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.species-edit-top-actions {
  grid-column: 3;
  grid-row: 1;
  display: inline-flex;
  gap: 4px;
  align-self: start;
  justify-self: end;
  margin-top: 0;
}

.species-name-badge {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  justify-self: end;
  margin-right: 4px;
  margin-top: 4px;
}

.edit-add-button,
.edit-lock-button,
.edit-save-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: var(--surface-soft);
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
}

.edit-add-button {
  color: #4b3520;
  font-size: 1.35rem;
  font-weight: 800;
}

.edit-lock-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e4eee7;
}

.edit-save-button {
  color: var(--accent-strong);
}

.species-edit-form.is-locked .detail-control input,
.species-edit-form.is-locked .detail-control select,
.species-edit-form.is-locked .detail-control textarea,
.species-edit-form.is-locked .dot-picker-dropdown summary,
.species-edit-form.is-locked .single-picker-dropdown summary,
.species-edit-form.is-locked .multi-text-picker-dropdown summary,
.species-edit-form.is-locked .lookalike-add,
.species-edit-form.is-locked .lookalike-remove {
  cursor: not-allowed;
  opacity: 0.62;
}

.species-edit-form.is-locked .dot-toggle {
  cursor: not-allowed;
}

.detail-edit-row {
  display: grid;
  grid-template-columns: minmax(82px, 35%) minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.detail-edit-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.detail-edit-row-images {
  grid-template-columns: minmax(0, 1fr);
}

.detail-edit-row-images label,
.detail-edit-row-images .detail-control {
  grid-column: 1;
}

.species-edit-name-row + .detail-edit-row {
  border-top: 0;
}

.detail-edit-row label {
  padding-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.detail-control {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.detail-control input,
.detail-control select,
.detail-control textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.8rem;
}

.detail-control input,
.detail-control select {
  min-height: 28px;
  padding: 3px 6px;
}

.detail-control textarea {
  resize: vertical;
  padding: 4px 6px;
  line-height: 1.25;
}

.detail-control select[multiple] {
  min-height: 64px;
}

.detail-marker-preview {
  justify-self: start;
}

.dot-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.dot-picker-with-description {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.dot-picker-with-description .dot-picker-selected {
  min-width: 42px;
}

.dot-picker-with-description .color-description-input {
  min-height: 24px;
  padding: 2px 6px;
  font-size: 0.78rem;
}

.dot-picker-selected {
  min-width: 0;
}

.dot-picker-dropdown {
  position: relative;
  justify-self: end;
}

.dot-picker-dropdown summary {
  cursor: pointer;
  list-style: none;
  border: 0;
  border-radius: 999px;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  color: #4a2f1e;
  font-size: 1rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.dot-picker-dropdown summary::-webkit-details-marker {
  display: none;
}

.dot-picker-dropdown[open] summary {
  color: #3a2416;
}

.dot-picker-dropdown[open] .dot-toggle-group {
  position: absolute;
  right: 0;
  z-index: 5;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dot-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.dot-toggle {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0;
  background: transparent;
}

.dot-toggle .value-marker {
  border-color: rgba(31, 41, 36, 0.62);
  background: var(--marker-color);
  opacity: 1;
  filter: none;
}

.dot-toggle:hover,
.dot-toggle:focus-visible {
  background: var(--surface-soft);
}

.single-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.single-picker-selected {
  min-width: 0;
  color: var(--text);
  font-size: 0.82rem;
}

.single-picker-dropdown {
  position: relative;
  justify-self: end;
}

.single-picker-dropdown summary {
  cursor: pointer;
  list-style: none;
  border: 0;
  border-radius: 999px;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  color: #4a2f1e;
  font-size: 1rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.single-picker-dropdown summary::-webkit-details-marker {
  display: none;
}

.single-picker-dropdown[open] summary {
  color: #3a2416;
}

.single-picker-dropdown[open] .single-picker-options {
  position: absolute;
  right: 0;
  z-index: 6;
  min-width: 180px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.single-picker-option {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 5px;
  padding: 5px 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  text-align: left;
}

.single-picker-option:hover,
.single-picker-option[aria-pressed="true"] {
  background: #d9f2e4;
}

.multi-text-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.multi-text-picker-selected {
  min-width: 0;
  color: var(--text);
  font-size: 0.82rem;
}

.multi-text-picker-dropdown {
  position: relative;
  justify-self: end;
}

.multi-text-picker-dropdown summary {
  cursor: pointer;
  list-style: none;
  border: 0;
  border-radius: 999px;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  color: #4a2f1e;
  font-size: 1rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.multi-text-picker-dropdown summary::-webkit-details-marker {
  display: none;
}

.multi-text-picker-dropdown[open] summary {
  color: #3a2416;
}

.multi-text-picker-dropdown[open] .multi-text-picker-options {
  position: absolute;
  right: 0;
  z-index: 6;
  min-width: 160px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.multi-text-picker-option {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 5px;
  padding: 5px 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  text-align: left;
}

.multi-text-picker-option:hover,
.multi-text-picker-option[aria-pressed="true"] {
  background: #d9f2e4;
}

.lookalikes-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: start;
}

.lookalikes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.lookalike-item {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 3px 2px 7px;
  background: var(--surface-soft);
}

.lookalike-name-chip {
  max-width: 150px;
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lookalike-add,
.lookalike-remove {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.lookalike-add {
  width: 28px;
  height: 28px;
  padding: 0;
}

.lookalike-remove {
  width: 18px;
  height: 18px;
  font-size: 0.72rem;
  padding: 0;
  line-height: 1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 41, 36, 0.34);
}

.lookalike-modal {
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.modal-field input,
.modal-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 400;
}

.lookalike-suggestions {
  display: grid;
  gap: 3px;
  margin-top: 2px;
}

.lookalike-suggestions[hidden] {
  display: none;
}

.lookalike-suggestion {
  display: grid;
  gap: 1px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fbfcf8;
  color: var(--text);
  text-align: left;
}

.lookalike-suggestion:hover,
.lookalike-suggestion:focus-visible {
  border-color: var(--accent);
  background: #d9f2e4;
}

.lookalike-suggestion-swedish {
  font-size: 0.88rem;
  font-weight: 800;
}

.lookalike-suggestion-scientific {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.modal-error {
  margin: 0;
  color: var(--contradiction-text);
  font-size: 0.86rem;
  font-weight: 800;
}

.modal-actions button {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--surface-soft);
}

.modal-actions button[type="submit"] {
  border-color: var(--accent);
  background: #d9f2e4;
  color: var(--accent-strong);
  font-weight: 800;
}

.new-species-modal .modal-actions button {
  padding: 5px 8px;
  font-size: 0.86rem;
}

.advanced-detail-fields {
  display: grid;
  gap: 5px;
}

.advanced-detail-fields .detail-edit-row:first-of-type {
  margin-top: 0;
}

.detail-missing {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.image-control .image-grid {
  margin-top: 0;
}

.image-control input[type="hidden"] {
  display: none;
}

.species-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.species-actions .species-graph-button {
  margin: 0;
}

.other-species-dialog {
  width: min(92vw, 620px);
  max-height: 85vh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.other-species-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.other-species-context {
  font-weight: 700;
}

.other-species-list {
  padding-left: 22px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.other-species-locations {
  color: var(--muted);
  font-size: 0.9em;
}

.other-species-list a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.artfakta-button {
  box-sizing: border-box;
  text-decoration: none;
}

.artfakta-button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: default;
}

.species-graph-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 10px;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0;
  background: var(--surface-soft);
  color: var(--accent-strong);
  line-height: 1;
}

.species-graph-button:hover,
.species-graph-button:focus-visible {
  border-color: var(--accent);
  background: #e4eee7;
}

.species-graph-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.image-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.image-card {
  width: 100%;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.image-open-button {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  text-align: left;
}

.image-open-button:focus-visible {
  outline: 3px solid rgba(101, 126, 80, 0.42);
  outline-offset: -3px;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--border);
}

.image-card figcaption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 6px 8px;
  background: linear-gradient(180deg, rgba(25, 20, 15, 0), rgba(25, 20, 15, 0.84));
  color: #fffaf0;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 160ms ease, transform 160ms ease;
}

.image-open-button:hover figcaption,
.image-open-button:focus-visible figcaption {
  opacity: 1;
  transform: translateY(0);
}

.image-lightbox-overlay {
  background: rgba(17, 14, 11, 0.76);
  z-index: 80;
}

.image-lightbox {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(94vw, 1160px);
  height: min(92vh, 820px);
  border: 1px solid rgba(255, 250, 240, 0.24);
  border-radius: 8px;
  overflow: hidden;
  background: #191611;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.46);
}

.image-lightbox-toolbar {
  display: flex;
  justify-content: end;
  padding: 8px 10px;
  background: rgba(255, 250, 240, 0.08);
}

.image-lightbox-caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(25, 20, 15, 0), rgba(25, 20, 15, 0.86));
  color: #fffaf0;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 160ms ease, transform 160ms ease;
}

.image-lightbox-controls {
  display: inline-flex;
  gap: 6px;
}

.image-lightbox-controls button {
  min-width: 34px;
  height: 32px;
  border: 1px solid rgba(255, 250, 240, 0.26);
  border-radius: 6px;
  padding: 0 9px;
  background: rgba(255, 250, 240, 0.12);
  color: #fffaf0;
  font-weight: 900;
}

.image-lightbox-close {
  margin-left: 4px;
}

.image-lightbox-viewport {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  cursor: zoom-in;
}

.image-lightbox-figure {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
}

.image-lightbox-figure:hover .image-lightbox-caption,
.image-lightbox-figure:focus-within .image-lightbox-caption {
  opacity: 1;
  transform: translateY(0);
}

.image-lightbox-image {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  transition: width 120ms ease;
}

.species-graph-overlay {
  z-index: 70;
}

.species-graph-modal {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  width: min(94vw, 980px);
  height: min(88vh, 720px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.species-graph-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.species-graph-title-line,
.species-graph-head h3,
.species-graph-head p,
.species-graph-status {
  margin: 0;
}

.species-graph-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}

.species-graph-head h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.species-graph-context::before {
  content: "- ";
}

.species-graph-head p,
.species-graph-status {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.species-graph-close {
  min-width: 34px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 900;
}

.species-graph-control {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) minmax(34px, auto);
  gap: 10px;
  align-items: center;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
}

.species-graph-control input[type="range"] {
  width: 100%;
}

.species-graph-weight {
  color: var(--accent-strong);
  text-align: right;
}

.species-graph-canvas {
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcf8;
}

.hidden {
  display: none;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  }

  .results-panel {
    order: 2;
  }

  .details-panel {
    order: 3;
    grid-column: 1 / -1;
  }

  .comparison-panel {
    order: 4;
  }

  .all-species-panel {
    order: 5;
  }
}

@media (max-width: 520px) {
  .image-grid {
    gap: 6px;
  }

  .image-lightbox {
    width: 96vw;
    height: 92vh;
  }

  .image-lightbox-controls {
    justify-content: end;
  }
}

@media (max-width: 860px) {
  .panel.mushroom-panel {
    max-height: none;
    overflow: visible;
  }

  .header-content {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .eyebrow,
  h1,
  .header-save-button,
  .intro,
  .source-note {
    grid-column: 1;
  }

  .eyebrow {
    justify-self: center;
  }

  .header-save-button {
    justify-self: center;
  }

  .source-note {
    justify-self: center;
    margin-top: 0;
  }

  h1 {
    white-space: normal;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .details-panel {
    grid-column: auto;
  }

  .sticky-results,
  .sticky-details {
    position: static;
  }

  .details-panel {
    overflow: auto;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .wrap {
    width: min(100% - 20px, 1410px);
  }

  .panel,
  .sticky-results,
  .details-panel {
    padding: 14px;
  }

  .options-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-form .options-grid {
    display: flex;
    flex-wrap: wrap;
  }

  .filter-group {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .filter-title,
  .options-grid,
  .filter-group .reset-group {
    grid-column: 1;
  }

  .filter-group .reset-group {
    justify-self: stretch;
    width: 100%;
  }
}
