* {
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: 100vh; /* changed from min-height */
  overflow-x: hidden; /* prevent horizontal scroll */
  overflow-y: hidden; /* prevent double scrollbars */
  background: #f5f5f5;
  padding: 1rem;
  font-family: Arial, sans-serif;
}

.container {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 1000px;
  height: 100%;           /* allow it to fill available space */
  display: flex;
  flex-direction: column; /* so .results can grow */
  overflow: hidden;       /* don't let it scroll */
}


.controls {
  /* This container holds the filters + input + buttons */
  flex-shrink: 0;           /* Prevent it from shrinking */
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
}

button {
  width: 100%;
  padding: 0.75rem;
  background: #7fa06f;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 1rem;
}
button:hover { background: #6e8c5e; }

#resultCount {
  margin: 0.5rem 0;
  font-weight: bold;
  color: #333;
}

#searchBtn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  font-family: inherit;
  /* Reserve enough space for maximum dots (5 in your case) */
}

#searchBtn .dots {
  /* Reserve 5 characters width for dots so it won't shift */
  display: inline-block;
  width: 5ch;  /* 5 characters worth of space */
  text-align: left; /* dots grow to the right */
  font-weight: normal;
}

.results {
  flex: 1 1 auto;      /* take remaining vertical space */
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem;
  background: #f0f0f0;
}

.result-item {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: #fdfdfd;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.category-inline {
  font-size: 0.8rem;
  color: #999;
  font-style: italic;
}
.audio-buttons button {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 4px;
  background: #7fa06f;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
}

.value-with-audio {
  display: flex;
  align-items: center;
}

.value-with-audio span.value-text {
  flex: 1;
}

.value-with-audio .audio-buttons {
  margin-left: 1rem;
}

.audio-button-wrapper {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 0.65rem;
  color: #555;
  margin-left: 0.5rem;
  position: static;
}

.audio-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audio-buttons button:hover {
  background: #6e8c5e;
}

.field {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.field .label {
  font-weight: bold;
  color: #333;
}

.field .sub-label {
  font-style: italic;
  color: #444;
}

.light-grey {
  color: #999;
  font-style: italic;
  margin-left: 0.5rem;
}

.separator {
  border-top: 1px solid #bbb;
  margin: 0.75rem 0;
}

.sub-separator {
  border-top: 1px dashed #ddd;
  margin: 0.5rem 0;
}

.section-title {
  font-weight: bold;
  margin: 0.75rem 0 0.35rem 0;
}

.source {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-style: italic;
  color: #777;
  text-align: right;
}


/* ---------------------- MOBILE OPTIMIZATION ---------------------- */

@media (max-width: 500px) {
  .field {
    grid-template-columns: 1fr; /* stack label + value */
  }

  .container {
    padding: 1rem 0.5rem;
  }

  input[type="text"], button {
    font-size: 1rem;
  }

  .audio-buttons button {
    width: 1.75rem;
    height: 1.75rem;
  }

  .audio-button-wrapper {
    font-size: 0.55rem;
  }
}