/* Mobile-first refinement layer for the Suzhou Gardens learning unit. */
.mobile-scroll-progress {
  position: fixed;
  z-index: 140;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #d7b06a, #b85d4f);
  box-shadow: 0 1px 5px rgba(20, 53, 46, .22);
  pointer-events: none;
}

.mobile-top-button {
  position: fixed;
  z-index: 125;
  right: 14px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: rgba(21, 53, 47, .94);
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 50%;
  box-shadow: 0 8px 28px rgba(13, 36, 30, .25);
  font: 800 18px/1 Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
}

.mobile-top-button.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 700px) {
  :root { --mobile-dock-height: 68px; }

  html {
    max-width: 100%;
    scroll-padding-top: 10px;
    scroll-padding-bottom: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom));
  }

  body,
  #root {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

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

  .unit-page {
    padding-bottom: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom));
  }

  #story,
  #sentence-lab,
  #segment-studios,
  #retell {
    scroll-margin-top: 10px;
    scroll-margin-bottom: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom));
  }

  .global-access-bar {
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 7px 10px;
  }

  .global-access-mark { display: none; }

  .global-access-bar p {
    display: block;
    flex: 1 1 180px;
    min-width: 0;
  }

  .global-access-bar p b {
    display: block;
    font-size: 10px;
  }

  .global-access-bar p span {
    display: -webkit-box;
    margin-top: 2px;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .global-access-bar button,
  .offline-ready {
    flex: 0 0 auto;
    width: auto;
    max-width: 42%;
    min-height: 38px;
    margin: 0;
    padding: 7px 10px;
    font-size: 9px;
    line-height: 1.25;
  }

  .mobile-quick-nav {
    position: fixed;
    z-index: 120;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: var(--mobile-dock-height);
    padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: rgba(20, 53, 46, .97);
    border-top: 1px solid rgba(255, 255, 255, .22);
    border-bottom: 0;
    box-shadow: 0 -10px 30px rgba(12, 31, 26, .22);
  }

  .mobile-quick-nav a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 54px;
    padding: 5px 3px;
    text-align: center;
    border-right-color: rgba(255, 255, 255, .14);
  }

  .mobile-quick-nav b {
    display: block;
    font-size: 9px;
  }

  .mobile-quick-nav span {
    gap: 2px;
    font-size: 9px;
  }

  .mobile-quick-nav small {
    display: block;
    font-size: 7px;
  }

  .unit-hero {
    padding-top: 18px;
  }

  .unit-hero-grid {
    margin-top: 34px;
  }

  .unit-hero-copy h1 {
    font-size: clamp(48px, 15vw, 62px);
  }

  .unit-hero-copy h2 {
    font-size: clamp(20px, 6vw, 24px);
  }

  .story-section,
  .imitate-section,
  .reflect-section,
  .unit-next,
  .segment-section,
  .memory-section,
  .notice-section,
  .retell-section {
    content-visibility: auto;
    contain-intrinsic-size: 900px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .section-intro h2,
  .imitate-copy h2,
  .segment-heading h2,
  .retell-heading h2,
  .reflect-section h2,
  .unit-next h2 {
    overflow-wrap: anywhere;
    font-size: clamp(32px, 9.6vw, 41px);
  }

  button,
  a,
  summary,
  select,
  input,
  textarea {
    touch-action: manipulation;
  }

  button,
  summary,
  select {
    min-height: 44px;
  }

  textarea,
  input,
  select {
    font-size: 16px !important;
  }

  audio {
    width: 100%;
    max-width: 100%;
  }

  .story-scenes,
  .sentence-strip,
  .segment-tabs,
  .model-tabs,
  .layer-tabs,
  .ktv-scroll {
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .story-scenes,
  .sentence-strip,
  .segment-tabs,
  .model-tabs {
    scrollbar-width: thin;
  }

  .ktv-scroll {
    margin-inline: 0;
    border-radius: 7px;
  }

  .ktv-stage {
    min-width: 680px;
  }

  .melody-panel,
  .lab-card,
  .recorder-card,
  .segment-studio,
  .retell-workbench,
  .retell-console,
  .model-library,
  .segment-speaking {
    min-width: 0;
    max-width: 100%;
  }

  .model-en,
  .model-zh,
  .transcript-row p,
  .segment-transcript-editor textarea,
  .retell-transcript-editor textarea {
    overflow-wrap: anywhere;
  }

  .segment-speaking,
  .retell-console {
    min-height: 0 !important;
  }

  .segment-playback,
  .segment-transcript-actions,
  .retell-transcript-actions,
  .segment-nav {
    gap: 9px;
  }

  .segment-record-row button,
  .retell-record button,
  .story-play,
  .model-voice-play,
  .main-play {
    min-height: 52px;
  }

  .story-visual img,
  .hero-garden-photo img,
  .segment-context img,
  .picture-support img,
  .current-memory-cue img {
    content-visibility: auto;
  }

  .mobile-top-button { display: grid; }
}

@media (min-width: 701px) {
  .mobile-scroll-progress,
  .mobile-top-button { display: none; }
}

@media (max-width: 370px) {
  .mobile-quick-nav b { display: none; }
  .mobile-quick-nav span { font-size: 8px; }
  .mobile-quick-nav small { font-size: 7px; }
  .global-access-bar p span { -webkit-line-clamp: 1; }
  .unit-hero-copy h1 { font-size: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-top-button { transition: none; }
}
