:root {
  --bg: #bff6bd;
  --surface: #ffffff;
  --surface-alt: #f5f5f5;
  --text: #1a1a1a;
  --text-muted: #5a5a5a;
  --accent: #2f6b2f;
  --accent-soft: rgba(47, 107, 47, 0.08);
  --border: #d8d8d8;
  --radius: 14px;
  --radius-pill: 999px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);
  --gap: 8px;
  --gap-2: 16px;
  --gap-3: 24px;
  --gap-4: 32px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main#app {
  padding: 0 var(--gap-2) calc(var(--gap-4) + var(--safe-bottom));
  min-height: 100vh;
}

a {
  color: var(--accent);
}

h1 {
  font-size: 1.6rem;
  margin: var(--gap-2) 0 0 0;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: 1.2rem;
  margin: var(--gap-3) 0 0 0;
  line-height: 1.2;
  font-style: italic;
  font-weight: 500;
  color: var(--text-muted);
}

h1 {
  margin-top: -8px;
}

h3 {
  font-size: 0.85rem;
  margin: var(--gap-3) 0 0 0;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

p {
  margin: var(--gap) 0;
  color: var(--text);
}

#search-container {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(var(--safe-top) + var(--gap-2)) var(--gap-2) var(--gap-2);
  background: var(--bg);
  margin-inline: calc(-1 * var(--gap-2));
}

#search {
  width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

#search::placeholder {
  color: var(--text-muted);
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#suggestions {
  position: absolute;
  left: var(--gap-2);
  right: var(--gap-2);
  top: 100%;
  margin-top: var(--gap);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 70vh;
  overflow-y: auto;
  z-index: 20;
}

#suggestions .suggestion {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

#suggestions .suggestion:last-child {
  border-bottom: none;
}

#suggestions .suggestion:hover,
#suggestions .suggestion:focus {
  background: var(--surface-alt);
}

#suggestions .suggestion .thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-alt);
  flex-shrink: 0;
}

#suggestions .suggestion .text {
  flex: 1;
  min-width: 0;
}

#suggestions .suggestion .dk {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#suggestions .suggestion .la {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.85em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#suggestions .error {
  padding: 12px 14px;
  color: #9b2c2c;
  font-size: 0.9em;
}

#details {
  padding-top: var(--gap-2);
}

#details .error {
  color: #9b2c2c;
}

.meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  margin: 0 0 var(--gap-3);
  font-size: 0.95em;
}

.meta .k {
  font-weight: 700;
  color: var(--text-muted);
}

.meta .v {
  color: var(--text);
  word-break: break-word;
}

.section.attributes table {
  background: transparent;
  border-radius: 0;
  overflow: visible;
}

.section.attributes th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9em;
  color: var(--text);
  width: 35%;
}

.section.attributes tr:nth-child(odd) th,
.section.attributes tr:nth-child(odd) td {
  background: var(--surface);
}

.section.attributes tr:nth-child(even) th,
.section.attributes tr:nth-child(even) td {
  background: var(--surface-alt);
}

.section.attributes td,
.section.attributes th {
  border-bottom: none;
}

.section {
  margin-top: var(--gap);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.images.strip {
  display: flex;
  gap: 12px;
  padding: 4px 2px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.images.strip .cell {
  flex: 0 0 auto;
  width: 140px;
  display: flex;
  flex-direction: column;
  color: var(--text-muted);
  text-decoration: none;
}

.images.strip .cell img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface-alt);
  display: block;
}

.images.strip .cell small {
  font-size: 0.75em;
  margin-top: 6px;
  line-height: 1.3;
  display: block;
  color: var(--text-muted);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--gap);
}

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  color: var(--accent);
  font-size: 0.9em;
  min-height: 36px;
  text-decoration: none;
}

.pill em {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.85em;
}

.pill:hover,
.pill:focus {
  background: var(--accent-soft);
  text-decoration: none;
}

.pill:active {
  background: var(--accent-soft);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
}

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

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

th {
  background: var(--surface-alt);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72em;
  letter-spacing: 0.06em;
}

#similar-taxa ul {
  margin: var(--gap) 0;
  padding-left: var(--gap-2);
}

.obs-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  margin-top: var(--gap);
}

.obs-photos .cell-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.obs-photos .cell {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: var(--surface-alt);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 10px;
  transition: transform 0.15s ease;
}

.obs-photos .cell:active {
  transform: scale(0.97);
}

.obs-photos .caption {
  font-size: 0.75em;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
  text-decoration: none;
}

.obs-photos .caption:hover,
.obs-photos .caption:focus {
  text-decoration: underline;
}

#photos-sentinel {
  width: 100%;
  height: 1px;
}

.photos-end {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85em;
  padding: var(--gap-2);
}

#to-top {
  position: fixed;
  bottom: calc(var(--gap-2) + var(--safe-bottom));
  right: var(--gap-2);
  width: 44px;
  height: 44px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 30;
  padding: 0;
}

#to-top:active {
  background: var(--accent-soft);
}

@media (max-width: 360px) {
  .obs-photos {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 480px) {
  h1 {
    font-size: 1.8rem;
  }

  #suggestions .suggestion .thumb {
    width: 56px;
    height: 56px;
  }

  .images.strip .cell {
    width: 170px;
  }

  .images.strip .cell img {
    height: 170px;
  }

  .obs-photos {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap-2);
  }
}

@media (min-width: 768px) {
  main#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--gap-3) var(--gap-4);
  }

  #search-container {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
  }

  #suggestions {
    left: 0;
    right: 0;
  }

  .obs-photos {
    grid-template-columns: repeat(5, 1fr);
  }

  .section table {
    max-width: 800px;
  }
}

@media (min-width: 1100px) {
  .obs-photos {
    grid-template-columns: repeat(6, 1fr);
  }
}
