/* app.css — 무브 트레이스. Warm ivory ground, slate text, clay accent; serif display over a system sans body. */
@font-face {
  font-family: 'MT Display';
  src: url('../fonts/display.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
:root {
  --ivory: #FAF9F5; --slate: #141413; --clay: #D97757; --clay-strong: #B5532F; --clay-press: #9C4A2B;
  --card: #F0EEE6; --track: #E8E6DC; --line: rgba(31, 30, 29, 0.12);
  --text-2: #5E5D59; --link: #A84E2C; --off: #8A8880; --video: #2B2A27;
  --serif: 'MT Display', 'Noto Serif KR', 'AppleMyungjo', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --pad: 24px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ivory); }
body { color: var(--slate); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; overscroll-behavior: none; word-break: keep-all; overflow-wrap: break-word; }
h1[tabindex="-1"]:focus { outline: none; }
button, input, label { font: inherit; color: inherit; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- app frame and screens ---- */
.app { position: relative; max-width: 480px; height: 100vh; height: 100dvh; margin: 0 auto; overflow: hidden; background: var(--ivory); }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  opacity: 0; transform: translateX(28px); pointer-events: none; visibility: hidden;
  transition: opacity 260ms var(--ease), transform 320ms var(--ease), visibility 0s linear 320ms;
}
.screen.is-on { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity 260ms var(--ease), transform 320ms var(--ease), visibility 0s; }
.screen.is-back { transform: translateX(-28px); }
.screen.no-anim { transition: none !important; }
.bar { height: 56px; flex: none; padding: 0 8px; display: flex; align-items: center; gap: 8px; }
.bar-brand { padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 8px; font: 500 18px/1 var(--serif); }
.brand img { width: 30px; height: 20px; }
.body { flex: 1; min-height: 0; padding: 4px var(--pad) 0; display: flex; flex-direction: column; gap: 24px; overflow-y: auto; }
.foot { flex: none; padding: 12px var(--pad) max(20px, env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; background: var(--ivory); }
.title { margin: 0; font: 500 28px/1.34 var(--serif); text-wrap: balance; white-space: pre-line; }
.lead { margin: 0; font-size: 16px; line-height: 1.55; color: var(--text-2); text-wrap: pretty; }
.meta { margin: 0; font-size: 14px; color: var(--text-2); }
.small { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 6px; }

/* ---- controls ---- */
.icon-btn { width: 44px; height: 44px; border: 0; margin: 0; padding: 0; border-radius: 12px; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 160ms ease, transform 120ms ease; }
.icon-btn:active { background: var(--track); transform: scale(.94); }
.btn {
  flex: 1; height: 56px; border: 0; margin: 0; border-radius: 16px; padding: 0 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 17px; font-weight: 700; text-decoration: none; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: transform 120ms ease, background 160ms ease, opacity 160ms ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--clay-strong); color: #FFFFFF; }
.btn-primary:active { background: var(--clay-press); }
.btn-secondary { background: var(--card); color: var(--slate); }
.btn-secondary:active { background: var(--track); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn-wide { flex: 1.6; }
.chip-btn { flex: none; min-width: 64px; height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: #FFFFFF; font-size: 15px; font-weight: 700; cursor: pointer; transition: transform 120ms ease; }
.chip-btn:active { transform: scale(.96); }
:focus-visible { outline: 3px solid var(--clay-strong); outline-offset: 2px; }
.file-cta:focus-within { outline: 3px solid var(--slate); outline-offset: 3px; }
.link { color: var(--link); font-weight: 500; text-underline-offset: 2px; background: none; border: 0; padding: 0 6px; cursor: pointer; font-size: inherit; text-decoration: underline; min-height: 44px; display: inline-flex; align-items: center; }

.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--track); position: relative; }
.seg button { position: relative; z-index: 1; height: 44px; border: 0; margin: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-size: 15px; font-weight: 500; cursor: pointer; transition: color 200ms ease; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { color: var(--slate); font-weight: 700; }
.seg .seg-thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 6px); border-radius: 10px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(20, 20, 19, .12); transition: transform 260ms var(--ease); }
.seg[data-sel="1"] .seg-thumb { transform: translateX(calc(100% + 4px)); }

.switch-row { width: 100%; min-height: 56px; padding: 0 16px; border: 0; margin: 0; border-radius: 16px; background: var(--card); font-size: 15px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; text-align: left; }
.switch { flex: none; width: 51px; height: 31px; border-radius: 16px; padding: 2px; background: var(--off); transition: background 200ms ease; display: flex; }
.switch::after { content: ''; width: 27px; height: 27px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 3px rgba(20, 20, 19, .25); transition: transform 220ms var(--ease); }
.switch-row[aria-checked="true"] .switch { background: var(--clay-strong); }
.switch-row[aria-checked="true"] .switch::after { transform: translateX(20px); }

/* ---- home ---- */
.outs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.out { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.out-art { aspect-ratio: 4 / 5; border-radius: 20px; overflow: hidden; background: var(--video); }
.out-art svg { display: block; width: 100%; height: 100%; }
.out b { display: block; font-size: 15px; }
.out span { font-size: 13px; line-height: 1.45; color: var(--text-2); }
.privacy { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.privacy svg { flex: none; }
.notice { padding: 14px 16px; border-radius: 16px; background: var(--card); font-size: 14px; line-height: 1.5; }
.notice b { display: block; margin-bottom: 2px; }
.notice span { display: block; color: var(--text-2); }
.notice .btn { width: 100%; }
.file-cta { position: relative; overflow: hidden; }
.file-cta input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }

/* ---- processing ---- */
.eta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.eta b { font-size: 17px; font-weight: 500; }
.eta span { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.progress > div { height: 100%; width: 100%; border-radius: 4px; background: var(--clay-strong); transform-origin: 0 50%; transform: scaleX(0); transition: transform 500ms ease-out; }
.play { position: relative; flex: 1 1 300px; min-height: 260px; max-height: 420px; border-radius: 24px; background: var(--card); overflow: hidden; }
.play-deco { position: absolute; inset: 0; width: 100%; height: 100%; }
.play-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 48px; background: var(--track); border-top: 4px solid #E3DACC; }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.steps li { min-height: 40px; display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--text-2); }
.steps .dot { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #C9C6BB; display: flex; align-items: center; justify-content: center; color: #FFFFFF; transition: background 200ms ease, border-color 200ms ease; }
.steps .dot svg { opacity: 0; transform: scale(.6); transition: opacity 200ms ease, transform 260ms var(--ease); }
.steps li[data-s="cur"] { color: var(--slate); font-weight: 700; }
.steps li[data-s="cur"] .dot { border-color: var(--clay-strong); }
.steps li[data-s="done"] { color: var(--slate); }
.steps li[data-s="done"] .dot { background: var(--clay-strong); border-color: var(--clay-strong); }
.steps li[data-s="done"] .dot svg { opacity: 1; transform: none; }
.steps li[data-s="skip"] { display: none; }

/* ---- result ---- */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.vid { position: relative; height: 100%; max-width: 100%; border-radius: 20px; overflow: hidden; background: var(--video); }
.vid video { display: block; height: 100%; width: 100%; object-fit: contain; background: var(--video); }
.vid .mute { position: absolute; right: 10px; bottom: 14px; width: 44px; height: 44px; border: 0; border-radius: 22px; background: rgba(20, 20, 19, .55); color: var(--ivory); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.vid .play-overlay { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 0; border-radius: 32px; background: rgba(20, 20, 19, .55); color: var(--ivory); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.vid .play-overlay svg { margin-left: 3px; }
.vid .vbar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(250, 249, 245, .25); }
.vid .vbar > div { height: 100%; width: 100%; background: var(--ivory); transform-origin: 0 50%; transform: scaleX(0); }
.fixline { text-align: center; }

/* ---- fix / pick ---- */
.fix-card { min-height: 88px; padding: 16px; border-radius: 20px; background: var(--card); display: flex; align-items: center; gap: 14px; }
.fix-card .thumb { flex: none; width: 56px; height: 56px; border-radius: 14px; overflow: hidden; background: var(--video); display: flex; align-items: center; justify-content: center; }
.fix-card .thumb canvas, .fix-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fix-card .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fix-card .txt b { font-size: 16px; }
.fix-card .txt span { font-size: 13px; color: var(--text-2); }
.swatch { width: 30px; height: 24px; border-radius: 12px 14px 10px 12px; box-shadow: inset 0 -3px 0 rgba(20, 20, 19, .18); }
.fix-col { flex-direction: column; align-items: stretch; gap: 12px; }
.pick-stage { position: relative; height: 100%; max-width: 100%; border-radius: 20px; overflow: hidden; background: var(--video); touch-action: manipulation; }
.pick-stage canvas { display: block; height: 100%; width: 100%; object-fit: contain; cursor: crosshair; }
.pick-mark { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; pointer-events: none; }
.pick-mark::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--clay); animation: mt-pulse 1.4s ease-out infinite; }
.pick-mark::after { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: var(--clay); border: 3px solid #FFFFFF; }
.scrub { display: flex; flex-direction: column; gap: 6px; }
.scrub label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.scrub input { width: 100%; height: 44px; margin: 0; accent-color: var(--clay-strong); }

/* ---- toast ---- */
.toast { position: absolute; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 30; padding: 14px 16px; border-radius: 16px; background: var(--slate); color: var(--ivory); font-size: 14px; line-height: 1.5; box-shadow: 0 8px 24px rgba(20, 20, 19, .25); opacity: 0; transform: translateY(12px); transition: opacity 220ms ease, transform 260ms var(--ease); pointer-events: none; }
.toast.is-on { opacity: 1; transform: none; }

/* ---- character (css/app.css owns its keyframes; js/ui/character.js picks them) ---- */
.mt-actor { position: absolute; left: -48px; bottom: 48px; width: 96px; height: 64px; will-change: transform; visibility: hidden; pointer-events: none; -webkit-touch-callout: none; }
.mt-actor.is-on { visibility: visible; }
.mt-shadow { position: absolute; left: 22px; right: 22px; bottom: -6px; height: 10px; border-radius: 50%; background: var(--slate); opacity: .18; will-change: transform; }
.mt-flip { position: absolute; inset: 0; transition: transform 160ms ease; }
.mt-body { position: absolute; inset: 0; transform-origin: 50% 100%; will-change: transform; }
.mt-img { position: absolute; inset: 0; width: 96px; height: 64px; image-rendering: pixelated; user-select: none; -webkit-user-drag: none; }
.mt-body .mt-img:nth-child(3) { opacity: 0; animation: mt-blinkf 3.6s steps(1) infinite; }
.mt-wall { position: absolute; left: 28px; bottom: 0; width: 40px; height: 140px; display: none; }
.mt-fx { position: absolute; left: 48px; bottom: 0; width: 0; height: 0; }
.mt-pt { position: absolute; width: 16px; height: auto; image-rendering: pixelated; will-change: transform, opacity; }
.mt-pt-dust { width: 16px; animation: mt-dust .5s ease-out infinite; }
.mt-pt-z { width: 16px; animation: mt-z 2.4s ease-out infinite; opacity: 0; }
.mt-pt-star { width: 20px; opacity: 0; }
.mt-pt-chalk { width: 16px; opacity: 0; }
@keyframes mt-blinkf { 0%, 92% { opacity: 0 } 93%, 96% { opacity: 1 } 97%, 100% { opacity: 0 } }
@keyframes mt-swapA { 0%, 49.9% { opacity: 1 } 50%, 100% { opacity: 0 } }
@keyframes mt-swapB { 0%, 49.9% { opacity: 0 } 50%, 100% { opacity: 1 } }
@keyframes mt-hop { 0%, 100% { transform: translateY(0) scale(1, 1) } 15% { transform: scale(1.12, .86) } 45% { transform: translateY(-34px) scale(.92, 1.1) } 70% { transform: translateY(0) scale(1.1, .9) } 85% { transform: scale(1, 1) } }
@keyframes mt-jump { 0%, 100% { transform: translateY(0) scale(1, 1) } 20% { transform: scale(1.25, .72) } 45% { transform: translateY(-96px) scale(.85, 1.18) } 60% { transform: translateY(-100px) scale(1, 1) } 82% { transform: translateY(0) scale(1.22, .78) } 92% { transform: scale(1, 1) } }
@keyframes mt-wiggle { 0%, 100% { transform: rotate(0) } 15% { transform: rotate(-10deg) } 30% { transform: rotate(9deg) } 45% { transform: rotate(-7deg) } 60% { transform: rotate(6deg) } 75% { transform: rotate(-2deg) } }
@keyframes mt-spin { 0% { transform: translateY(0) rotate(0) } 30% { transform: translateY(-40px) rotate(180deg) } 60% { transform: translateY(0) rotate(360deg) } 70% { transform: rotate(360deg) scale(1.1, .88) } 80%, 100% { transform: rotate(360deg) scale(1, 1) } }
@keyframes mt-walk { 0%, 50%, 100% { transform: translateY(0) rotate(0) } 25% { transform: translateY(-5px) rotate(-5deg) } 75% { transform: translateY(-5px) rotate(5deg) } }
@keyframes mt-run { 0%, 100% { transform: translateY(0) rotate(0) } 25% { transform: translateY(-10px) rotate(10deg) } 50% { transform: translateY(0) rotate(8deg) } 75% { transform: translateY(-10px) rotate(10deg) } }
@keyframes mt-dust { 0% { transform: translate(0, 0) scale(1); opacity: .9 } 100% { transform: translate(-18px, -12px) scale(.3); opacity: 0 } }
@keyframes mt-tilt { 0%, 50%, 100% { transform: rotate(0) } 25% { transform: rotate(-4deg) } 75% { transform: rotate(4deg) } }
@keyframes mt-breathe { 0%, 100% { transform: scale(1, 1) } 50% { transform: scale(1.05, .93) } }
@keyframes mt-z { 0% { transform: translate(0, 0) scale(.6); opacity: 0 } 20% { opacity: 1 } 100% { transform: translate(20px, -48px) scale(1.1); opacity: 0 } }
@keyframes mt-look { 0%, 100% { transform: translateX(0) rotate(0) } 20%, 35% { transform: translateX(-8px) rotate(-6deg) } 55%, 70% { transform: translateX(8px) rotate(6deg) } }
@keyframes mt-squash { 0%, 100% { transform: scale(1, 1) } 25% { transform: scale(1.3, .7) } 50% { transform: scale(.8, 1.25) } 75% { transform: scale(1.1, .9) } }
@keyframes mt-dance { 0%, 100% { transform: translate(0, 0) rotate(0) } 20% { transform: translate(-14px, 0) rotate(-10deg) } 40% { transform: translate(0, -14px) rotate(0) } 60% { transform: translate(14px, 0) rotate(10deg) } 80% { transform: translate(0, -14px) rotate(0) } }
@keyframes mt-climb { 0% { transform: translate(0, 0) } 12% { transform: translate(-6px, -22px) rotate(-6deg) } 24% { transform: translate(4px, -44px) rotate(6deg) } 36% { transform: translate(-6px, -66px) rotate(-6deg) } 48% { transform: translate(4px, -88px) rotate(6deg) } 60%, 72% { transform: translate(0, -104px) rotate(0) } 86% { transform: translate(0, 0) scale(1.2, .8) } 94% { transform: translate(0, -10px) scale(1, 1) } 100% { transform: translate(0, 0) } }
@keyframes mt-fall { 0% { transform: translateY(-190px) rotate(-20deg); opacity: 0 } 8% { opacity: 1 } 40% { transform: translateY(0) rotate(0) scale(1.3, .65) } 55% { transform: translateY(-26px) scale(.92, 1.08) } 70% { transform: translateY(0) scale(1.12, .88) } 80% { transform: translateY(-8px) scale(1, 1) } 90%, 100% { transform: translateY(0) scale(1, 1); opacity: 1 } }
@keyframes mt-roll { 0% { transform: translateY(0) rotate(0) } 15% { transform: translateY(-14px) rotate(54deg) } 85% { transform: translateY(-14px) rotate(306deg) } 100% { transform: translateY(0) rotate(360deg) } }
@keyframes mt-shiver { 0%, 100% { transform: translateX(0) } 10%, 30%, 50%, 70%, 90% { transform: translateX(-3px) } 20%, 40%, 60%, 80% { transform: translateX(3px) } }
@keyframes mt-float { 0% { transform: translateY(0) rotate(0) } 20% { transform: translateY(-40px) rotate(-4deg) } 45% { transform: translateY(-70px) rotate(4deg) } 70% { transform: translateY(-46px) rotate(-3deg) } 100% { transform: translateY(0) rotate(0) } }
@keyframes mt-cheer { 0%, 100% { transform: translateY(0) scale(1, 1) } 15% { transform: scale(1.15, .85) } 40% { transform: translateY(-34px) scale(.95, 1.08) } 65% { transform: translateY(0) scale(1.1, .9) } 80% { transform: scale(1, 1) } }
@keyframes mt-pump { 0%, 100% { transform: translateY(0) scale(1, 1) } 50% { transform: translateY(-6px) scale(.97, 1.04) } }
@keyframes mt-star1 { 0% { transform: translate(0, 0) scale(.3); opacity: 0 } 30% { opacity: 1 } 100% { transform: translate(-34px, -44px) scale(1); opacity: 0 } }
@keyframes mt-star2 { 0% { transform: translate(0, 0) scale(.3); opacity: 0 } 30% { opacity: 1 } 100% { transform: translate(0, -60px) scale(1); opacity: 0 } }
@keyframes mt-star3 { 0% { transform: translate(0, 0) scale(.3); opacity: 0 } 30% { opacity: 1 } 100% { transform: translate(34px, -44px) scale(1); opacity: 0 } }
@keyframes mt-stretch { 0%, 100% { transform: scale(1, 1) } 30%, 60% { transform: scale(.86, 1.24) } 75% { transform: scale(1.12, .88) } 88% { transform: scale(1, 1) } }
@keyframes mt-peek { 0% { transform: translateY(0) } 18% { transform: translateY(70px) } 40%, 52% { transform: translateY(26px) } 62%, 74% { transform: translateY(26px) rotate(-8deg) } 88% { transform: translateY(70px) } 100% { transform: translateY(0) } }
@keyframes mt-dip { 0%, 100% { transform: translateY(0) scale(1, 1) } 25% { transform: translateY(0) scale(1.12, .84) } 50% { transform: translateY(-12px) scale(.94, 1.08) } 70% { transform: translateY(0) scale(1, 1) } }
@keyframes mt-puff1 { 0%, 40% { transform: scale(.3); opacity: 0 } 55% { opacity: .95 } 100% { transform: translate(-34px, -26px) scale(1.4); opacity: 0 } }
@keyframes mt-puff2 { 0%, 40% { transform: scale(.3); opacity: 0 } 55% { opacity: .95 } 100% { transform: translate(32px, -30px) scale(1.4); opacity: 0 } }
@keyframes mt-puff3 { 0%, 40% { transform: scale(.3); opacity: 0 } 55% { opacity: .95 } 100% { transform: translate(0, -46px) scale(1.4); opacity: 0 } }
@keyframes mt-shadow { 0%, 100% { transform: scaleX(1); opacity: .18 } 45% { transform: scaleX(.6); opacity: .08 } }
@keyframes mt-pulse { 0% { transform: scale(.7); opacity: .9 } 100% { transform: scale(1.6); opacity: 0 } }

@media (prefers-reduced-motion: reduce) {
  .screen, .toast, .seg .seg-thumb { transition-duration: 1ms !important; }
  .mt-pt { display: none; }
  .mt-body, .mt-body .mt-img, .mt-shadow, .pick-mark::before { animation: none !important; }
  .mt-actor { transition: none !important; }
}
@media (min-width: 520px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
