/* 手机练习：限定在练习入口和作答页，保留桌面与结算层的既有布局。
   CSS Module 的可读类名前缀在源码构建和线上增量发布中保持一致。 */
@media (max-width: 767px) {
  .app-shell[data-role="student"]:has([data-testid="practice-entry"]) {
    padding-bottom: 0;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-main {
    padding: 12px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-topbar {
    min-height: 64px;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 20px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-profile {
    min-width: 0;
    gap: 8px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-profile > span {
    min-width: 0;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-profile strong {
    display: block;
    max-width: 7em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-profile small {
    font-size: 12px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-profile .ui-button {
    flex-shrink: 0;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-home-chip {
    min-width: 44px;
    min-height: 44px;
    padding: 6px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-home-logo {
    width: 32px;
    height: 32px;
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-mobile-nav {
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    min-height: 60px;
    padding: 4px;
    border-radius: 22px;
    background: rgba(250, 249, 255, .97);
    box-shadow: 0 4px 20px rgba(41, 34, 76, .12);
  }

  .app-shell:has([data-testid="practice-entry"]) .app-shell-mobile-nav .app-shell-nav-link {
    min-height: 52px;
    padding: 4px;
    gap: 2px;
  }

  [data-testid="practice-entry"].material-shell {
    width: 100%;
    min-width: 0;
    gap: 14px;
    padding: 4px 0 calc(88px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  [data-testid="practice-entry"].material-shell::before,
  [data-testid="practice-entry"].material-shell::after {
    display: none;
  }

  [data-testid="practice-entry"] [class*="_entryHeader_"] {
    padding: 4px;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  [data-testid="practice-entry"] [class*="_eyebrow_"] {
    margin: 0 0 6px;
    font-size: 12px;
    line-height: 1.5;
  }

  [data-testid="practice-entry"] [class*="_entryHeader_"] h1 {
    margin: 0;
    font-size: clamp(21px, 6vw, 25px);
    line-height: 1.35;
    letter-spacing: -.025em;
    text-wrap: balance;
  }

  :is([data-testid="practice-entry"], [data-testid="practice-session"]) [class*="_statsStrip_"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin-top: 12px;
    padding: 10px 0;
    border: 1px solid rgba(111, 101, 165, .12);
    border-radius: 16px;
    background: rgba(255, 255, 255, .75);
  }

  :is([data-testid="practice-entry"], [data-testid="practice-session"]) [class*="_statsStrip_"] > div {
    min-width: 0;
    gap: 4px;
    padding: 0 10px;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  :is([data-testid="practice-entry"], [data-testid="practice-session"]) [class*="_statsStrip_"] > div + div {
    border-left: 1px solid rgba(111, 101, 165, .14);
  }

  :is([data-testid="practice-entry"], [data-testid="practice-session"]) [class*="_statsStrip_"] span {
    font-size: 11px;
    line-height: 1.5;
  }

  :is([data-testid="practice-entry"], [data-testid="practice-session"]) [class*="_statsStrip_"] strong {
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  [data-testid="practice-entry"] [class*="_modeCards_"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
    border-radius: 20px;
    background: rgba(226, 223, 243, .65);
  }

  [data-testid="practice-entry"] [class*="_modeCard_"] {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    min-height: 66px;
    gap: 4px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 16px;
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  [data-testid="practice-entry"] [class*="_modeCard_"][aria-pressed="true"] {
    border-color: rgba(105, 87, 200, .4);
    background: #fff;
    box-shadow: 0 2px 6px rgba(65, 48, 126, .08);
  }

  [data-testid="practice-entry"] [class*="_modeCardTitle_"] {
    font-size: 16px;
    line-height: 1.4;
  }

  /* 说明在下面的当前模式面板完整呈现；切换器保留其可访问描述。 */
  [data-testid="practice-entry"] [class*="_modeCardDescription_"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  [data-testid="practice-entry"] [class*="_modeCards_"] [class*="_selectionText_"] {
    padding: 0;
    background: none;
    color: #665d7e;
    font-size: 11px;
    line-height: 1.4;
  }

  [data-testid="practice-entry"] [class*="_modeCard_"][aria-pressed="true"] [class*="_selectionText_"] {
    color: #50419e;
  }

  [data-testid="practice-entry"] [class*="_entryPanel_"] {
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(118, 105, 172, .14);
    border-radius: 20px;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 4px 16px rgba(53, 43, 96, .05);
  }

  [data-testid="practice-entry"] [class*="_entryPanel_"]::before,
  [data-testid="practice-entry"] [class*="_entryPanel_"]::after {
    display: none;
  }

  [data-testid="practice-entry"] [class*="_entryPanel_"] h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.45;
  }

  [data-testid="practice-entry"] [class*="_entryPanel_"] > p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
  }

  [data-testid="practice-entry"] [class*="_scopeModePicker_"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    box-shadow: none;
  }

  [data-testid="practice-entry"] [class*="_scopeModePicker_"] button {
    min-width: 0;
    min-height: 44px;
    padding: 8px 2px;
    font-size: 14px;
    line-height: 1.5;
  }

  [data-testid="practice-entry"] [class*="_scopeModeLabel_"] {
    display: block;
    white-space: normal;
  }

  [data-testid="practice-entry"] [class*="_scopeModeLabel_"] > span {
    display: inline;
  }

  [data-testid="practice-entry"] [class*="_scopeSummary_"] {
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    box-shadow: none;
  }

  [data-testid="practice-entry"] [class*="_scopeCopy_"] {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.6;
  }

  [data-testid="practice-entry"] [class*="_primaryAction_"] {
    width: 100%;
    min-height: 48px;
    padding: 12px;
    border-radius: 14px;
    font-size: 16px;
    line-height: 1.5;
  }

  [data-testid="practice-entry"] [class*="_chapterRoller_"] {
    padding: 2px 2px 10px;
    scroll-padding-inline: 2px;
  }

  [data-testid="practice-entry"] [class*="_chapterCard_"] {
    width: min(78vw, 260px);
    min-height: 100px;
    padding: 12px;
    border-radius: 14px;
    box-shadow: none;
  }

  [data-testid="practice-entry"] [class*="_focusComposer_"] textarea {
    min-width: 0;
    width: 100%;
    font-size: 16px;
    line-height: 1.6;
  }

  [data-testid="practice-session"][class*="_quickSessionLayout_"] {
    align-content: start;
  }

  [data-testid="practice-session"][class*="_layout_"] [class*="_quickStats_"] {
    display: block;
  }

  [data-testid="practice-session"][class*="_layout_"] [class*="_statsStrip_"] {
    margin-top: 0;
    padding-block: 8px;
  }

  [data-testid="practice-session"][class*="_layout_"] [data-testid="question-card"] {
    margin-block: 0;
    padding: 16px;
    border-radius: 18px;
    box-shadow: 0 4px 16px rgba(53, 43, 96, .07);
  }

  [data-testid="practice-session"][class*="_layout_"] [data-testid="question-card"] h2 {
    max-width: none;
    font-size: 20px;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }

  [data-testid="practice-session"][class*="_layout_"] [class*="_option_"] {
    min-height: 48px;
    font-size: 16px;
    line-height: 1.5;
  }

  [data-testid="practice-session"][class*="_layout_"] :is([class*="_matchingSource_"], [class*="_matchingTarget_"]) {
    min-width: 0;
    min-height: 48px;
    flex-wrap: wrap;
    overflow-wrap: anywhere;
  }

  [data-testid="practice-session"][class*="_layout_"] [class*="_sessionActions_"] .ui-button {
    min-height: 48px;
  }

  [data-testid="practice-session"][class*="_layout_"] [class*="_tableScroll_"] {
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 767px) and (forced-colors: active) {
  [data-testid="practice-entry"] [class*="_modeCard_"][aria-pressed="true"] {
    border: 2px solid Highlight;
  }
}

@media (max-width: 767px) and (prefers-reduced-transparency: reduce) {
  [data-testid="practice-entry"] :is([class*="_entryPanel_"], [class*="_modeCards_"]),
  :is([data-testid="practice-entry"], [data-testid="practice-session"]) [class*="_statsStrip_"] {
    background: var(--color-surface-raised, #fff);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
