body[data-page="character-profiles"] .layout-shell,
body[data-page="voice-actors"] .layout-shell,
body[data-page="character-songs"] .layout-shell,
body[data-page="music-releases"] .layout-shell {
  max-width: 1280px;
  margin-top: 0;
}

body[data-page="character-profiles"] .main-content,
body[data-page="voice-actors"] .main-content,
body[data-page="character-songs"] .main-content,
body[data-page="music-releases"] .main-content {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 2px;
  padding-bottom: 28px;
}

.derived-hero {
  margin-top: 0;
  margin-bottom: 8px;
  padding-top: 0;
}

.derived-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  margin-bottom: 8px;
}

.derived-hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.derived-hero .subpage-back-link {
  margin: 0;
  flex: 0 0 auto;
}

.derived-hero .page-updated-at {
  position: static;
  margin: 0;
  flex: 0 0 auto;
  text-align: right;
}

.derived-hero .subpage-title {
  font-size: 1.35rem;
  line-height: 1.2;
  margin: 0 0 4px;
  color: var(--accent);
}

.derived-search-box {
  display: grid;
  gap: 0;
  width: 100%;
}

.derived-search-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  width: 100%;
  margin-bottom: 0;
  z-index: 1;
}

.derived-search-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  border: 2px solid var(--brand-light);
  background: #fff;
  color: var(--accent);
  border-bottom: 2px solid var(--brand-light);
  border-radius: 12px 12px 0 0;
  min-height: 44px;
  padding: 7px 6px 6px;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  box-sizing: border-box;
}

.derived-search-tab + .derived-search-tab {
  margin-left: -2px;
}

.derived-search-tab.is-active {
  background: linear-gradient(135deg, #eef6ff 0%, #dcecff 100%);
  border-color: var(--brand);
  position: relative;
  z-index: 2;
}

.derived-search {
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border: 2px solid var(--brand-light);
  border-radius: 0 0 12px 12px;
  font: inherit;
  background: #fff;
  color: var(--text-main);
  margin-top: -2px;
}

.derived-search:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(47, 123, 189, 0.12);
}

.derived-filter-label {
  margin: 0 0 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-muted);
}

.derived-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.derived-tab {
  appearance: none;
  border: 2px solid var(--brand-light);
  background: #fff;
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: 2px 2px 0 rgba(47, 123, 189, 0.14);
  box-sizing: border-box;
}

.derived-tab:hover,
.derived-tab:focus-visible {
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: 4px 4px 0 rgba(47, 123, 189, 0.18);
}

.derived-tab.is-active {
  background: linear-gradient(135deg, #eef6ff 0%, #dcecff 100%);
  border-width: 3px;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(47, 123, 189, 0.08) inset;
}

.derived-table-wrap {
  overflow-x: auto;
  border: 2px solid #c7def4;
  border-radius: 18px;
  background: #fffdfd;
}

.derived-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.derived-table th,
.derived-table td {
  vertical-align: middle;
}

.derived-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f8fd;
  border-bottom: 2px solid #b9d5ef;
  padding: 0;
  text-align: left;
  white-space: nowrap;
}

.derived-table tbody td {
  padding: 13px 12px;
  border-bottom: 1px solid #d9e9f8;
  font-size: 0.96rem;
  word-break: break-word;
}

.derived-table tbody tr:last-child td {
  border-bottom: 0;
}

.derived-table tbody tr:nth-child(even) {
  background: rgba(240, 247, 253, 0.55);
}

.derived-sort-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 13px 12px;
  font: inherit;
  font-weight: 800;
  color: var(--accent);
  cursor: pointer;
}

.derived-sort-button:hover,
.derived-sort-button:focus-visible {
  background: rgba(47, 123, 189, 0.08);
  outline: none;
}

.derived-title-button {
  width: 100%;
  display: inline-flex;
  align-items: flex-start;
  gap: 7px;
  justify-content: flex-start;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.derived-title-button:hover .derived-title-button-text,
.derived-title-button:focus-visible .derived-title-button-text {
  color: var(--accent);
}

.derived-title-button:focus-visible {
  outline: none;
}

.derived-title-button-text {
  display: block;
  min-width: 0;
  font-weight: 700;
  word-break: break-word;
}

.derived-title-button-icon {
  flex: 0 0 auto;
  margin-top: 0.16em;
  font-size: 0.7rem;
  line-height: 1;
  color: #2f7bbd;
}

.derived-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.derived-count {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
}

.derived-detail-cell {
  padding: 12px;
  background: #f8fbff;
}

.derived-detail {
  display: grid;
  gap: 8px;
  border: 1px solid #cfe2f4;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px 12px;
}

.derived-detail-list {
  margin: 0;
  display: grid;
  gap: 8px;
}

.derived-detail-item {
  margin: 0;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.derived-detail-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.derived-detail-value {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-main);
  word-break: break-word;
}

.derived-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.derived-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.derived-empty {
  margin: 0;
  padding: 28px 18px;
  text-align: center;
  color: var(--text-muted);
}

.derived-cards {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.derived-mobile-sort {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 8px 0;
}

.derived-mobile-sort .derived-sort-button {
  min-height: 40px;
  justify-content: center;
  border: 2px solid #c7def4;
  border-radius: 12px;
  background: #fff;
  padding: 8px 6px;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.15;
  box-sizing: border-box;
}

.derived-mobile-list-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
  padding: 0 2px 2px;
}

.derived-mobile-sort-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
}

.derived-mobile-sort-button.is-active {
  color: var(--accent);
}

.derived-mobile-sort-button--side {
  text-align: right;
}

.derived-card {
  border: 2px solid #c7def4;
  border-radius: 14px;
  background: #fff;
  padding: 10px 12px;
}

.derived-card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.derived-card-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.derived-card-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--text-main);
  word-break: break-word;
}

.derived-card-side {
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f3f8fd;
  text-align: center;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.derived-card .derived-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #d9e9f8;
}

@media (max-width: 850px) {
  body[data-page="character-profiles"] .page-affiliate-note,
  body[data-page="voice-actors"] .page-affiliate-note,
  body[data-page="character-songs"] .page-affiliate-note,
  body[data-page="music-releases"] .page-affiliate-note {
    display: block;
  }

  body[data-page="character-profiles"] .main-content,
  body[data-page="voice-actors"] .main-content,
  body[data-page="character-songs"] .main-content,
  body[data-page="music-releases"] .main-content {
    padding: 6px 8px 8px;
  }

  .panel {
    padding: 8px 6px;
    margin-bottom: 4px;
  }

  .derived-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
    gap: 6px;
  }

  .derived-tab {
    width: 100%;
    min-width: 0;
    padding: 7px 0;
    font-size: 0.82rem;
    line-height: 1;
    box-shadow: none;
  }

  .derived-search-tab {
    min-height: 48px;
    padding: 7px 4px 6px;
    font-size: 0.82rem;
  }

  .derived-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .derived-mobile-sort {
    display: grid;
  }
}

@media (max-width: 520px) {
  .panel {
    padding: 8px 6px;
  }

  .derived-hero {
    margin-top: -4px;
    margin-bottom: 6px;
    padding: 0 4px;
  }

  .derived-hero-top {
    margin-bottom: 6px;
  }

  .derived-hero-links {
    gap: 6px;
  }

  .derived-filter-label {
    margin-bottom: 4px;
  }

  .derived-pill {
    gap: 5px;
    padding: 5px 8px;
    font-size: 0.74rem;
  }

  .derived-detail-item {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
  }

  .derived-mobile-list-head {
    gap: 6px;
  }

  .derived-mobile-sort-button {
    font-size: 0.78rem;
  }

  .derived-card-side {
    min-width: 56px;
    font-size: 1rem;
  }
}
