.jm-search-page, .jm-search-dialog {
  --jm-search-red: #cf1418;
  --jm-search-text: #191919;
  color: var(--jm-search-text);
}

.jm-search-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.jm-search-page {
  width: min(1120px, calc(100% - 2.5rem));
  min-height: 50vh;
  margin: 0 auto;
  padding: clamp(1.75rem, 4vw, 3.5rem) 0;
}

.jm-search-back, .jm-search-page p a {
  color: var(--jm-search-red);
  text-decoration: underline;
  text-underline-offset: .18em;
}

.jm-search-page h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.12;
  margin: .65rem 0 .8rem;
}

.jm-search-form {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  max-width: 42rem;
  margin: 0 0 1rem;
}

.jm-search-form input[type="search"] {
  flex: 1 1 12rem;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #777;
  border-radius: .25rem;
  min-height: 46px;
  padding: .55rem .8rem;
  background: #fff;
  color: #191919;
  font: inherit;
  font-size: max(1rem, 16px);
}

.jm-search-submit, .jm-search-close {
  cursor: pointer;
  border: 0;
  border-radius: .25rem;
  min-height: 46px;
  min-width: 46px;
  font: inherit;
  font-weight: 700;
}

.jm-search-submit {
  padding: .55rem 1.15rem;
  background: var(--jm-search-red);
  color: #fff;
}

.jm-search-close {
  color: #191919;
  background: #f2f2f2;
  font-size: 1.5rem;
}

.jm-search-page :focus-visible, .jm-search-dialog :focus-visible {
  outline: 2px solid #191919;
  outline-offset: 3px;
}

.jm-search-page .jm-search-query {
  font-size: 1.2rem;
  margin: 1.5rem 0 .7rem;
  overflow-wrap: anywhere;
}

.jm-search-page .jm-search-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  grid-auto-rows: 1fr;
  gap: .85rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.jm-search-result {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  height: 100%;
  gap: .55rem;
  border: 1px solid #ddd;
  border-top: 3px solid var(--jm-search-red);
  border-radius: .25rem;
  padding: 1rem;
  background: #fff;
}

.jm-search-result h3 {
  color: #191919;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  padding: 0;
  overflow-wrap: anywhere;
}

.jm-search-detail, .jm-search-page .page-numbers {
  color: var(--jm-search-red);
}

.jm-search-group {
  color: #515151;
  font-size: .9rem;
}

.jm-search-result:hover h3, .jm-search-page a.page-numbers {
  text-decoration: underline;
  text-underline-offset: .18em;
}

.jm-search-page .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.jm-search-dialog:not([open]) { display: none; }

.jm-search-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  box-sizing: border-box;
  width: min(34rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 1.25rem;
  background: #fff;
  border: 0;
  border-top: 4px solid var(--jm-search-red);
  border-radius: .35rem;
  box-shadow: 0 .8rem 2.5rem #0004;
}

.jm-search-dialog::backdrop { background: #0008; }
.jm-search-dialog .jm-search-form { margin: 0; }

.jm-search-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
}

.jm-search-dialog-head h2 {
  font-weight: 700;
  font-size: 1.45rem;
  padding: 0;
}

@media (max-width: 480px) {
  .jm-search-form input[type="search"], .jm-search-submit { flex-basis: 100%; }
}
