html { scrollbar-gutter: stable; touch-action: pan-x pan-y; }
.top-actions { min-width: 0; display: flex; align-items: center; gap: 14px; }
.mode-switch { max-width: 100%; display: flex; gap: 3px; padding: 3px; border: 2px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 3px 3px 0 var(--ink); overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.mode-switch::-webkit-scrollbar { display: none; }
.mode-switch a { min-height: 34px; padding: 6px 11px; border: 0; border-radius: 9px; background: transparent; color: #586274; display: grid; place-items: center; font-size: 11px; font-weight: 900; text-decoration: none; cursor: pointer; white-space: nowrap; }
.mode-switch a.is-active { background: var(--ink); color: #fff; }
footer a { display: inline-block; margin-left: 8px; padding: 6px 10px; border: 2px solid var(--ink); border-radius: 10px; background: #fff2bd; color: var(--ink); box-shadow: 2px 2px 0 var(--ink); font-weight: 900; text-decoration: none; transition: transform .16s ease, box-shadow .16s ease; }
footer a:hover { transform: translateY(-2px); }
footer a:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--ink); }

body.moments-mode main { background: radial-gradient(circle at 8% 17%, #fff 0 3px, transparent 4px), linear-gradient(#c8eff4 0 300px, #fff8e7 300px); }
body.moments-mode .hero,
body.moments-mode .play-area,
body.moments-mode .grownup-tip,
body.moments-mode .cloud { display: none; }

.moments-section { width: min(1120px, calc(100% - 40px)); margin: 42px auto 64px; }
.moments-heading { max-width: 760px; margin-bottom: 30px; }
.moments-heading > span, .moments-step, .moments-result-head span { color: #2e7d87; font-size: 10px; letter-spacing: .16em; font-weight: 900; }
.moments-heading h1 { margin: 10px 0 12px; font-size: clamp(42px, 5vw, 70px); line-height: 1; letter-spacing: -.055em; }
.moments-heading p { margin: 0; color: #566574; line-height: 1.7; }

.moments-workspace { display: grid; grid-template-columns: 350px minmax(0, 1fr); border: 3px solid var(--ink); border-radius: 26px; overflow: hidden; box-shadow: 10px 10px 0 var(--ink); background: #fff; }
.moments-controls { padding: 28px; background: #dff5e5; border-right: 3px solid var(--ink); }
.count-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 14px 0 30px; }
.count-options button { min-height: 80px; border: 2px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
.count-options button b, .count-options button small { display: block; }
.count-options button b { font-size: 26px; line-height: 1; }
.count-options button small { margin-top: 6px; color: #6c7482; font-size: 9px; }
.count-options button.is-active { background: var(--yellow); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.moments-upload { width: 100%; min-height: 210px; margin-top: 14px; border: 3px dashed #4a8a66; border-radius: 18px; background: #f8fff9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; cursor: pointer; }
.moments-upload.is-dragging { background: #fff2bd; border-color: #9b8541; }
.moments-upload > span { width: 58px; height: 58px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--green); font-size: 34px; box-shadow: 4px 4px 0 var(--ink); }
.moments-upload strong { margin-top: 8px; font-size: 18px; }
.moments-upload small { color: #6a766f; font-size: 10px; }
.moments-privacy { margin: 18px 0 0; color: #5d6c62; font-size: 10px; line-height: 1.6; }

.moments-preview { min-height: 590px; padding: 28px; display: grid; place-items: center; background: #fff; }
.moments-empty { text-align: center; color: #858b95; }
.moments-empty > div { width: 240px; height: 240px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px; border: 2px solid #c6bdd9; border-radius: 18px; background: #eee8fb; }
.moments-empty i { border-radius: 5px; background: #f8f5ff; }
.moments-empty i:nth-child(2n) { background: #e4dbf8; }
.moments-empty p { margin-top: 22px; font-size: 12px; }
.moments-result { width: min(100%, 620px); }
.moments-result-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.moments-result-head h2 { margin: 5px 0 0; font-size: 25px; }
.moments-result-head button { min-height: 42px; padding: 8px 15px; border: 2px solid var(--ink); border-radius: 12px; background: #fff2bd; box-shadow: 3px 3px 0 var(--ink); font-size: 11px; font-weight: 900; cursor: pointer; }
.moments-grid { --columns: 2; display: grid; grid-template-columns: repeat(var(--columns), 1fr); gap: 7px; padding: 7px; border: 3px solid var(--ink); border-radius: 18px; background: var(--ink); overflow: hidden; }
.moments-tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; overflow: hidden; background: #eee; cursor: pointer; }
.moments-tile img { width: 100%; height: 100%; display: block; object-fit: cover; }
.moments-tile span { position: absolute; top: 7px; left: 7px; width: 25px; height: 25px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-size: 11px; font-weight: 900; }
.moments-tile:hover img { filter: brightness(.82); }
.moments-download { width: 100%; min-height: 52px; margin-top: 16px; border: 2px solid var(--ink); border-radius: 14px; background: var(--pink); color: #fff; box-shadow: 4px 4px 0 var(--ink); font-weight: 900; cursor: pointer; }
.moments-download-tip { margin: 12px 0 0; text-align: center; color: #777e88; font-size: 10px; }

@media (max-width: 900px) {
  .parent-note { display: none; }
  .topbar { width: calc(100% - 22px); min-height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .topbar .brand { font-size: 0; gap: 0; }
  .topbar .brand-mark { width: 28px; height: 28px; }
  .top-actions { flex: 1; justify-content: flex-end; gap: 0; }
  .mode-switch { max-width: calc(100vw - 72px); }
  .mode-switch a { min-height: 38px; padding: 5px 6px; font-size: 8px; }
}

@media (max-width: 700px) {
  .moments-workspace { grid-template-columns: 1fr; }
  .moments-controls { border-right: 0; border-bottom: 3px solid var(--ink); }
  .moments-upload { min-height: 160px; }
  .moments-preview { min-height: 520px; }
}

@media (max-width: 600px) {
  .top-actions { flex: 1; justify-content: flex-end; gap: 0; }
  .topbar .brand { font-size: 0; gap: 0; }
  .mode-switch { box-shadow: 2px 2px 0 var(--ink); }
  .mode-switch { max-width: calc(100vw - 72px); }
  .mode-switch a { min-height: 38px; padding: 5px 6px; font-size: 8px; }
  body.moments-mode .topbar { min-height: calc(54px + env(safe-area-inset-top)); }
  .moments-section { width: calc(100% - 26px); margin: 24px auto 44px; }
  .moments-heading { margin-bottom: 20px; }
  .moments-heading h1 { font-size: 38px; }
  .moments-heading p { font-size: 13px; }
  .moments-workspace { border-radius: 20px; box-shadow: 7px 7px 0 var(--ink); }
  .moments-controls, .moments-preview { padding: 18px 14px; }
  .count-options { margin-bottom: 24px; }
  .count-options button { min-height: 68px; }
  .moments-upload { min-height: 145px; }
  .moments-preview { min-height: 390px; }
  .moments-empty > div { width: 210px; height: 210px; }
  .moments-grid { gap: 4px; padding: 4px; border-radius: 14px; }
}

@media (max-width: 360px) {
  .mode-switch { max-width: calc(100vw - 66px); gap: 2px; padding-inline: 2px; }
  .mode-switch a { min-height: 38px; padding-inline: 5px; font-size: 8px; }
}

/* 朋友圈裁图页动效 */
.moments-heading > span { animation: moments-rise .5s ease-out both; }
.moments-heading h1 { animation: moments-rise .65s .08s ease-out both; }
.moments-heading p { animation: moments-rise .65s .16s ease-out both; }
.moments-workspace { animation: moments-card-in .72s .18s cubic-bezier(.2,.8,.2,1) both; }
.moments-upload > span { animation: moments-plus-float 2.6s ease-in-out infinite; }
.count-options button, .moments-upload, .moments-result-head button, .moments-download { transition: transform .16s ease, box-shadow .16s ease, filter .16s ease; }
.count-options button:hover, .moments-result-head button:hover, .moments-download:hover { transform: translateY(-2px); filter: brightness(1.03); }
.count-options button:active, .moments-result-head button:active, .moments-download:active { transform: translate(2px, 2px) scale(.98); box-shadow: 1px 1px 0 var(--ink); }
.moments-tile { animation: moments-tile-in .38s cubic-bezier(.2,.8,.2,1) both; transition: transform .16s ease; }
.moments-tile:nth-child(2) { animation-delay: .04s; }
.moments-tile:nth-child(3) { animation-delay: .08s; }
.moments-tile:nth-child(4) { animation-delay: .12s; }
.moments-tile:nth-child(5) { animation-delay: .16s; }
.moments-tile:nth-child(6) { animation-delay: .2s; }
.moments-tile:nth-child(7) { animation-delay: .24s; }
.moments-tile:nth-child(8) { animation-delay: .28s; }
.moments-tile:nth-child(9) { animation-delay: .32s; }
.moments-tile:hover { transform: scale(.975); }

@keyframes moments-rise {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes moments-card-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes moments-plus-float {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-6px) rotate(5deg); }
}
@keyframes moments-tile-in {
  from { opacity: 0; transform: scale(.9); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .moments-heading > span, .moments-heading h1, .moments-heading p, .moments-workspace, .moments-upload > span, .moments-tile {
    animation: none !important;
  }
  .count-options button, .moments-upload, .moments-result-head button, .moments-download, .moments-tile {
    transition: none !important;
  }
}
