/* Phone-only tweaks. iPad/PC use min-width 700px and stay unchanged. */
@media (max-width: 699px) {
  :root {
    --kb-inset: 0px;
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  /* Nav: keep one row, allow swipe if items overflow */
  header.sticky nav[aria-label="主导航"] {
    justify-content: flex-start;
    gap: 0.85rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  header.sticky nav[aria-label="主导航"]::-webkit-scrollbar {
    display: none;
  }
  header.sticky nav[aria-label="主导航"] a {
    font-size: 13px;
  }

  /* Login / register: extra bottom space for iOS home indicator */
  .login-left + div,
  body:not(.practice-immersive) main {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #payment-step-qrcode .desktop-pay-hint { display: none; }
  #payment-qrcode { display: none; }
  #payment-mobile-link {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 1rem;
    border-radius: 999px;
    background: #07c160;
    padding: 0.85rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff !important;
    text-decoration: none !important;
  }
  #payment-step-qrcode .phone-pay-hint {
    display: block;
  }

  /* Word practice: shrink chrome so the prompt + input stay above the keyboard */
  body.practice-immersive,
  body.practice-immersive main,
  #immersive-practice-shell,
  #scene-practice-shell {
    height: 100dvh;
    max-height: 100dvh;
  }
  #immersive-practice-shell {
    padding-bottom: var(--kb-inset);
  }
  .practice-shell-inner {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    padding-top: 0.55rem;
    padding-bottom: 0.35rem;
  }
  #immersive-practice-shell header {
    padding: 0.65rem 0.8rem;
    border-radius: 1.15rem;
  }
  #immersive-practice-shell header .rounded-full {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
    font-size: 10px;
  }
  #immersive-practice-shell header h1 {
    margin-top: 0.25rem;
    font-size: 1.05rem;
  }
  #immersive-practice-shell header .mt-1.text-sm {
    display: none;
  }
  #immersive-practice-shell header .flex.h-12.w-12 {
    height: 2.5rem;
    width: 2.5rem;
  }
  #word-input.word-letter-capture {
    font-size: 1.65rem !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }
  .word-letter-slot {
    min-width: 1.45rem;
    height: 3.2rem;
  }
  .word-letter-glyph {
    font-size: 2.1rem;
  }
  .word-letter-slots {
    gap: 0.14rem;
  }
  #translation-summary,
  .practice-translation-summary {
    font-size: 1.125rem !important;
    line-height: 1.55 !important;
  }
  #practice-shortcuts-footer {
    gap: 0.35rem;
    padding: 0.45rem 0.5rem max(0.55rem, env(safe-area-inset-bottom));
  }
  #practice-shortcuts-footer .jlb-kbd {
    display: none;
  }
  #practice-shortcuts-footer .practice-touch-btn {
    flex: 1 1 0;
    min-height: 44px;
    border-radius: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.45rem 0.25rem;
  }
  #practice-shortcuts-footer .practice-touch-btn.is-primary {
    background: linear-gradient(90deg, #0ea5e9 0%, #38bdf8 55%, #2dd4bf 100%);
    border-color: transparent;
    color: #fff;
  }

  /* Phrase practice */
  #phrase-zh {
    font-size: 1.35rem !important;
    line-height: 1.35;
  }
  .jlb-blank {
    min-height: 36px;
    margin-bottom: 2.1rem;
    font-size: 1.65rem;
    font-weight: 700;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }
  .jlb-blank.has-letter-slots {
    min-height: 3rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
  }
  .jlb-letter-slot {
    min-width: 1rem;
    height: 2.1rem;
  }
  .jlb-letter-glyph {
    font-size: 1.35rem;
  }
  .jlb-letter-row {
    gap: 0.1rem;
  }
  footer#phrase-practice-footer {
    gap: 0.4rem;
    padding: 0.5rem 0.6rem calc(max(0.6rem, env(safe-area-inset-bottom)) + 20px);
  }
  footer#phrase-practice-footer .jlb-kbd {
    display: none;
  }
  footer#phrase-practice-footer button {
    flex: 1 1 0;
    min-height: 44px;
    border-radius: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    font-weight: 700;
    color: #fff;
  }

  /* Scene practice: typing first; map is a collapsible drawer */
  #scene-practice-shell {
    height: 100dvh;
    max-height: 100dvh;
    padding-bottom: var(--kb-inset);
  }
  #scene-practice-shell.jlb-shell {
    height: 100dvh;
  }
  .practice-map-panel {
    max-height: none;
  }
  .practice-map-panel:not(.is-collapsed) {
    max-height: 34vh;
  }
  .practice-side-board {
    display: none;
  }
  #scene-zh-prompt {
    font-size: 1.2rem !important;
  }
  #scene-footer {
    gap: 0.35rem;
    padding: 0.45rem 0.5rem max(0.55rem, env(safe-area-inset-bottom));
  }
  #scene-footer .jlb-kbd {
    display: none;
  }
  #scene-footer [data-action] {
    flex: 1 1 0;
    min-height: 44px;
    justify-content: center;
    border-radius: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
  }
  #scene-footer [data-action="primary"] {
    background: linear-gradient(90deg, #0ea5e9 0%, #38bdf8 55%, #2dd4bf 100%);
    border-color: transparent;
  }
  #scene-footer [data-action="next"] {
    position: static;
    transform: none;
    flex: 0 0 44px;
    font-size: 1.4rem;
  }
}

@media (min-width: 700px) {
  .practice-touch-label-only {
    display: none;
  }
}

@keyframes nav-feedback-badge-shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-1px, 0) rotate(-10deg); }
  40% { transform: translate(1px, 0) rotate(10deg); }
  60% { transform: translate(-1px, 0) rotate(-8deg); }
  80% { transform: translate(1px, 0) rotate(8deg); }
}

.nav-feedback-badge {
  animation: nav-feedback-badge-shake 0.85s ease-in-out infinite;
}
