body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 0 1rem 2rem;
  color: #222;
  background: #fafafa;
}

header,
footer {
  text-align: center;
  padding: 1rem 0;
}

.attribution {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 700px;
  margin: 0.5rem auto 0;
  font-size: 0.8rem;
  color: #595959;
}

.tmdb-logo {
  height: 14px;
  width: auto;
}

nav {
  max-width: 1200px;
  margin: 0 auto 1rem;
  padding: 0 0.5rem;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.nav-link {
  background: none;
  border: none;
  font: inherit;
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem;
}

.data-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.data-actions button,
.data-actions .import-data-label {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
}

#data-status-message {
  max-width: 1200px;
  margin: 0.5rem auto 0;
  font-size: 0.85rem;
  color: #444;
}

#data-status-message:empty {
  display: none;
}

#back-to-shows-link {
  display: inline-block;
}

.show-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto 1rem;
  padding: 0 0.5rem;
}

#current-show-name {
  margin: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto 1.5rem;
  padding: 0 0.5rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.control label {
  font-size: 0.85rem;
  font-weight: bold;
}

.my-services-panel {
  max-width: 1200px;
  margin: 0 auto 1.5rem;
  padding: 0.5rem 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.my-services-panel summary {
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9rem;
  padding: 0.25rem 0;
}

.my-services-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 0.5rem;
  max-height: 220px;
  overflow-y: auto;
}

.service-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.control input,
.control select {
  padding: 0.4rem;
  font-size: 1rem;
}

#match-count,
#show-match-count {
  margin: 0;
  color: #444;
}

#status-message,
#shows-status-message {
  text-align: center;
  font-size: 1.1rem;
  color: #444;
}

#status-message:empty,
#shows-status-message:empty {
  display: none;
}

.shows-cache-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  max-width: 1200px;
  margin: 0 auto 1rem;
  padding: 0 0.5rem;
}

#refresh-catalog-btn {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
}

#refresh-catalog-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#shows-background-status {
  font-size: 0.8rem;
  color: #595959;
  text-align: center;
}

#shows-background-status:empty,
#availability-background-status:empty {
  display: none;
}

#availability-background-status {
  font-size: 0.8rem;
  color: #595959;
  text-align: center;
}

#load-more-shows-btn:not([hidden]) {
  display: block;
  margin: 2rem auto 0;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
}

.episode-card:focus,
.show-card:focus,
#current-show-name:focus {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

#root,
#shows-root,
.favourites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.favourites-group {
  max-width: 1200px;
  margin: 0 auto 2rem;
}

.favourites-group h3 {
  padding: 0 0.5rem;
}

.favourites-group-empty {
  padding: 0 0.5rem;
  color: #595959;
  font-size: 0.9rem;
}

.favourites-group-empty:empty {
  display: none;
}

.episode-card,
.show-card,
.favourite-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem;
  background: white;
  display: flex;
  flex-direction: column;
}

.episode-card.watched {
  background: #f0f4ff;
  border-color: #93c5fd;
}

.episode-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.watched-toggle,
.select-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  max-width: 1200px;
  margin: 0 auto 1rem;
  padding: 0 0.5rem;
}

.bulk-actions button {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.bulk-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#episode-selection-count {
  font-size: 0.85rem;
  color: #444;
}

.episode-card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}

.episode-card h3 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

.episode-code {
  font-weight: normal;
  color: #666;
}

.episode-image,
.show-image {
  width: 100%;
  border-radius: 4px;
}

.episode-summary,
.show-summary {
  font-size: 0.9rem;
  flex-grow: 1;
}

.episode-link {
  align-self: flex-start;
  margin-top: 0.5rem;
}

.show-card h2,
.favourite-card h3 {
  font-size: 1.1rem;
  margin: 0;
}

.show-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.show-name-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: bold;
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
}

.favourite-toggle {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.favourite-toggle[aria-pressed="true"] {
  background: #fef3c7;
  border-color: #f59e0b;
}

.favourite-card .favourite-next-episode {
  font-size: 0.9rem;
  flex-grow: 1;
}

.favourite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.favourite-actions button {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.now-watching-toggle {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.now-watching-toggle[aria-pressed="true"] {
  background: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
  font-weight: bold;
}

.favourite-card.now-watching {
  background: #f0fdf4;
  border-color: #16a34a;
  box-shadow: 0 0 0 1px #16a34a;
}

.show-genres {
  font-size: 0.85rem;
  color: #666;
  margin: 0.25rem 0;
}

.show-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

.show-meta div {
  display: flex;
  flex-direction: column;
}

.show-meta dt {
  font-weight: bold;
  color: #444;
}

.show-meta dd {
  margin: 0;
}
