/* Shared control vocabulary for the workspace, including body-mounted layers.
   This is deliberately not a button reset: reading annotations, answer choices,
   charts, segmented navigation, the gradient header and artwork keep their own
   geometry and semantic colours. No layout, scrolling or animation is added. */
body.ep-top-navigation {
  --ep-control-font: var(--ds-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif);
  --ep-control-size: 14px;
  --ep-control-leading: 1.5;
  --ep-control-radius: 10px;
  --ep-control-space-1: 4px;
  --ep-control-space-2: 8px;
  --ep-control-space-3: 12px;
  --ep-control-space-4: 16px;
  --ep-control-space-5: 24px;
  --ep-control-paper: #fffefa;
  --ep-control-hover: #f0f2f5;
  --ep-control-ink: #354256;
  --ep-control-muted: #626b78;
  --ep-control-line: #d6d9df;
  --ep-control-line-hover: #9baabd;
  --ep-control-primary: #47658e;
  --ep-control-primary-hover: #39557b;
  --ep-control-on-primary: #ffffff;
  --ep-control-selected: #e8eef7;
  --ep-control-focus: #3f669b;
  --ep-control-disabled: #ebecef;
  --ep-control-disabled-ink: #5f6774;
  --ep-control-danger: #9e3945;
  --ep-control-danger-hover: #f9edf0;
  --ep-control-menu-shadow: 0 8px 24px #25395414, 0 1px 3px #2539540a;
  --ep-control-dialog-shadow: 0 16px 48px #1d2a4029;
}

@media screen {
  /* Explicit action aliases: typography and hit area, never full-card choices. */
  body.ep-top-navigation :is(
    .migration-button, .ep-home-action__link, .ep-wordbook-button,
    .ep-write-arsenal-open, .ep-draft-actions button,
    .ep-book-browse-link, .ep-wordbook-back, .ep-bookshelf-tools button,
    .ep-personal-card-heading button, [data-personal-action="retry"],
    .ep-decompose-primary, .ep-decompose-secondary, .ep-profile-primary, .ep-profile-secondary,
    .ep-arsenal-card__actions button, .ep-excerpt-editor__actions button,
    .ep-profile-focus-actions a, .ep-profile-item footer button, .ep-profile-batch button,
    .ep-profile-notes footer button, .ep-profile-data-source button, .ep-viz-guide-save button,
    .ep-archive-card__actions a, .ep-archive-card__actions button, .ep-archive-empty a, .ep-archive-more, .ep-archive-next__cta,
    .ep-review-actions a, .ep-review-actions button, .ep-review-back, .ep-review-footer a,
    .ep-vocab-browser__actions button, .ep-vocab-browser__pagination button,
    .ep-essay-lifecycle button, .ep-training-paragraph__navigation button,
    .ep-training-paragraph-finish button, .ep-training-draft__actions button,
    .ep-training-draft__submit button, .ep-training-draft__reference-controls button,
    .ep-report-training-choice__actions button, .ep-report-practice-link,
    .ep-report-print, .ep-report-training-gate, .ep-map-return, .ep-training-status button,
    .ep-unit-actions button, .ep-unit-footer button,
    .migration-main .ep-study-page .ep-study-heading__actions > button, .ep-study-reader-toolbar button,
    .ep-chat-shell .ep-coach-quick-actions button, .ep-chat-more > summary,
    .ep-study-content button, .ep-arsenal-guide-card footer button,
    .ep-arsenal-guide-open, .ep-arsenal-guide-invite button, .ep-lookup-retry, .ep-lookup-entry__detail button,
    .ep-round-leave button, .ep-packing-page button, .ep-wordbook-print button
  ) {
    min-height: 44px;
    padding: var(--ep-control-space-2) var(--ep-control-space-3);
    border: 1px solid var(--ep-control-line);
    border-radius: var(--ep-control-radius);
    background: var(--ep-control-paper);
    color: var(--ep-control-ink);
    box-shadow: none;
    font-family: var(--ep-control-font);
    font-size: var(--ep-control-size);
    font-weight: 550;
    line-height: var(--ep-control-leading);
    text-decoration: none;
    text-underline-offset: 3px;
    cursor: pointer;
    touch-action: manipulation;
  }
  body.ep-top-navigation :is(
    .migration-button, .ep-home-action__link, .ep-wordbook-button,
    .ep-write-arsenal-open, .ep-draft-actions button,
    .ep-book-browse-link, .ep-wordbook-back, .ep-bookshelf-tools button,
    .ep-personal-card-heading button, [data-personal-action="retry"],
    .ep-decompose-primary, .ep-decompose-secondary, .ep-profile-primary, .ep-profile-secondary,
    .ep-arsenal-card__actions button, .ep-excerpt-editor__actions button,
    .ep-profile-focus-actions a, .ep-profile-item footer button, .ep-profile-batch button,
    .ep-profile-notes footer button, .ep-profile-data-source button, .ep-viz-guide-save button,
    .ep-archive-card__actions a, .ep-archive-card__actions button, .ep-archive-empty a, .ep-archive-more, .ep-archive-next__cta,
    .ep-review-actions a, .ep-review-actions button, .ep-review-back, .ep-review-footer a,
    .ep-vocab-browser__actions button, .ep-vocab-browser__pagination button,
    .ep-essay-lifecycle button, .ep-training-paragraph__navigation button,
    .ep-training-paragraph-finish button, .ep-training-draft__actions button,
    .ep-training-draft__submit button, .ep-training-draft__reference-controls button,
    .ep-report-training-choice__actions button, .ep-report-practice-link,
    .ep-report-print, .ep-report-training-gate, .ep-map-return, .ep-training-status button,
    .ep-unit-actions button, .ep-unit-footer button,
    .migration-main .ep-study-page .ep-study-heading__actions > button, .ep-study-reader-toolbar button,
    .ep-chat-shell .ep-coach-quick-actions button, .ep-chat-more > summary,
    .ep-study-content button, .ep-arsenal-guide-card footer button,
    .ep-arsenal-guide-open, .ep-arsenal-guide-invite button, .ep-lookup-retry, .ep-lookup-entry__detail button,
    .ep-round-leave button, .ep-packing-page button, .ep-wordbook-print button
  ):where(:not(:disabled):not([aria-disabled="true"]):hover) {
    border-color: var(--ep-control-line-hover);
    background: var(--ep-control-hover);
    color: var(--ep-control-ink);
  }

  /* Primary means the next action, not every selected tab or lesson answer. */
  body.ep-top-navigation :is(
    .migration-write-submit, .ep-home-action__link--primary, .ep-wordbook-button--primary,
    .ep-decompose-primary, .migration-main .ep-learning-profile a.ep-profile-primary, .ep-viz-guide-save button,
    .ep-archive-card__actions .ep-archive-card__resume, .ep-archive-next__cta,
    .ep-review-actions button, .ep-report-practice-link, .ep-essay-lifecycle button.ep-essay-lifecycle__next,
    .ep-training-paragraph-finish button, .ep-training-draft__submit button,
    .ep-unit-footer button[data-unit-action="next"],
    .ep-vocab-browser__actions .ep-vocab-browser__study, .ep-guide-next,
    .ep-study-content button[data-study-action="submit"],
    .ep-study-content button[data-study-action="begin"],
    .ep-study-content button[data-study-action="date-save"],
    .ep-round-leave button[data-round-end], .ep-packing-page button[data-packing-confirm],
    .ep-wordbook-print button.ep-wordbook-print__primary
  ) {
    border-color: var(--ep-control-primary);
    background: var(--ep-control-primary);
    color: var(--ep-control-on-primary);
    box-shadow: none;
    font-weight: 600;
  }
  body.ep-top-navigation :is(
    .migration-write-submit, .ep-home-action__link--primary, .ep-wordbook-button--primary,
    .ep-decompose-primary, .migration-main .ep-learning-profile a.ep-profile-primary, .ep-viz-guide-save button,
    .ep-archive-card__actions .ep-archive-card__resume, .ep-archive-next__cta,
    .ep-review-actions button, .ep-report-practice-link, .ep-essay-lifecycle button.ep-essay-lifecycle__next,
    .ep-training-paragraph-finish button, .ep-training-draft__submit button,
    .ep-unit-footer button[data-unit-action="next"],
    .ep-vocab-browser__actions .ep-vocab-browser__study, .ep-guide-next,
    .ep-study-content button[data-study-action="submit"],
    .ep-study-content button[data-study-action="begin"],
    .ep-study-content button[data-study-action="date-save"],
    .ep-round-leave button[data-round-end], .ep-packing-page button[data-packing-confirm],
    .ep-wordbook-print button.ep-wordbook-print__primary
  ):where(:not(:disabled):not([aria-disabled="true"]):hover) {
    border-color: var(--ep-control-primary-hover);
    background: var(--ep-control-primary-hover);
    color: var(--ep-control-on-primary);
  }
  /* The retained write stylesheet has two important paint declarations. */
  body.ep-top-navigation .migration-main .migration-write-page .migration-write-submit {
    background: var(--ep-control-primary) !important;
    box-shadow: none !important;
  }
  body.ep-top-navigation .migration-main .migration-write-page .migration-write-submit:not(:disabled):hover {
    background: var(--ep-control-primary-hover) !important;
  }

  body.ep-top-navigation :is(
    .ep-arsenal-card button.ep-arsenal-card__copy, .ep-archive-card__actions .ep-archive-card__shelve,
    .migration-main .ep-learning-profile button[data-profile-action="ignore"],
    .ep-packing-actions [data-packing-cancel], .ep-study-reader-toolbar button,
    .ep-decompose-text-button, .ep-wordbook-back, .ep-bookshelf-tools button,
    .ep-report-print, .ep-training-status button, .ep-arsenal-guide-invite [data-arsenal-guide-skip]
  ) {
    border-color: transparent;
    background: transparent;
    color: var(--ep-control-muted);
    box-shadow: none;
  }
  body.ep-top-navigation :is(
    .migration-main .ep-arsenal-card button[data-arsenal-remove], [data-excerpt-remove],
    [data-personal-action="remove"], [data-packing-remove], .ep-draft-discard
  ) {
    color: var(--ep-control-danger);
    background: transparent;
    border-color: transparent;
  }
  body.ep-top-navigation :is(
    .migration-main .ep-arsenal-card button[data-arsenal-remove], [data-excerpt-remove],
    [data-personal-action="remove"], [data-packing-remove], .ep-draft-discard
  ):where(:not(:disabled):hover) {
    color: var(--ep-control-danger);
    background: var(--ep-control-danger-hover);
    border-color: var(--ep-control-danger);
  }

  /* Menus share a surface, not position, width, visibility or keyboard logic. */
  body.ep-top-navigation :is(
    .migration-main .ep-topic-menu, .migration-main .ep-type-menu,
    .ep-arsenal-topic-menu, .migration-category-options,
    .ep-chat-shell .ep-chat-more-items, .ep-workspace-account__panel, .ep-lookup-panel, .ep-plan-options
  ) {
    border: 1px solid var(--ep-control-line);
    border-radius: 12px;
    background: var(--ep-control-paper);
    box-shadow: var(--ep-control-menu-shadow);
    color: var(--ep-control-ink);
    font-family: var(--ep-control-font);
  }
  body.ep-top-navigation :is(
    .migration-main .migration-write-page .ep-type-menu button, .migration-main .migration-write-page .ep-topic-option-button,
    .ep-arsenal-topic-menu button, .migration-category-options button,
    .ep-chat-shell .ep-chat-more-items > button, .ep-chat-shell .ep-chat-more-items > a,
    .ep-study-page .ep-study-picker-list > button, .ep-plan-options [role="option"]
  ) {
    min-height: 44px;
    padding: var(--ep-control-space-2) var(--ep-control-space-3);
    border-radius: 8px;
    color: var(--ep-control-ink);
    font-family: var(--ep-control-font);
    font-size: var(--ep-control-size);
    line-height: var(--ep-control-leading);
    box-shadow: none;
  }
  body.ep-top-navigation :is(
    .migration-main .migration-write-page .ep-type-menu button, .migration-main .migration-write-page .ep-topic-option-button,
    .ep-arsenal-topic-menu button, .migration-category-options button,
    .ep-chat-shell .ep-chat-more-items > button, .ep-chat-shell .ep-chat-more-items > a,
    .ep-study-page .ep-study-picker-list > button, .ep-plan-options [role="option"]
  ):where(:not(:disabled):hover) {
    background: var(--ep-control-hover);
    color: var(--ep-control-ink);
  }
  body.ep-top-navigation :is(
    .migration-main .migration-write-page .ep-type-menu button[aria-checked="true"],
    .migration-main .migration-write-page .ep-topic-option-button[aria-checked="true"],
    .ep-arsenal-topic-menu button[aria-checked="true"],
    .migration-category-options button.is-selected,
    .ep-study-page .ep-study-picker-list > button[aria-pressed="true"],
    .ep-plan-options [role="option"][aria-selected="true"],
    .ep-plan-options [role="option"][aria-selected="true"].is-active
  ) {
    background: var(--ep-control-selected);
    border-color: #a7b7cf;
    color: #294b78;
    box-shadow: none;
  }

  /* The bookshelf keeps illustrated cover buttons; its settings use the same
     field vocabulary, including the progressive native-select fallback. */
  body.ep-top-navigation .ep-wordbook-settings .ep-book-plan-fields :is(select, .ep-plan-select) {
    min-height: 44px;
    padding: var(--ep-control-space-2) var(--ep-control-space-3);
    border: 1px solid var(--ep-control-line);
    border-radius: var(--ep-control-radius);
    background: var(--ep-control-paper);
    color: var(--ep-control-ink);
    box-shadow: none;
    font-family: var(--ep-control-font);
    font-size: var(--ep-control-size);
    line-height: var(--ep-control-leading);
  }
  body.ep-top-navigation .ep-wordbook-settings .ep-book-plan-fields :is(select, .ep-plan-select):hover {
    border-color: var(--ep-control-line-hover);
  }
  body.ep-top-navigation .ep-wordbook-settings .ep-book-plan-fields .ep-plan-select[aria-expanded="true"] {
    border-color: var(--ep-control-focus);
    background: var(--ep-control-paper);
  }
  body.ep-top-navigation .ep-wordbook-settings .ep-book-plan-fields label { gap: var(--ep-control-space-2); }
  body.ep-top-navigation .ep-book-settings-panel {
    border-color: var(--ep-control-line);
    border-radius: 16px;
    background: var(--ep-control-paper);
    box-shadow: 0 1px 3px #2539540a;
  }

  /* Native dialogs and existing focus-managed body-mounted panels. */
  body.ep-top-navigation :is(
    .migration-main .ep-study-picker-dialog, .ep-arsenal-picker,
    .ep-study-panel, .ep-arsenal-guide-card, .ep-write-assistant-panel,
    .ep-round-leave, .ep-packing-page, .ep-wordbook-print__surface
  ) {
    border-color: var(--ep-control-line);
    border-radius: 16px;
    background: var(--ep-control-paper);
    color: var(--ep-control-ink);
    box-shadow: var(--ep-control-dialog-shadow);
    font-family: var(--ep-control-font);
  }
  body.ep-top-navigation :is(
    .ep-study-picker-heading h2, .ep-arsenal-picker__heading h2,
    .ep-study-panel .ep-study-heading h2, .ep-arsenal-guide-card h2,
    .ep-write-assistant-heading h2, .ep-round-leave h2,
    .ep-packing-heading h1, .ep-wordbook-print__header h2
  ) {
    font-family: var(--ep-control-font);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -.015em;
  }
  body.ep-top-navigation :is(
    .ep-study-picker-heading p,
    .ep-arsenal-guide-card > p, .ep-write-assistant-heading p,
    .ep-round-leave p, .ep-wordbook-print__header p, .ep-wordbook-print__footer p
  ) {
    color: var(--ep-control-muted);
    font-size: var(--ep-control-size);
    line-height: 1.7;
  }
  body.ep-top-navigation :is(
    .ep-study-picker-heading, .ep-arsenal-picker__heading, .ep-study-panel .ep-study-heading,
    .ep-write-assistant-heading, .ep-wordbook-print__header,
    .ep-arsenal-guide-card footer, .ep-wordbook-print__footer,
    .ep-round-leave > div, .ep-packing-actions
  ) { gap: var(--ep-control-space-3); }

  /* Close/audio icons stay compact; retain layout-sized toolbar boxes. */
  body.ep-top-navigation :is(
    .ep-study-picker-heading > button, .ep-arsenal-picker__heading > button,
    .ep-study-panel .ep-study-heading > button, .ep-arsenal-guide-card header button,
    .ep-write-assistant-heading button, .ep-wordbook-print__header > button,
    .ep-lookup-panel > header button
  ) {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ep-control-muted);
    box-shadow: none;
    font-size: 22px;
    line-height: 1;
  }
  body.ep-top-navigation :is(
    .ep-study-picker-heading > button, .ep-arsenal-picker__heading > button,
    .ep-study-panel .ep-study-heading > button, .ep-arsenal-guide-card header button,
    .ep-write-assistant-heading button, .ep-wordbook-print__header > button,
    .ep-lookup-panel > header button
  ):hover { background: var(--ep-control-hover); color: var(--ep-control-ink); }

  /* All workspace keyboard controls get one visible, non-motion focus cue. */
  body.ep-top-navigation :is(
    .migration-app button, .migration-app a, .migration-app summary,
    .migration-app input, .migration-app select, .migration-app textarea,
    .ep-study-overlay :is(button,input,textarea,summary),
    .ep-arsenal-guide-layer button, .ep-write-assistant-backdrop :is(button,a,summary,input,textarea),
    .ep-round-leave-overlay :is(button,input), .ep-packing-overlay :is(button,input),
    .ep-wordbook-print :is(button,input,select)
  ):focus-visible {
    outline: 2px solid var(--ep-control-focus);
    outline-offset: 3px;
  }
  /* A nested search has an enclosing focus ring; no inner rectangular frame. */
  body.ep-top-navigation :is(.ep-chat-search, .ep-global-lookup form):focus-within {
    border-color: var(--ep-control-focus);
    box-shadow: 0 0 0 3px #3f669b14;
  }
  body.ep-top-navigation :is(.ep-chat-search input, .ep-global-lookup input):focus-visible {
    outline: none;
    box-shadow: none;
  }
  body.ep-top-navigation .migration-header :is(a, button, summary):focus-visible {
    outline-color: #ffffff;
  }

  /* Disabled wins over primary, hover and destructive colour without opacity. */
  body.ep-top-navigation :is(
    .migration-app .migration-main .migration-button, .migration-app .ep-wordbook-button,
    .migration-app .ep-draft-actions button, .migration-app .ep-write-arsenal-open,
    .migration-app .ep-book-browse-link, .migration-app .ep-bookshelf-tools button,
    .migration-app .ep-personal-card-heading button, .migration-app [data-personal-action="retry"],
    .migration-app .ep-decompose-primary, .migration-app .ep-decompose-secondary,
    .migration-app .ep-arsenal-card__actions button, .migration-app .ep-excerpt-editor__actions button,
    .migration-app .ep-profile-item footer button, .migration-app .ep-profile-batch button,
    .migration-app .ep-profile-notes footer button, .migration-app .ep-profile-data-source button,
    .migration-app .ep-viz-guide-save button, .migration-app .ep-essay-lifecycle button,
    .migration-app .ep-training-draft__actions button, .migration-app .ep-training-draft__submit button,
    .migration-app .ep-training-paragraph__navigation button, .migration-app .ep-training-paragraph-finish button,
    .migration-app .ep-unit-actions button, .migration-app .ep-unit-footer button,
    .migration-app .ep-vocab-browser__actions button,
    .migration-app .ep-report-print, .migration-app .ep-report-training-gate,
    .migration-app .ep-training-status button,
    .ep-study-content button, .ep-arsenal-guide-card footer button,
    .ep-round-leave button, .ep-packing-page button, .ep-wordbook-print button
  ):is(:disabled, [aria-disabled="true"]) {
    border-color: var(--ep-control-line);
    background: var(--ep-control-disabled);
    color: var(--ep-control-disabled-ink);
    box-shadow: none;
    opacity: 1;
    cursor: not-allowed;
  }
  body.ep-top-navigation .migration-main .migration-write-page .migration-write-submit:disabled {
    background: var(--ep-control-disabled) !important;
    color: var(--ep-control-disabled-ink);
  }
}
