body[data-page="characters"] .layout-shell,
body[data-page="music-notes"] .layout-shell {
  max-width: 1280px;
  margin-top: 0;
}

body[data-page="characters"] .main-content,
body[data-page="music-notes"] .main-content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 0 28px;
}

body[data-page="characters"] .page-affiliate-note,
body[data-page="music-notes"] .page-affiliate-note {
  display: none;
}

html {
  scroll-behavior: smooth;
}

.directory-hero {
  margin: 0 0 12px;
  padding: 8px 4px 18px;
}

.directory-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.directory-hero h1 {
  margin: 8px 0;
  color: var(--accent);
  font-size: clamp(1.55rem, 2.7vw, 2.15rem);
  line-height: 1.25;
  text-wrap: balance;
}

.directory-intro {
  max-width: 78ch;
  margin: 0;
  color: #334f53;
  font-size: 1rem;
  line-height: 1.7;
}

.directory-jump {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.directory-jump a {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--brand-light);
  border-radius: 12px;
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
}

.directory-jump a:hover,
.directory-jump a:focus-visible {
  border-color: var(--brand);
  outline: 3px solid color-mix(in srgb, var(--brand) 25%, transparent);
  outline-offset: 2px;
}

.directory-section {
  scroll-margin-top: 16px;
  margin: 0 0 18px;
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid #d9e8e6;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(29, 83, 85, 0.06);
}

.directory-section-header {
  margin-bottom: 14px;
}

.directory-section-header h2 {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  line-height: 1.35;
  text-wrap: balance;
}

.directory-section-header p {
  margin: 0;
  color: #5b6a6d;
  line-height: 1.6;
}

.directory-controls {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 14px 0 10px;
}

.directory-control {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 700;
}

.directory-control input,
.directory-control select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 9px 11px;
  border: 1px solid #9bbfbd;
  border-radius: 10px;
  background: #fff;
  color: var(--text-main);
  font: inherit;
  font-weight: 400;
}

.directory-control input:focus-visible,
.directory-control select:focus-visible {
  border-color: var(--brand);
  outline: 3px solid color-mix(in srgb, var(--brand) 24%, transparent);
  outline-offset: 1px;
}

.directory-result-count {
  display: block;
  margin: 4px 0 8px;
  color: #5b6a6d;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.directory-table-wrap {
  min-width: 0;
}

.directory-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--text-main);
}

.directory-table--profiles th:nth-child(1),
.directory-table--profiles td:nth-child(1) { width: 19%; }
.directory-table--profiles th:nth-child(2),
.directory-table--profiles td:nth-child(2) { width: 13%; }
.directory-table--profiles th:nth-child(3),
.directory-table--profiles td:nth-child(3) { width: 16%; }
.directory-table--profiles th:nth-child(4),
.directory-table--profiles td:nth-child(4) { width: 12%; }
.directory-table--profiles th:nth-child(5),
.directory-table--profiles td:nth-child(5) { width: 40%; }

.directory-table--birthdays th:nth-child(1),
.directory-table--birthdays td:nth-child(1) { width: 13%; }
.directory-table--birthdays th:nth-child(2),
.directory-table--birthdays td:nth-child(2) { width: 22%; }
.directory-table--birthdays th:nth-child(3),
.directory-table--birthdays td:nth-child(3) { width: 15%; }
.directory-table--birthdays th:nth-child(4),
.directory-table--birthdays td:nth-child(4) { width: 50%; }

.directory-table--cast th:nth-child(1),
.directory-table--cast td:nth-child(1) { width: 22%; }
.directory-table--cast th:nth-child(2),
.directory-table--cast td:nth-child(2) { width: 14%; }
.directory-table--cast th:nth-child(3),
.directory-table--cast td:nth-child(3) { width: 26%; }
.directory-table--cast th:nth-child(4),
.directory-table--cast td:nth-child(4) { width: 38%; }

.directory-table--songs th:nth-child(1),
.directory-table--songs td:nth-child(1) { width: 29%; }
.directory-table--songs th:nth-child(2),
.directory-table--songs td:nth-child(2) { width: 25%; }
.directory-table--songs th:nth-child(3),
.directory-table--songs td:nth-child(3) { width: 15%; }
.directory-table--songs th:nth-child(4),
.directory-table--songs td:nth-child(4) { width: 31%; }

.directory-table--discography th:nth-child(1),
.directory-table--discography td:nth-child(1) { width: 34%; }
.directory-table--discography th:nth-child(2),
.directory-table--discography td:nth-child(2) { width: 17%; }
.directory-table--discography th:nth-child(3),
.directory-table--discography td:nth-child(3) { width: 18%; }
.directory-table--discography th:nth-child(4),
.directory-table--discography td:nth-child(4) { width: 31%; }

.directory-table--creators th:nth-child(1),
.directory-table--creators td:nth-child(1) { width: 23%; }
.directory-table--creators th:nth-child(2),
.directory-table--creators td:nth-child(2) { width: 21%; }
.directory-table--creators th:nth-child(3),
.directory-table--creators td:nth-child(3) { width: 16%; }
.directory-table--creators th:nth-child(4),
.directory-table--creators td:nth-child(4) { width: 40%; }

.directory-table caption {
  padding: 0 0 8px;
  color: #5b6a6d;
  text-align: left;
}

.directory-table th,
.directory-table td {
  padding: 11px 10px;
  border-bottom: 1px solid #d9e8e6;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.directory-table thead th {
  background: #edf6f4;
  color: #285b5b;
  font-size: 0.88rem;
}

.directory-table tbody tr:nth-child(even) {
  background: #f8fbfa;
}

.directory-table tbody th[scope="row"] {
  color: var(--accent);
  font-size: 1rem;
}

.directory-table td[data-label="詳細"] {
  min-width: 130px;
}

.directory-table details > summary {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  line-height: 1.35;
}

.directory-table details > summary:hover,
.directory-table details > summary:focus-visible {
  background: #edf6f4;
  outline: 2px solid var(--brand);
}

.directory-details {
  min-width: 0;
  margin: 8px 0 0;
}

.directory-details > div {
  display: grid;
  grid-template-columns: minmax(6rem, 0.35fr) minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid #e2eceb;
}

.directory-details dt {
  color: #5b6a6d;
  font-weight: 700;
}

.directory-details dd {
  min-width: 0;
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.directory-details ul {
  margin: 4px 0 0;
  padding-left: 1.25rem;
}

.directory-details li + li {
  margin-top: 5px;
}

.directory-empty {
  margin: 8px 0 0;
  padding: 18px;
  border-radius: 10px;
  background: #f3f8f7;
  color: #5b6a6d;
  text-align: center;
}

.directory-common-links {
  margin-top: 18px;
}

.directory-section:target {
  outline: 3px solid color-mix(in srgb, var(--brand) 25%, transparent);
  outline-offset: 2px;
}

.directory-table tr[hidden],
.directory-empty[hidden] {
  display: none !important;
}

@media (max-width: 850px) {
  body[data-page="characters"] .main-content,
  body[data-page="music-notes"] .main-content {
    padding: 6px 8px 20px;
  }

  .directory-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .directory-control--search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .directory-jump {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .directory-jump a {
    justify-content: flex-start;
    text-align: left;
  }

  .directory-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .directory-control--search {
    grid-column: auto;
  }

  .directory-table,
  .directory-table caption,
  .directory-table tbody,
  .directory-table tr,
  .directory-table th,
  .directory-table td {
    display: block;
    width: 100%;
  }

  .directory-section .directory-table tbody th:nth-child(n),
  .directory-section .directory-table tbody td:nth-child(n) {
    width: 100%;
  }

  .directory-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
  }

  .directory-table tbody tr {
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid #c9ddda;
    border-radius: 12px;
    background: #fff;
  }

  .directory-table tbody th[scope="row"] {
    padding: 7px 2px 9px;
    border-bottom: 1px solid #d9e8e6;
    font-size: 1rem;
  }

  .directory-table tbody td {
    display: grid;
    grid-template-columns: minmax(5.5rem, 0.36fr) minmax(0, 1fr);
    gap: 8px;
    padding: 8px 2px;
    border-bottom: 1px solid #edf2f1;
  }

  .directory-table tbody td::before {
    content: attr(data-label);
    color: #5b6a6d;
    font-size: 0.82rem;
    font-weight: 700;
  }

  .directory-table tbody td[data-label="詳細"] {
    display: block;
    padding-top: 5px;
  }

  .directory-table tbody td[data-label="詳細"]::before {
    content: none;
  }

  .directory-table details > summary {
    min-height: 44px;
  }

  .directory-details > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

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