/* Homepage import / more menus
   Hybrid direction: text triggers from proposal A + low-color menu rows from proposal B. */

body.first-visit .hero-input,
body.first-visit .hero-actions,
body.first-visit .hero-secondary-actions {
  overflow: visible;
}

body.first-visit .hero-menu-details {
  position: relative;
  overflow: visible;
}

body.first-visit .hero-menu-details > summary.hero-text-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 8px 0;
  line-height: 1.2;
  list-style: none;
}

body.first-visit .hero-menu-details > summary.hero-text-action::-webkit-details-marker {
  display: none;
}

body.first-visit .hero-menu-details > summary.hero-text-action::marker {
  content: "";
}

body.first-visit .hero-menu-chevron {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(-0.5px);
  transform-origin: 50% 50%;
  transition: transform 140ms ease;
}

body.first-visit .hero-menu-details[open] > summary.hero-text-action {
  color: var(--color-primary, #6750A4);
}

body.first-visit .hero-menu-details[open] .hero-menu-chevron {
  transform: translateY(-0.5px) rotate(180deg);
}

body.first-visit .hero-menu-popover,
body.first-visit .hero-more-menu .hero-menu-popover {
  position: absolute !important;
  z-index: 60;
  top: calc(100% + 8px) !important;
  bottom: auto !important;
  left: 0 !important;
  right: auto !important;
  width: 252px;
  max-width: min(252px, calc(100vw - 32px));
  margin: 0 !important;
  padding: 0;
  overflow: hidden;
  border: 1px solid #E2DDE6;
  border-radius: 11px;
  background: #FFFFFF;
  box-shadow: 0 10px 28px rgba(45, 34, 69, .10);
  transform: none !important;
}

body.first-visit .hero-more-menu .hero-menu-popover {
  width: 188px;
  max-width: min(188px, calc(100vw - 32px));
}

body.first-visit .hero-menu-item {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid #F0ECF2;
  border-radius: 0;
  background: #FFFFFF;
  color: #1C1B1F;
  text-align: left;
  box-shadow: none;
}

body.first-visit .hero-menu-item:last-child {
  border-bottom: 0;
}

body.first-visit .hero-menu-item:hover,
body.first-visit .hero-menu-item:focus-visible {
  background: #F8F6FA;
  color: #1C1B1F;
  outline: none;
  transform: none;
}

body.first-visit .hero-menu-item-label {
  min-width: 0;
  font-size: var(--type-size-control);
  font-weight: 500;
  line-height: 1.35;
}

body.first-visit .hero-beta-pill {
  padding: 2px 6px;
  border: 0;
  border-radius: 999px;
  background: #F2EEF6;
  color: #6750A4;
  font-size: var(--type-size-caption);
  font-weight: 600;
  line-height: 1.25;
}

@media (max-width: 640px) {
  body.first-visit .hero-secondary-actions {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
  }

  body.first-visit .hero-secondary-actions > *,
  body.first-visit .hero-menu-details,
  body.first-visit .hero-menu-details > summary.hero-text-action,
  body.first-visit .hero-secondary-actions > .hero-text-action {
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.first-visit .hero-menu-popover,
  body.first-visit .hero-more-menu .hero-menu-popover {
    left: auto !important;
    right: 0 !important;
    max-width: calc(100vw - 28px);
  }
}

/* Mobile reader controls stay visible in two consistent, left-aligned groups. */
@media (max-width: 720px) {
  body[data-view="reading"] #readerToolbar.reader-toolbar {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    justify-content: stretch !important;
    gap: 6px !important;
    overflow: visible !important;
  }

  body[data-view="reading"] #readerToolbar .reader-tool-group,
  body[data-view="reading"] #readerToolbar .reader-tool-group-end {
    width: 100% !important;
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
    flex-wrap: nowrap !important;
  }

  body[data-view="reading"] #readerToolbar .reader-tool-divider {
    display: none !important;
  }

  body[data-view="reading"] #readerToolbar .reader-tool {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }

  body[data-view="reading"] #readerToolbar .reader-tool-wide {
    width: auto !important;
    min-width: 72px !important;
    padding-right: 12px !important;
    padding-left: 12px !important;
  }
}

/* Settings dropdowns use the same quiet menu language as the homepage and vocab tools. */
body[data-view="settings"] .settings-tts-controls {
  overflow: visible;
}

body[data-view="settings"] .settings-choice-menu {
  position: relative;
  width: 172px;
  max-width: 100%;
}

body[data-view="settings"] .settings-choice-menu--voice {
  width: 172px;
}

body[data-view="settings"] .settings-choice-trigger {
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 0 42px 0 16px;
  border: 1px solid #C9C4D0;
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--color-text);
  list-style: none;
  cursor: pointer;
}

body[data-view="settings"] .settings-choice-trigger::-webkit-details-marker {
  display: none;
}

body[data-view="settings"] .settings-choice-trigger::marker {
  content: "";
}

body[data-view="settings"] .settings-choice-trigger::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-65%) rotate(45deg);
  transition: transform 140ms ease;
}

body[data-view="settings"] .settings-choice-menu[open] .settings-choice-trigger::after {
  transform: translateY(-35%) rotate(225deg);
}

body[data-view="settings"] .settings-choice-trigger:hover,
body[data-view="settings"] .settings-choice-trigger:focus-visible,
body[data-view="settings"] .settings-choice-menu[open] .settings-choice-trigger {
  border-color: var(--color-primary, #6750A4);
  box-shadow: 0 0 0 2px rgba(103, 80, 164, .10);
  outline: none;
}

body[data-view="settings"] .settings-choice-title {
  min-width: 0;
  color: var(--color-text);
  font-size: var(--type-size-body);
  font-weight: 650;
}

body[data-view="settings"] .settings-choice-options {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid #DADDE3;
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: 0 16px 40px rgba(32, 35, 42, .14);
}

body[data-view="settings"] .settings-choice-options button {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text);
  font-size: var(--type-size-step-13-5);
  font-weight: 650;
  text-align: left;
}

body[data-view="settings"] .settings-choice-options--voice {
  width: max-content;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 32px));
}

body[data-view="settings"] .settings-choice-options--voice button > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="settings"] .settings-choice-options button:hover,
body[data-view="settings"] .settings-choice-options button:focus-visible {
  background: #F8F6FA;
  outline: none;
}

body[data-view="settings"] .settings-choice-options button.is-selected {
  background: #F2EEF6;
  color: var(--color-primary, #6750A4);
  font-weight: 600;
}

body[data-view="settings"] .settings-choice-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: #F0ECF6;
  color: var(--color-primary, #6750A4);
  font-size: var(--type-size-caption);
  font-weight: 600;
  line-height: 1.25;
}

@media (max-width: 720px) {
  body[data-view="settings"] .settings-choice-menu,
  body[data-view="settings"] .settings-choice-menu--voice {
    width: min(172px, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.first-visit .hero-menu-chevron,
  body[data-view="settings"] .settings-choice-trigger::after {
    transition: none;
  }
}
