.stories-directory {
  max-width: 960px;
}

.stories-toc {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
  margin: 1rem 0 1.5rem;
}

.stories-toc a {
  display: block;
  padding: 0.65rem 0.85rem;
  border: 1px solid #c8d4df;
  border-radius: 4px;
  color: #173f62;
  font-weight: 700;
  text-align: center;
}

.stories-toc a:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  justify-self: center;
  box-sizing: border-box;
  width: calc(50% - 0.5rem);
}

.story-search {
  margin: 1.5rem 0 2rem;
  padding: 1rem;
  border: 1px solid #d7d7d7;
  border-radius: 5px;
  background: #f7f7f7;
}

.story-search label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.story-search-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
}

.story-search input,
.story-search button {
  box-sizing: border-box;
  min-height: 2.7rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #888;
  border-radius: 4px;
  font: inherit;
}

.story-search button {
  background: #fff;
  color: #173f62;
  cursor: pointer;
  font-weight: 700;
}

.story-search-status {
  min-height: 1.3em;
  margin: 0.55rem 0 0;
  color: #555;
  font-size: 0.9em;
}

.story-district {
  scroll-margin-top: 1rem;
}

.story-district > h2 {
  margin: 2.4rem 0 0.8rem;
  border-bottom: 2px solid #c8d4df;
  padding-bottom: 0.3rem;
  font-size: 1.3em;
  text-align: left;
}

.story-entry {
  scroll-margin-top: 1rem;
  padding: 0.25rem 0 1rem;
}

.story-entry h3 {
  margin-top: 1.45rem;
}

.story-entry p {
  margin: 0 0 1.15em;
}

.story-entry img {
  max-width: 100%;
  height: auto;
}

.story-search-highlight {
  padding: 0.05em 0.08em;
  background: #ffe36a;
  color: #111;
}

.story-search-empty {
  padding: 1rem;
  border: 1px solid #d7d7d7;
  background: #f7f7f7;
  text-align: center;
}

.story-back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  width: 2.7rem;
  height: 2.7rem;
  align-items: center;
  justify-content: center;
  border: 1px solid #777;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #173f62;
  font-size: 1.6rem;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

body.night-mode .stories-toc a,
body.night-mode .story-search button,
body.night-mode .story-back-to-top {
  border-color: #555;
  background: #272727;
  color: #7db8e6;
}

body.night-mode .story-search,
body.night-mode .story-search-empty {
  border-color: #444;
  background: #2a2a2a;
}

body.night-mode .story-search input {
  border-color: #666;
  background: #1e1e1e;
  color: #ddd;
}

body.night-mode .story-search-status {
  color: #aaa;
}

body.night-mode .story-district > h2 {
  border-color: #444;
}

@media (max-width: 600px) {
  .stories-toc {
    gap: 0.45rem;
  }

  .stories-toc a {
    padding: 0.55rem 0.35rem;
    font-size: 0.9em;
  }

  .story-search-controls {
    grid-template-columns: 1fr;
  }

  .story-search button {
    width: 100%;
  }

  .story-back-to-top {
    right: 0.65rem;
    bottom: 0.65rem;
  }
}
