/* akusento pitch accent dictionary search */
.search-page {
  --search-surface: var(--ink-soft);
  --search-surface-2: color-mix(in srgb, var(--ink-soft) 86%, var(--paper) 14%);
  --search-border: rgba(127, 127, 127, 0.24);
  --search-muted: var(--paper-dim);
  --search-radius: 4px;
}

.search-main {
  display: block !important;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 72px 0 88px;
}

.search-hero {
  margin-bottom: 36px;
}

.search-kicker {
  margin: 0 0 10px;
  color: var(--vermillion);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.search-hero h1 {
  max-width: 20ch;
  margin: 0 0 18px;
  font-family: var(--en-font);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  font-weight: 600;
  line-height: 1.02;
  color: var(--paper);
}

.search-hero h1 span {
  color: var(--vermillion);
}

.search-lead {
  max-width: 60ch;
  margin: 0;
  color: var(--paper-dim);
  font-size: 1.05rem;
  font-weight: 300;
  line-height: 1.8;
}

.search-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
  background: var(--search-surface);
  border: 1px solid var(--search-border);
  border-radius: var(--search-radius);
  box-shadow: 0 18px 40px rgba(26, 20, 16, 0.1);
}

.legend {
  display: flex;
}

.legend[hidden] {
  display: none;
}

.legend-card {
  width: 100%;
  background: var(--search-surface-2);
  border: 1px solid var(--search-border);
  border-radius: var(--search-radius);
  padding: 14px 16px;
}

.legend-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--paper);
  margin-bottom: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--search-muted);
}

.legend-item[hidden] {
  display: none;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.legend-swatch.atamadaka { background: var(--atamadaka-color); }
.legend-swatch.heiban { background: var(--heiban-color); }
.legend-swatch.nakadaka { background: var(--nakadaka-color); }
.legend-swatch.odaka { background: var(--odaka-color); }
.legend-swatch.kifuku { background: var(--kifuku-color); }

.search-input-row {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-icon {
  position: absolute;
  left: 16px;
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: var(--search-muted);
  stroke-width: 2.1;
  stroke-linecap: round;
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px 0 48px;
  border: 1px solid var(--search-border);
  border-radius: var(--search-radius);
  background: color-mix(in srgb, var(--search-surface-2) 82%, transparent);
  color: var(--paper);
  font-size: 1.15rem;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.search-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--vermillion) 55%, var(--search-border));
  background: var(--search-surface-2);
}

.search-input::placeholder {
  color: var(--search-muted);
  font-family: var(--en-font);
}

.search-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: -4px;
}

.search-wildcard-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--search-muted);
  font-size: 0.78rem;
}

.search-help {
  position: relative;
  display: inline-flex;
}

.search-help-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  border-radius: 999px;
  color: var(--search-muted);
  cursor: pointer;
  list-style: none;
  transition: color 0.16s ease;
}

.search-help-toggle::-webkit-details-marker {
  display: none;
}

.search-help-toggle:hover,
.search-help[open] .search-help-toggle {
  color: var(--vermillion);
}

.search-help-icon {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-help-dot {
  fill: currentColor;
  stroke: none;
}

.search-help-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: max-content;
  max-width: min(360px, 80vw);
  padding: 14px 16px;
  background: var(--search-surface-2);
  border: 1px solid var(--search-border);
  border-radius: var(--search-radius);
  box-shadow: 0 18px 40px rgba(26, 20, 16, 0.18);
}

.search-help-title {
  margin: 0 0 8px;
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-help-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--search-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.search-help-list strong {
  color: var(--vermillion);
  font-family: var(--en-font);
}

.search-help-list em {
  color: var(--paper);
  font-style: normal;
}

.search-literal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--search-muted);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

.search-literal-toggle input {
  accent-color: var(--vermillion);
}

.search-recent[hidden] {
  display: none;
}

.search-recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.search-recent-label {
  color: var(--search-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-recent-clear {
  border: none;
  background: transparent;
  color: var(--search-muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.search-recent-clear:hover {
  color: var(--paper);
}

.search-recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-recent-chip {
  padding: 6px 14px;
  border: 1px solid var(--search-border);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.search-recent-chip:hover {
  border-color: color-mix(in srgb, var(--vermillion) 55%, var(--search-border));
  background: color-mix(in srgb, var(--vermillion) 10%, transparent);
}

.search-results {
  display: grid;
  gap: 10px;
}

.search-examples {
  margin-top: 4px;
}

.search-examples[hidden] {
  display: none;
}

.search-examples-heading {
  margin-bottom: 8px;
}

.search-example-reading {
  margin-left: 0.35em;
  color: var(--search-muted);
  font-size: 0.7em;
}

.search-state-message {
  margin: 8px 0;
  color: var(--search-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.search-result-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 18px;
  align-items: center;
  padding: 16px 20px 16px 18px;
  border: 1px solid var(--search-border);
  border-left: 3px solid var(--search-border);
  border-radius: var(--search-radius);
  background: var(--search-surface);
  transition: border-color 0.16s ease;
}

.search-result-card::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--search-border);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.search-result-card.Heiban { border-left-color: var(--heiban-color); }
.search-result-card.Heiban::after { background: var(--heiban-color); }
.search-result-card.Atamadaka { border-left-color: var(--atamadaka-color); }
.search-result-card.Atamadaka::after { background: var(--atamadaka-color); }
.search-result-card.Nakadaka { border-left-color: var(--nakadaka-color); }
.search-result-card.Nakadaka::after { background: var(--nakadaka-color); }
.search-result-card.Odaka { border-left-color: var(--odaka-color); }
.search-result-card.Odaka::after { background: var(--odaka-color); }
.search-result-card.Kifuku { border-left-color: var(--kifuku-color); }
.search-result-card.Kifuku::after { background: var(--kifuku-color); }

.search-result-word {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5em;
  font-size: 1.35rem;
  line-height: 2.2;
}

.search-result-patterns {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / 2;
  gap: 6px;
}

.search-result-pattern-chip {
  padding: 2px 10px;
  border: 1px solid var(--search-border);
  border-radius: 999px;
  background: transparent;
  color: var(--search-muted);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.search-result-pattern-chip:hover {
  border-color: color-mix(in srgb, var(--vermillion) 55%, var(--search-border));
  color: var(--paper);
}

.search-result-pattern-chip.is-active {
  border-color: var(--vermillion);
  background: color-mix(in srgb, var(--vermillion) 18%, transparent);
  color: var(--paper);
}

.search-result-romaji {
  grid-column: 1 / 2;
  color: var(--search-muted);
  font-family: var(--en-font);
  font-size: 0.88rem;
  opacity: 0;
}

.search-result-pos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-content: start;
}

.search-result-pos-tag {
  padding: 3px 9px;
  border: 1px solid var(--search-border);
  border-radius: 999px;
  color: var(--search-muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .search-result-card {
    grid-template-columns: 1fr;
  }

  .search-result-pos {
    justify-content: flex-start;
  }
}
