body {
  font-family: sans-serif;
  margin: 1rem;
}

/* Mobile-sized container on all screens */
#upload-form,
#results {
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Center the list itself too */
#titles-list {
  padding: 0;
  margin: 0 auto 1rem;
  max-width: 400px;
  list-style: none;
}

/* Ensure inputs fill their container */
#titles-list input {
  width: 100%;
  box-sizing: border-box;
}

/* Buttons display block on mobile-style list */
.remove-btn,
.search-btn {
  display: inline-block;
  margin: 0.25rem 0;
}

/* Mobile optimization: stack vertically */
@media (max-width: 600px) {
  #titles-list li {
    flex-direction: column;
    align-items: stretch;
  }
  #titles-list input,
  .remove-btn,
  .search-btn {
    width: 100%;
    margin: 0.25rem 0;
  }
}
/* Center the app title */
.app-title {
  text-align: center;
  margin: 0;      /* remove default margins if desired */
  padding: 1rem 0;
  font-size: 1.5rem;
}
/* Ensure each title row stays on one line, buttons to the right */
#titles-list li {
  display: flex;
  flex-direction: row;    /* always side-by-side */
  align-items: center;
  flex-wrap: nowrap;      /* prevent wrapping */
}

/* Input stretches, but won’t force buttons off-screen */
#titles-list input {
  flex: 1;                /* take all remaining space */
  min-width: 0;           /* allow flex to shrink below content size */
  margin-right: 0.5rem;   /* space before buttons */
}

/* Buttons sit tight to the right with no wrapping */
.remove-btn,
.search-btn {
  white-space: nowrap;    /* don’t wrap their text */
  margin: 0 0.25rem;      /* small side padding */
  flex-shrink: 0;         /* never shrink */
}

/* Override mobile stacking if you have a media rule */
@media (max-width: 600px) {
  #titles-list li {
    flex-direction: row;  /* keep row layout on mobile too */
  }
}
/* Ensure horizontal scrolling if content overflows */
#results {
  overflow-x: auto;
}

/* Title row: flex container that never wraps */
#titles-list li {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
}

/* Input: grow and shrink, but never below zero width */
#titles-list input {
  flex: 1 1 auto;   /* allow input to take remaining space */
  min-width: 0;     /* allow input to shrink below its content width */
  margin-right: 0.5rem;
}

/* Buttons: only as big as their text, but allow wrapping if needed */
.remove-btn,
.search-btn {
  flex: 0 0 auto;    /* don’t grow or shrink */
  padding: 0.3em 0.6em;
  white-space: normal; /* allow text wrap instead of forcing a giant width */
  margin-left: 0.25rem;
  font-size: 0.9rem;
}

/* On very narrow screens, reduce font-size of buttons slightly */
@media (max-width: 400px) {
  .remove-btn,
  .search-btn {
    font-size: 0.8rem;
    padding: 0.25em 0.4em;
  }
}

/* Make the table scroll horizontally if it's too wide */
#results {
  overflow-x: auto;
}

/* Simple styling */
#titles-table th,
#titles-table td {
  border-bottom: 1px solid #ddd;
}

/* Keep buttons a consistent size */
.remove-btn,
.search-btn {
  padding: 0.3em 0.6em;
  font-size: 1rem;
  min-width: 2em;
}

/* On very narrow screens, shrink the icons a bit */
@media (max-width: 400px) {
  .remove-btn,
  .search-btn {
    font-size: 0.8rem;
    padding: 0.2em 0.4em;
  }
}
/* Card container */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
  margin: 1rem auto;
}

/* Individual card */
.card {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  background: #fff;
}

/* Editable input filler */
.card-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 0.25rem;
  font-size: 1rem;
}

/* Button container inside card */
.card-buttons {
  display: flex;
  gap: 0.5rem;
  margin-left: 0.5rem;
}

/* Reset button styles */
.btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* On hover */
.btn:hover {
  opacity: 0.8;
}

/* Hint text under cards */
.hint {
  text-align: center;
  font-size: 0.9rem;
  color: #555;
}

/* Mobile adjustments */
@media (min-width: 600px) {
  .cards-container {
    max-width: 600px;
  }
}
/* Allow the input to shrink so buttons stay visible */
.card-input {
  flex: 1 1 auto;   /* grow and shrink */
  min-width: 0;     /* allow it to shrink below its content width */
}

/* Keep the buttons from shrinking */
.card-buttons {
  display: flex;
  gap: 0.5rem;
  margin-left: 0.5rem;
  flex-shrink: 0;   /* never shrink away */
}

/* If even that overflows, let the card scroll horizontally */
.card {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  background: #fff;
  flex-wrap: nowrap;    /* keep everything in one row */
  overflow-x: auto;     /* allow horizontal scroll if too tight */
}

/* Optional: slightly smaller icons on very narrow screens */
@media (max-width: 350px) {
  .card-buttons img {
    width: 20px;
    height: 20px;
  }
}
