.migration-header { gap: 14px; }
.ep-source-notice { flex: 0 0 auto; align-self: center; margin-top: 7px; color: #6e809b; font-size: 12px; text-decoration: none; }
.ep-source-notice:hover { color: #365e95; text-decoration: underline; }
#sidebar-toggle { display: grid; place-items: center; flex: 0 0 36px; min-width: 36px; min-height: 36px; padding: 6px; border-radius: 8px; color: #58708f; }
#sidebar-toggle svg { width: 20px; height: 20px; }
#sidebar-toggle:hover { background: #e9eff8; }
#sidebar-toggle:disabled { opacity: .35; cursor: default; }
.ep-global-lookup { position: absolute; left: 50%; transform: translateX(-50%); width: clamp(260px, 33vw, 470px); }
.ep-global-lookup form { display: flex; align-items: center; gap: 8px; padding: 4px 7px 4px 12px; border: 1px solid #c3d0e0; border-radius: 12px; background: #f9fbfe; }
.ep-global-lookup form:focus-within { border-color: #6889b7; box-shadow: 0 0 0 3px #6689b312; }
.ep-global-lookup form > svg { flex: 0 0 16px; width: 16px; height: 16px; color: #8092ad; }
.ep-global-lookup input { min-width: 0; width: 100%; height: 26px; padding: 0; border: 0; outline: none; background: transparent; color: #334d70; font: inherit; font-size: 12px; }
.ep-global-lookup input::placeholder { color: #7f8ea3; opacity: 1; }
.ep-global-lookup input::-webkit-search-cancel-button { -webkit-appearance: none; }
.ep-global-lookup form button { flex: 0 0 auto; white-space: nowrap; padding: 4px 7px; border: 0; border-radius: 6px; background: #eaf0f8; color: #526c8f; font: inherit; font-size: 12px; cursor: pointer; }
.ep-global-lookup.is-exam-disabled { opacity: .65; }
#global-lookup-clear { width: 25px; height: 25px; padding: 0; border-radius: 50%; background: transparent; color: #7a8ca5; font-size: 18px; }
#global-lookup-clear:hover { background: #e6edf6; color: #344d70; }
#global-lookup-clear[hidden] { display: none; }
.ep-global-lookup button:focus-visible { outline: 2px solid #6584af; outline-offset: 2px; }
.ep-lookup-panel { position: absolute; top: calc(100% + 9px); left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); max-height: min(610px, calc(100dvh - 82px)); overflow-y: auto; padding: 11px 14px; border: 1px solid #c4d0e0; border-radius: 16px; background: #fbf9f5; box-shadow: 0 15px 45px #253e6129; }
.ep-lookup-panel[hidden] { display: none; }
.ep-lookup-panel > header { display: flex; align-items: center; justify-content: space-between; color: #344d70; font-size: 13px; }
.ep-lookup-panel > header button { border: 0; background: transparent; color: #7b8ca3; font-size: 19px; cursor: pointer; }
.ep-lookup-empty p { color: #718098; font-size: 12px; line-height: 1.6; }
.ep-lookup-empty { padding: 17px 6px; color: #415776; }
.ep-lookup-list { margin-top: 7px; }
.ep-lookup-candidates { display: grid; grid-template-columns: minmax(95px, 1fr) 44px minmax(0, 2fr) 44px; margin-top: 7px; }
.ep-lookup-candidates > .ep-lookup-list { display: contents; }
.ep-lookup-candidates .ep-lookup-entry { grid-column: 1 / 4; display: grid; grid-template-columns: subgrid; min-width: 0; }
.ep-lookup-candidates .ep-lookup-entry__choice { grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; gap: 0; min-height: 44px; height: 100%; }
.ep-lookup-candidates .ep-lookup-entry__choice strong { grid-column: 1; }
.ep-lookup-candidates .ep-lookup-entry__choice span { grid-column: 3; padding-left: 8px; }
.ep-lookup-row-pronounce, .ep-lookup-row-save { display: flex; align-items: center; justify-content: center; border-top: 1px solid #edf1f6; }
/* Separate controls share the row grid, without nesting buttons in a listbox option. */
.ep-lookup-row-pronounce { grid-column: 2; position: relative; }
.ep-lookup-row-save { grid-column: 4; }
.ep-lookup-row-save .ep-word-save--icon { flex-wrap: nowrap; gap: 0; }
.ep-lookup-pronounce { display: grid; place-items: center; width: 36px; height: 36px; padding: 8px; border: 0; border-radius: 50%; background: transparent; color: #58749a; cursor: pointer; }
.ep-lookup-pronounce:hover { background: #edf3fb; color: #304e79; }
.ep-lookup-pronounce svg { width: 18px; height: 18px; }
.ep-lookup-suggestion-title { margin: 14px 8px 4px; color: #526c8f; font-size: 12px; font-weight: 600; }
.ep-lookup-list--suggestions { margin-top: 0; }
.ep-lookup-list--suggestions .ep-lookup-entry__choice { grid-template-columns: minmax(0, 1fr) auto; }
.ep-lookup-list--suggestions .ep-lookup-entry__choice span { color: #8797ad; font-size: 12px; }
.ep-lookup-entry { border-top: 1px solid #edf1f6; color: #3e526d; }
.ep-lookup-entry__choice { display: grid; grid-template-columns: minmax(95px, 34%) minmax(0, 1fr); align-items: baseline; gap: 12px; width: 100%; min-height: 43px; padding: 10px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; font: inherit; cursor: pointer; }
.ep-lookup-entry__choice:focus-visible, .ep-lookup-entry.is-active .ep-lookup-entry__choice { outline: none; background: #edf3fb; }
.ep-lookup-entry__choice strong { color: #233b5d; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.ep-lookup-entry__choice span { color: #718098; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-lookup-entry__detail { margin: 12px 0 2px; padding: 13px 15px; border: 1px solid #e0e8f3; border-radius: 12px; background: #f5f8fc; }
.ep-lookup-entry__detail > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ep-lookup-entry__detail strong { color: #233b5d; font-size: 17px; overflow-wrap: anywhere; }
.ep-lookup-entry__detail small { color: #7387a3; font-size: 12px; }
.ep-lookup-entry__detail p { margin: 5px 0 9px; color: #405874; font-size: 12px; line-height: 1.65; white-space: pre-line; }
.ep-lookup-entry__detail button { border: 1px solid #d2dce9; border-radius: 6px; padding: 4px 8px; background: #fbf9f5; color: #557196; font: inherit; font-size: 12px; cursor: pointer; }
.ep-lookup-retry { margin: 12px 0 4px; padding: 7px 12px; border: 1px solid #d2dce9; border-radius: 6px; background: #f5f8fc; color: #415d84; font: inherit; font-size: 12px; cursor: pointer; }
#global-lookup-status { margin: 9px 0 0; color: #6c7f99; font-size: 12px; }
#global-lookup-status:empty { display: none; }
.ep-wordbook-lookup {
  position: fixed;
  inset: calc(54px + env(safe-area-inset-top, 0px)) 0 auto;
  box-sizing: border-box;
  width: min(500px, calc(100% - 28px));
  max-height: calc(100dvh - 74px - env(safe-area-inset-top, 0px));
  margin: 0 auto;
  padding: 4px 14px 14px;
  overscroll-behavior: contain;
  border: 1px solid #dce9e4;
  border-radius: 19px;
  background: #fff;
  color: #243e3b;
  box-shadow: 0 12px 34px #1b403520;
}
.ep-wordbook-lookup::backdrop { background: #22383040; }
.ep-wordbook-lookup > header { display: flex; align-items: center; justify-content: space-between; }
.ep-wordbook-lookup h2 { margin: 0 0 0 6px; font-size: 16px; }
.ep-wordbook-lookup > header button {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: #485f5b; font-size: 25px;
}
.ep-wordbook-lookup #global-lookup {
  position: relative; inset: auto; transform: none;
  width: 100%; min-width: 0; max-width: none; margin: 0;
}
.ep-wordbook-lookup #global-lookup-form {
  height: auto; min-height: 44px; padding-block: 0;
  border-color: #d9e7e1; border-radius: 12px; background: #f4f9f6;
}
.ep-wordbook-lookup #global-lookup-input { min-height: 44px; font-size: 16px; border: 0; }
.ep-wordbook-lookup #global-lookup-input:focus-visible { box-shadow: none !important; outline: 0; }
.ep-wordbook-lookup #global-lookup-form button {
  min-width: 44px; min-height: 44px; background: transparent; color: #3c625a; font-size: 13px;
}
.ep-wordbook-lookup #global-lookup-panel {
  position: static; transform: none; width: auto; max-height: none;
  padding: 5px 0 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
.ep-wordbook-lookup #global-lookup-panel > header { display: none; }
@media (min-width: 1001px) {
  body.ep-sidebar-collapsed #sidebar { display: none; }
  body.ep-sidebar-collapsed .migration-main { margin-left: 0; }
}
@media (max-width: 1000px) {
  .migration-header { padding: 0 12px; gap: 8px; }
  .ep-global-lookup { position: relative; left: auto; transform: none; width: auto; flex: 1 1 300px; max-width: 470px; margin-right: auto; }
  .migration-header .ep-global-site-entry { flex: 0 0 auto; font-size: 12px; }
}
@media (max-width: 600px), (pointer: coarse) and (max-width: 1000px) and (max-height: 500px) {
  .migration-header .ep-global-site-entry strong span { display: none; }
  .migration-header .ep-global-site-entry { border-radius: 8px; }
  .ep-global-lookup { min-width: 0; }
  .ep-lookup-panel { position: fixed; left: 12px; right: 12px; width: auto; top: 62px; transform: none; }
  .ep-global-lookup input { font-size: 12px; }
  .ep-global-lookup form { gap: 5px; padding-left: 8px; }
}
@media print { #global-lookup, #sidebar-toggle { display: none !important; } }

@media screen and (max-width: 600px), screen and (pointer: coarse) and (max-width: 1000px) and (max-height: 500px) {
  body.ep-mobile-shell #home-content .ep-global-lookup {
    position: relative; z-index: 12; flex: 0 0 auto; inset: auto; transform: none;
    width: 100%; max-width: none; margin: 4px 0 10px;
  }
  body.ep-mobile-shell #home-content .ep-global-lookup form {
    min-height: 46px; gap: 8px; padding: 0 4px 0 13px;
    border: 1px solid #ffffffaa; border-radius: 15px; background: #fbfcffcf;
    box-shadow: 0 3px 12px #666b9210;
  }
  body.ep-mobile-shell #home-content .ep-global-lookup input { height: 44px; font-size: 16px; color: #343b58; }
  body.ep-mobile-shell #home-content .ep-global-lookup input:is(:focus, :focus-visible) { border: 0; outline: 0; box-shadow: none; background: transparent; }
  body.ep-mobile-shell #home-content .ep-global-lookup input::placeholder { font-size: 13px; color: #727991; }
  body.ep-mobile-shell #home-content .ep-global-lookup form button { min-width: 44px; min-height: 44px; padding: 7px; border-radius: 11px; background: transparent; color: #625683; font-size: 13px; }
  body.ep-mobile-shell #home-content .ep-global-lookup form > svg { display: block; color: #7a7198; }
  body.ep-mobile-shell #home-content .ep-lookup-panel {
    position: absolute; inset: calc(100% + 6px) 0 auto; transform: none; width: 100%;
    max-height: min(440px, calc(100dvh - 190px)); background: #fcfcff; border-color: #e0dfed;
  }
  body.ep-mobile-shell #home-content .ep-lookup-panel > header button { min-width: 44px; min-height: 44px; }
  body.ep-mobile-shell #home-content .ep-lookup-panel > header {
    position: sticky; top: 0; z-index: 1; background: inherit;
  }
  body.ep-mobile-shell:has(#home-content [data-compact-lookup] .ep-lookup-panel:not([hidden])) .ep-mobile-learning-nav { visibility: hidden; }
  body.ep-mobile-shell #home-content .ep-global-lookup[data-compact-lookup]:has(.ep-lookup-panel:not([hidden])) {
    position: fixed; inset: calc(var(--ep-phone-view-top, 0px) + 4px) 8px auto;
    z-index: 40; box-sizing: border-box; width: auto; margin: 0;
    display: flex; flex-direction: column; max-height: calc(var(--ep-phone-view-height, 100dvh) - 8px);
    padding: 4px; border-radius: 16px; background: #fcfcff; box-shadow: 0 6px 24px #253e6126;
  }
  body.ep-mobile-shell #home-content [data-compact-lookup] form { flex-shrink: 0; }
  body.ep-mobile-shell #home-content [data-compact-lookup] .ep-lookup-panel {
    position: static; min-height: 0; max-height: none; width: auto; margin-top: 2px;
    padding: 0 10px 8px; overflow-y: auto; overscroll-behavior: contain; box-shadow: none;
  }
  body.ep-mobile-shell .ep-wordbook-lookup[open] {
    --lookup-inset: max(54px, var(--ep-phone-safe-top, 0px));
    top: calc(var(--ep-phone-view-top, 0px) + var(--lookup-inset));
    max-height: calc(var(--ep-phone-view-height, 100dvh) - var(--lookup-inset) - max(8px, var(--ep-phone-safe-bottom, 0px)));
    display: flex; flex-direction: column; overflow: hidden;
  }
  body.ep-mobile-shell .ep-wordbook-lookup[open]:has([data-compact-lookup]) { --lookup-inset: max(8px, var(--ep-phone-safe-top, 0px)); }
  body.ep-mobile-shell .ep-wordbook-lookup[open]:has([data-compact-lookup] .ep-lookup-panel:not([hidden])) {
    height: var(--ep-phone-view-height, 100dvh);
  }
  body.ep-mobile-shell .ep-wordbook-lookup > header,
  body.ep-mobile-shell .ep-wordbook-lookup form { flex-shrink: 0; }
  body.ep-mobile-shell .ep-wordbook-lookup #global-lookup { display: flex; flex-direction: column; min-height: 0; }
  body.ep-mobile-shell .ep-wordbook-lookup #global-lookup-panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  body.ep-mobile-shell .ep-book-entry--personal > .ep-global-lookup { margin-bottom: 16px; }
}
