/* F2 (2026-10-22): phone practice toolbar in one row (<=56px) and a one-row action bar.
   Scoped to html[data-f2-toolbar] (set by the practice script once the 更多 menu exists), so nothing is hidden
   before its replacement is in place. Desktop keeps the C3 layout. CSP: no inline styles anywhere. */

/* ---------- action bar (phones and small tablets) ---------- */
@media (max-width: 900px) {
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions[data-f2-slot="answer"] #check-material,
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions[data-f2-slot="material"] #check-answer { display: none; }
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions { gap: 6px; padding: 6px; }
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions :is(#check-answer, #check-material) { flex: 1 1 0; font-size: 14px; }
  /* reveal: one line, short label; the full label stays in the accessibility tree */
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions #reveal-answer {
    flex: 0 0 auto; width: auto; max-width: none; min-width: 72px; padding: 0 10px; white-space: nowrap;
    font-size: 0; line-height: 1; text-decoration: none;
  }
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions #reveal-answer::after {
    content: attr(data-f2-short); font-size: 13.5px; font-weight: 650; line-height: 1.2; color: var(--jt-brand-ink, #1F4E39);
  }
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions .practice-step-navigation #next-question { flex: 1 1 0; }
  html[data-f2-toolbar][data-practice-ui-experiment] body .question-actions #check-material.f2-primary { border-color: var(--jt-brand, #2E6A4E); color: #fff; background: var(--jt-brand, #2E6A4E); }
}

/* ---------- toolbar: one row on phones ---------- */
@media (max-width: 680px) {
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header {
    display: flex; flex-wrap: nowrap; align-items: center; gap: 6px;
    height: 56px; min-height: 0; padding: 6px 8px; box-sizing: border-box;
  }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .jt-practice-lead { flex: 0 0 auto; gap: 6px; }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .jt-practice-brand { padding-right: 6px; }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .session-context,
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #open-practice-selection,
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #mark-question,
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #toggle-unit-words,
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #save-state { display: none; }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header-actions {
    display: flex; flex: 1 1 auto; min-width: 0; align-items: center; justify-content: flex-end; gap: 6px;
  }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .session-tools {
    display: flex; flex: 1 1 auto; flex-wrap: nowrap; min-width: 0; align-items: center; justify-content: flex-end; gap: 6px; row-gap: 0;
  }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .session-tools[hidden] { display: none; }
  /* back link reads "‹ U01"; its full text stays for screen readers */
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .unit-return {
    max-width: none; min-width: 44px; padding: 0 9px; font-size: 0; overflow: visible;
  }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .unit-return::before {
    content: "‹ " attr(data-f2-short); font-size: 14px; font-weight: 650; line-height: 1; white-space: nowrap;
  }
  /* counter: number first, unit words dropped, position within a passage kept small */
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .question-counter {
    flex: 0 1 auto; min-width: 0; margin-right: auto; padding-left: 2px; white-space: nowrap; overflow: hidden; font-size: 13px;
  }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header :is(#question-position-prefix, #question-position-unit) { display: none; }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #question-subposition { font-size: 12px; color: var(--jt-muted, #66726B); }
  /* assist badge stays visible (honesty of the record) but compact */
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .assist-badge:not([hidden]) {
    flex: none; padding: 2px 7px; border-radius: 999px; font-size: 0; line-height: 1;
    color: var(--jt-assist, #5F3A93); background: var(--jt-assist-bg, #EEE7F7);
  }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .assist-badge:not([hidden])::before { content: "辅助"; font-size: 11.5px; font-weight: 650; }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #open-question-overview.p0-docked,
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #open-question-overview.is-listening-docked {
    flex: none; min-width: 44px; min-height: 44px; padding: 0 9px; justify-content: center; gap: 4px;
  }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header .f2-header-more {
    display: inline-flex; flex: none; width: 44px; min-width: 44px; min-height: 44px; padding: 0; align-items: center; justify-content: center;
  }
  /* layout offsets that assumed the old 106px two-row toolbar */
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-panel { scroll-margin-top: 64px; }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .mobile-pane-tabs { top: 56px; }
  html[data-jt][data-f2-toolbar][data-practice-ui-experiment="zen-shell-all-units-v1"]:root body .session.is-toefl_listening #question-card { scroll-margin-block-start: calc(118px + env(safe-area-inset-top, 0px)); }
}
@media (max-width: 360px) {
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .jt-practice-brand { display: none; }
  html[data-jt][data-f2-toolbar]:root body[data-jt-page="practice"][data-jt-page] .practice-header #open-question-overview .zen-practice-drawer-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
html[data-f2-toolbar] .f2-more-glyph { font-size: 22px; font-weight: 700; line-height: 1; letter-spacing: 0; transform: translateY(-3px); }
/* desktop and tablets: the 更多 button and menu exist but are not needed */
@media (min-width: 681px) {
  html[data-f2-toolbar] .f2-header-more, html[data-f2-toolbar] .f2-header-menu { display: none; }
}

/* ---------- the 更多 menu itself ---------- */
html[data-f2-toolbar] .f2-header-menu {
  position: absolute; top: calc(100% + 4px); right: 8px; z-index: 60;
  width: min(320px, calc(100vw - 16px)); padding: 6px; box-sizing: border-box;
  border: 1px solid var(--jt-line, #E1E5DD); border-radius: 12px; background: var(--jt-surface, #fff);
  box-shadow: var(--jt-float-shadow, 0 6px 20px rgba(28, 39, 34, .10)); font-family: var(--jt-sans, sans-serif);
}
html[data-f2-toolbar] .f2-header-menu[hidden] { display: none; }
html[data-f2-toolbar] .f2-menu-context { margin: 4px 10px 6px; color: var(--jt-muted, #66726B); font-size: 12px; line-height: 1.4; }
html[data-f2-toolbar] .f2-menu-item {
  display: flex; width: 100%; min-height: 48px; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--jt-ink, #1C2722);
  font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
}
html[data-f2-toolbar] .f2-menu-item + .f2-menu-item { border-top: 1px solid var(--jt-line, #E1E5DD); border-radius: 0 0 8px 8px; }
html[data-f2-toolbar] .f2-menu-item:hover:not(:disabled) { background: var(--jt-sunken, #EEF0EA); }
html[data-f2-toolbar] .f2-menu-item:focus-visible { outline: none; box-shadow: var(--jt-focus, 0 0 0 2px #fff, 0 0 0 4px #2E6A4E); }
html[data-f2-toolbar] .f2-menu-item:disabled { color: var(--jt-muted, #66726B); cursor: default; }
html[data-f2-toolbar] .f2-menu-label { display: grid; gap: 2px; min-width: 0; }
html[data-f2-toolbar] .f2-menu-label small { color: var(--jt-muted, #66726B); font-size: 12px; font-weight: 400; line-height: 1.35; overflow-wrap: anywhere; }
html[data-f2-toolbar] .f2-menu-state {
  flex: none; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 650;
  color: var(--jt-brand-ink, #1F4E39); background: var(--jt-brand-soft, #E4EFE8);
}

/* ---------- unit-word chips: never cut the Chinese gloss (it was ellipsised at 7–9em) ---------- */
html[data-practice-ui-experiment] body .p2a-word-chip small { white-space: normal; overflow: visible; text-overflow: clip; max-width: 12em; line-height: 1.3; }
@media (max-width: 680px) { html[data-practice-ui-experiment] body .p2a-word-chip small { max-width: 10em; } }
