/* Optional density, independent of Kajero's colour themes. Load last.
   Only dictionary results/lists change; fixed navigation, the composer,
   learning-note prose, course prose and editing dialogs keep their layout. */

html[data-kajero-density="compact"] body .kajero-search-timeline {
  gap: 8px;
}

html[data-kajero-density="compact"] body .kajero-search-turn__result.grid {
  gap: 8px;
  margin-top: 6px;
}

html[data-kajero-density="compact"] body :is(.entry-tabs__panels, .entry-tabs .entry-panel) {
  gap: 8px;
}

/* Keep the entry-parent branches: Console's mobile card selector has the
   same specificity, so this last-loaded density layer must match it. */
html[data-kajero-density="compact"] body :is(
  .entry-panel > .word-card, .entry > .word-card,
  .word-card, .root-card, .sense-card, .example-card,
  .example-translation-search-card, .related-card, .translation-card,
  .detail-card, .search-mode-card
) {
  padding: 10px;
  border-radius: 6px;
  box-shadow: none;
}

html[data-kajero-density="compact"] body :is(
  .entry-panel > .word-card, .entry > .word-card,
  .word-card, .root-card, .sense-card, .example-card,
  .example-translation-search-card, .related-card, .translation-card,
  .detail-card, .search-mode-card
) > .card-title {
  gap: 6px;
  margin-bottom: 6px;
}

/* Flatten the dictionary's inner frame in the light/classic palettes too. */
html[data-kajero-density="compact"] body :is(
  .entry-panel > .word-card, .entry > .word-card,
  .word-card, .root-card, .sense-card, .example-card,
  .example-translation-search-card, .related-card, .translation-card,
  .detail-card, .search-mode-card
) > .inner {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

html[data-kajero-density="compact"] body :is(.word-card, .root-card) .entry__head {
  margin-bottom: 6px;
}

html[data-kajero-density="compact"] body .entry__head :is(.word-head, .language-row, .headword-row) {
  gap: 6px;
}

html[data-kajero-density="compact"] body .entry__head .headword {
  font-size: min(var(--headword-fit-size, 1.65rem), 1.65rem);
}

html[data-kajero-density="compact"] body .word-card .meaning {
  margin-top: 6px;
}

html[data-kajero-density="compact"] body :is(.word-card, .root-card) .pronunciation-line {
  gap: 4px 8px;
}

html[data-kajero-density="compact"] body :is(.entry-tabs__nav, .entry-secondary-tabs) {
  gap: 4px;
}

html[data-kajero-density="compact"] body .entry-tabs__nav {
  padding: 5px;
}

html[data-kajero-density="compact"] body .entry-tab {
  padding: 6px 8px;
}

html[data-kajero-density="compact"] body .entry-secondary-details--tabs > .entry-secondary-tabs {
  margin-bottom: 6px;
  margin-inline-start: 0;
}

html[data-kajero-density="compact"] body .entry-secondary-tab {
  min-height: 32px;
  padding-inline: 8px;
  border-radius: 4px;
}

html[data-kajero-density="compact"] body .sense-card__list {
  gap: 6px;
}

html[data-kajero-density="compact"] body .sense-card__item {
  padding: 8px;
  border-radius: 4px;
}

html[data-kajero-density="compact"] body .sense-card__item-head {
  gap: 6px;
}

html[data-kajero-density="compact"] body .sense-card__translation-group {
  gap: 5px;
  margin-top: 7px;
}

html[data-kajero-density="compact"] body .sense-card__translations {
  gap: 5px;
}

html[data-kajero-density="compact"] body .root-card .root-meta {
  gap: 6px;
  margin-block: 4px 8px;
}

html[data-kajero-density="compact"] body .root-card .root-meta-row {
  gap: 8px;
}

html[data-kajero-density="compact"] body :is(.example-list, .example-card ul) {
  gap: 8px;
}

html[data-kajero-density="compact"] body :is(.example-item, .example-translation-hit) {
  gap: 8px;
  padding-block: 7px;
}

html[data-kajero-density="compact"] body .example-card .example-text {
  padding-top: 2px;
}

html[data-kajero-density="compact"] body .example-reading-actions {
  gap: 5px;
  margin-top: 5px;
}

html[data-kajero-density="compact"] body .example-translation-hit__meta {
  gap: 3px 10px;
  margin-top: 4px;
}

html[data-kajero-density="compact"] body :is(.example-learning-list, .example-search-groups) .example-language[data-translation-language] {
  margin-block: .65rem .2rem;
}

html[data-kajero-density="compact"] body :is(.example-learning-list, .example-search-groups) ul + .example-language[data-translation-language] {
  margin-block-start: 1.4rem;
}

html[data-kajero-density="compact"] body .related-card .related-item {
  gap: 7px;
  padding-bottom: 7px;
}

html[data-kajero-density="compact"] body .search-mode-body {
  gap: 8px;
}

html[data-kajero-density="compact"] body .search-mode-list {
  gap: 6px;
}

/* Tag/dictionary lists also live inside information-page shells. Restrict
   their compact frame to shells that actually contain the existing list;
   prose-only information pages keep their original padding and typography. */
html[data-kajero-density="compact"] body .info-page-card:has(.info-page-body .search-mode-list) {
  padding: 0;
  border-radius: 6px;
  box-shadow: none;
}

html[data-kajero-density="compact"] body .info-page-card .info-page-body:has(.search-mode-list) {
  padding: 10px;
}

/* Keep the existing fit-driven control-row/word-row split. Compact mode
   changes the space within rows, never forces a word beside its controls. */
html[data-kajero-density="compact"] body .search-mode-list-item {
  gap: 5px;
}

html[data-kajero-density="compact"] body .search-mode-list a {
  padding: 5px 8px;
  min-height: 32px;
}

html[data-kajero-density="compact"] body :is(
  .entry__head .language-pill, .sense-card__field,
  .detail-card .tag-pill, .search-mode-card .chip,
  .info-page-related .tag-pill
) {
  min-height: 28px;
  padding: 3px 7px;
  border-radius: 4px;
}

html[data-kajero-density="compact"] body .entry__head .language-pill {
  min-width: 0;
}

/* A shorter visual control remains a labelled, keyboard-focusable button.
   Coarse pointers below restore a comfortable touch target. */
html[data-kajero-density="compact"] body :is(
  .word-card, .root-card, .example-card, .example-translation-search-card
) :is(.pronunciation-synthesize, .example-reading-actions > a) {
  min-height: 32px;
  padding: 4px 8px;
}

@media (max-width: 640px) {
  html[data-kajero-density="compact"] body :is(
    .entry-panel > .word-card, .entry > .word-card,
    .word-card, .root-card, .sense-card, .example-card,
    .example-translation-search-card, .related-card, .translation-card,
    .detail-card, .search-mode-card
  ) {
    padding: 8px;
  }

  html[data-kajero-density="compact"] body .info-page-card .info-page-body:has(.search-mode-list) {
    padding: 8px;
  }
}

@media (pointer: coarse) {
  html[data-kajero-density="compact"] body :is(.entry-tab, .entry-secondary-tab) {
    min-height: 44px;
  }

  html[data-kajero-density="compact"] body .search-mode-list a {
    min-height: 44px;
  }

  html[data-kajero-density="compact"] body :is(
    .word-card, .root-card, .example-card, .example-translation-search-card,
    .search-mode-list, .partial-match-item, .info-page-section .search-mode-list-item
  ) :is(.pronunciation-synthesize, .example-reading-actions > a, .pronunciation-widget button) {
    min-height: 44px;
    min-width: 44px;
  }

  html[data-kajero-density="compact"] body :is(
    .word-card, .root-card, .example-card, .example-translation-search-card,
    .search-mode-list, .partial-match-item, .info-page-section .search-mode-list-item
  ) .star-check {
    height: 44px;
    min-height: 44px;
    min-width: 44px;
  }
}
